in reply to Re: XML data extraction (updated x2)
in thread XML data extraction
Thanks haukex for help.
It will be grateful if you can help to correct below two queries :
Want to calculate the Time Stamp between date now and timereceived .
Getting error in pattern not matching ,can u share the correct pattern for "10/10/2017 11:35 PM"
#Begin###Calculate the time difference my $dtnow = DateTime->now; my $timereceived = "10/10/2017 11:35 PM"; my $strp = DateTime::Format::Strptime->new(on_error=>'croak',pattern = +> '%m/%d/%Y %H:%M %t', time_zone=>'UTC'); my $dtevent = $strp->parse_datetime($timereceived); my $diff_sec = $dtnow->subtract_datetime_absolute($dtevent)->in_units( +'seconds'); my $diff_hours = sprintf("%.0f" , $diff_sec/(60*60)); #End###Calculate the time difference
Another query in expression formatting ---
my name = 'greenfield (Glossary) (100)' foreach ( $name =~ /\((.*?)\)/ ) { $appID = $1; }
variable $name is having two value in two different brackets (Glossary) and (100) with below regular expression i am getting output as
'appid' => 'Glossary'
But i want 'appid' => '100'
it should avoid the first bracket (Glossary) values and only last (100) bracket vales it should pick
-Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: XML data extraction
by haukex (Archbishop) on Oct 12, 2017 at 07:47 UTC | |
by snehit.ar (Beadle) on Oct 12, 2017 at 09:11 UTC | |
by hippo (Archbishop) on Oct 12, 2017 at 10:34 UTC | |
by haukex (Archbishop) on Oct 12, 2017 at 10:35 UTC |