This code compiles the set using hash keys of unique stubs of the base name in the set of paths.
%stubs = map { $f=basename $_; $f =~ /^([A-Za-z]+[0-9]+)\./ ; $1=>() } @pathlist;
Why do I need links $fhere? I thought that everything would be with me:
%stubs = map { basename; /^([A-Za-z]+[0-9]+)\./; $1=>() } @pathlist;
But I do not meet. Am I not allowed to change $ _ in a map block?
For those who are wondering what the code is doing:
For each $ path (@pathlist), it gets a base name by matching the first sequence of alphabetic numbers, and then returns the first match as a key as the value of an empty list. Example:
/some/dir/foo123.adfjijoijb
/some/dir/foo123.oibhobihe
/some/dir/bar789.popjpoj
returns
foo123 => ()
bar789 => ()
After that, I use the map keys as a set of values, so I process it.
source
share