For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > April 2005 > Re: Binding Operator =~ Pattern Matching









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Binding Operator =~ Pattern Matching
Paul Kraus

2005-04-27, 3:56 am

> (my $orders_dir)
> File 121212.TXT ...contains
> 12345.html <spaces> CR
> 12346.html <spaces> CR
>=20
> Here is the piece I'm having trouble w/
>=20
> foreach my $html (@htmls) {
> if ($html =3D~ /^($_)\s*/) {
> my $msg =3D MIME::Lite->new (


Where does it fail?=20
if ($html =3D~ /^($_)\s*/)=20
$_ has no value since you forloop is assigning to $html so I am not
sure what you are trying to match with ($_)

looking at your sample data this would work
if ( $html =3D~ /^(\d+\.html)/ ){
my $filename =3D $1;
} =20
filename would contain your files.

^ Beg line
\d+ any number of digits (0-9)
\. followed by a period
html followed by html

the () capture the match into $1.

HTH,
Paul
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com