#!/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__
In reply to Re^2: tagging question
by beable
in thread tagging question
by bagerson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |