in reply to Re^3: print question
in thread print question
Hi,
First off its qw(a b) not qw(a, b)
Yes ("a", "b") and qw(a b) are two ways of defining the same list but saying print ("a", "b")[1] and print qw(a b)[1] are not quite the same!
When you say print ("a", "b")[1] it looks like you're telling Perl "print my list ("a", "b")" and passing it an anonymous array whose single element is 1. That entire construct is confusing to Perl and as such it complains!
However when you say print qw(a b)[1] you're saying to Perl "print the 2nd element of the list qw(a b)", which makes perfect sense to Perl and as such ... it obliges and prints "b" :)
Hope that helps ;)