Fwd: Date format search in the file
- From: paikkos@xxxxxxxxxxxxxx (Dermot)
- Date: Mon, 24 Nov 2008 15:06:23 +0000
2008/11/22 sftriman <dalyea@xxxxxxxxx>:
On Nov 22, 6:16 am, paik...@xxxxxxxxxxxxxx (Dermot) wrote:
2008/11/22 Sureshkumar M (HCL Financial Services) <Sureshkuma...@xxxxxx>:
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.
.
- References:
- Perl code shows high usage in "top" - why?
- From: Sftriman
- Date format search in the file
- From: "Sureshkumar M (HCL Financial Services)"
- Re: Date format search in the file
- From: Dermot
- Re: Date format search in the file
- From: Sftriman
- Perl code shows high usage in "top" - why?
- Prev by Date: Re: Uninitialized value in array
- Next by Date: Re: how to read file content into an array?
- Previous by thread: Re: Date format search in the file
- Next by thread: Re: Date format search in the file
- Index(es):
Relevant Pages
|