Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: What's the difference between stat and sort?

by PetaMem (Priest)
on Jul 15, 2004 at 10:03 UTC ( [id://374587]=note: print w/replies, xml ) Need Help??


in reply to Re: What's the difference between stat and sort?
in thread What's the difference between stat and sort?

Aaah. As the germans say: "I get the crisis!"

my $lf = (sort(<*>))[-1]; print $lf,"\n";
works. While the (what I tested)
print (sort(<*>))[-1], "\n";
throws a
print (...) interpreted as function at ./template.pl line 6.
syntax error at ./template.pl line 6, near ")["
Execution of ./template.pl aborted due to compilation errors.

Bye
 PetaMem
    All Perl:   MT, NLP, NLU

Replies are listed 'Best First'.
Re^3: What's the difference between stat and sort?
by Chady (Priest) on Jul 15, 2004 at 10:12 UTC
Re^3: What's the difference between stat and sort?
by beable (Friar) on Jul 15, 2004 at 10:17 UTC
    Oh that's easy, parenthesisation. Try this:
    perl -e 'print((sort(<*>))[1]);'

    Once the expression is fully inside parentheses, there is no syntax error. With the square brackets outside the parens, it must be trying to get the first element of the array returned by print(), which doesn't return an array.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://374587]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-24 23:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found