From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Greg Aiken
Sent: 10 March 2009 21:20
To: perl-win32-users@listserv.activestate.com
Subject: implied variables (what are they actually?)

> while (<>) {        #line1
>             print;     #line2
> }
>  
> I read one may create a 'filter' by running the above as;
> prog.pl < file_contents_to_send_to_prog_pl.txt

Actually you don't need a script to do that, 'perl -p' does the same
thing. (See 'perldoc perlrun' for details).

>  
> I know this is using a couple of 'implied' variables, as clearly no
direct variable names are being used here.

The two special variables in use are $_ and the null file handle. Many
functions and operators use $_ by default, see 'perldoc pperlop' and
'perldoc perlfun', and 'perldoc perlvar' for a description of $_. You
can replace the use of $_ in your script by changing '<>' to 'my $var =
<>', and 'print' to 'print $var'.

You cannot simply replace the null filehandle with a specific one, as
this use of the null filehandle has additional 'magic'. See the
description of I/O operators in 'perldoc perlop'.

>  
> But so that I could add some better control of this program, can
anyone please tell me what the ACTUAL VARIABLE > name is that is being
internally used in '<>' (line 1)?
>  
> And what ACTUAL VARIABLE name is being internally used in 'print;'
(line 2).
>  
> I would like to modify the above program so that it will run with
variable names that can be seen, as a 
> learning exercise...

The learning exercise will be more effective if you read the
documentation for the syntax, operators and functions that want to you
use. If you still have questions after a combination of reading the
documentation, and trial and error, please ask in fora like this.

HTH

-- 
Brian Raven 

-----------------------------------------------------------------------------------------------------------
This e-mail may contain confidential and/or privileged information. If you are 
not the intended recipient or have received this e-mail in error, please advise 
the sender immediately by reply e-mail and delete this message and any 
attachments without retaining a copy. Any unauthorised copying, disclosure or 
distribution of the material in this e-mail is strictly forbidden.


_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to