Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Executing an app and returning output in a regex.

by Gibble (Novice)
on Dec 07, 2000 at 01:55 UTC ( [id://45337]=perlquestion: print w/replies, xml ) Need Help??

Gibble has asked for the wisdom of the Perl Monks concerning the following question:

I have the following regex: $_ =~ s/<!--PERLINSERT:transformXML-->/`sabcmd $boilervalues{'XSLTPath'}\\$xsl $xml`/gie; It works but...I need to replace the <!--PERLINSERT:transformXML--> with the output from the `sabcmd $boilervalues{'XSLTPath'}\\$xsl $xml` and am not getting the output!!! sabcmd is an app that is on the path so the program IS being run. Please help!!!
  • Comment on Executing an app and returning output in a regex.

Replies are listed 'Best First'.
(Ovid) Re: Executing an app and returning output in a regex.
by Ovid (Cardinal) on Dec 07, 2000 at 02:05 UTC
    Not sure what your difficulty is, but here are some thoughts:

    • Try specifying the absolute path to sabcmd: /usr/bin/sabcmd or something similar.
    • I assume you realize that \\$xsl is escaping the escape and therefore interpolating $xsl.
    • Have you tried printing $boilervalues{'XSLTPath'}, $xsl, and $xml to verify that they are getting values?
    • Try print the results of `sabcmd $boilervalues{'XSLTPath'}\\$xsl $xml` to verify that it is returning something. Even if it is fine, it may be a problem with the regex itself failing to match.
    • Have you verified that the target text is really there? Try printing that out, too.

    Cheers,
    Ovid

    Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Re: Executing an app and returning output in a regex.
by kilinrax (Deacon) on Dec 07, 2000 at 02:04 UTC
    That code should work, if `sabcmd ...` is returning a value.
    Try testing it by breaking that secion of code into two chunks:
    my $sabcmd = `sabcmd $boilervalues{'XSLTPath'}\\$xsl $xml`; print "SABCMD: $sabcmd\n"; $_ =~ s/<!--PERLINSERT:transformXML-->/$sabcmd/gi;
      Well that works! Of course I was wondering why I had all the extra output until I noticed the print "SABCMD..." line :) Tx for the help!!! I am still wondering why it didn't work in the regex though?
Re: Executing an app and returning output in a regex.
by chipmunk (Parson) on Dec 07, 2000 at 02:14 UTC
    The structure of your substitution worked fine for me; when I changed sabcmd to echo and set some values for the variables, I got back the results of `echo ...` in $_, as expected.

    Could you provide some more details about what happens when you run your program?

Re: Executing an app and returning output in a regex.
by c-era (Curate) on Dec 07, 2000 at 02:06 UTC
    That is the correct regex, what do you get if you just run the sabcmd expression?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://45337]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-19 04:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found