in reply to Re: Re: problem with substituting
in thread problem with substituting
Note the lack of substitute. If you want to replace $checksize1 with the result of calling ax.pl then all you need to do is:my $checksize1 = qq{<html><head></head><body>Huge wad of html</body></ +html>}; # Run ./cgi-local/axis/ax.pl over $checksize1 # Note, calling qx{} is the same as using backticks # calling qx{} in an array context means each # separate line returned is added as the next # element in an array. If you want it all in # a single scalar, call it in scalar context. # doing things this way assumes that ax.pl is # happy to take info on STDIN my @results = qx{ ./cgi-local/axis/ax.pl < $checksize1 };
Now, if you ONLY wanted to run ax.pl over the BODY of the huge wad of html, or any other small section then the method you have to use is different. You'll need to extract that small section and then rejoin the strings. Something like:$checksize1 = qx{ ./cgi-local/axis/ax.pl < $checksize1 };
Note however that HTML is MUCH more complicated that this (consider the possiblity of having a close body tag within your input...) and that (at the least) you'll need to ensure that your BODY tags are consistant such that you can make a regular expression that will consistantly find and match them. (Note also that .* isn't a recommended grab all). You will need to have a better regexp than I have here. You might even consider using one of the HTML modules (like HTML::Parser).my $checksize1 = qq{<html>\n<head>\n</head>\n<body>\nHuge wad of html\ +n</body>\n</html>}; my ($head, $body, $foot) = $checksize1 =~ m{(.*)<body>(.*)</body>(.*)$ +}si; $body = qx{./cgi-local/axis/ax.pl < $body}; $checksize1 = qq{$head<body>\n$body</body>$foot};
If all you are trying to do is to run ax.pl over the .shtml file once it's been written to, your job is much easier.
open(FILE, "> blah.shtml") or die "$!"; print FILE $checksize1; close(FILE); my $res = qx{./cgi-local/axis/ax.pl blah.shtml}; if($res ....){} # don't forget to ensure that ax.pl worked.
If none of this helps you do what you need to do, then please try responding with more than 2 sentences explaining in detail what it is that you are trying to do, and giving us clear test data and expected results.
Hope this helps.
jarich
|
|---|