my $text = "a=10|b=20|c=20|d=\' I am multing line string A=10
dfasd fas
d
as df
asd
f a
sd
fas
d fsd \'|e=10"
foreach my $pairing (split(/\|/,$text)) {
print "$pairing ";
my ($field,$value)=split(/=/,$pairing);
print "**$field,$value**";
}
its not printing a= 10 , b=20 , c=20 , and
d=I am multing line string A=10 dfasd fas
d
as df
asd
f a
sd
fas
d fsd , e =10 ?
答案 0 :(得分:2)
指定第二个split
的限制:
#!/usr/bin/perl
use strict; use warnings;
my $text = "a=10|b=20|c=20|d=\' I am multing line string A=10
dfasd fas
d
as df
asd
f a
sd
fas
d fsd \'|e=10";
foreach my $pairing (split qr{\|}, $text) {
my ($field, $value) = split /=/, $pairing, 2;
print "**$field,$value**\n";
}