Re: HoA building
- From: krahnj@xxxxxxxxx (John W. Krahn)
- Date: Wed, 27 Dec 2006 21:56:46 -0800
M. Lewis wrote:
John W. Krahn wrote:
M. Lewis wrote:
my ($prod, $flavor) = split /\s/, $ln, 2;
You probably should use ' ' instead of /\s/ as the first argument to
split:
my ($prod, $flavor) = split ' ', $ln, 2;
Ok, but why? Are they not the same?
No.
$ perl -le'
my $ln = " one two three four ";
print map " *$_* ", split /\s/, $ln, 2;
print map " *$_* ", split " ", $ln, 2;
'
** * one two three four *
*one* *two three four *
$ perl -le'
my $ln = "one two three four ";
print map " *$_* ", split /\s/, $ln, 2;
print map " *$_* ", split " ", $ln, 2;
'
*one* * two three four *
*one* *two three four *
/\s/ matches a single whitespace character, ' ' matches one or more whitespace
characters.
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
.
- Follow-Ups:
- Re: HoA building
- From: M. Lewis
- Re: HoA building
- References:
- HoA building
- From: "M. Lewis"
- Re: HoA building
- From: John W. Krahn
- Re: HoA building
- From: "M. Lewis"
- HoA building
- Prev by Date: Re: Remove an element from middle of array
- Next by Date: Re: HoA building
- Previous by thread: Re: HoA building
- Next by thread: Re: HoA building
- Index(es):
Relevant Pages
|
|