in reply to dd related

another option is to assign the output of the command to a filehandle, and then <> it. check open() for the details, but basically you can do:
open(DD, "/bin/dd $dd_options |"); while ($line = <DD>) { # do whatever with the output of dd, one line at a time ... }
hope this helps.

Replies are listed 'Best First'.
Re: Re: dd related
by arc_of_descent (Hermit) on Mar 27, 2002 at 13:10 UTC

    Hi,
    Is there any difference between the backticks and the process open
    which you have just demonstrated?
    I mean, does perl internally implement it differently?
    For eg. A backtick may be passed to the shell directly
    while the open(as above) may be implemented using popen,
    which involves creating a pipe, forking, and invoking
    the shell.
    Or does perl just execute the command and then provide you
    with a line by line output as you read it.

    Thanx
    --
    arc_of_descent
      > Is there any difference between the backticks and the process open which you have just demonstrated?
      A quick glance over the perlipc manpage reveals they that are similar in intent. They both fork and execute the process, but open() ...
      ... gives you finer control of the whole process, letting you to kill off the child process early if you'd like.
      So you might use open() if you want to exit from the process early in order to avoid unnecessary overhead.
      HTH

      broquaint