On Jan 04, 2002 at 05:24 +0800, Connie Chan took the soap box and proclaimed:
: say, $a = "1234:4321;abcde;fghij::;klmno";
: In case, I want $x = "1234" , $y = "4321", $data = "abcde;fghij::;klmno"
: Then I do in this way :
:
: @dataLine = split(/;/, $a);
: ($x, $y) = split (/:/, $dataLine[0]);
: $data = join(";", shift(@dataLine));
:
: So I can get the result what I want... but, anybody can suggest me if
: this process can be done simplier ?
There is a third argument to split, the number of items to split the
string into. Use this argument to split your string on colons or
semicolons, into no more than three chunks:
my( $x, $y, $data ) = split( /[;:]/, $a, 3 );
Enjoy!
Casey West
--
Shooting yourself in the foot with English
You put your foot in your mouth, then bite it off. (For those who
don't know, English is a McDonnell Douglas/PICK query language which
allegedly requires 110% of system resources to run happily.)
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]