srd wrote:
#!/usr/bin/env perl
use warnings;
use strict;
my $x= (1,2,3);
print $x,"\n";
exit(0);
*************************************
output:
Useless use of a constant in void context at ./try.plx line 4.
3
*************************************
If we put $x=(1,2) then we get 2 without the error message.
Can someone please explain why?
Yes, perl places the last item in the list into the variable. That's
why the others are "useless".
Try:
my $x = ( 1, 2, 'this one' );
--
Just my 0.00000002 million dollars worth,
Shawn
Programming is as much about organization and communication
as it is about coding.
I like Perl; it's the only language where you can bless your
thingy.
Eliminate software piracy: use only FLOSS.
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/