On 6/25/07, Mihir Kamdar <[EMAIL PROTECTED]> wrote:
if (2 != ($#ARGV+1)) {
That works, but it's usually written more like this: if (@ARGV != 2) {
open INFILE, "<$ARGV[0]" || die "unable to open INFILE"; open OUTFILE, ">$ARGV[1]" || die "unable to open OUTFILE";
These don't do what they look like. The vertical-bar-or operator is high precedence, so the string sticks too tightly to the die, and so the open will never die. Either put parentheses around the part to the left of the vertical-bar-or operator, or change to the low-precedence word 'or' operator. See the precedence chart in the perlop manpage.
It converts the fields in my input file like 097611/4 to 097611 097612 097613 097614 But there are some of the fields like 09778/0, which should be converted to 09778 09779 09770
So the 0 is a special case. Is that last one supposed to be 09770 or 09780? You can check for 0 and handle it separately. If $end isn't 0, you get what you need from ($start..$end) . If it is 0, your list of suffixes would be ($start..9, 0) instead. If you need 09780, you might need to go with something like this: my $range; if ($end) { @range = "$stub$start".."$stub$end"; } else { my $stub1 = $stub; $stub1++; # magical autoincrement @range = "$stub$start".."$stub1$end"; } Good luck with it! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/