Timjc86 has asked for the wisdom of the Perl Monks concerning the following question:
Hello, monks! I am starting my third week of Perl experience. Coming from a (limited) C++ background, I am fascinated with the ease and potency of regular expressions. But now I have run into something I don't think regexes can solve.
The problem: I have a number of strings composed of a hodgepodge of information - dates, times, comments, other numbers, etc. I am trying to replace some of the dates with their epoch timestamps.
Thus far:
Where I'm stuck: I'm not sure how to get the timestamp back into the appropriate string in the proper place(s). I have tried using a subroutine with search and replace, i.e. s/<regex to find date>/&<subroutine to calculate date's timestamp>/ge, but I continue to get syntax errors (I assume because you can't call subroutines inside a regex).
Thoughts on how to proceed:
Thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Search, modify, replace?
by ikegami (Patriarch) on Jun 10, 2009 at 14:59 UTC | |
|
Re: Search, modify, replace?
by JavaFan (Canon) on Jun 10, 2009 at 15:03 UTC | |
|
Re: Search, modify, replace?
by Timjc86 (Novice) on Jun 10, 2009 at 15:28 UTC | |
by AnomalousMonk (Archbishop) on Jun 10, 2009 at 18:25 UTC | |
|
Re: Search, modify, replace?
by Utilitarian (Vicar) on Jun 10, 2009 at 15:02 UTC |