http://www.perlmonks.org?node_id=1071341


in reply to Question regarding split

Highlighting a different sentence in the section quoted by Anonymous Monk at Re^2: Question regarding split
If LIMIT is specified and positive, it represents the maximum
number of fields the EXPR will be split into, though the actual
number of fields returned depends on the number of times
PATTERN matches within EXPR. If LIMIT is unspecified or zero,
trailing null fields are stripped (which potential users of
"pop" would do well to remember). If LIMIT is negative, it is
treated as if an arbitrarily large LIMIT had been specified.

Just add at LIMIT of -1 to your split. Note: if the last ';' is a terminator instead of a separator, you will have one extra (empty) element at the end of your array:

my @arr = split /;/, $str, -1; # pop @arr; # to drop the last element

Replies are listed 'Best First'.
Re^2: Question regarding split(SOLVED)
by rjohn1 (Sexton) on Jan 21, 2014 at 03:02 UTC

    Beautiful. This is what i wanted.

    Thanks a lot guys...