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__

Replies are listed 'Best First'.
Re^3: tagging question
by LassiLantar (Monk) on Jul 24, 2004 at 04:12 UTC
    I must not be a true perl master, because I hacked on your program and it got BIGGER!

    Gwuahaha! I am superior! (read: I am too lazy to write in use strict/use warnings on PM). I agree with you, use strict and warnings are totally necessary. I'm so lazy I even sometimes try to circumvent use strict by redeclaring my variables in random places, but really they're improving the way I write code. (As is sparring with the monks).

    Peace,
    LassiLantar