Front page | perl.perl5.porters |
Postings from January 2005
[perl #33703] Using format variable & write command clears hash values
From:
Fraya . Cohen @ synopsys . com
Date:
January 6, 2005 13:49
Subject:
[perl #33703] Using format variable & write command clears hash values
Message ID:
rt-3.0.11-33703-105297.16.7217495314327@perl.org
# New Ticket Created by Fraya.Cohen@synopsys.com
# Please include the string: [perl #33703]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org:80/rt3/Ticket/Display.html?id=33703 >
This is a bug report for perl from fraya@synopsys.com,
generated with the help of perlbug 1.35 running under perl v5.8.5.
#! /usr/bin/env perl -w
## The bug that I'm seeing is that when I use the format command then
## perform the write then the value associated with a particular key
## is cleared. I am passing the hash to a sub-routine shown below
## then trying to print a value from the hash reference. Then I'd like
## to continue using the hash value, but it is cleared after performing the
## write command. This appears to be a Perl bug since I've looked through
## the documenation, and I can't find where this is specified as expected behavior.
## Plus it's pretty annoying since I want to use the hash values after printing them, but I can't due to this bug.
## -- Fraya Cohen
## fraya@synopsys.com
## Sr. IC Design Engineer, Synopsys, Inc.
package printing;
use strict;
use Carp;
use FileHandle;
use English;
sub print_fruit
{
my ($self, $sim) = @_;
my $file_name = "./fruit_rpt.txt";
print $sim->{'fruit'};
print " is the fruit inside print_fruit\n";
format STDOUT =
| ^<<<<<<<< |||
$sim->{'fruit'}
.
write;
print $sim->{'fruit'};
print " is the fruit inside print_fruit after write\n";
}
package main;
use strict;
use Carp;
{
my %sim = (fruit=> "apple");
print $sim{'fruit'};
print " is the value of fruit before format\n";
my $print = printing->print_fruit(\%sim);
print $sim{'fruit'};
print " is the value of fruit after format\n";
}
---
Flags:
category=core
severity=medium
---
Site configuration information for perl v5.8.5:
Configured by corey at Fri Dec 3 16:18:28 CST 2004.
Summary of my perl5 (revision 5 version 8 subversion 5) configuration:
Platform:
osname=solaris, osvers=2.8, archname=sun4-solaris
uname='sunos sol8gcc 5.8 generic_108528-15 sun4u sparc '
config_args='-de -Dcc=gcc -Duseshrplib -Dprefix=/global/freeware/SunOS/5.8/perl-5.8.5'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='gcc', ccflags ='-fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O',
cppflags='-fno-strict-aliasing -pipe -I/usr/local/include'
ccversion='', gccversion='2.95.3 20010315 (release)', gccosandvers='solaris2.8'
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='gcc', ldflags =' -L/usr/local/lib '
libpth=/usr/local/lib /usr/lib /usr/ccs/lib
libs=-lsocket -lnsl -ldl -lm -lc
perllibs=-lsocket -lnsl -ldl -lm -lc
libc=/lib/libc.so, so=so, useshrplib=true, libperl=libperl.so
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' -R /global/freeware/SunOS/5.8/perl-5.8.5/lib/5.8.5/sun4-solaris/CORE'
cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'
Locally applied patches:
---
@INC for perl v5.8.5:
/global/freeware/SunOS/5.8/2003.01/perl/lib/site_perl/5.8.5
/global/local/2003.01/perl/lib/site_perl/5.6.1/sun4-solaris
/global/local/2003.01/perl/lib/site_perl/5.6.1
/global/freeware/SunOS/5.8/perl-5.8.5/lib/5.8.5/sun4-solaris
/global/freeware/SunOS/5.8/perl-5.8.5/lib/5.8.5
/global/freeware/SunOS/5.8/perl-5.8.5/lib/site_perl/5.8.5/sun4-solaris
/global/freeware/SunOS/5.8/perl-5.8.5/lib/site_perl/5.8.5
/global/freeware/SunOS/5.8/perl-5.8.5/lib/site_perl
.
---
Environment for perl v5.8.5:
HOME=/home/fraya
LANG=C
LANGUAGE (unset)
LD_LIBRARY_PATH=/global/freeware/SunOS/5.8/gcc-3.3.2/lib:/global/apps/vcs_7.1.1L1/sparcOS5/gnulib:/global/apps1/vera_6.3.30/vera-6.3.30-solaris7/lib:/global/apps1/vera_6.3.30/vera-6.3.30-solaris7/lib/mti:/global/apps1/vera_6.3.30/vera-6.3.30-solaris7/lib/sro:/global/apps1/vera_6.3.30/vera-6.3.30-solaris7/lib/nc_vhdl:/global/local/2003.01/lib:/usr/local/lib
LOGDIR (unset)
PATH=/global/freeware/SunOS/5.8/gcc-3.3.2/bin:/global/apps/vcs_7.1.1L1/bin:/global/apps/vcs_7.1.1L1/gui/virsim/bin:/global/apps/vcs_7.1.1L1/sparcOS5/bin:/global/freeware/SunOS/5.8/perl-5.8.5/bin:/global/apps1/vera_6.3.30/vera-6.3.30-solaris7/bin:/global/apps/mti_6.0/modeltech/bin:/global/apps/mti_6.0/modeltech/sunos5:/global/local/2003.01/bin:/global/apps/lsf/6.0/sparc-sol7-64/etc:/global/apps/lsf/6.0/sparc-sol7-64/bin:/usr/bin:/usr/X/bin:/usr/dt/bin:/usr/openwin/demo:/usr/local/bin:/bin:/usr/ucb:/usr/xpg4/bin:/usr/ccs/bin:/usr/openwin/bin:/opt/CTXSmf/bin:.:/opt/CTXSmf/bin
PERL5LIB=/global/freeware/SunOS/5.8/2003.01/perl/lib/site_perl/5.8.5:/global/local/2003.01/perl/lib/site_perl/5.6.1
PERL_BADLANG (unset)
SHELL=/global/bin/tcsh