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. Advertisements

  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. Advertisements

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.
Similar Threads
  1. Jeffry van de Vuurst
    Replies:
    0
    Views:
    2,294
    Jeffry van de Vuurst
    May 18, 2004
  2. jakk
    Replies:
    4
    Views:
    13,961
  3. Santa
    Replies:
    1
    Views:
    1,457
    Mark A. Odell
    Jul 17, 2003
  4. Replies:
    7
    Views:
    611
    Keith Thompson
    Oct 3, 2006
  5. arnuld
    Replies:
    33
    Views:
    1,553
  6. chad
    Replies:
    2
    Views:
    346
  7. PerlFAQ Server
    Replies:
    0
    Views:
    569
    PerlFAQ Server
    Jan 6, 2011
  8. PerlFAQ Server
    Replies:
    0
    Views:
    496
    PerlFAQ Server
    Apr 15, 2011
Loading...