vipinh has asked for the wisdom of the Perl Monks concerning the following question:
use vars qw(%seg000); %seg000 = (); #ONE OF THE MANY SUBROUTINES WHERE THE HASH IS ASSIGNED VAUES sub ProcessSegment000 { my $dataline = shift; $seg000{fileid} = substr($dataline,0,3); print "INSIDE the segment : " . $seg000{fileid} . "\n"; -#THIS PRINT + STATEMENT SHOWS THAT THE HASH NOW CONTAINS DATA $seg000{filetype} = substr($dataline,3,3); $seg000{fileversionid} = substr($dataline,6,5); $seg000{impactionind} = substr($dataline,11,1); $seg000{expactionind} = substr($dataline,12,1); $seg000{mornetcaseid} = substr($dataline,13,30); } sub readfile -- THIS SUB FIRES THE ABOVE SUBROUTINE { my $myfile = shift; while (!eof $myfile){ chomp($input = readline($myfile)); my $segmentno = substr($input,0,3); eval "\%seg000 = &ProcessSegment$segmentno(\$input,\\\%seg000) +"; print "OUTISDE THE SUBROUTINE " . $seg000{fileid}; #THIS PRINT STATEMENT SHOWS NO DATA IN THE HASH. } } $file="c\:\\0008022.fnm"; -the data file to be read open FILEHANDLE, "<$file"; readfile(\*FILEHANDLE);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(tye)RE: global hash going out of scope
by tye (Sage) on Oct 06, 2000 at 21:17 UTC | |
|
code tags (was: Re: RE: global hash going out of scope)
by merlyn (Sage) on Oct 06, 2000 at 20:44 UTC | |
by vroom (His Eminence) on Oct 06, 2000 at 20:49 UTC |