in reply to Regex with -

For the sake of efficiency, you will probably want to go with code that looks a lot like the snippet submitted by btrott although i think that this might be more similar to your initial posting. I added some extra whitespace matches, just because users are typically stupid.

if ($current_input =~ /^\s*ca\s+(\w+)\s*->\s*(\w+)\s*$/) { my ( $key, $value ) = ($1, $2); $aliases{$key} = $value; }


The other thought which occurs to me, is how are you attempting to retrieve the data back from the hash? You can always perform a sanity check to make sure that there is data in the hash.

foreach my $key (keys $aliases) { print "\$aliases{$key} = $alias{$key}\n"; }