On Sun, Aug 29, 2010 at 7:58 PM, Chas. Owens <chas.ow...@gmail.com> wrote: > On Sun, Aug 29, 2010 at 09:41, Kaushal Shriyan <kaushalshri...@gmail.com> > wrote: > snip >> Thanks a lot Chas. Understood now. >> Also what does $_ default variable means exactly, any example would >> really help me understand it > snip > > The default variable is set or read by many Perl 5 functions. For > instance, if you use the readline operator (<>) in a while loop's test > it sets $_ and print uses $_ if no arguments are passed to it, so > > #!/usr/bin/perl > > use strict; > use warnings; > > while (<DATA>) { > print; > } > > __DATA__ > foo > bar > baz > > will print the lines "foo\n", "bar\n", and "baz\n". $_ is also the > default target for regexes, so > > #!/usr/bin/perl > > use strict; > use warnings; > > while (<DATA>) { > next unless /b/; > print; > } > > __DATA__ > foo > bar > baz > > Will print "bar\n" and "baz\n", but not "foo\n" because it does not > match the regex. > > -- > Chas. Owens > wonkden.net > The most important skill a programmer can have is the ability to read. >
Hi Chas, Thanks Chas. Much appreciated :-) I am referring to http://www.perl.org/books/beginning-perl/. so I am planning to read upto chapter 10. is it recommended to even go beyond chapter 10. Please suggest. How do i start writing my own perl scripts. Please suggest. Do you recommend something else. Kaushal -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/