CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
Regular-Expr time

 



k.alex
New User

Dec 20, 2011, 6:20 PM

Post #1 of 2 (3426 views)
Regular-Expr time Can't Post

Hi everyone, I'm working on this example to extract some values from the lines which are provided as input from a text file. However, I'm encountering a strange result.

=====> Inputs
Monday I have an appointment with Alex at 12:40 PM.
we are going to a party on Thursday at 10:30 PM.
=====> Output
2:40
10:30

====> script
#!/usr/bin/perl
open ($fhandle1, "<", $ARGV[0]) or die $!;
open ($fhandle2, ">", $ARGV[1]) or die $!;
while (<$fhandle1>)
{
$time=$_;
$time=~ m/.*(([0]?[1-9]|[1-1][0-2])(([0-5][0-9])).*/;
$time="$1";
print $fhandle2 "Time: $time\n";
}
close ($fhandle2);
close ($fhandle1);
==========
Any help will be appreciated?

Best


FishMonger
Veteran / Moderator

Dec 20, 2011, 9:21 PM

Post #2 of 2 (3419 views)
Re: [k.alex] Regular-Expr time [In reply to] Can't Post

Cross posted at: http://forums.devshed.com/perl-programming-6/regular-expressions-872077.html

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives