in reply to Regex Semantics

Basically, the regex says 'May or may not start with 'a', but otherwise I don't care'. In other words, this regex will evaluate to TRUE with any value you pass it, since '*' signifies 'zero or many'.

If you are looking for a regex that says 'Must start with the character class I specify, otherwise fail', you will need to substitute the '*' for a '+', where the '+' implies 'one or many' rather than 'zero or many'.

Therefore:
$foo = "1"; if ( $foo =~ /^[a]+/ ) { print "Match\n"; }
You will see the difference.

Also, a good resource for these types of questions are in the Perl documentation. For Perl Regular Expressions, try 'perldoc -f perlre' from the command-line, or Perlmonks has the page as well.

---------
perl -le '$.=[qw(104 97 124 124 116 97)];*p=sub{[@{$_[0]},(45)x 2]};*d=sub{[(45)x 2,@{$_[0]}]};print map{chr}@{p(d($.))}'