in reply to small regex help

The following seems to be what you are after:

use strict; use warnings; my @lines = <DATA>; foreach my $line (@lines) { next if $line !~ m/(\d+\s)\s*(.+?)\s*$/; print "$1(Birthday) $2 - singer\n"; } __DATA__ January 1, 1915 Franck Pourcel January 3, 1926 George Martin January 3, 1945 Stephen Stills January 3, 1946 John Paul Jones January 4, 1942 John McLaughlin January 5, 1950 Chris Stein

Prints:

January 1, 1915 (Birthday) Franck Pourcel - singer January 3, 1926 (Birthday) George Martin - singer January 3, 1945 (Birthday) Stephen Stills - singer January 3, 1946 (Birthday) John Paul Jones - singer January 4, 1942 (Birthday) John McLaughlin - singer January 5, 1950 (Birthday) Chris Stein - singer

However you probably want to read up a little about sprintf (to clean up the formatting). You might also want to read the Tutorials sections here for an introduction to regexen. Also read the Perl man pages perlretut, perlrequick and perlre.


DWIM is Perl's answer to Gödel