in reply to Question about split
The first argument to split defines what you want to _split_ on. This implies that there will be an element that you want to keep _before_ the first match. In your case, that will always be an empty string as nothing comes before that in your data.
You don't actually want to use split for this. You should just use a match operator instead.
$f='453445-5.bmp'; ($base, $dash, $copy, $ext) = %f =~ /^(\d+|\w+)(-)(\d+)(\.bmp)/;
Use m// when you know what you want to keep. Use split when you know what you want to throw away.
Oh, and if you have PERL books, then I recommend getting rid of them and buying Perl books instead :)
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Question about split
by L8on (Acolyte) on Dec 10, 2004 at 18:41 UTC |