in reply to Re^2: Gettin certain lines of text from a text file!
in thread Gettin certain lines of text from a text file!

So, when you're looking for the date range, you can find the "Analysis Date Range", but then how do you decide what is the date coming after that?

I would say that you're looking for:

  1. First, the string "Analysis Date Range : " with an arbitrary amount of whitespace around the ':' (/Analysis Date Range\s+:\s+/)
  2. Then, at least one digit, which we want to remember (/([0-9]+)/)
  3. Then, a slash (which needs a backslash to escape it) followed by at least one digit, and record the digits but not the slash (/\/([0-9]+)/)
  4. Then, another slash followed by at least one digit, and again record the digits not the slash (/\/([0-9]+)/)
  5. And the rest doesn't matter
Combining that all into one:

# i modifer to make it case insensitive, just in case. if ($line =~ /Analysis Date Range\s*:\s*([0-9]+)\/([0-9]+)\/([0-9])+/i +) { print "I found an Analysis date with month/day $1, $2 in year $3\n"; }else{ print "This line did not have an analysis date that I recognize in i +t\n"; }

Another way to go, would be to grab larger chunks and then split them later:

  1. "Analysis Date Range : "
  2. Then a pile of digits-and-slashes (start date) ([0-9\/]+)
  3. Then whitespace and digits-and-colons (start time) \s([0-9:]+)
  4. Then more whitespace and some digits-and-slashes (end date)
  5. Finally, whitespace then digits-and-colons (end time)

PS: Is that date string "month day year" or "day month year"?

Replies are listed 'Best First'.
Re^4: Gettin certain lines of text from a text file!
by Foxyirish1987 (Novice) on Sep 15, 2009 at 14:30 UTC

    thanks a million that is really helping. had to modify some part of it for strawberrie perl, no idea why. but its working alright. To do the next part should be something simular so i'll work away with that for the time being. thanks :-) p.s (this is for ZEN) And already said it to the manager and expectations are lowered but it'd be nice to get it done no? :-)