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

  • Thread starter grocery_stocker
  • Start date
G

grocery_stocker

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?
 
G

grocery_stocker

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top