[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Perl realted..?



ISHWAR RATTAN <rattan@cps.cmich.edu>:
>  I am coming back to perl after a long time.
> 
>  The sample code these days also uses variable attribute my as:
> 
>     my $inst = Extutils::Installed->new();
>     my @modules = $inst->modules();
> 
>  Can any demistify 'my' for me??

      -----------------------------
           #!/usr/bin/perl
           # this just re-implements tail -1
           #
           # usage:
           #   /this/file < /some/text/file.txt
           #

           my $last;

           while( <> ) {
             $last = $_;
           }
           
           print $last;
      -----------------------------

Now, try with the "my $last;" *inside* the while().  That last print
line won't have a clue what $last is.


-- 
Any technology distinguishable from magic is insufficiently advanced.
(*)    http://blinkynet.net/comp/uip5.html      Linux Counter #80292
- -    http://www.faqs.org/rfcs/rfc1855.html    Please, don't Cc: me.


Reply to: