in reply to Filename Parsing
Best way? I don't know if there is a "best way", just lots of ways to do it.
Here is my solution:
#!/usr/bin/perl -w use strict; use warnings; use diagnostics; + my %fn=(); while (my $fnam=<DATA>) { chomp $fnam; next unless $fnam =~ m@ ^( # Begin capture $1 [a-zA-Z]+ # One or more alphas \_ # followed by underscore \d+ # one or more digits ) # End capture $1 .*$ # Who cares about the rest @x; $fn{$1}++; } + printf "%s\n",join("\n",sort keys %fn); exit(0); __END__ smith_13_503_de7.p smith_13_502_de7.v jones_104_503_de7.p jones_104_502_de7.v
When run it produces:
--$ perl fnamParse.pl jones_104 smith_13 --$
| Peter L. Berghold -- Unix Professional Peter at Berghold dot Net | |
| Dog trainer, dog agility exhibitor, brewer of fine Belgian style ales. Happiness is a warm, tired, contented dog curled up at your side and a good Belgian ale in your chalice. | |
|
|---|