Extract begins with the input line mycompany----engineer=====itdept-----33
1234965298.64138
1234965298.64149
1234965298.64153
1234965298.64158
####
#!/usr/bin/perl
use strict;
use warnings;
# use Data::Dumper;
use Time::HiRes qw(time);
my $Name = "MyName";
my ($Age, %Details);
my @source = ('acompany----engineer=====itdept-----33',
'bcompany----butcher=====killingfloor-----34',
'acompany----baker=====oven-----35',
'acompany----candlestickmaker=====tallow-----36',
'acompany----monk=====monastery-----37',
);
my $Pattern = "([a-z]+)\-+([a-z]+)\=+([a-z]+)\-+([0-9]+)";
my $start_time = time;
for my $str(@source) {
Extract($str, $Name, $Pattern);
}
my $end_time = time;
print "back in main elapsed time for a 5-element \@source was: ", $end_time - $start_time, "\n";
sub Extract
{
my @subarr = @_;
my ($Line,$Name,$Pattern) = @subarr;
my (@Arr,$CallId);
# print "Extract begins with the input line $Line\n";
# print time,"\n";
@Arr = ($Line =~ m/$Pattern/g);
# print time,"\n";
$Age = $Arr[$#Arr];
# print time,"\n";
$Details{$Age}{$Name} = \@Arr if defined($Age);
#print time,"\n";
}
####
C:\ww>perl 744750.pl
Extract begins with the input line acompany----engineer=====itdept-----33
Extract begins with the input line bcompany----butcher=====killingfloor-----34
Extract begins with the input line acompany----baker=====oven-----35
Extract begins with the input line acompany----candlestickmaker=====tallow-----36
Extract begins with the input line acompany----monk=====monastery-----37
back in main elapsed time for a 5-element @source was: 0.000818967819213867
####
C:\ww>perl 744750.pl
back in main elapsed time for a 5-element @source was: 0.000185966491699219