Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: hash problem

by licking9Volts (Pilgrim)
on May 21, 2002 at 15:57 UTC ( #168169=note: print w/replies, xml ) Need Help??

in reply to uninitialized value on hash lookup (was: hash problem)

It looks like $Line isn't getting a value assigned to it. I think your split command should have parentheses around the regexp:
my ($Line, $Filed, $Dvalue) = split(/\t/);
If you're splitting a record on tabs, you might want to check if multiple tabs separate the fields. If so, you could use:
my ($Line, $Filed, $Dvalue) = split(/\t+/);
I'm a beginner PERL user but I hope that helps.

Update: Changed /\t*/ to /\t+/ to avoid unexpected results. Thanks esper!

Replies are listed 'Best First'.
Re: Re: hash problem
by dsheroh (Prior) on May 21, 2002 at 16:10 UTC
    Just one minor detail: You want to split on /\t+/ instead of /\t*/ since the * will also match 0 tabs and could split within a field (since there are 0 tabs between every pair of characters) instead of only between fields.
Re: Re: hash problem
by Anonymous Monk on May 21, 2002 at 17:09 UTC

    Thank you for your help!
    My first file is a table:
    Line Field Dvalue
    a123 A1 12.83
    a124 A1 9.68
    and second file is a table too:
    Name Data
    a123 acgt...(whole sequence)
    a124 catt...
    both table all use tab to separate each column. Please help!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://168169]
[james28909]: it would be to much work just to get around renaming three subs lol
[james28909]: but you could put it all in one sub and return the same data type that was inputted. i could write a small example maybe
[Lady_Aleena]: Their uses are also vastly different.
[Lady_Aleena]: The first two make hashes and arrays from a file, the third returns data from a pre-existing hash.
[Lady_Aleena]: Well, HoH and AoH respectively.
[Lady_Aleena]: But if you want to play, play. I don't mind. 8)

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2017-05-24 05:06 GMT
Find Nodes?
    Voting Booth?