At 6:14 PM -0700 9/1/11, John W. Krahn wrote:
Jim Gibson wrote:
On 9/1/11 Thu Sep 1, 2011 5:15 PM, "Rajeev Prasad"<rp.ne...@yahoo.com>
scribbled:
@tmpAR2 = split(/ /,"$line");
There is no need to surround $line with double-quotes:
@tmpAR2 = split(/ /,$line);
Note that the split will delete the newline character from the last element
of @tmpAR2.
No it will not. The regular expression / / will only match the
space character.
Thanks for the correction. I originally suggested that Rajeev use
split(' ',...) and didn't notice that he had used split(/ /,...)
instead until after I had posted.
Beginning Perl programmers should note the difference between ' ' and
/ / for split. In most cases, it doesn't matter. However, the split
pattern ' ' is a special case that splits on any whitespace, which
includes the space character, the tab character, and the newline
character. It also changes the rules on what split does if there are
separator characters at the beginning or end of the string and what
split does if there are consecutive space characters in the string.
See 'perldoc -f split' and search for 'PATTERN of space'.
--
Jim Gibson
j...@gibson.org
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/