http://qs321.pair.com?node_id=377053


in reply to Re: tagging question
in thread tagging question

I must not be a true perl master, because I hacked on your program and it got BIGGER!
#!/usr/bin/perl # you have to use strict and warnings unless you # have a really good reason not to. use strict; use warnings; my $string = "il asdfasdfasdf"; my $tag = ""; # use matching here instead of substitution # all of the string should appear in the output # also, don't need square brackets in match if ($string =~ m/(\S{2})/) { $tag = "<$1>"; } # you don't need to concatenate, just interpolate the lot $string = "$tag $string $tag"; print "string = $string\n"; __END__