That depends on your definition of "better".
2;0 juerd@ouranos:~$ perl -we'@_[0]'
Scalar value @_[0] better written as $_[0] at -e line 1.
That's my definition. @_[0] is an array slice, which happens to have a single value, and just happens to work because of that. For example:
my @foo = qw(a b c d e f g h i j);
my @bar = @foo[1, 5, 6, 4]; # @bar is now qw(b f g e)
my $bar = $foo[0];
When you want a scalar, USE a scalar :)
If you're writing code to parse a language which is deliberately confusing, it's arguably better to parse it in as confusing a way as possible.
Perhaps, but I don't agree. And even if you were right, there's no need to use PERL for that. (note: "PERL" ne "Perl").
U28geW91IGNhbiBhbGwgcm90MTMgY
W5kIHBhY2soKS4gQnV0IGRvIHlvdS
ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
geW91IHNlZSBpdD8gIC0tIEp1ZXJk
-
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.
|