> Okay, I'm still struggling. <sigh> I just cannot seem to get my mind to > stop, look, and listen. Here's some code I'm working on:
> ------------------------- 8-< -------------------------------------------- > use strict; You might also want to add a use warnings after use strict and check how your program runs. > my %cmdLine; > my $DBG = 1; > while (<DATA>) { > chomp; > > my ($adx, $rest) = (split(/\:/,$_)); You don't have to escape ':' here, you can just write this as my ($adx, $rest) = split (/:/); perldoc -f split > if ($DBG) {print "\$adx=\t<$adx>\n\$rest=\t<$rest>\n";} > > while ($rest ne "") { If $_ contained the string 'abcd:', $rest will be undefined. This should be written as while (defined ($rest) && $rest ne "") > my ($opt, $arg, $newRest) = ($rest =~ /\s*([\-a-z]*)\s+([^ > ]*)\s+(.*)/); You don't have to escape '-' inside a character class when '-' is the first or last character within it. You should also use \s instead of [^ ]. perldoc perlre Better written as my ($opt, $arg, $newRest) = ($rest =~ /\s*([-a-z]*)\s+(\s*)\s+(.*)/); > $rest = $newRest; > $cmdLine{$opt} = $arg; > } > } > __DATA__ > ten-me-900: -r timbu -x me-900 -h ten-me-900 > hidit: -r tenbu -x networks-users -h hidit > postal: -x direct -h postal > pickit: -h pickit -x uncrp -r oakd > ------------------------- 8-< -------------------------------------------- > Why doesn't the while loop iterate all of $rest? I can't seem to figure > out how to get the loop to act on the entire $rest, and get it into the > hash. Make the above changes and see how it works > What am I doing wrong? I would suggest you use Getopt::Std for parsing switches perldoc Getopt::Std Here is an example #!/usr/local/bin/perl use strict; use warnings; use Getopt::Std; use Data::Dumper; while (<DATA>) { my %cmdLine; local @ARGV = split; (my $prog = shift (@ARGV)) =~ s/:$//; getopts ('r:x:h:', \%cmdLine); print Dumper(\%cmdLine); } __DATA__ ten-me-900: -r timbu -x me-900 -h ten-me-900 hidit: -r tenbu -x networks-users -h hidit postal: -x direct -h postal pickit: -h pickit -x uncrp -r oakd -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]