i am using use vars qw(%seg000) - where %seg000 is the hash name
here is a snippet of code :<br> 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);

In reply to Re: make a hash globally accessible by vipinh
in thread make a hash globally accessible by vipinh

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.