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.