Fantastic rp!

Will you not write your own Perl book? It should push O'Reilly of the shelf.
(Well my shelf anyway) O'Reilly is mostly perl man pages given a better
format.  I love O'Reilly books but their perl books sucks!! Escpecially on the
sections of pattern matching and magic variables.

Later ;-)

rpjday wrote:

>
> On Mon, 21 Feb 2000, Bret Hughes wrote:
>
> > Got to something worng with this code.  Are you sure it's perl?  I mean,
> > I can understand it.  too easy.  I wrote a perl script to parse a bunch
> > of stuff from debug logs in a long running program about a year ago
> > (thanks to O'riley and this list) and when I went back a couple of weeks
> > ago I had no @&* idea what I had done.  Really powerful really cryptic.
> > Like I said earlier are you sure this is perl?
> >
> > :)
> > > ================
> > >
> > > open(IN, logfile) ;
> > >
> > > while(<IN>) {
> > >         foreach (split) {
> > >                 ($key, $value) = split("=") ;
> > >                 print "$key, $value\n" ;
> > >         }
> > > }
> > > close IN ;
> > >
> > > ================
> > >
> > >   once you get the values in $key and $value, do with them whatever
> > > you wish.
>
> perhaps i wasn't solving the problem as it was asked, but what the above
> does is read a file of lines, each line of the format
>
>         key=value  key=value ....
>
> and an arbitrary number of those lines.  a running commentary:
>
> while (<IN>) {
>
>         read the next line into the magic variable $_, no need to chomp,
>         since we're going to deal with whitespace shortly anyway
>
> foreach (split) {
>
>         split the (default) magic variable $_, based on (default)
>         multiple whitespace (a great trick).  putting this into a
>         foreach loop places each "key=value" string into (tada!)
>         the (local to this foreach loop) $_ magic variable again.
>
> ($key, $value) = split("=") ;
>
>         split the "key=value" string in (default) $_ based on the
>         delimiter being an equal sign, place in scalar variables
>         $key and $value.  you can then print out these two values,
>         put them in a hash, whatever.
>
> any questions?
>
> rday
>
> p.s.  yeah, it's perl. :-)
>
> --
> To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
> as the Subject.

--
robert canary
system services
OhioCounty.Net
[EMAIL PROTECTED]
(270)298-9331 Office
(270)298-7449 Fax



-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.

Reply via email to