in reply to Handling scalars as regexs within a substitution. (Take 2)
So here's another version that works:
I believe this has the same security problems as evaluating with double quotes, because it allows the execution of arbitrary perl code.#!/usr/bin/perl my $string="realllylongstringthatrefusestoend <A HREF=\"http://perlmo +nks.org/images/blah/blah/blah\">\n"; print splitter($string,"<.*?>",'(\S{18})','$1." "'); sub splitter{ my($string,$spliton,$find,$replace)=@_; my @array=split(/$spliton/,$string); my $i=0; my @splitters; my $str; while($string=~/($spliton)/g){ push @splitters,$1; } for (@array){ s/$find/$replace/eeg; ; $str.=$array[$i]; $str.=$splitters[$i]; $i++; } $str; }
--ZZamboni
|
|---|