in reply to Re^8: warning: use of uninitialized value
in thread warning: use of uninitialized value
#!perl my %data_ids; while(my $line = <DATA>) { chomp $line; my ($key, $value) = split /::/, $line; $data_ids{$key} = $value; print $key, " => ", $value, "\n"; } for my $key (keys %data_ids) { print $key, " ==> ", $data_ids{$key}, "\n"; } # or just print $data_ids{'chipId'}, "\n"; print $data_ids{'subversid'}, "\n"; __DATA__ chipId::1925 subversid::0001
From your original code sample, I surmise that you need these IDs for generating an m4 macro. Using a hash might be useful for you since you can just look that up when generating the m4 file later on. Bear in mind all points raise in this thread, use close, closedir properly.
This got longer than expected. Next time around, you could save us all a lot of back and forth by including a small data sample as I showed above with __DATA__. Also, work through perlintro or an introductory perl book(learn.perl.org lists quite a few of them and some freely available online) and ask more questions here when you get stuck.
Good luck!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^10: warning: use of uninitialized value
by mrityunjaynath (Acolyte) on Jun 26, 2015 at 08:55 UTC | |
by robby_dobby (Hermit) on Jun 26, 2015 at 09:11 UTC | |
by mrityunjaynath (Acolyte) on Jun 26, 2015 at 10:17 UTC | |
by robby_dobby (Hermit) on Jun 26, 2015 at 10:31 UTC |