Re: about creating an array



Jm lists wrote:

2007/3/16, John W. Krahn <krahnj@xxxxxxxxx>:

Or you could remove all trailing whitespace:

while ( <HD> ) {
s/\s+\z//;
push @arr, $_;
}

Thanks John.That's the right way.
Another question,what's the regex of "\s+\z" ?

\s+ matches one or more whitespace characters and \z is the end of string anchor.



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
.



Relevant Pages

  • Re: about creating an array
    ... Or you could remove all trailing whitespace: ... push @arr, $_; ... So \s+\z matches one or more whitespace characters at the end of the string ...
    (perl.beginners)
  • Re: GAWK oddity...
    ... Don Stokes wrote: ... The first line is the default behaviour; the second a regex. ... matches the leading and trailing whitespace, ... case ignores leading and training spaces. ...
    (comp.lang.awk)
  • Re: remove double space from string
    ... Removing Leading and Trailing Whitespace ... but I'm not good at regex. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: RegEx question
    ... The following regex (Not including the end quotes): ... @paramfoo ... (Note the trailing whitespace in the regex as well as ...
    (comp.lang.python)