![]() |
exhalations |
|
Tuesday, January 23, 2001
I really do need to find the time to change this default blogger page, but it's either do that or ride the stationary bike for 30 min. and meditate... Took too long to write this short perl script to sort the project file created by 1stPage, the free html editor. It's a great program, but when one adds a project to the project file, it is appended to the end of the list and there's no way to sort the list (that I know of). # sortproj.pl # Written January 23, 2001 # Bruce Wright # Purpose: To sort the 1stPage project files by filename. # if ($ARGV[0] eq '' || $ARGV[1] eq '') { die "Usage: sortproj.pl infile outfile\n"; } $infile = $ARGV[0]; open (IN,$infile) || die "can't open $infile: $!"; # $! is error string var $outfile = $ARGV[1]; open (OUT,">$outfile") || die "can't open $outfile: $!"; # Skip first 3 lines and write to outfile. # for ($i=0;$i<3;$i++){ $null = print OUT $null; } $i=0; while ( chop $_; # # Be sure to use [] vs. {} # ($num[$i],$name[$i],$stat[$i],$loc[$i],$date[$i]) = split(/,/,$_); $counti{$i} = $i; $i++; } # # Sort the name field. # @sorted = sort @name; # # Name is sorted but the other fields aren't. Need to # figure out index for the other fields by comparing # the sorted name to the original name to retrieve it's index. # foreach $namesorted (@sorted) { $i = 0; foreach $index (@name) { if ($index eq $namesorted) { $indexnum = $i++; } else { $i++; } } print OUT $num[$indexnum],",",$name[$indexnum],",",$stat[$indexnum],",", $loc[$indexnum],",",$date[$indexnum],"\n"; } close(IN) || die "can't close $infile: $!"; close(OUT) || die "can't close $infile: $!";
Comments:
Post a Comment
|