Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
what i want to do, and can't, is cut /<%bar%>/and put it into /foo/ while replacing /textarea/ with /input/<img src="xhtml/img/cancel.gif" width="24" height="13" alt="Cancel" / +> <textarea type="text" value="foo" name="text_message" /> <%bar%>& +nbsp;</p>
many thanks!foreach $file (@files) { $file_new = $file; open(IN, $file_new); $content = <IN>; $content =~s/xhtml/wml/g; #...do lots more swopping here... $content =~s/<h1>/<p><b>/g; # now i want to replace /textarea/ below with /input/ and also tak +e /<%bar%>/ and put it into /foo/ # trying something like this- doesn't work while ($content =~ m/\(<textarea.*?>\)/sg) { my $match = $1; $match =~ s/\n//g; print " MATCH $match\n"; if($bar=~m/<%*?%>/){ $foo =~ m/foo/; $value_of_bar = $bar; # how to get $bar into $foo? $content =~ s/$foo/$bar/g; } } # write $content to file open(OUT, ">$ARGV[1]/$file_new") || die "cannot open $ARGV[1]/$file_ne +w"; print $content; print OUT $content;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: extracting regex into, and interpolating, variable
by roik (Scribe) on Oct 23, 2002 at 13:57 UTC | |
by zusuki-san (Initiate) on Oct 23, 2002 at 14:41 UTC | |
by roik (Scribe) on Oct 23, 2002 at 15:23 UTC |