in reply to Re^2: Question using system.
in thread Question using system.

Better yet:
open(my $cmd, '-|', 'getfilesdata', 'file.txt')

Replies are listed 'Best First'.
Re^4: Question using system.
by oko1 (Deacon) on Jul 10, 2008 at 20:36 UTC

    Perhaps I don't understand IPC as well as I thought I did. ikegami, would you mind explaining why this is supposed to be better?

    
    -- 
    Human history becomes more and more a race between education and catastrophe. -- HG Wells
    

      It wasn't required for that particular command, but it avoids the need for shell quoting.

      # XXX Buggy and susceptible to injection attacks. open(my $cmd, "getfilesdata $file |") # Fixed open(my $cmd, '-|', 'getfilesdata', $file)

        Sorry, I'm still unclear. I can see the 'buggy' part - e.g., specifying a "filename" containing odd characters which would cause Perl to barf on syntax - but injection attacks? Searching the Web doesn't come up with anything other than SQL injection attacks.

        
        -- 
        Human history becomes more and more a race between education and catastrophe. -- HG Wells