develooper Front page | perl.perl5.porters | Postings from January 2005

[perl #33703] Using format variable & write command clears hash values

Fraya . Cohen @ synopsys . com
January 6, 2005 13:49
[perl #33703] Using format variable & write command clears hash values
Message ID:
# New Ticket Created by 
# Please include the string:  [perl #33703]
# in the subject line of all future correspondence about this issue. 
# <URL: >

This is a bug report for perl from,
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
## 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 =
   |  ^<<<<<<<< |||

  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";

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:
    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
    cc='gcc', ccflags ='-fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    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/, so=so, useshrplib=true,
  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:

Environment for perl v5.8.5:
    LANGUAGE (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)
    SHELL=/global/bin/tcsh Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About