Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

pvac5le.cgi

Name: Anonymous 2009-02-08 16:52

I'm editing some perl and my output isn't what it should be.

its outputing like file names as the same file name.
ie pch1-3_0.spch & pch1-3_1.spch are both outputed as pch1-3_1.spch so it generates pch1-3_1.spch twice.


opendir (THISDIR, "$pch_file_directory") || die "No Directory";
while ( $file_name = readdir(THISDIR)){
 if($file_name =~ /.*\.pch/ || $file_name =~ /.*\.spch/){
 
  $i++;

  #ファイル編集時間取得
  ($hour, $min, $sec, $mday, $mon, $year)=localtime((stat("$pch_file_directory$file_name"))[9]);
 
  #ファイルデータサイズ取得
  $byte = (stat("$pch_file_directory$file_name"))[7];
  if($byte > 0 && $byte < 1024) { $byte = 1024;} 
 
  #表示時間修正処理
  $year += 1900;
  $mon = sprintf("%02d", ++$mon);
  $mday = sprintf("%02d", $mday);
  $hour = sprintf("%02d", $hour);
  $min = sprintf("%02d", $min);
  $sec = sprintf("%02d", $sec);
 
  #日付リスト作成
  $file_time[$i] = int("$year$mon$mday$hour$min$sec");
 
  #ファイル情報テーブルに代入
  $file_table{$file_time[$i]}[0] = "$file_name";
  #$newvar{$file_time[$i]}[0] = "$file_name";
  $file_table{$file_time[$i]}[1] = "$mon/$mday/$year";

  $file_table{$file_time[$i]}[2] = int( $byte / 1024 + 0.5 );


}
}
closedir THISDIR;


what it pertains to in the rest of the script.


for($i,$c=0;$c<=$i;$c++){

 #print qq($file_table{$file_time[$c]}[0] <br />);
 #表示ファイルサイズ確認
 if($file_table{$file_time[$c]}[2] > $printbyte){

   #ファイル数カウント
   $files_count++;

$vres = ($page + 1) * $epp; # view results
if ($files_count > ($vres - $epp) && files_count <= $vres) {

  
   if( $file_table{$file_time[$c]}[0] =~ /.*\.pch/ ) {

        print qq(    <td>\n).
          qq(     <a href="$ENV{'SCRIPT_NAME'}?mode=$file_table{$file_time[$c]}[0]&amp;printapplet=$printappletv2">$file_table{$file_time[$c]}[0]</a>\n).
          qq(    </td>\n);

   } elsif ( $file_table{$file_time[$c]}[0] =~ /.*\.spch/ ) {

       print qq(    <td>\n).
          qq(     <a href="$ENV{'SCRIPT_NAME'}?mode=$file_table{$file_time[$c]}[0]&amp;printapplet=$printappletv3">$file_table{$file_time[$c]}[0]</a>\n).
          qq(    </td>\n);

   }

   print qq(    <td>\n     $file_table{$file_time[$c]}[2] KB\n    </td>\n    <td>\n     $file_table{$file_time[$c]}[1]\n    </td>\n);

   if($print_download eq "1"){
       print qq(    <td class="center">\n     <a href="$print_dir_url$file_table{$file_time[$c]}[0]">Download</a>\n    </td>\n);
   }
  
   print qq(   </tr>\n   <tr>\n);


 }
}
}


any ideas or clues?

Name: Anonymous 2009-02-08 17:00

What the fuck is with the comments? Not only are they absolutely useless, but more importantly, they are not in English.

Name: Anonymous 2009-02-08 17:06

I'm editing a Japanese script.

Name: Anonymous 2009-02-08 17:16

>>2
They're not completely useless if you can read Japanese

Name: 2 2009-02-08 17:17

>>4
Either you can't read Japanese or you don't know how to write comments.

Name: Anonymous 2009-02-08 17:20

ok so i know for a fact the reason why the script isn't doing what i want it do is because of the comments.

Name: Anonymous 2009-02-08 17:42

>>5
No, I have no idea how to write comments. Functional programming languages barely need comments.

Name: Anonymous 2009-02-08 17:46

Programming barely needs comments.

Name: Anonymous 2009-02-08 17:53

>>6

Name: Anonymous 2009-02-08 17:54

Those comments are only useful if you can't read English.

Name: Anonymous 2009-02-08 18:06

>>1
use warnings;
use strict;

use POSIX qw(strftime);

# ...

opendir my $thisdir, $pch_file_directory or die "$0: $pch_file_directory: $!\n";

while (defined(my $file_name = readdir $thisdir)) {
    $file_name =~ /\.s?pch\z/ or next;

    my @stat = stat "$pch_file_directory/$file_name" or do {
        warn "$0: $pch_file_directory/$file_name: $!\n";
        next;
    };

    my ($size, $mtime) = @stat[7, 9];
    if ($size > 0 && $size < 1024) {
        $size = 1024;
    }

    my @localtime = localtime $mtime;
    my $key = strftime '%Y%m%d%H%M%S', @localtime;
    my $date = strftime '%m/%d/%Y', @localtime;  # blech

    $file_time[++$i] = $key;
    $file_table{$key} = [$file_name, $date, int($size / 1024 + 0.5)];
}

closedir $thisdir;

The other part is too awful. It looks like the whole thing needs a cleanup.

Name: Anonymous 2009-02-08 18:36

>>11
thanku sir i will try this.

Name: Anonymous 2009-02-08 18:47

>>11
couldn't get it to work. keeps giving me the 500 no matter what i do to it.

Name: Anonymous 2009-02-08 19:42

>>12,13
Kill yourself.

Name: Anonymous 2009-02-08 20:06

when i delete these three lines it works.

    my @localtime = localtime $mtime;
    my $key = strftime '%Y%m%d%H%M%S', @localtime;
    my $date = strftime '%m/%d/%Y', @localtime;  # blech

Name: Anonymous 2009-02-08 20:09


they needed parenthesis

    my @localtime = localtime($mtime);
    my $key = strftime( '%Y%m%d%H%M%S', @localtime);
    my $date = strftime( '%m/%d/%Y', @localtime);  # blech

Name: Anonymous 2009-02-08 20:17

>>15,16
I've gotta agree with >>14, you should kill yourself.

Name: Anonymous 2010-12-24 7:18

Name: Anonymous 2010-12-24 13:08


Don't change these.
Name: Email:
Entire Thread Thread List