Front page | perl.perl5.porters |
Postings from July 2000
Looking for a starting point (Mark-Jason?, Chip?, Jarkko?)
Thread Next
From:
H . Merijn Brand
Date:
July 25, 2000 13:53
Subject:
Looking for a starting point (Mark-Jason?, Chip?, Jarkko?)
Message ID:
20000725224509.81FE.H.M.BRAND@hccnet.nl
Jan-Pieter an I are (still) searching for that format extension.
After doing the next patch
--8<---
*** pp.c.org Tue Jul 25 21:06:25 2000
--- pp.c Tue Jul 25 12:06:00 2000
***************
*** 591,596 ****
--- 591,599 ----
case 'F':
if (strEQ(elem, "FILEHANDLE")) /* XXX deprecate in 5.005 */
tmpRef = (SV*)GvIOp(gv);
+ else
+ if (strEQ(elem, "FORMAT"))
+ tmpRef = (SV*)GvFORM(gv);
break;
case 'G':
if (strEQ(elem, "GLOB"))
-->8---
we are able to examine the SCALAR contents of a glob like
if (defined *XX{FORMAT}) { ... }
And the copy of a glob as in '*YY = *XX' also copies the FORMAT entry - which
it of course already did before the path - but a single assignment of only the
FORMAT entry will assign to the SCALAR entry - Arrghh.
Next code snippet shows what happens:
--8<---
#!/pro/3gl/CPAN/perl-5.6.0/perl
#!/pro/3gl/CPAN/perl-5.6.0/perl -D42815
use Data::Dumper;
sub showglobs ()
{
foreach my $x (qw(SCALAR ARRAY HASH CODE IO FORMAT GLOB)) {
print $x, "\t", *XX{$x}, "\t", Data::Dumper->Dump ([*XX{$x}], ["XX"]),
"\t", *YY{$x}, "\t", Data::Dumper->Dump ([*YY{$x}], ["YY"]),
"\t", *ZZ{$x}, "\t", Data::Dumper->Dump ([*ZZ{$x}], ["ZZ"]),
"\n";
}
} # showglobs
$XX = "foo";
@XX = ("foo");
%XX = ( foo => 1 );
open XX, "</dev/null";
sub XX { "foo" };
format XX =
foo
.
*YY = *XX;
*ZZ = \*XX{FORMAT};
showglobs;
-->8---
will show (reformatted):
--8<---
cannot handle ref type 14 at /pro/lib/perl5/5.6.0/PA-RISC2.0/Data/Dumper.pm line 150.
SCALAR SCALAR(0x40059934) $XX = \'foo';
SCALAR(0x40059934) $YY = \'foo';
SCALAR(0x40022648) $ZZ = \;
ARRAY ARRAY(0x40022468) $XX = [ 'foo' ];
ARRAY(0x40022468) $YY = [ 'foo' ];
$ZZ = undef;
HASH HASH(0x400a3504) $XX = { 'foo' => 1 };
HASH(0x400a3504) $YY = { 'foo' => 1 };
$ZZ = undef;
CODE CODE(0x400a3570) $XX = sub { "DUMMY" };
CODE(0x400a3570) $YY = sub { "DUMMY" };
$ZZ = undef;
cannot handle ref type 15 at /pro/lib/perl5/5.6.0/PA-RISC2.0/Data/Dumper.pm line 150.
cannot handle ref type 15 at /pro/lib/perl5/5.6.0/PA-RISC2.0/Data/Dumper.pm line 150.
IO IO::Handle=IO(0x400a3540) $XX = bless (, 'IO::Handle');
IO::Handle=IO(0x400a3540) $YY = bless (, 'IO::Handle');
$ZZ = undef;
cannot handle ref type 14 at /pro/lib/perl5/5.6.0/PA-RISC2.0/Data/Dumper.pm line 150.
cannot handle ref type 14 at /pro/lib/perl5/5.6.0/PA-RISC2.0/Data/Dumper.pm line 150.
FORMAT FORMAT(0x400a35b8) $XX = ;
FORMAT(0x400a35b8) $YY = ;
$ZZ = undef;
GLOB GLOB(0x4005997c) $XX = \*::XX;
GLOB(0x40035b5c) $YY = \*::XX;
GLOB(0x4009f9ac) $ZZ = \*::ZZ;
-->8---
In this case *ZZ{SCALAR} should still be undef, whereas *ZZ{FORMAT} should not
be undef.
We've been trying to understand the code in the plane back to the Netherlands,
but we seem to be stuck. Where do we look?
BTW. The patch for accessing the FORMAT entry in the glob fixes a problem in
several of my programs, but I really do not want to apply it if a side
effect like described is introduced.
--
H.Merijn Brand Amsterdam Perl Mongers (http://www.amsterdam.pm.org/)
using perl5.005.03, 5.6.0 & 516 on HP-UX 10.20, HP-UX 11.00, AIX 4.2, AIX 4.3,
DEC OSF/1 4.0 and WinNT 4.0 SP-6a, often with Tk800.022 and/or DBD-Unify
ftp://ftp.funet.fi/pub/languages/perl/CPAN/authors/id/H/HM/HMBRAND/
Thread Next
-
Looking for a starting point (Mark-Jason?, Chip?, Jarkko?)
by H . Merijn Brand