It's the same trick as in
while (my $line = <$fh>) {
which is a shorthand for
while (defined( my $line = readline($fh) )) {
where, again, my $line appears as an
argument operand of =
which in turn is an argument operand of defined.
my has two effects, one compile time and one run time. In compile time, you declare a lexical variable, and in runtime, you use it as an lvalue (i.e. assign a value to it). Variables declared in block conditions (if, while, unless, until) are accessible until the last conditional operator block.
if (my $x = func()) {
print "$x accesible here";
} elsif ($x eq 0) { # even here,
print "and also here: $x";
}
Updated.
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.