Hello,

I have 2 little programs here and they do different things, but I don't understand why.

# First program

use warnings;
use strict;
my $line = "TRAVSTAT 08-27-2002 02:20:15 There is no output file required.";
(my $word) = ($line =~ /(\S+)/);
print $word;
# Prints TRAVSTAT

# Second program

use warnings;
use strict;
my $line = "TRAVSTAT 08-27-2002 02:20:15 There is no output file required.";
my $word = ($line =~ /(\S+)/);
print $word;
# Prints 1

The only difference is the lack of parentheses around my $word on the 4th line.  I 
read that this has something to do with scalar context, but I don't see why one would 
be scalar context and not the other.  They both look like scalars to me.

Will someone help me understand the difference?

TIA,

Eddie



---------------------------------
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes

Reply via email to