[ale] Perl and $_ ?
Adam Teja
arteja at yahoo.com
Tue Jan 12 10:20:04 EST 1999
...what Mark said, $_ is a default variable, here are a few one liner
examples that I thought may help (just happended to have a Perl book
out)... as you can probably figure out; you can, in most cases,
explicitly reference the $_ variable...
while( <FILEHANDLER> ) = while( $_ = <FILEHANDLER> )
chomp; = chomp $_;
print "ok" if /$pat/; = print "ok" if $_ =~/$pat/;
s/$pat/$repl/; = $_ =~ s/$pat/$repl/;
tr/ \t/\n/; = $_ =~ tr/ \t/\n/;
print; = print $_;
split /$sep/; = split /$sep/, $_;
foreach (@list) = foreach $_ (@list)
hope this helps,
Adam
---"David S. Jackson" <dsj at dsj.net> wrote:
>
> Okay, I'm just chugging through "Learning Perl" and came to Chapter
6 and
> the $_ variable. I thought I understood it, but now that I'm chugging
> through Chapter 7 (Regular Expressions) I'm not so sure.
>
> Could someone explain it to me in their own words with simple
examples,
> maybe?
>
> TIA! :-)
>
> --
> David S. Jackson http://www.dsj.net
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> "You may satisfy all your senses and still not be satisfied."
> --Edward S. Martin
>
==
******************************************************************
all my email accounts are being forwarded to web-mail...
you may still email to:
ateja at acm.org, ateja at spsu.edu, arteja at mediaone.net
arteja at mindspring.com
_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com
More information about the Ale
mailing list