in reply to split function gives emply line as output of the array element

perldoc -f split
split /PATTERN/ split Splits the string EXPR into a list of strings and returns that list. By default, empty leading fields are preserved, and empt +y trailing ones are deleted. (If all fields are empty, they are considered to be trailing.)
Why don't you split on ";" like has already been suggested?
  • Comment on Re: split function gives emply line as output of the array element
  • Download Code

Replies are listed 'Best First'.
Re^2: split function gives emply line as output of the array element
by Anonymous Monk on Nov 09, 2009 at 07:01 UTC
    If there is no leading empty space (field), in his case shouldn't split return just two elements in the array?
      split CUTS your string into fields. Between the beginning of string and "WINGFRAME ", there is the empty string. Example
      $ perl -e " print qq!($_)\n! for split /,/, q!,1,2,3!" () (1) (2) (3) $ perl -e " print qq!($_)\n! for split /,/, q!,,,,1,2,3!" () () () () (1) (2) (3) $ perl -e " print qq!($_)\n! for split /(,)/, q!,,,,1,2,3!" () (,) () (,) () (,) () (,) (1) (,) (2) (,) (3)
      There is an empty string around every corner
      $ perl -e " print qq!($_)\n! for split /,/, q!5,,,!" (5) $ perl -e " print qq!($_)\n! for split /(,)/, q!5,,,!" (5) (,) () (,) () (,)