Hi, I'm new to Perl but I have some experience in other languages.
Anyway I need to split a string on the character "|".
let's say our string is "one|two|th ree"
when I try the following code:
[CODE=perl] @fields = split('|' , $line); [/CODE]
My line gets splitted into serperated letters instead of one two and three. Same when I replace '|' with /|/
when I replace the | with a space in my string, and do thesame in my split-code:
[CODE=perl]
$line = "one two three";
@fields = split(' ' , $line);[/CODE]
the split does what I expect.
the elements of the array are:
$fields[0] : one
$fields[1] : two
$fields[2] : three
So..I'm confused why it works with a space, and not with '|'.. I need to get it to work with '|' ..Can anyone help me?
Anyway I need to split a string on the character "|".
let's say our string is "one|two|th ree"
when I try the following code:
[CODE=perl] @fields = split('|' , $line); [/CODE]
My line gets splitted into serperated letters instead of one two and three. Same when I replace '|' with /|/
when I replace the | with a space in my string, and do thesame in my split-code:
[CODE=perl]
$line = "one two three";
@fields = split(' ' , $line);[/CODE]
the split does what I expect.
the elements of the array are:
$fields[0] : one
$fields[1] : two
$fields[2] : three
So..I'm confused why it works with a space, and not with '|'.. I need to get it to work with '|' ..Can anyone help me?
Comment