What's the difference between *ERROR and \*ERROR in the followingcode

Discussion in 'Perl Misc' started by grocery_stocker, Oct 6, 2008.

  1. When I take a glob reference to ERROR....

    m-net% more mv.pl
    #!/usr/bin/perl -w

    use IPC::Open3;

    local (*READ, *WRITE, *ERROR);

    $pid = open3(\*READ, \*WRITE, \*ERROR, 'mv abc /efg');

    waitpid($pid, 0);
    if($?) {
    warn "exit code = ", $?>>8, "\n";
    my $result = <ERROR>;
    print $result;

    }

    I get....
    m-net% ./mv.pl
    exit code = 1
    mv: rename abc to /efg: No such file or directory


    But when I DON'T take a glob reference to ERROR, I get the same thing.
    m-net% more mv2.pl
    #!/usr/bin/perl -w

    use IPC::Open3;

    local (*READ, *WRITE, *ERROR);

    $pid = open3(*READ, *WRITE, *ERROR, 'mv abc /efg');

    waitpid($pid, 0);
    if($?) {
    warn "exit code = ", $?>>8, "\n";
    my $result = <ERROR>;
    print $result;

    }

    m-net% ./mv2.pl
    exit code = 1
    mv: rename abc to /efg: No such file or directory
    m-net%

    Why is this?
     
    grocery_stocker, Oct 6, 2008
    #1
    1. Advertising

  2. On Oct 5, 5:22 pm, grocery_stocker <> wrote:
    > When I take a glob reference to ERROR....
    >
    > m-net% more mv.pl
    > #!/usr/bin/perl -w
    >
    > use IPC::Open3;
    >
    > local (*READ, *WRITE, *ERROR);
    >
    > $pid = open3(\*READ, \*WRITE, \*ERROR, 'mv abc /efg');
    >
    > waitpid($pid, 0);
    > if($?) {
    >     warn "exit code = ", $?>>8, "\n";
    >     my $result = <ERROR>;
    >     print $result;
    >
    > }
    >
    > I get....
    > m-net% ./mv.pl
    > exit code = 1
    > mv: rename abc to /efg: No such file or directory
    >
    > But when I DON'T take a glob reference to ERROR, I get the same thing.
    > m-net% more mv2.pl
    > #!/usr/bin/perl -w
    >
    > use IPC::Open3;
    >
    > local (*READ, *WRITE, *ERROR);
    >
    > $pid = open3(*READ, *WRITE, *ERROR, 'mv abc /efg');
    >
    > waitpid($pid, 0);
    > if($?) {
    >     warn "exit code = ", $?>>8, "\n";
    >     my $result = <ERROR>;
    >     print $result;
    >
    > }
    >
    > m-net% ./mv2.pl
    > exit code = 1
    > mv: rename abc to /efg: No such file or directory
    > m-net%
    >
    > Why is this?



    Never mind. When I use strict refs in the later, I get an error.
    Presumably because the later could possibly be used as a ref string.
     
    grocery_stocker, Oct 6, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page