in reply to Match variables : Beginner in perl
Sometimes it is useful to try matching the components of your dataset against a regex or two to see what works and why. eg:
use strict; use warnings; use Test::More; for my $word (split (/ /, "I fear that I'll be extinct after a few mil +lion years.")) { like $word, qr/^\w*$/, "Match $word with \\w"; like $word, qr/^\S*$/, "Match $word with \\S"; } done_testing ();
Without the additional anchors here (the ^ and the $) everything would match so they are just necessary to force the proper test. If you run this you will see the differences between using \w and \S to match word or non-space characters. HTH.
|
|---|