Subject: | Does not work under "use strict" |
The first SYNOPSIS example does not work if "use strict" is in effect:
use strict;
use File::Remote qw(:replace); # special :replace tag
# read from a remote file
open(REMOTE, "host:/remote/file") or die $!;
print while (<REMOTE>);
close(REMOTE);
This is causing compilation errors (tried with perl 5.18.4 and 5.8.1):
Bareword "REMOTE" not allowed while "strict subs" in use at ...
Bareword "REMOTE" not allowed while "strict subs" in use at ...
Execution of ... aborted due to compilation errors.
Using a lexical filehandle also does not work:
open(my $REMOTE, "host:/remote/file") or die $!;
print while (<$REMOTE>);
close($REMOTE);
This is causing a runtime error:
Bad usage of open(HANDLE, file) at ...
Here's a variant which seems to work under "use strict":
open(\*REMOTE, "host:/remote/file") or die $!;
print while (<REMOTE>);
close(\*REMOTE);