Mailing List Archive

Re: use strict
probably select() should return a \*FH instead of "FH".

--tom
Re: use strict [ In reply to ]
Graham Barr <bodg@tiuk.ti.com> writes:
>I was just attempting to test some of my check some of my code with
>use strict;
>
>However my code contained the following statement
>
> select((select($fd), $| = 1)[$[]);
>
>use strict 'refs' causes this to crash with
>
>Can't use string ("main::STDOUT") as a symbol ref while "strict refs" in use at tst line 80.
>
>My question is, is this a bug or is there some other way to turn on
>autoflushing of a file handle ?

It seems that select always returns the name ot the currently selected
filehandle, eg

#!/usr/local/bin/perl
$fd = \*STDERR;
print $fd,"\n",select($fd),"\n",select($fd),"\n";

outputs:

GLOB(0x8e2cc)
main::STDOUT
main::STDERR

Is this really what we want ?

although as a work for use strict

use strict;
select( ( eval '\\*' .select($fd), $| = 1)[0]);

does not fail :-)

Regards,
Graham.


--
Graham Barr <bodg@tiuk.ti.com>
Texas Instruments Ltd.
Re: use strict [ In reply to ]
Tom Christiansen <tchrist@mox.perl.com> writes:
>probably select() should return a \*FH instead of "FH".
>

Hers a patch which does just that

--- pp_sys.c.orig Thu Nov 16 02:51:33 1995
+++ pp_sys.c Fri Nov 24 17:12:16 1995
@@ -698,11 +698,7 @@
if (! hv)
XPUSHs(&sv_undef);
else {
- GV **gvp = hv_fetch(hv, GvNAME(egv), GvNAMELEN(egv), FALSE);
- if (gvp && *gvp == egv)
- gv_efullname(TARG, defoutgv);
- else
- sv_setsv(TARG, sv_2mortal(newRV(egv)));
+ sv_setsv(TARG, sv_2mortal(newRV(egv)));
XPUSHTARG;
}

Regards,
Graham.

--
Graham Barr <bodg@tiuk.ti.com>
Texas Instruments Ltd.