#!/usr/bin/perl -w use strict; my @la = (); my %card; open FILE, $ARGV[0] or die "couldn't open $ARGV[0]: $!\n"; while (1) { my $response; if ( scalar @la == 0 ) { last if eof FILE; chomp( $la[0] = ); } if ( $la[0] =~ /^\s*(\S.*\S*)\s*$/ ) { $la[0] = $1; print < ); if ( $response == 2 ) { $card{'ln'} = $la[0]; shift @la; } if ( $response == 3 ) { $card{'fn'} = $la[0]; shift @la; } if ( $response == 4 ) { $card{'sa'} = $la[0]; shift @la; } if ( $response == 5 ) { $card{'ci'} = $la[0]; shift @la; print "in response == 5: $la[0]\n"; #"OH" like you would expect } if ( $response == 6 ) { $card{'st'} = $la[0]; shift @la; } if ( $response == 7 ) { $card{'hp'} = $la[0]; shift @la; } if ( $response == 8 ) { $card{'wp'} = $la[0]; shift @la; } if ( $response == 9 ) { $card{'cp'} = $la[0]; shift @la; } if ( $response == 1 ) { @la = split /\,\s*/, $la[0]; } else { $card{'co'} = $la[0]; shift @la; } if ($la[0] eq undef) { print "\$la[0] is undef\n"; #now it's undef! } } else { #nothing matched on this line, probably empty warn "WARN: $la[0]\n"; @la = (); } } close FILE;