yitzle wrote:
my $sepchar = grep( /,/ => @_ ) ? ";" : ",";

And I also don't understand what ";" is doing in the ternary operator??
The ";" is what is returned if the condition is TRUE.

"( / ,/ => @_)" is a(n anonymous) hash.

No it is not.  /,/ and @_ are just two arguments to the grep() function.


I've had no idea that grep can
operate on a hash.
However, it seems that "grep( / ,/ => @_)" and "grep( / ,/, @_)" are equivalent.

Yes, '=>' and ',' are just different versions of the comma operator.


__CODE__
@a = qw/aa ab ba bb/;
print join(", ", grep(/a/, @a) );
print "\n";
print join(", ", grep(/a/ => @a) );
print "\n";
__END__
aa, ab, ba
aa, ab, ba

@_ is a list/array, and that is what grep is searching for the RegEx / ,/.

perldoc -q "What is the difference between a list and an array"

And the regexp in the example is /,/ not / ,/.



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to