Thanks Tom and James for your help.

Sorry I forgot to mention that the filename has the filename "path" in it. 
Hence the caret "^" wouldn;t work.
Eg of filename:"C:\ba\log\ULOG.20010101"

I did have a look at the perlre manpage. Tried the options but I could'nt 
get it to work.

Do you or anyone else have any suggestion.

Thanks
Steven Chua


>From: Thomas Bätzler <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>CC: "'Steven&Alison Chua'" <[EMAIL PROTECTED]>
>Subject: RE: FileName Pattern Matching
>Date: Thu, 27 Sep 2001 10:47:26 +0200
>MIME-Version: 1.0
>Received: from [213.69.87.217] by hotmail.com (3.2) with ESMTP id 
>MHotMailBD7C3285003D40043794D54557D9B14B0; Thu, 27 Sep 2001 01:47:02 -0700
>Received: from kardeexc01.peregrine.com (localhost [127.0.0.1])by 
>rhein.harbinger.de (8.9.1b+Sun/8.9.1) with ESMTP id KAA24606;Thu, 27 Sep 
>2001 10:40:09 +0200 (MET DST)
>Received: by kardeexc01.harbinger.de with Internet Mail Service 
>(5.5.2650.21)id <T1NG6FDP>; Thu, 27 Sep 2001 10:47:26 +0200
>From [EMAIL PROTECTED] Thu, 27 Sep 2001 01:47:47 -0700
>Message-ID: 
><[EMAIL PROTECTED]>
>X-Mailer: Internet Mail Service (5.5.2650.21)
>
> > From: Steven&Alison Chua [mailto:[EMAIL PROTECTED]] asked:
> > I'm having some difficulty matching files starting with a name.
>[...]
> > I've tried using the following line but it is not accurate as
> > it retuens
> > files with ULOG at the end of the filename as well:
> >
> > (-f $_ && $_=~/\ULOG/i && ...
>
>Read the perlre manpage.
>
>I guess you want "$_ =~ m/^ulog/i" where the caret anchors the
>pattern at the start of the string and the /i modifier makes
>this a case-independant match:
>
>#!/usr/bin/perl -w
>
>use strict;
>
>my @tests = ("ulogbla.foo", "blaulog.foo", "foobla.ulog",
>            "ULOGbla.foo", "UlOGfoo.bla", "uLoGbla.foo" );
>
>foreach my $test ( @tests ){
>   if( $test =~ m/^ulog/i ){
>     print "$test matches\n";
>   }
>}
>
>__END__
>
>Output:
>
>ulogbla.foo matches
>ULOGbla.foo matches
>UlOGfoo.bla matches
>uLoGbla.foo matches
>
>MfG,
>--
>Thomas Bätzler, System Administrator, Network Operations EMEA
>Harbinger, e-Business Connectivity Group, a part of Peregrine
>Steinhäuserstraße 22                 phone: +49-721-98143-110
>D-76135 Karlsruhe / Germany            fax: +49-721-98143-196


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activeperl

Reply via email to