in reply to Regex with -

What isn't working about it? It works for me; I added some code to dump out aliases (using Data::Dumper) and it contains the correct data:
% test.pl ca foo->bar $VAR1 = { 'foo' => 'bar' };
An alternate way of doing this, rather than using split, would be to use matching parens in the regular expression that you already have:
if ($in =~ /^(\w{2})\s+(\w+)->(\w+)$/) { my($command, $key, $value) = ($1, $2, $3); $aliases{$key} = $value; }
This would work if your commands are always 2 characters long, and if they always have the same format with the "->".

Replies are listed 'Best First'.
RE: Re: Regex with -
by elusion (Curate) on Jul 21, 2000 at 01:27 UTC
    When I try to access the value using $aliases{something} it's not giving me anything. The other part of the script is taking input from the user and accessing the hash with the key to produce the value. It works with the keys/values of the hash that I wrote into the script, but not the ones that the user adds.
    - p u n k k i d