http://www.perlmonks.org?node_id=782695


in reply to Re: find acronyms in a text
in thread find acronyms in a text

my @words = $_ =~ m/\b[A-Z]+\b/g;

Aren't you missing capturing brackets there?

my @words = m/\b([A-Z]+)\b/g;
foreach(@words) { $acronyms_captured{$_} = undef; }

Personally, I'd write that as:

@acronyms_captured{@words} = ();

I like hash slices a lot :-)

--

See the Copyright notice on my home node.

Perl training courses

Replies are listed 'Best First'.
Re^3: find acronyms in a text
by arun_kom (Monk) on Jul 23, 2009 at 15:46 UTC
    well, i thought it didnt matter in this case either way as whatever is captured here is what i want ... but i guess adding capturing brackets to make it explicit is better practise.
    ... and also the same with using ( ) for undef
    am learning ... thanks