in reply to Re: Grabbing tokens
in thread Grabbing tokens

Are you sure? I tried and it failed. To my understanding
$ret_var = <`$prg`>;
would first run $prg because of the backticks, and then try to handle this output as a filehandle.
$ret_var = `$prg`;
will do what you stated.

Replies are listed 'Best First'.
Re: Re: Re: Grabbing tokens
by cbro (Pilgrim) on May 14, 2003 at 12:43 UTC
    Yes, I'm sure...otherwise, I would not have stated that I tested it.
    Here are the exact programs so that you can verify. I will admit, I did mistype one thing...I forgot to put the './' in the $prg scalar:
    ###Begin Perl### #!/usr/local/bin/perl $prg = "./testers.sh"; $ret_val = <`$prg`>; print "\n\n$ret_val:From Perl Not BASH Script\n\n"; ###End Perl#### ###Begin Bash### #!/usr/local/bin/bash `/bin/cp /wantstats.sh /newstats.sh` echo Success ###End Bash###
    What is printed:


    Success:From Perl Not BASH Script


    Try these scripts Skeeve. I wouldn't just claimed to have tested something...
      Not here!
      $ ./p1 `./testers.sh`:From Perl Not BASH Script $
      I think you don't know what thos `` mean! In your testers.sh I see:
      `/bin/cp /wantstats.sh /newstats.sh`
      Luckily /bin/cp doesn't have any STDOUTput! Just go ahead and enter:
      `echo ls`
      You will get the output of ls not the text "ls"!

      this is because `xxx` first execute xxx and then execute the output of xxx!

      No don't execute but try to imagine what this will do:
      `echo rm -rf \*`
        I do know what the backticks mean...that is not the problem. I found out where the 'problem' is. Now...this is with the exact programs that I just posted on my last node. The reason we had a discrepency, IMO, is the versions of Perl we are using. You are right...the program does not work...at least not with perl, v5.6.1. I was working with perl, v5.00503, and it *DOES* work. I promise, I've ran it at least twenty times by now trying to replicate what you're getting. I ran it under 5.6.1 and there you go...I bow out, it's not working. BUT...If you have a 5.00503 install please try it so that I may have some redemption ;o).