D
dgp
I recenctly received some help from this group (thanks again) in
comparing the first two fields of comma delimited data in a text file.
One of the suggestions used the following line to define a variable
containing the first two comma delimited fields from a line:
my $key = join ',', (split /,/ )[0,1];
This seems to work but if 'use warnings;' is envoked the line gives the
following warning: Use of uninitialized value in join or string...
I was able to avoid the warning if I broke up the line and used an
additional variable:
my @key = split /,/;
my $keyvalue = join(',', @key[0,1]);
The original line looks a more "Perlish" but what is the "proper" way
to accomplish this and avoid the warnings. Should I turn off 'use
warnings'?
Thanks for any help,
Dave
comparing the first two fields of comma delimited data in a text file.
One of the suggestions used the following line to define a variable
containing the first two comma delimited fields from a line:
my $key = join ',', (split /,/ )[0,1];
This seems to work but if 'use warnings;' is envoked the line gives the
following warning: Use of uninitialized value in join or string...
I was able to avoid the warning if I broke up the line and used an
additional variable:
my @key = split /,/;
my $keyvalue = join(',', @key[0,1]);
The original line looks a more "Perlish" but what is the "proper" way
to accomplish this and avoid the warnings. Should I turn off 'use
warnings'?
Thanks for any help,
Dave