in reply to Compiled regex as hash key vs. string?
outputsuse strict; use warnings; my %test; my $re = qr/foo/; my $s = 'foo'; print('re: ', ref($re) || 'Not Regexp', "\n"); print('s: ', ref($s ) || 'Not Regexp', "\n"); $test{$re} = 1; $test{$s } = 1; foreach (keys %test) { print("key $_: ", ref($_) || 'Not Regexp', "\n"); }
re: Regexp s: Not Regexp key (?-xism:foo): Not Regexp key foo: Not Regexp
|
|---|