2008/11/22 sftriman <[EMAIL PROTECTED]>:
> On Nov 22, 6:16 am, [EMAIL PROTECTED] (Dermot) wrote:
>> 2008/11/22 Sureshkumar M (HCL Financial Services) <[EMAIL PROTECTED]>:

>> I could be wrong but I don't think \w will not match a hypen "-" so
>> the test will fail.
>> This works for me:
>>
>> if ($_=~/\d{1,2}-(\d{2}|\w{3})-\d+/)
>>
>> HTH,
>> Dp.

Opps, yes John that correct. I didn't scroll down to the bit where it said

Output should be.

>
> Thanks for the reply.  I added strict and warning, and thankfully,
> there were no messages.
>
> The while loop on the file handle makes sense - I should do that.
>
> What are you referring to in the if part?  I see I have an unescaped
> hyphen which
> I will make \- in the regexp compare.

Who escaped a hypen? There is no need to escape a hypen. You escape
meta-characters and a hypen isn't.

But what is the compare you are
> writing?

My Regex was incorrect, as John pointed out. I was looking for

1 or 2 digit, a hypen, a 2 digit number of 3 character string, a hypen
and any number of  word characters.

You only want two digit day values and a 2-4 digit year value so
/\d{2}-(\d{2}|\w{3}-\d{2,4}/  would be the regex I would use.

Have a look at perldoc perlretut


> Also, I ran the script many times just now - it runs so fast, I can't
> see why it's
> causing the CPU surge:
>
> <Q>$ time proc-js*pl
>    0.29s real     0.24s user     0.04s system
> <Q>$ time proc-js*pl
>    0.33s real     0.28s user     0.03s system
> <Q>$ time proc-js*pl
>    0.39s real     0.34s user     0.05s system

Can't help with that. :-/

Dp.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to