At 05:12 PM 6/22/02 -0400, zentara wrote:
>On Sat, 22 Jun 2002 11:06:58 -0700, [EMAIL PROTECTED] (Peter Scott) wrote:
> >
> >Don't read the entire file into memory; just change the next line to
> >
> > while (<VS>) {
> > chomp;
> >
> >>foreach (@vs){
> >>($name,$value) = split(/=/,$_);
> >>$sigs{$name}=$value;}
> >
> >That code is clear enough (aside from the lack of indentation)... by
> >"clever" did you mean "shorter, even if more obfuscated"? Okay:
> >
> > @ARGV = 'vs';
> > my %sigs = map { chomp; split /=/ } <>;
> >
> >Yes... that does read the whole file into memory. This one doesn't:
> >
> > @ARGV = 'vs';
> > my %sigs;
> > /(.*?)=(.*)/ and $sigs{$1} = $2 while <>;
>
>Brilliant!!!!!!! I feel like I found a real gem today, another snippet
>for the library. Thanks.
<VADER>Don't feel too proud of this technological terror you've
constructed. The ability to combine multiple statements with a
postfixed while() iterating magically over @ARGV is insignificant next
to the power of clear and simple coding.</VADER>
--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]