Richard Lee wrote: > > Rob Dixon wrote: >> >> while (<FILE>) { >> my ($file1,$file2,$file3,$file4,$file5,$file6,$file10,$f`ile25,$file27) = >> map $_||'default', (split /\|/)[3,4,6,7,12,40,41,42,43,46,56,64]; >> } > > Thank you everyone. > > I like this solution the best and thanks for pointing out that I was > misusing |= vs ||=
I'm not entirely happy with it as it stands. The numbered $file99 variables are ugly and are screaming for an array, but without knowing more about what you're doing I can't improve on what you originally wrote. But I would prefer to see list of indices declared as a constant and the data values defaulted separately, like this: use constant INDICES => (3,4,6,7,12,40,41,42,43,46,56,64); while (<FILE>) { my @data = map $_ || 'default', split /\|/; my ($file1,$file2,$file3,$file4,$file5,$file6,$file10,$file25,$file27) = @data[(INDICES)]; } HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/