in reply to Re: I'm splitting a scalar and putting the results in an array. Why is the first element empty?
in thread I'm splitting a scalar and putting the results in an array. Why is the first element empty?

I think they apply, unless I am mistaken. Granted, english is not my first language, so I may have misunderstood your post, but it is a normal behaviour for split not to enter the separator in the returned array.
For example, this bit of code :
my $string = "aa:bb:cc:dd:ee:ff:gg:hh"; my @table = split /:/ , $string; print "@table\n";
would print
aa bb cc dd ee ff gg hh
  • Comment on Re^2: I'm splitting a scalar and putting the results in an array. Why is the first element empty?
  • Select or Download Code

Replies are listed 'Best First'.
Re^3: I'm splitting a scalar and putting the results in an array. Why is the first element empty?
by artist (Parson) on Aug 14, 2006 at 14:17 UTC
    It does if you have parans in the regex.
    my @table = split /(:)/, $string
    --Artist