#!/usr/bin/perl -w
$in_xml = 0;
while (<>&) {
if ($in_xml) {
print $_;
if ($_ =~ /^--- End/) {
$in_xml = 0;
}
} else {
if ($_ =~ /^--- XML/) {
print $_;
$in_xml = 1;
}
}
}
$in_xml = 0;
while (<>&) {
if ($in_xml) {
print $_;
if ($_ =~ /^--- End/) {
$in_xml = 0;
}
} else {
if ($_ =~ /^--- XML/) {
print $_;
$in_xml = 1;
}
}
}
I then remembered that I didn't have to specify the =~ or $_, Perl being able to assume that for you, my revised version is:
#!/usr/bin/perl -w
$in_xml = 0;
while (<>) {
if ($in_xml) {
print $_;
if (/^--- End/) {
$in_xml = 0;
}
} else {
if (/^--- XML/) {
print $_;
$in_xml = 1;
}
}
}
$in_xml = 0;
while (<>) {
if ($in_xml) {
print $_;
if (/^--- End/) {
$in_xml = 0;
}
} else {
if (/^--- XML/) {
print $_;
$in_xml = 1;
}
}
}
1 This is entirely unlike mechanically separated chicken.
No comments:
Post a Comment