summaryrefslogtreecommitdiff
path: root/doio.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-09-17 20:47:26 -0700
committerFather Chrysostomos <sprout@cpan.org>2011-09-17 20:47:26 -0700
commit433644eed8ac93495dfaad947c1503ce219b414b (patch)
treef7e8fdd9ff6ec961b60681c593ac42ef7ccfcce1 /doio.c
parent1f26655e82dbc83bdd3dbbc6003d6099c44c2982 (diff)
downloadperl-433644eed8ac93495dfaad947c1503ce219b414b.tar.gz
Make -l always treat non-bareword arguments as file names
Here is some suspicious code in Perl_my_lstat_flags: if (SvROK(sv) && isGV_with_GP(SvRV(sv)) && ckWARN(WARN_IO)) { Perl_warner(aTHX_ packWARN(WARN_IO), "Use of -l on filehandle %s", GvENAME((const GV *)SvRV(sv))); return (PL_laststatval = -1); } The behaviour differs depending on whether warnings are enabled. That -1 turns into undef in pp_ftlink. So we get an undef return value with warnings on, but a file test on a file name otherwise. In 5.6.2, -l $foo always treated $foo as a file name. In 5.8+, if it is a reference (ignoring magic) and the reference points to a typeglob (ignoring magic) and io warnings are on, it warns and returns undef. So the only time that undef return is reached is when a warning has been emitted, so it’s code that will likely be corrected before it goes into production. Hence I think it unlikely that anyone could be relying on the behaviour of -l \*foo (under warnings). So this commit restores the 5.6 behaviour for that case.
Diffstat (limited to 'doio.c')
-rw-r--r--doio.c5
1 files changed, 0 insertions, 5 deletions
diff --git a/doio.c b/doio.c
index f03db274c4..e6e9016785 100644
--- a/doio.c
+++ b/doio.c
@@ -1352,11 +1352,6 @@ Perl_my_lstat_flags(pTHX_ const U32 flags)
PL_statgv = NULL;
sv = POPs;
PUTBACK;
- if (SvROK(sv) && isGV_with_GP(SvRV(sv)) && ckWARN(WARN_IO)) {
- Perl_warner(aTHX_ packWARN(WARN_IO), "Use of -l on filehandle %s",
- GvENAME((const GV *)SvRV(sv)));
- return (PL_laststatval = -1);
- }
file = SvPV_flags_const_nolen(sv, flags);
sv_setpv(PL_statname,file);
PL_laststatval = PerlLIO_lstat(file,&PL_statcache);