Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Henry Law
July 6, 2008, 5:44 pm
rate this thread
printing or some such). I code it like this:
my $ugly_variable = some_function(); # Or read from a file maybe
my $nice_variable = $ugly_variable; # Take a copy ...
$nice_variable =~ s/nasty/nice/g; # ... and then make it look nice
Of course that works very well. But it doesn't look perlish, and it
takes two statements. I'm looking for some one-shot construction, along
the lines of this
my $nice_variable = ($ugly_variable =~ s/nasty/nice/g);
... but if course that doesn't do what I want: $nice_variable ends up as
the number of substitutions done by s///. But is there a neater, more
succinct (but not hard to maintain) way of doing what I want? I'm sure
I saw something that looked like my wrong example above, but it must
have been different in some subtle way.
Of course I Googled for an answer to this; it's not that I found
nothing, more that I couldn't structure a query that returned anything
Henry Law Manchester, England
- » Authen::Captcha - How do I make it display the image
- — Previous thread in » PERL Discussions