in reply to Re^4: warning: use of uninitialized value
in thread warning: use of uninitialized value
Ok, so I understand that the first line of the file “config.txt” is as follows:
chipid 1925 subversid 0003
It seems you have now chosen to split on whitespace; in which case, it’s safer to use:
@words = split /\s+/, $readline;
as this will split on one or more consecutive spaces (or tabs, etc.). This will result in the array @words containing four elements: chipid, 1925, subversid, and 0003. The following one-liner demonstrates this:
23:29 >perl -MData::Dump -wE "my $s = qq[chipid 1925 subversid 0003\n] +; my @w = split /\s+/, $s; dd \@w;" ["chipid", 1925, "subversid", "0003"] 23:30 >
So, in this case (and remembering that array subscripts begin at zero), the values you want are in $words[1] and $words[3].
BTW, why do you read the second line from $CFILE into $readline, when that second line is never used?
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: warning: use of uninitialized value
by u65 (Chaplain) on Jun 25, 2015 at 17:14 UTC | |
by hippo (Archbishop) on Jun 25, 2015 at 19:22 UTC | |
by u65 (Chaplain) on Jun 25, 2015 at 20:18 UTC | |
|
Re^6: warning: use of uninitialized value
by mrityunjaynath (Acolyte) on Jun 26, 2015 at 04:00 UTC | |
by robby_dobby (Hermit) on Jun 26, 2015 at 05:05 UTC | |
by mrityunjaynath (Acolyte) on Jun 26, 2015 at 05:26 UTC | |
by robby_dobby (Hermit) on Jun 26, 2015 at 05:47 UTC | |
by mrityunjaynath (Acolyte) on Jun 26, 2015 at 08:55 UTC | |
|