John,

Thanks for making things pretty simple for mere mortals ..


>>
> chomp( my $raw_file = glob "@ARGV" );
>

I am of the view that glob sub is used for as  tree (that is to get all the
files in a folder and all its sub-folders. From the above, it seems like it
could be used for something else... Someone should help me out here.


> Why are you copying the contents of @ARGV to a string and then globbing
> that string?
>
> If @ARGV contains more than one element then this will not work correctly.
>
> And why chomp() a string that will not contain newlines?
>
> What you want is something like:
>
> my $raw_file = $ARGV[ 0 ];
>
>
>
>    while(<READFILE>){chomp;
>>           $ln.="\n" if /^\W.?+$/;
>>     if(/^\d{4}/){$yr=$&;}  # get the year
>>     if(/^[A-Z].+/){ $cat=$&; # get the Category
>>        $cat=join"",split /,/,$cat; # remove the comma in front
>>      $ln.=" $yr: ".$cat;           # add both the year and Category
>>     }
>>     if(/\--.+/){$win=$`;     # get the winner
>>
>
> The use of $&, $' and $` will slow down *ALL* regular expressions in the
> program.  Better to just use capturing parentheses.
>
>    if (/^(\d{4})/ ) { $yr = $1 }  # get the year
>    if ( /^([A-Z].+)/ ) {
>        $cat = $1; # get the Category
>
>        $cat = join "", split /,/, $cat; # remove the comma in front
>        $ln.= " $yr: " . $cat;           # add both the year and Category
>    }
>    if ( /(.*?)\--.+/ ) { $win = $1;     # get the winner
>


What is the idiomatic Perl , $1 or $[`, &,'] ? And what makes [$&, $', $`]
to slow down *ALL* regular expressions in the program.

>
>
>
>


-- 
*Satajanus  Nig. Ltd


*

Reply via email to