Hi AnomalousMonk, Thanks for the comment. I understood that the problem was with the g - global modifier in the patters m//g. I achieved the desired output: 2016-09-30T00:00:00,2016-12-28T23:59:59 by using the below code.
#/usr/bin/perl use strict; use warnings; my $timeLimit = '<timeLimit endTime="2016-12-28T23:59:59" startTime="2 +016-09-30T00:00:00"></timeLimit>'; $timeLimit =~ m/startTime="(.*?)"/g; my $startTime = $1; chomp($timeLimit); my $endTime =''; if ($timeLimit =~ m/endTime/) { $timeLimit =~ m/endTime="(.*?)"/; $endTime = $1; } print "[$startTime],[$endTime]\n";
In reply to Re^2: Pattern matching and deriving the data between the "(double quotes) in HTML tag
by sp4rperl
in thread Pattern matching and deriving the data between the "(double quotes) in HTML tag
by sp4rperl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |