Re: split()'s pattern argument



Jerry Adair wrote:
to split(), it just so happens that the first line of data begins with a
space, followed by two "words" that are separated by whitespace. So the
list that I get back from split() has 3 elements in it

If all you want to do is split $_ on whitespace ignoring any leading
whitespace the you can simply say "split". Observe:

#!/usr/bin/perl

use warnings; use strict;

$_ = ' foo bar ';
my @array = split;

print map {"'$_'\n"} @array;

__END__


--
http://DavidFilmer.com

.



Relevant Pages

  • Re: Generating bitmaps of alpha characters
    ... letters seem to have whitespace ... this whitespace when printing them to a jpeg file. ... neither perfectly black nor white because of the compression. ... Get contents of figure with getframe (it returns an image array). ...
    (comp.soft-sys.matlab)
  • Re: A challenge? Help isolating links in a WebPage
    ... # extract URLs from a string return an array of arrays; ... # each inner array has the text and the URL ... # remove everything after, and including, the first whitespace ...
    (comp.lang.php)
  • Re: regex to split whitespace-separated values
    ... but, unfortunately, the first value in the array is now an empty value. ... PATTERN is also omitted, splits on whitespace (after ... PATTERN is taken to be a delimiter separating the ...
    (perl.beginners)
  • Re: How to check for where a text file begins?
    ... def find_first_two_lines ... Returns an array of the first two non whitespace lines delimited by \n ... Mikel Lindsaar ... elements of the array. ...
    (comp.lang.ruby)
  • critique me script!
    ... #assign second element into $features and remove colon ... #split $line along whitespace and place into an array ...
    (perl.beginners)