From mariassai at gmail.com Sun Jun 14 02:31:10 2009 From: mariassai at gmail.com (sairam pareek) Date: Sun, 14 Jun 2009 15:01:10 +0530 Subject: [Bangalore-pm] Please help me in Parsing KML file in perl using regular expression.(its urgent) Message-ID: Hello everyone. I have a kml file, and struggling to write a perl script to parse its value between tags, this is my first task. and the second is to update the value between the tag in the postgresql database table. I m attaching the KML file, Please find the attachment. (I want to parse the longitude, latitude vlaues in these) Please help me, its urgent. Waiting for your replies. Hoping for great help from you guys. I wanted to use regular expression for this. I found this group on orkut. Thanks in advance. Regards, Sairam -- "It is not how much you do, but how much love you put in the doing." -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Al waab B villa.kml Type: application/vnd.google-earth.kml+xml Size: 1498 bytes Desc: not available URL: From superpulse.x at gmail.com Sun Jun 14 21:53:49 2009 From: superpulse.x at gmail.com (wolf) Date: Mon, 15 Jun 2009 10:23:49 +0530 Subject: [Bangalore-pm] Please help me in Parsing KML file in perl using regular expression.(its urgent) In-Reply-To: References: Message-ID: Hey, I used your KML file ( renamed it of course ): cat test.kml | perl -ne ' print "$1: $2\n " if m!<(longitude|latitude)\s*?>\s*?([0-9\.]+)\s*?!' Hope this helps, Cheers, V 2009/6/14 sairam pareek > Hello everyone. > > I have a kml file, and struggling to write a perl script to parse its value > between tags, this is my first task. > and the second is to update the value between the tag in the postgresql > database table. I m attaching the KML file, Please find the attachment. (I > want to parse the longitude, latitude vlaues in these) > > Please help > me, its urgent. Waiting for your replies. Hoping for great help from you > guys. I wanted to use regular expression for this. I found this group on > orkut. > Thanks in advance. > > Regards, > Sairam > > -- > "It is not how much you do, but how much love you put in the doing." > > _______________________________________________ > Bangalore-pm mailing list > Bangalore-pm at pm.org > http://mail.pm.org/mailman/listinfo/bangalore-pm > -------------- next part -------------- An HTML attachment was scrubbed... URL: From simran at tlims.cc Sun Jun 14 22:02:55 2009 From: simran at tlims.cc (simran) Date: Mon, 15 Jun 2009 10:32:55 +0530 Subject: [Bangalore-pm] Please help me in Parsing KML file in perl using regular expression.(its urgent) In-Reply-To: References: Message-ID: <22a825cb0906142202o1d4b0743v875c5372bf261b20@mail.gmail.com> probably best to use the XML::Simple module... http://search.cpan.org/~grantm/XML-Simple-2.18/lib/XML/Simple.pm 2009/6/15 wolf > Hey, > > I used your KML file ( renamed it of course ): > > cat test.kml | perl -ne ' print "$1: $2\n " if > m!<(longitude|latitude)\s*?>\s*?([0-9\.]+)\s*?!' > > Hope this helps, > > Cheers, > V > > > 2009/6/14 sairam pareek > >> Hello everyone. >> >> I have a kml file, and struggling to write a perl script to parse its >> value between tags, this is my first task. >> and the second is to update the value between the tag in the postgresql >> database table. I m attaching the KML file, Please find the attachment. (I >> want to parse the longitude, latitude vlaues in these) >> >> Please >> help me, its urgent. Waiting for your replies. Hoping for great help from >> you guys. I wanted to use regular expression for this. I found this group on >> orkut. >> Thanks in advance. >> >> Regards, >> Sairam >> >> -- >> "It is not how much you do, but how much love you put in the doing." >> >> _______________________________________________ >> Bangalore-pm mailing list >> Bangalore-pm at pm.org >> http://mail.pm.org/mailman/listinfo/bangalore-pm >> > > > _______________________________________________ > Bangalore-pm mailing list > Bangalore-pm at pm.org > http://mail.pm.org/mailman/listinfo/bangalore-pm > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mariassai at gmail.com Sun Jun 14 22:57:30 2009 From: mariassai at gmail.com (sairam pareek) Date: Sun, 14 Jun 2009 22:57:30 -0700 Subject: [Bangalore-pm] Please help me in Parsing KML file in perl using regular expression.(its urgent) In-Reply-To: <22a825cb0906142202o1d4b0743v875c5372bf261b20@mail.gmail.com> References: <22a825cb0906142202o1d4b0743v875c5372bf261b20@mail.gmail.com> Message-ID: Thanks for your replies, I m happy to be in this group, I tried the given solutions, they are working fine. If I have some problem further Ill let you know. Thanks once again. On Sun, Jun 14, 2009 at 10:02 PM, simran wrote: > probably best to use the XML::Simple module... > > http://search.cpan.org/~grantm/XML-Simple-2.18/lib/XML/Simple.pm > > 2009/6/15 wolf > > Hey, >> >> I used your KML file ( renamed it of course ): >> >> cat test.kml | perl -ne ' print "$1: $2\n " if >> m!<(longitude|latitude)\s*?>\s*?([0-9\.]+)\s*?!' >> >> Hope this helps, >> >> Cheers, >> V >> >> >> 2009/6/14 sairam pareek >> >>> Hello everyone. >>> >>> I have a kml file, and struggling to write a perl script to parse its >>> value between tags, this is my first task. >>> and the second is to update the value between the tag in the postgresql >>> database table. I m attaching the KML file, Please find the attachment. (I >>> want to parse the longitude, latitude vlaues in these) >>> >>> Please >>> help me, its urgent. Waiting for your replies. Hoping for great help from >>> you guys. I wanted to use regular expression for this. I found this group on >>> orkut. >>> Thanks in advance. >>> >>> Regards, >>> Sairam >>> >>> -- >>> "It is not how much you do, but how much love you put in the doing." >>> >>> _______________________________________________ >>> Bangalore-pm mailing list >>> Bangalore-pm at pm.org >>> http://mail.pm.org/mailman/listinfo/bangalore-pm >>> >> >> >> _______________________________________________ >> Bangalore-pm mailing list >> Bangalore-pm at pm.org >> http://mail.pm.org/mailman/listinfo/bangalore-pm >> > > -- "It is not how much you do, but how much love you put in the doing." -------------- next part -------------- An HTML attachment was scrubbed... URL: From joecheri at gmail.com Sun Jun 14 23:48:03 2009 From: joecheri at gmail.com (Joe Cheri) Date: Mon, 15 Jun 2009 12:18:03 +0530 Subject: [Bangalore-pm] Bangalore-pm Digest, Vol 16, Issue 1 In-Reply-To: References: Message-ID: <3060a0480906142348h298b9576ke7377b02bbcae884@mail.gmail.com> It is good to use XML::Simple or some other packages. 2009/6/15 > Send Bangalore-pm mailing list submissions to > bangalore-pm at pm.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.pm.org/mailman/listinfo/bangalore-pm > or, via email, send a message with subject or body 'help' to > bangalore-pm-request at pm.org > > You can reach the person managing the list at > bangalore-pm-owner at pm.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Bangalore-pm digest..." > > Today's Topics: > > 1. Please help me in Parsing KML file in perl using regular > expression.(its urgent) (sairam pareek) > > > ---------- Forwarded message ---------- > From: sairam pareek > To: bangalore-pm at pm.org > Date: Sun, 14 Jun 2009 15:01:10 +0530 > Subject: [Bangalore-pm] Please help me in Parsing KML file in perl using > regular expression.(its urgent) > Hello everyone. > > I have a kml file, and struggling to write a perl script to parse its value > between tags, this is my first task. > and the second is to update the value between the tag in the postgresql > database table. I m attaching the KML file, Please find the attachment. (I > want to parse the longitude, latitude vlaues in these) > > Please help > me, its urgent. Waiting for your replies. Hoping for great help from you > guys. I wanted to use regular expression for this. I found this group on > orkut. > Thanks in advance. > > Regards, > Sairam > > -- > "It is not how much you do, but how much love you put in the doing." > > _______________________________________________ > Bangalore-pm mailing list > Bangalore-pm at pm.org > http://mail.pm.org/mailman/listinfo/bangalore-pm > -------------- next part -------------- An HTML attachment was scrubbed... URL: From SReddy at securities.com Mon Jun 15 05:33:34 2009 From: SReddy at securities.com (Srinivas Reddy) Date: Mon, 15 Jun 2009 08:33:34 -0400 Subject: [Bangalore-pm] Need Help to optimise the code Message-ID: <5B7E14CC96EC8D41A27766C3B51F9AB61B04CA57AA@KOCL385273EXCH.msp.tech.int.digex.com> Hi , Please help to optimize the code below. We basically read 2 xls files into an array @xls2 and @xls1 . For each cell we want to compare ( starting from col 32 ) values in each cell and if they are not equal we need to store it in a different array. This we will then use to bold those particular cells. The loop which does this comparison could be replacement by some in built array difference kind of function. I am new to perl so apologies if I ve used any wrong terminologies here. Appreciate your help on the same. Please find attached whole code as well for reference sub cell_handler2 { my $workbook = $_[0]; my $sheet_index = $_[1]; my $row = $_[2]; my $col = $_[3]; my $cell = $_[4]; # Construct array for Dx code push @xls2 , { 'row2' => $row, 'col2' => $col, 'value2' => $cell->value(), }; return @xls2; } #print Dumper(@xls2); # Print the End Time to read second excel file print scalar(localtime) . ": End Reading Excel2 \n"; print scalar(localtime) . ": Start Populating Bolding Array \n"; # Inefficient way of looping # Please change this as it could boost the performance significantly for(@xls2) { if($_->{'col2'} > 32 && $_->{'row2'} > '0' ) { $newvalue = $_->{'value2'}; $newrow = $_->{'row2'}; $newcol = $_->{'col2'}; for(@xls1) { $oldrow = $_->{'row1'}; $oldcol = $_->{'col1'}; if($_->{'col1'} > 32 && $_->{'row1'} > 0 && $_->{'row1'} eq $newrow && $_->{'col1'} eq $newcol) { $oldvalue = $_->{'value1'}; last; } } if($oldvalue ne $newvalue) { push @bold_array , { 'row' => $_->{'row2'}, 'col' => $_->{'col2'}, 'value' => $_->{'value2'}, }; } } } Regards, Srinivas Reddy ______________________________________________________________________ This communication contains information which is confidential. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note any distribution, copying or use of this communication or the information in it is strictly prohibited. If you have received this communication in error please notify us by e-mail or by telephone (as above) and then delete the e-mail and all attachments and any copies thereof. ______________________________________________________________________ -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: bold-unoptimized.pl Type: application/octet-stream Size: 5544 bytes Desc: bold-unoptimized.pl URL: From ravish.kumar at gs.com Mon Jun 15 05:44:02 2009 From: ravish.kumar at gs.com (Kumar, Ravish) Date: Mon, 15 Jun 2009 08:44:02 -0400 Subject: [Bangalore-pm] Need Help to optimise the code In-Reply-To: <5B7E14CC96EC8D41A27766C3B51F9AB61B04CA57AA@KOCL385273EXCH.msp.tech.int.digex.com> References: <5B7E14CC96EC8D41A27766C3B51F9AB61B04CA57AA@KOCL385273EXCH.msp.tech.int.digex.com> Message-ID: <7005D07FC06E4A49B8595ACA8AAF27FF13706AC4@gsmbnbp24es.firmwide.corp.gs.com> First thing : my $workbook = $_[0]; my $sheet_index = $_[1]; my $row = $_[2]; my $col = $_[3]; my $cell = $_[4]; don't accept input parms like this, this degardes the performance and code doesn't look nice. above thing should be replaced like this : my ($workbook, $sheet_index, $row, $col, $cell ) = @_; for(@xls2) { if($_->{'col2'} > 32 && $_->{'row2'} > '0' ) { $newvalue = $_->{'value2'}; $newrow = $_->{'row2'}; $newcol = $_->{'col2'}; for(@xls1) { $oldrow = $_->{'row1'}; $oldcol = $_->{'col1'}; if($_->{'col1'} > 32 && $_->{'row1'} > 0 && $_->{'row1'} eq $newrow && $_->{'col1'} eq $newcol) { $oldvalue = $_->{'value1'}; last; } } if($oldvalue ne $newvalue) { push @bold_array , { 'row' => $_->{'row2'}, 'col' => $_->{'col2'}, 'value' => $_->{'value2'}, }; } } } Same thing as above, Iterate loop like : Foreach my $value (@xls2) { $value->{'col2'} . ...... } From: bangalore-pm-bounces+ravish.kumar=gs.com at pm.org [mailto:bangalore-pm-bounces+ravish.kumar=gs.com at pm.org] On Behalf Of Srinivas Reddy Sent: Monday, June 15, 2009 6:04 PM To: bangalore-pm at pm.org Subject: [Bangalore-pm] Need Help to optimise the code Hi , Please help to optimize the code below. We basically read 2 xls files into an array @xls2 and @xls1 . For each cell we want to compare ( starting from col 32 ) values in each cell and if they are not equal we need to store it in a different array. This we will then use to bold those particular cells. The loop which does this comparison could be replacement by some in built array difference kind of function. I am new to perl so apologies if I ve used any wrong terminologies here. Appreciate your help on the same. Please find attached whole code as well for reference sub cell_handler2 { my $workbook = $_[0]; my $sheet_index = $_[1]; my $row = $_[2]; my $col = $_[3]; my $cell = $_[4]; # Construct array for Dx code push @xls2 , { 'row2' => $row, 'col2' => $col, 'value2' => $cell->value(), }; return @xls2; } #print Dumper(@xls2); # Print the End Time to read second excel file print scalar(localtime) . ": End Reading Excel2 \n"; print scalar(localtime) . ": Start Populating Bolding Array \n"; # Inefficient way of looping # Please change this as it could boost the performance significantly for(@xls2) { if($_->{'col2'} > 32 && $_->{'row2'} > '0' ) { $newvalue = $_->{'value2'}; $newrow = $_->{'row2'}; $newcol = $_->{'col2'}; for(@xls1) { $oldrow = $_->{'row1'}; $oldcol = $_->{'col1'}; if($_->{'col1'} > 32 && $_->{'row1'} > 0 && $_->{'row1'} eq $newrow && $_->{'col1'} eq $newcol) { $oldvalue = $_->{'value1'}; last; } } if($oldvalue ne $newvalue) { push @bold_array , { 'row' => $_->{'row2'}, 'col' => $_->{'col2'}, 'value' => $_->{'value2'}, }; } } } Regards, Srinivas Reddy ______________________________________________________________________ This communication contains information which is confidential. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note any distribution, copying or use of this communication or the information in it is strictly prohibited. If you have received this communication in error please notify us by e-mail or by telephone (as above) and then delete the e-mail and all attachments and any copies thereof. ______________________________________________________________________ -------------- next part -------------- An HTML attachment was scrubbed... URL: From simran at tlims.cc Mon Jun 15 05:47:10 2009 From: simran at tlims.cc (simran) Date: Mon, 15 Jun 2009 18:17:10 +0530 Subject: [Bangalore-pm] Need Help to optimise the code In-Reply-To: <5B7E14CC96EC8D41A27766C3B51F9AB61B04CA57AA@KOCL385273EXCH.msp.tech.int.digex.com> References: <5B7E14CC96EC8D41A27766C3B51F9AB61B04CA57AA@KOCL385273EXCH.msp.tech.int.digex.com> Message-ID: <22a825cb0906150547w2baa6032h8b79d1c5531c1d87@mail.gmail.com> Hi Srinivas, The code is not very complex, and unless you change the structure, it will not optimise too much... better to write it neatly (and with better arg passing... as suggested in the email by Ravish. If you are looking for absolute speed, better to write in in C and plug it in via XS. simran. 2009/6/15 Srinivas Reddy > Hi , > > > > Please help to optimize the code below. We basically read 2 xls files into > an array @xls2 and @xls1 . For each cell we want to compare ( starting from > col 32 ) values in each cell and if they are not equal we need to store it > in a different array. This we will then use to bold those particular cells. > > > > The loop which does this comparison could be replacement by some in built > array difference kind of function. I am new to perl so apologies if I ve > used any wrong terminologies here. Appreciate your help on the same. Please > find attached whole code as well for reference > > > > sub cell_handler2 { > > > > my $workbook = $_[0]; > > my $sheet_index = $_[1]; > > my $row = $_[2]; > > my $col = $_[3]; > > my $cell = $_[4]; > > # Construct array for Dx code > > > > push @xls2 , { > > 'row2' => $row, > > 'col2' => $col, > > 'value2' => $cell->value(), > > }; > > return @xls2; > > > > } > > #print Dumper(@xls2); > > # Print the End Time to read second excel file > > print scalar(localtime) . ": End Reading Excel2 \n"; > > > > print scalar(localtime) . ": Start Populating Bolding Array \n"; > > # Inefficient way of looping > > # Please change this as it could boost the performance significantly > > for(@xls2) { > > if($_->{'col2'} > 32 && $_->{'row2'} > '0' ) { > > $newvalue = $_->{'value2'}; > > $newrow = $_->{'row2'}; > > $newcol = $_->{'col2'}; > > for(@xls1) { > > $oldrow = $_->{'row1'}; > > $oldcol = $_->{'col1'}; > > if($_->{'col1'} > 32 && > $_->{'row1'} > 0 && $_->{'row1'} eq $newrow && $_->{'col1'} eq $newcol) { > > > $oldvalue = $_->{'value1'}; > > > last; > > } > > } > > if($oldvalue ne $newvalue) { > > push @bold_array , { > > 'row' => > $_->{'row2'}, > > 'col' => > $_->{'col2'}, > > 'value' => > $_->{'value2'}, > > }; > > } > > } > > } > > > > > > Regards, > > > > Srinivas Reddy > > ______________________________________________________________________ > This communication contains information which is confidential. It is for > the > exclusive use of the intended recipient(s). If you are not the intended > recipient(s) please note any distribution, copying or use of this > communication or the information in it is strictly prohibited. If you have > received this communication in error please notify us by e-mail or > by telephone (as above) and then delete the e-mail and all attachments and > any copies thereof. > ______________________________________________________________________ > > _______________________________________________ > Bangalore-pm mailing list > Bangalore-pm at pm.org > http://mail.pm.org/mailman/listinfo/bangalore-pm > -------------- next part -------------- An HTML attachment was scrubbed... URL: From SReddy at securities.com Mon Jun 15 05:55:09 2009 From: SReddy at securities.com (Srinivas Reddy) Date: Mon, 15 Jun 2009 08:55:09 -0400 Subject: [Bangalore-pm] Need Help to optimise the code In-Reply-To: <22a825cb0906150547w2baa6032h8b79d1c5531c1d87@mail.gmail.com> References: <5B7E14CC96EC8D41A27766C3B51F9AB61B04CA57AA@KOCL385273EXCH.msp.tech.int.digex.com> <22a825cb0906150547w2baa6032h8b79d1c5531c1d87@mail.gmail.com> Message-ID: <5B7E14CC96EC8D41A27766C3B51F9AB61B04CA57AC@KOCL385273EXCH.msp.tech.int.digex.com> Hi Thnx a lot for your quick help. Sry C is rules out as this willl form a part of perl script and we have 'C' Expertise issue as well. I think kumars solution would really help . Let us rewrite it and check the performance. I am still looking at a function which takes 2 arrays and gives me the difference in them , in my case these array contain my xls file ( row , col and value associated with each cell ) . Regards, Srinivas Reddy Asia Technology and Global Projects Manager Skype : sreddyisi Cell : +91 9740076449 LandLine : +91 9900524073/74/76./78 Fax : +91 8026729764 Url : www.securities.com www.thefinancialnet.com elearning.securities.com P Please consider the environment before printing this email ________________________________ From: simrangambhir at gmail.com [mailto:simrangambhir at gmail.com] On Behalf Of simran Sent: Monday, June 15, 2009 6:17 PM To: Srinivas Reddy Cc: bangalore-pm at pm.org Subject: Re: [Bangalore-pm] Need Help to optimise the code Hi Srinivas, The code is not very complex, and unless you change the structure, it will not optimise too much... better to write it neatly (and with better arg passing... as suggested in the email by Ravish. If you are looking for absolute speed, better to write in in C and plug it in via XS. simran. 2009/6/15 Srinivas Reddy > Hi , Please help to optimize the code below. We basically read 2 xls files into an array @xls2 and @xls1 . For each cell we want to compare ( starting from col 32 ) values in each cell and if they are not equal we need to store it in a different array. This we will then use to bold those particular cells. The loop which does this comparison could be replacement by some in built array difference kind of function. I am new to perl so apologies if I ve used any wrong terminologies here. Appreciate your help on the same. Please find attached whole code as well for reference sub cell_handler2 { my $workbook = $_[0]; my $sheet_index = $_[1]; my $row = $_[2]; my $col = $_[3]; my $cell = $_[4]; # Construct array for Dx code push @xls2 , { 'row2' => $row, 'col2' => $col, 'value2' => $cell->value(), }; return @xls2; } #print Dumper(@xls2); # Print the End Time to read second excel file print scalar(localtime) . ": End Reading Excel2 \n"; print scalar(localtime) . ": Start Populating Bolding Array \n"; # Inefficient way of looping # Please change this as it could boost the performance significantly for(@xls2) { if($_->{'col2'} > 32 && $_->{'row2'} > '0' ) { $newvalue = $_->{'value2'}; $newrow = $_->{'row2'}; $newcol = $_->{'col2'}; for(@xls1) { $oldrow = $_->{'row1'}; $oldcol = $_->{'col1'}; if($_->{'col1'} > 32 && $_->{'row1'} > 0 && $_->{'row1'} eq $newrow && $_->{'col1'} eq $newcol) { $oldvalue = $_->{'value1'}; last; } } if($oldvalue ne $newvalue) { push @bold_array , { 'row' => $_->{'row2'}, 'col' => $_->{'col2'}, 'value' => $_->{'value2'}, }; } } } Regards, Srinivas Reddy ______________________________________________________________________ This communication contains information which is confidential. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note any distribution, copying or use of this communication or the information in it is strictly prohibited. If you have received this communication in error please notify us by e-mail or by telephone (as above) and then delete the e-mail and all attachments and any copies thereof. ______________________________________________________________________ _______________________________________________ Bangalore-pm mailing list Bangalore-pm at pm.org http://mail.pm.org/mailman/listinfo/bangalore-pm ______________________________________________________________________ This communication contains information which is confidential. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note any distribution, copying or use of this communication or the information in it is strictly prohibited. If you have received this communication in error please notify us by e-mail or by telephone (as above) and then delete the e-mail and all attachments and any copies thereof. ______________________________________________________________________ -------------- next part -------------- An HTML attachment was scrubbed... URL: From ravish.kumar at gs.com Mon Jun 15 05:58:23 2009 From: ravish.kumar at gs.com (Kumar, Ravish) Date: Mon, 15 Jun 2009 08:58:23 -0400 Subject: [Bangalore-pm] Need Help to optimise the code In-Reply-To: <5B7E14CC96EC8D41A27766C3B51F9AB61B04CA57AC@KOCL385273EXCH.msp.tech.int.digex.com> References: <5B7E14CC96EC8D41A27766C3B51F9AB61B04CA57AA@KOCL385273EXCH.msp.tech.int.digex.com><22a825cb0906150547w2baa6032h8b79d1c5531c1d87@mail.gmail.com> <5B7E14CC96EC8D41A27766C3B51F9AB61B04CA57AC@KOCL385273EXCH.msp.tech.int.digex.com> Message-ID: <7005D07FC06E4A49B8595ACA8AAF27FF13706AF2@gsmbnbp24es.firmwide.corp.gs.com> Check this link for array process : http://perlmonks.com/?node_id=149566 From: bangalore-pm-bounces+ravish.kumar=gs.com at pm.org [mailto:bangalore-pm-bounces+ravish.kumar=gs.com at pm.org] On Behalf Of Srinivas Reddy Sent: Monday, June 15, 2009 6:25 PM To: simran Cc: bangalore-pm at pm.org Subject: Re: [Bangalore-pm] Need Help to optimise the code Hi Thnx a lot for your quick help. Sry C is rules out as this willl form a part of perl script and we have 'C' Expertise issue as well. I think kumars solution would really help . Let us rewrite it and check the performance. I am still looking at a function which takes 2 arrays and gives me the difference in them , in my case these array contain my xls file ( row , col and value associated with each cell ) . Regards, Srinivas Reddy Asia Technology and Global Projects Manager Skype : sreddyisi Cell : +91 9740076449 LandLine : +91 9900524073/74/76./78 Fax : +91 8026729764 Url : www.securities.com www.thefinancialnet.com elearning.securities.com P Please consider the environment before printing this email ________________________________ From: simrangambhir at gmail.com [mailto:simrangambhir at gmail.com] On Behalf Of simran Sent: Monday, June 15, 2009 6:17 PM To: Srinivas Reddy Cc: bangalore-pm at pm.org Subject: Re: [Bangalore-pm] Need Help to optimise the code Hi Srinivas, The code is not very complex, and unless you change the structure, it will not optimise too much... better to write it neatly (and with better arg passing... as suggested in the email by Ravish. If you are looking for absolute speed, better to write in in C and plug it in via XS. simran. 2009/6/15 Srinivas Reddy Hi , Please help to optimize the code below. We basically read 2 xls files into an array @xls2 and @xls1 . For each cell we want to compare ( starting from col 32 ) values in each cell and if they are not equal we need to store it in a different array. This we will then use to bold those particular cells. The loop which does this comparison could be replacement by some in built array difference kind of function. I am new to perl so apologies if I ve used any wrong terminologies here. Appreciate your help on the same. Please find attached whole code as well for reference sub cell_handler2 { my $workbook = $_[0]; my $sheet_index = $_[1]; my $row = $_[2]; my $col = $_[3]; my $cell = $_[4]; # Construct array for Dx code push @xls2 , { 'row2' => $row, 'col2' => $col, 'value2' => $cell->value(), }; return @xls2; } #print Dumper(@xls2); # Print the End Time to read second excel file print scalar(localtime) . ": End Reading Excel2 \n"; print scalar(localtime) . ": Start Populating Bolding Array \n"; # Inefficient way of looping # Please change this as it could boost the performance significantly for(@xls2) { if($_->{'col2'} > 32 && $_->{'row2'} > '0' ) { $newvalue = $_->{'value2'}; $newrow = $_->{'row2'}; $newcol = $_->{'col2'}; for(@xls1) { $oldrow = $_->{'row1'}; $oldcol = $_->{'col1'}; if($_->{'col1'} > 32 && $_->{'row1'} > 0 && $_->{'row1'} eq $newrow && $_->{'col1'} eq $newcol) { $oldvalue = $_->{'value1'}; last; } } if($oldvalue ne $newvalue) { push @bold_array , { 'row' => $_->{'row2'}, 'col' => $_->{'col2'}, 'value' => $_->{'value2'}, }; } } } Regards, Srinivas Reddy ______________________________________________________________________ This communication contains information which is confidential. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note any distribution, copying or use of this communication or the information in it is strictly prohibited. If you have received this communication in error please notify us by e-mail or by telephone (as above) and then delete the e-mail and all attachments and any copies thereof. ______________________________________________________________________ _______________________________________________ Bangalore-pm mailing list Bangalore-pm at pm.org http://mail.pm.org/mailman/listinfo/bangalore-pm ______________________________________________________________________ This communication contains information which is confidential. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note any distribution, copying or use of this communication or the information in it is strictly prohibited. If you have received this communication in error please notify us by e-mail or by telephone (as above) and then delete the e-mail and all attachments and any copies thereof. ______________________________________________________________________ -------------- next part -------------- An HTML attachment was scrubbed... URL: From mkirank at gmail.com Mon Jun 15 09:13:27 2009 From: mkirank at gmail.com (Kiran Kumar) Date: Mon, 15 Jun 2009 11:13:27 -0500 Subject: [Bangalore-pm] Need Help to optimise the code In-Reply-To: <5B7E14CC96EC8D41A27766C3B51F9AB61B04CA57AA@KOCL385273EXCH.msp.tech.int.digex.com> References: <5B7E14CC96EC8D41A27766C3B51F9AB61B04CA57AA@KOCL385273EXCH.msp.tech.int.digex.com> Message-ID: Hi Srinivas, You will need to profile your code (check Devel::NYTProf on CPAN) to find out the exact bottleneck, you can do a grep from xls1 once instead of going through all the values each time my @xls1_vals = grep {$_->{'row2'} > 32 && $_->{'col2'} > 0} @xls1; for my $row ( grep {$_->{'row2'} > 32 && $_->{'col2'} > 0} @xls2 ) { } Its easier to actually find out where the issue is first -Kiran 2009/6/15 Srinivas Reddy > Hi , > > > > Please help to optimize the code below. We basically read 2 xls files into > an array @xls2 and @xls1 . For each cell we want to compare ( starting from > col 32 ) values in each cell and if they are not equal we need to store it > in a different array. This we will then use to bold those particular cells. > > > > The loop which does this comparison could be replacement by some in built > array difference kind of function. I am new to perl so apologies if I ve > used any wrong terminologies here. Appreciate your help on the same. Please > find attached whole code as well for reference > > > > sub cell_handler2 { > > > > my $workbook = $_[0]; > > my $sheet_index = $_[1]; > > my $row = $_[2]; > > my $col = $_[3]; > > my $cell = $_[4]; > > # Construct array for Dx code > > > > push @xls2 , { > > 'row2' => $row, > > 'col2' => $col, > > 'value2' => $cell->value(), > > }; > > return @xls2; > > > > } > > #print Dumper(@xls2); > > # Print the End Time to read second excel file > > print scalar(localtime) . ": End Reading Excel2 \n"; > > > > print scalar(localtime) . ": Start Populating Bolding Array \n"; > > # Inefficient way of looping > > # Please change this as it could boost the performance significantly > > for(@xls2) { > > if($_->{'col2'} > 32 && $_->{'row2'} > '0' ) { > > $newvalue = $_->{'value2'}; > > $newrow = $_->{'row2'}; > > $newcol = $_->{'col2'}; > > for(@xls1) { > > $oldrow = $_->{'row1'}; > > $oldcol = $_->{'col1'}; > > if($_->{'col1'} > 32 && > $_->{'row1'} > 0 && $_->{'row1'} eq $newrow && $_->{'col1'} eq $newcol) { > > > $oldvalue = $_->{'value1'}; > > > last; > > } > > } > > if($oldvalue ne $newvalue) { > > push @bold_array , { > > 'row' => > $_->{'row2'}, > > 'col' => > $_->{'col2'}, > > 'value' => > $_->{'value2'}, > > }; > > } > > } > > } > > > > > > Regards, > > > > Srinivas Reddy > > ______________________________________________________________________ > This communication contains information which is confidential. It is for > the > exclusive use of the intended recipient(s). If you are not the intended > recipient(s) please note any distribution, copying or use of this > communication or the information in it is strictly prohibited. If you have > received this communication in error please notify us by e-mail or > by telephone (as above) and then delete the e-mail and all attachments and > any copies thereof. > ______________________________________________________________________ > > _______________________________________________ > Bangalore-pm mailing list > Bangalore-pm at pm.org > http://mail.pm.org/mailman/listinfo/bangalore-pm > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mkirank at gmail.com Mon Jun 15 14:30:54 2009 From: mkirank at gmail.com (Kiran Kumar) Date: Mon, 15 Jun 2009 16:30:54 -0500 Subject: [Bangalore-pm] Need Help to optimise the code In-Reply-To: <5B7E14CC96EC8D41A27766C3B51F9AB61B04CA57AC@KOCL385273EXCH.msp.tech.int.digex.com> References: <5B7E14CC96EC8D41A27766C3B51F9AB61B04CA57AA@KOCL385273EXCH.msp.tech.int.digex.com> <22a825cb0906150547w2baa6032h8b79d1c5531c1d87@mail.gmail.com> <5B7E14CC96EC8D41A27766C3B51F9AB61B04CA57AC@KOCL385273EXCH.msp.tech.int.digex.com> Message-ID: you will not be able to compare hashes but you can convert your data to strings and it will make it easier , something like this #!perl use strict; use warnings; use Data::Dumper; my @arr =( { 'row' => 33, 'col' => 1, 'value' => 'xx', }, { 'row' => 30, 'col' => 1, 'value' => 'zz', }, { 'row' => 34, 'col' => 1, 'value' => 'yy', }, ); my @arr1 =( { 'row' => 33, 'col' => 1, 'value' => 'xx', }, { 'row' => 30, 'col' => 1, 'value' => 'zz', }, { 'row' => 35, 'col' => 1, 'value' => 'yy', }, ); my @vals = map {$_->{'row'} > 32 && $_->{'col'} > 0 ?stringify(%$_):()} @arr; my @vals1 = map {$_->{'row'} > 32 && $_->{'col'} > 0 ?stringify(%$_):()} @arr1; my %hash; @hash{@vals} = 1 x @vals; my @diff = grep {not exists$hash{$_}} @vals1; sub stringify { return "@_"; } 2009/6/15 Srinivas Reddy > Hi Thnx a lot for your quick help. Sry C is rules out as this willl form > a part of perl script and we have ?C? Expertise issue as well. I think > kumars solution would really help . Let us rewrite it and check the > performance. > > > > I am still looking at a function which takes 2 arrays and gives me the > difference in them , in my case these array contain my xls file ( row , col > and value associated with each cell ) . > > > > Regards, > > > > Srinivas Reddy > > Asia Technology and Global Projects Manager > > Skype : sreddyisi > > Cell : +91 9740076449 > > LandLine : +91 9900524073/74/76./78 > > Fax : +91 8026729764 > > Url : www.securities.com > > www.thefinancialnet.com > > elearning.securities.com > > P Please consider the environment before printing this email > ------------------------------ > > *From:* simrangambhir at gmail.com [mailto:simrangambhir at gmail.com] *On > Behalf Of *simran > *Sent:* Monday, June 15, 2009 6:17 PM > *To:* Srinivas Reddy > *Cc:* bangalore-pm at pm.org > *Subject:* Re: [Bangalore-pm] Need Help to optimise the code > > > > Hi Srinivas, > > The code is not very complex, and unless you change the structure, it will > not optimise too much... better to write it neatly (and with better arg > passing... as suggested in the email by Ravish. > > If you are looking for absolute speed, better to write in in C and plug it > in via XS. > > simran. > > 2009/6/15 Srinivas Reddy > > Hi , > > > > Please help to optimize the code below. We basically read 2 xls files into > an array @xls2 and @xls1 . For each cell we want to compare ( starting from > col 32 ) values in each cell and if they are not equal we need to store it > in a different array. This we will then use to bold those particular cells. > > > > The loop which does this comparison could be replacement by some in built > array difference kind of function. I am new to perl so apologies if I ve > used any wrong terminologies here. Appreciate your help on the same. Please > find attached whole code as well for reference > > > > sub cell_handler2 { > > > > my $workbook = $_[0]; > > my $sheet_index = $_[1]; > > my $row = $_[2]; > > my $col = $_[3]; > > my $cell = $_[4]; > > # Construct array for Dx code > > > > push @xls2 , { > > 'row2' => $row, > > 'col2' => $col, > > 'value2' => $cell->value(), > > }; > > return @xls2; > > > > } > > #print Dumper(@xls2); > > # Print the End Time to read second excel file > > print scalar(localtime) . ": End Reading Excel2 \n"; > > > > print scalar(localtime) . ": Start Populating Bolding Array \n"; > > # Inefficient way of looping > > # Please change this as it could boost the performance significantly > > for(@xls2) { > > if($_->{'col2'} > 32 && $_->{'row2'} > '0' ) { > > $newvalue = $_->{'value2'}; > > $newrow = $_->{'row2'}; > > $newcol = $_->{'col2'}; > > for(@xls1) { > > $oldrow = $_->{'row1'}; > > $oldcol = $_->{'col1'}; > > if($_->{'col1'} > 32 && > $_->{'row1'} > 0 && $_->{'row1'} eq $newrow && $_->{'col1'} eq $newcol) { > > > $oldvalue = $_->{'value1'}; > > > last; > > } > > } > > if($oldvalue ne $newvalue) { > > push @bold_array , { > > 'row' => > $_->{'row2'}, > > 'col' => > $_->{'col2'}, > > 'value' => > $_->{'value2'}, > > }; > > } > > } > > } > > > > > > Regards, > > > > Srinivas Reddy > > > ______________________________________________________________________ > This communication contains information which is confidential. It is for > the > exclusive use of the intended recipient(s). If you are not the intended > recipient(s) please note any distribution, copying or use of this > communication or the information in it is strictly prohibited. If you have > received this communication in error please notify us by e-mail or > by telephone (as above) and then delete the e-mail and all attachments and > any copies thereof. > ______________________________________________________________________ > > > _______________________________________________ > Bangalore-pm mailing list > Bangalore-pm at pm.org > http://mail.pm.org/mailman/listinfo/bangalore-pm > > > > ______________________________________________________________________ > This communication contains information which is confidential. It is for > the > exclusive use of the intended recipient(s). If you are not the intended > recipient(s) please note any distribution, copying or use of this > communication or the information in it is strictly prohibited. If you have > received this communication in error please notify us by e-mail or > by telephone (as above) and then delete the e-mail and all attachments and > any copies thereof. > ______________________________________________________________________ > > _______________________________________________ > Bangalore-pm mailing list > Bangalore-pm at pm.org > http://mail.pm.org/mailman/listinfo/bangalore-pm > -------------- next part -------------- An HTML attachment was scrubbed... URL: From graghav at gmail.com Mon Jun 15 19:00:03 2009 From: graghav at gmail.com (raghu) Date: Tue, 16 Jun 2009 07:30:03 +0530 Subject: [Bangalore-pm] Bangalore-pm Digest, Vol 16, Issue 8 In-Reply-To: References: Message-ID: Try using Array module http://search.cpan.org/~muenalan/Class-Maker-0.05.18/Maker/Examples/Array.pm On Tue, Jun 16, 2009 at 3:01 AM, wrote: > Send Bangalore-pm mailing list submissions to > bangalore-pm at pm.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.pm.org/mailman/listinfo/bangalore-pm > or, via email, send a message with subject or body 'help' to > bangalore-pm-request at pm.org > > You can reach the person managing the list at > bangalore-pm-owner at pm.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Bangalore-pm digest..." > > > Today's Topics: > > 1. Re: Need Help to optimise the code (Kiran Kumar) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Mon, 15 Jun 2009 16:30:54 -0500 > From: Kiran Kumar > Subject: Re: [Bangalore-pm] Need Help to optimise the code > To: Srinivas Reddy > Cc: "bangalore-pm at pm.org" > Message-ID: > > Content-Type: text/plain; charset="windows-1252" > > you will not be able to compare hashes but you can convert your data to > strings and it will make it easier , something like this > > #!perl > use strict; > > use warnings; > use Data::Dumper; > > my @arr =( > { > 'row' => 33, > 'col' => 1, > 'value' => 'xx', > }, > > { > 'row' => 30, > 'col' => 1, > 'value' => 'zz', > }, > > { > 'row' => 34, > 'col' => 1, > 'value' => 'yy', > }, > > ); > > my @arr1 =( > > { > 'row' => 33, > 'col' => 1, > 'value' => 'xx', > }, > > { > 'row' => 30, > 'col' => 1, > 'value' => 'zz', > }, > > { > 'row' => 35, > 'col' => 1, > 'value' => 'yy', > }, > > ); > > > my @vals = map {$_->{'row'} > 32 && $_->{'col'} > 0 ?stringify(%$_):()} > @arr; > my @vals1 = map {$_->{'row'} > 32 && $_->{'col'} > 0 ?stringify(%$_):()} > @arr1; > > > my %hash; > @hash{@vals} = 1 x @vals; > my @diff = grep {not exists$hash{$_}} @vals1; > > > sub stringify { > return "@_"; > } > > > > > 2009/6/15 Srinivas Reddy > > > Hi Thnx a lot for your quick help. Sry C is rules out as this willl form > > a part of perl script and we have ?C? Expertise issue as well. I think > > kumars solution would really help . Let us rewrite it and check the > > performance. > > > > > > > > I am still looking at a function which takes 2 arrays and gives me the > > difference in them , in my case these array contain my xls file ( row , > col > > and value associated with each cell ) . > > > > > > > > Regards, > > > > > > > > Srinivas Reddy > > > > Asia Technology and Global Projects Manager > > > > Skype : sreddyisi > > > > Cell : +91 9740076449 > > > > LandLine : +91 9900524073/74/76./78 > > > > Fax : +91 8026729764 > > > > Url : www.securities.com > > > > www.thefinancialnet.com > > > > elearning.securities.com > > > > P Please consider the environment before printing this email > > ------------------------------ > > > > *From:* simrangambhir at gmail.com [mailto:simrangambhir at gmail.com] *On > > Behalf Of *simran > > *Sent:* Monday, June 15, 2009 6:17 PM > > *To:* Srinivas Reddy > > *Cc:* bangalore-pm at pm.org > > *Subject:* Re: [Bangalore-pm] Need Help to optimise the code > > > > > > > > Hi Srinivas, > > > > The code is not very complex, and unless you change the structure, it > will > > not optimise too much... better to write it neatly (and with better arg > > passing... as suggested in the email by Ravish. > > > > If you are looking for absolute speed, better to write in in C and plug > it > > in via XS. > > > > simran. > > > > 2009/6/15 Srinivas Reddy > > > > Hi , > > > > > > > > Please help to optimize the code below. We basically read 2 xls files > into > > an array @xls2 and @xls1 . For each cell we want to compare ( starting > from > > col 32 ) values in each cell and if they are not equal we need to store > it > > in a different array. This we will then use to bold those particular > cells. > > > > > > > > The loop which does this comparison could be replacement by some in built > > array difference kind of function. I am new to perl so apologies if I ve > > used any wrong terminologies here. Appreciate your help on the same. > Please > > find attached whole code as well for reference > > > > > > > > sub cell_handler2 { > > > > > > > > my $workbook = $_[0]; > > > > my $sheet_index = $_[1]; > > > > my $row = $_[2]; > > > > my $col = $_[3]; > > > > my $cell = $_[4]; > > > > # Construct array for Dx code > > > > > > > > push @xls2 , { > > > > 'row2' => $row, > > > > 'col2' => $col, > > > > 'value2' => $cell->value(), > > > > }; > > > > return @xls2; > > > > > > > > } > > > > #print Dumper(@xls2); > > > > # Print the End Time to read second excel file > > > > print scalar(localtime) . ": End Reading Excel2 \n"; > > > > > > > > print scalar(localtime) . ": Start Populating Bolding Array \n"; > > > > # Inefficient way of looping > > > > # Please change this as it could boost the performance significantly > > > > for(@xls2) { > > > > if($_->{'col2'} > 32 && $_->{'row2'} > '0' ) { > > > > $newvalue = $_->{'value2'}; > > > > $newrow = $_->{'row2'}; > > > > $newcol = $_->{'col2'}; > > > > for(@xls1) { > > > > $oldrow = $_->{'row1'}; > > > > $oldcol = $_->{'col1'}; > > > > if($_->{'col1'} > 32 && > > $_->{'row1'} > 0 && $_->{'row1'} eq $newrow && $_->{'col1'} eq $newcol) { > > > > > > $oldvalue = $_->{'value1'}; > > > > > > last; > > > > } > > > > } > > > > if($oldvalue ne $newvalue) { > > > > push @bold_array , { > > > > 'row' => > > $_->{'row2'}, > > > > 'col' => > > $_->{'col2'}, > > > > 'value' => > > $_->{'value2'}, > > > > }; > > > > } > > > > } > > > > } > > > > > > > > > > > > Regards, > > > > > > > > Srinivas Reddy > > > > > > ______________________________________________________________________ > > This communication contains information which is confidential. It is for > > the > > exclusive use of the intended recipient(s). If you are not the intended > > recipient(s) please note any distribution, copying or use of this > > communication or the information in it is strictly prohibited. If you > have > > received this communication in error please notify us by e-mail or > > by telephone (as above) and then delete the e-mail and all attachments > and > > any copies thereof. > > ______________________________________________________________________ > > > > > > _______________________________________________ > > Bangalore-pm mailing list > > Bangalore-pm at pm.org > > http://mail.pm.org/mailman/listinfo/bangalore-pm > > > > > > > > ______________________________________________________________________ > > This communication contains information which is confidential. It is for > > the > > exclusive use of the intended recipient(s). If you are not the intended > > recipient(s) please note any distribution, copying or use of this > > communication or the information in it is strictly prohibited. If you > have > > received this communication in error please notify us by e-mail or > > by telephone (as above) and then delete the e-mail and all attachments > and > > any copies thereof. > > ______________________________________________________________________ > > > > _______________________________________________ > > Bangalore-pm mailing list > > Bangalore-pm at pm.org > > http://mail.pm.org/mailman/listinfo/bangalore-pm > > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://mail.pm.org/pipermail/bangalore-pm/attachments/20090615/c7591548/attachment.html > > > > ------------------------------ > > _______________________________________________ > Bangalore-pm mailing list > Bangalore-pm at pm.org > http://mail.pm.org/mailman/listinfo/bangalore-pm > > End of Bangalore-pm Digest, Vol 16, Issue 8 > ******************************************* > -------------- next part -------------- An HTML attachment was scrubbed... URL: From graghav at gmail.com Mon Jun 15 19:00:03 2009 From: graghav at gmail.com (raghu) Date: Tue, 16 Jun 2009 07:30:03 +0530 Subject: [Bangalore-pm] Bangalore-pm Digest, Vol 16, Issue 8 In-Reply-To: References: Message-ID: Try using Array module http://search.cpan.org/~muenalan/Class-Maker-0.05.18/Maker/Examples/Array.pm On Tue, Jun 16, 2009 at 3:01 AM, wrote: > Send Bangalore-pm mailing list submissions to > bangalore-pm at pm.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.pm.org/mailman/listinfo/bangalore-pm > or, via email, send a message with subject or body 'help' to > bangalore-pm-request at pm.org > > You can reach the person managing the list at > bangalore-pm-owner at pm.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Bangalore-pm digest..." > > > Today's Topics: > > 1. Re: Need Help to optimise the code (Kiran Kumar) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Mon, 15 Jun 2009 16:30:54 -0500 > From: Kiran Kumar > Subject: Re: [Bangalore-pm] Need Help to optimise the code > To: Srinivas Reddy > Cc: "bangalore-pm at pm.org" > Message-ID: > > Content-Type: text/plain; charset="windows-1252" > > you will not be able to compare hashes but you can convert your data to > strings and it will make it easier , something like this > > #!perl > use strict; > > use warnings; > use Data::Dumper; > > my @arr =( > { > 'row' => 33, > 'col' => 1, > 'value' => 'xx', > }, > > { > 'row' => 30, > 'col' => 1, > 'value' => 'zz', > }, > > { > 'row' => 34, > 'col' => 1, > 'value' => 'yy', > }, > > ); > > my @arr1 =( > > { > 'row' => 33, > 'col' => 1, > 'value' => 'xx', > }, > > { > 'row' => 30, > 'col' => 1, > 'value' => 'zz', > }, > > { > 'row' => 35, > 'col' => 1, > 'value' => 'yy', > }, > > ); > > > my @vals = map {$_->{'row'} > 32 && $_->{'col'} > 0 ?stringify(%$_):()} > @arr; > my @vals1 = map {$_->{'row'} > 32 && $_->{'col'} > 0 ?stringify(%$_):()} > @arr1; > > > my %hash; > @hash{@vals} = 1 x @vals; > my @diff = grep {not exists$hash{$_}} @vals1; > > > sub stringify { > return "@_"; > } > > > > > 2009/6/15 Srinivas Reddy > > > Hi Thnx a lot for your quick help. Sry C is rules out as this willl form > > a part of perl script and we have ?C? Expertise issue as well. I think > > kumars solution would really help . Let us rewrite it and check the > > performance. > > > > > > > > I am still looking at a function which takes 2 arrays and gives me the > > difference in them , in my case these array contain my xls file ( row , > col > > and value associated with each cell ) . > > > > > > > > Regards, > > > > > > > > Srinivas Reddy > > > > Asia Technology and Global Projects Manager > > > > Skype : sreddyisi > > > > Cell : +91 9740076449 > > > > LandLine : +91 9900524073/74/76./78 > > > > Fax : +91 8026729764 > > > > Url : www.securities.com > > > > www.thefinancialnet.com > > > > elearning.securities.com > > > > P Please consider the environment before printing this email > > ------------------------------ > > > > *From:* simrangambhir at gmail.com [mailto:simrangambhir at gmail.com] *On > > Behalf Of *simran > > *Sent:* Monday, June 15, 2009 6:17 PM > > *To:* Srinivas Reddy > > *Cc:* bangalore-pm at pm.org > > *Subject:* Re: [Bangalore-pm] Need Help to optimise the code > > > > > > > > Hi Srinivas, > > > > The code is not very complex, and unless you change the structure, it > will > > not optimise too much... better to write it neatly (and with better arg > > passing... as suggested in the email by Ravish. > > > > If you are looking for absolute speed, better to write in in C and plug > it > > in via XS. > > > > simran. > > > > 2009/6/15 Srinivas Reddy > > > > Hi , > > > > > > > > Please help to optimize the code below. We basically read 2 xls files > into > > an array @xls2 and @xls1 . For each cell we want to compare ( starting > from > > col 32 ) values in each cell and if they are not equal we need to store > it > > in a different array. This we will then use to bold those particular > cells. > > > > > > > > The loop which does this comparison could be replacement by some in built > > array difference kind of function. I am new to perl so apologies if I ve > > used any wrong terminologies here. Appreciate your help on the same. > Please > > find attached whole code as well for reference > > > > > > > > sub cell_handler2 { > > > > > > > > my $workbook = $_[0]; > > > > my $sheet_index = $_[1]; > > > > my $row = $_[2]; > > > > my $col = $_[3]; > > > > my $cell = $_[4]; > > > > # Construct array for Dx code > > > > > > > > push @xls2 , { > > > > 'row2' => $row, > > > > 'col2' => $col, > > > > 'value2' => $cell->value(), > > > > }; > > > > return @xls2; > > > > > > > > } > > > > #print Dumper(@xls2); > > > > # Print the End Time to read second excel file > > > > print scalar(localtime) . ": End Reading Excel2 \n"; > > > > > > > > print scalar(localtime) . ": Start Populating Bolding Array \n"; > > > > # Inefficient way of looping > > > > # Please change this as it could boost the performance significantly > > > > for(@xls2) { > > > > if($_->{'col2'} > 32 && $_->{'row2'} > '0' ) { > > > > $newvalue = $_->{'value2'}; > > > > $newrow = $_->{'row2'}; > > > > $newcol = $_->{'col2'}; > > > > for(@xls1) { > > > > $oldrow = $_->{'row1'}; > > > > $oldcol = $_->{'col1'}; > > > > if($_->{'col1'} > 32 && > > $_->{'row1'} > 0 && $_->{'row1'} eq $newrow && $_->{'col1'} eq $newcol) { > > > > > > $oldvalue = $_->{'value1'}; > > > > > > last; > > > > } > > > > } > > > > if($oldvalue ne $newvalue) { > > > > push @bold_array , { > > > > 'row' => > > $_->{'row2'}, > > > > 'col' => > > $_->{'col2'}, > > > > 'value' => > > $_->{'value2'}, > > > > }; > > > > } > > > > } > > > > } > > > > > > > > > > > > Regards, > > > > > > > > Srinivas Reddy > > > > > > ______________________________________________________________________ > > This communication contains information which is confidential. It is for > > the > > exclusive use of the intended recipient(s). If you are not the intended > > recipient(s) please note any distribution, copying or use of this > > communication or the information in it is strictly prohibited. If you > have > > received this communication in error please notify us by e-mail or > > by telephone (as above) and then delete the e-mail and all attachments > and > > any copies thereof. > > ______________________________________________________________________ > > > > > > _______________________________________________ > > Bangalore-pm mailing list > > Bangalore-pm at pm.org > > http://mail.pm.org/mailman/listinfo/bangalore-pm > > > > > > > > ______________________________________________________________________ > > This communication contains information which is confidential. It is for > > the > > exclusive use of the intended recipient(s). If you are not the intended > > recipient(s) please note any distribution, copying or use of this > > communication or the information in it is strictly prohibited. If you > have > > received this communication in error please notify us by e-mail or > > by telephone (as above) and then delete the e-mail and all attachments > and > > any copies thereof. > > ______________________________________________________________________ > > > > _______________________________________________ > > Bangalore-pm mailing list > > Bangalore-pm at pm.org > > http://mail.pm.org/mailman/listinfo/bangalore-pm > > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://mail.pm.org/pipermail/bangalore-pm/attachments/20090615/c7591548/attachment.html > > > > ------------------------------ > > _______________________________________________ > Bangalore-pm mailing list > Bangalore-pm at pm.org > http://mail.pm.org/mailman/listinfo/bangalore-pm > > End of Bangalore-pm Digest, Vol 16, Issue 8 > ******************************************* > -------------- next part -------------- An HTML attachment was scrubbed... URL: From simran at tlims.cc Mon Jun 15 20:35:11 2009 From: simran at tlims.cc (simran) Date: Tue, 16 Jun 2009 09:05:11 +0530 Subject: [Bangalore-pm] Need Help to optimise the code In-Reply-To: References: <5B7E14CC96EC8D41A27766C3B51F9AB61B04CA57AA@KOCL385273EXCH.msp.tech.int.digex.com> <22a825cb0906150547w2baa6032h8b79d1c5531c1d87@mail.gmail.com> <5B7E14CC96EC8D41A27766C3B51F9AB61B04CA57AC@KOCL385273EXCH.msp.tech.int.digex.com> Message-ID: <22a825cb0906152035o395a91b1yc5e21f7193f83cb8@mail.gmail.com> Hi Srinivas, You can also try the benchmark module... http://perldoc.perl.org/Benchmark.html simran. 2009/6/16 Kiran Kumar > you will not be able to compare hashes but you can convert your data to > strings and it will make it easier , something like this > > #!perl > use strict; > > use warnings; > use Data::Dumper; > > my @arr =( > { > 'row' => 33, > 'col' => 1, > 'value' => 'xx', > }, > > { > 'row' => 30, > 'col' => 1, > 'value' => 'zz', > }, > > { > 'row' => 34, > 'col' => 1, > 'value' => 'yy', > }, > > ); > > my @arr1 =( > > { > 'row' => 33, > 'col' => 1, > 'value' => 'xx', > }, > > { > 'row' => 30, > 'col' => 1, > 'value' => 'zz', > }, > > { > 'row' => 35, > 'col' => 1, > 'value' => 'yy', > }, > > ); > > > my @vals = map {$_->{'row'} > 32 && $_->{'col'} > 0 ?stringify(%$_):()} > @arr; > my @vals1 = map {$_->{'row'} > 32 && $_->{'col'} > 0 ?stringify(%$_):()} > @arr1; > > > my %hash; > @hash{@vals} = 1 x @vals; > my @diff = grep {not exists$hash{$_}} @vals1; > > > sub stringify { > return "@_"; > > } > > > > > 2009/6/15 Srinivas Reddy > >> Hi Thnx a lot for your quick help. Sry C is rules out as this willl form >> a part of perl script and we have ?C? Expertise issue as well. I think >> kumars solution would really help . Let us rewrite it and check the >> performance. >> >> >> >> I am still looking at a function which takes 2 arrays and gives me the >> difference in them , in my case these array contain my xls file ( row , col >> and value associated with each cell ) . >> >> >> >> Regards, >> >> >> >> Srinivas Reddy >> >> Asia Technology and Global Projects Manager >> >> Skype : sreddyisi >> >> Cell : +91 9740076449 >> >> LandLine : +91 9900524073/74/76./78 >> >> Fax : +91 8026729764 >> >> Url : www.securities.com >> >> www.thefinancialnet.com >> >> elearning.securities.com >> >> P Please consider the environment before printing this email >> ------------------------------ >> >> *From:* simrangambhir at gmail.com [mailto:simrangambhir at gmail.com] *On >> Behalf Of *simran >> *Sent:* Monday, June 15, 2009 6:17 PM >> *To:* Srinivas Reddy >> *Cc:* bangalore-pm at pm.org >> *Subject:* Re: [Bangalore-pm] Need Help to optimise the code >> >> >> >> Hi Srinivas, >> >> The code is not very complex, and unless you change the structure, it will >> not optimise too much... better to write it neatly (and with better arg >> passing... as suggested in the email by Ravish. >> >> If you are looking for absolute speed, better to write in in C and plug it >> in via XS. >> >> simran. >> >> 2009/6/15 Srinivas Reddy >> >> Hi , >> >> >> >> Please help to optimize the code below. We basically read 2 xls files >> into an array @xls2 and @xls1 . For each cell we want to compare ( starting >> from col 32 ) values in each cell and if they are not equal we need to store >> it in a different array. This we will then use to bold those particular >> cells. >> >> >> >> The loop which does this comparison could be replacement by some in built >> array difference kind of function. I am new to perl so apologies if I ve >> used any wrong terminologies here. Appreciate your help on the same. Please >> find attached whole code as well for reference >> >> >> >> sub cell_handler2 { >> >> >> >> my $workbook = $_[0]; >> >> my $sheet_index = $_[1]; >> >> my $row = $_[2]; >> >> my $col = $_[3]; >> >> my $cell = $_[4]; >> >> # Construct array for Dx code >> >> >> >> push @xls2 , { >> >> 'row2' => $row, >> >> 'col2' => $col, >> >> 'value2' => $cell->value(), >> >> }; >> >> return @xls2; >> >> >> >> } >> >> #print Dumper(@xls2); >> >> # Print the End Time to read second excel file >> >> print scalar(localtime) . ": End Reading Excel2 \n"; >> >> >> >> print scalar(localtime) . ": Start Populating Bolding Array \n"; >> >> # Inefficient way of looping >> >> # Please change this as it could boost the performance significantly >> >> for(@xls2) { >> >> if($_->{'col2'} > 32 && $_->{'row2'} > '0' ) { >> >> $newvalue = $_->{'value2'}; >> >> $newrow = $_->{'row2'}; >> >> $newcol = $_->{'col2'}; >> >> for(@xls1) { >> >> $oldrow = $_->{'row1'}; >> >> $oldcol = $_->{'col1'}; >> >> >> if($_->{'col1'} > 32 && >> $_->{'row1'} > 0 && $_->{'row1'} eq $newrow && $_->{'col1'} eq $newcol) { >> >> >> $oldvalue = $_->{'value1'}; >> >> >> last; >> >> } >> >> } >> >> if($oldvalue ne $newvalue) { >> >> push @bold_array , { >> >> 'row' => >> $_->{'row2'}, >> >> 'col' => >> $_->{'col2'}, >> >> 'value' => >> $_->{'value2'}, >> >> }; >> >> } >> >> } >> >> } >> >> >> >> >> >> Regards, >> >> >> >> Srinivas Reddy >> >> >> ______________________________________________________________________ >> This communication contains information which is confidential. It is for >> the >> exclusive use of the intended recipient(s). If you are not the intended >> recipient(s) please note any distribution, copying or use of this >> communication or the information in it is strictly prohibited. If you have >> received this communication in error please notify us by e-mail or >> by telephone (as above) and then delete the e-mail and all attachments and >> any copies thereof. >> ______________________________________________________________________ >> >> >> _______________________________________________ >> Bangalore-pm mailing list >> Bangalore-pm at pm.org >> http://mail.pm.org/mailman/listinfo/bangalore-pm >> >> >> >> ______________________________________________________________________ >> This communication contains information which is confidential. It is for >> the >> exclusive use of the intended recipient(s). If you are not the intended >> recipient(s) please note any distribution, copying or use of this >> communication or the information in it is strictly prohibited. If you have >> received this communication in error please notify us by e-mail or >> by telephone (as above) and then delete the e-mail and all attachments and >> any copies thereof. >> ______________________________________________________________________ >> >> _______________________________________________ >> Bangalore-pm mailing list >> Bangalore-pm at pm.org >> http://mail.pm.org/mailman/listinfo/bangalore-pm >> > > > _______________________________________________ > Bangalore-pm mailing list > Bangalore-pm at pm.org > http://mail.pm.org/mailman/listinfo/bangalore-pm > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mariassai at gmail.com Tue Jun 16 03:01:01 2009 From: mariassai at gmail.com (sairam pareek) Date: Tue, 16 Jun 2009 03:01:01 -0700 Subject: [Bangalore-pm] Please help me in Parsing KML file in perl using regular expression.(its urgent) In-Reply-To: References: <22a825cb0906142202o1d4b0743v875c5372bf261b20@mail.gmail.com> Message-ID: Hi everyone, Need your help once again I have a a kml file for parsing (please find the attachment below) I have used XML::Simple for parsing & for storing the value by hash array(key, value). Below is the code:: ****************************************************************************************** #!/usr/bin/perl use XML::Simple; use Data::Dumper; my $file = 'Al waab B villa.kml'; #create a object my $xm1 = XML::Simple->new(); #read XML file my $data = $xm1->XMLin("Al waab B villa.kml"); print Dumper($data); my $tags = $data->{Document}->{Placemark}->{LookAt}; my %hash; my $val; foreach $val (keys %$hello) { push @{$hash{$tags}}, $val; } print Dumper \%hash; ****************************************************************************************** I get output as: $VAR1 = { 'HASH(0x1ad903c)' => [ 'longitude', 'latitude', 'heading', 'tilt', 'range', 'altitudeMode', 'altitude' ] }; For a single key I want tag values between them not the name. And I want output as::(with a pipe operator between each value) LookAt => 51.47891287538003|25.26764114641654|0|3709.372423858944|0-0.002617566196780602|relativeToGround wating for your replies. Thanks in advance. On Sun, Jun 14, 2009 at 10:57 PM, sairam pareek wrote: > Thanks for your replies, > > I m happy to be in this group, I tried the given solutions, they are > working fine. > > If I have some problem further Ill let you know. > > Thanks once again. > > > On Sun, Jun 14, 2009 at 10:02 PM, simran wrote: > >> probably best to use the XML::Simple module... >> >> http://search.cpan.org/~grantm/XML-Simple-2.18/lib/XML/Simple.pm >> >> 2009/6/15 wolf >> >> Hey, >>> >>> I used your KML file ( renamed it of course ): >>> >>> cat test.kml | perl -ne ' print "$1: $2\n " if >>> m!<(longitude|latitude)\s*?>\s*?([0-9\.]+)\s*?!' >>> >>> Hope this helps, >>> >>> Cheers, >>> V >>> >>> >>> 2009/6/14 sairam pareek >>> >>>> Hello everyone. >>>> >>>> I have a kml file, and struggling to write a perl script to parse its >>>> value between tags, this is my first task. >>>> and the second is to update the value between the tag in the postgresql >>>> database table. I m attaching the KML file, Please find the attachment. (I >>>> want to parse the longitude, latitude vlaues in these) >>>> >>>> Please >>>> help me, its urgent. Waiting for your replies. Hoping for great help from >>>> you guys. I wanted to use regular expression for this. I found this group on >>>> orkut. >>>> Thanks in advance. >>>> >>>> Regards, >>>> Sairam >>>> >>>> -- >>>> "It is not how much you do, but how much love you put in the doing." >>>> >>>> _______________________________________________ >>>> Bangalore-pm mailing list >>>> Bangalore-pm at pm.org >>>> http://mail.pm.org/mailman/listinfo/bangalore-pm >>>> >>> >>> >>> _______________________________________________ >>> Bangalore-pm mailing list >>> Bangalore-pm at pm.org >>> http://mail.pm.org/mailman/listinfo/bangalore-pm >>> >> >> > > > -- > "It is not how much you do, but how much love you put in the doing." > -- "It is not how much you do, but how much love you put in the doing." -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Al waab B villa.kml Type: application/vnd.google-earth.kml+xml Size: 1498 bytes Desc: not available URL: From deepak at perl.org.in Tue Jun 16 10:28:36 2009 From: deepak at perl.org.in (Deepak Tripathi) Date: Tue, 16 Jun 2009 22:58:36 +0530 Subject: [Bangalore-pm] Question to all. Message-ID: Hi , I was not able to access this link before couple of days ? why this link was down ?? my question to moderator ? Thanks dk http://qa.debian.org/developer.php?login=apenguinlinux at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From diwakar211 at gmail.com Wed Jun 17 07:17:18 2009 From: diwakar211 at gmail.com (The Rising Sun) Date: Wed, 17 Jun 2009 19:47:18 +0530 Subject: [Bangalore-pm] Please help me in debugging Socket6 perl module Message-ID: Here is the test case info #cat use.t use strict; use Test; use Socket; BEGIN { plan tests => 3 } use Socket6; ok(1); my @tmp = getaddrinfo("localhost", "", AF_INET, SOCK_STREAM, 0, 0); if ($#tmp >= 1) { ok(2); } my($family, $socktype, $protocol, $sin, $canonname) = splice(@tmp, $[, 5); my($addr, $port) = getnameinfo($sin, NI_NUMERICHOST | NI_NUMERICSERV); if ($addr eq "127.0.0.1" && $port eq "0") { ok(3); } exit; __END__ This is passing fine in my AIX-53 machine, but if i include comment line ranging 100-200 lines( I have attache the file which is failing for me) , this test case is getting failed on the same machine. Please help me out in debugging this strange defect. If it is not recreatable for you, try to increase the comment lines and run the script. Machine env details : AIX-53L perl-5.8.8 openssl-0.9.8 Compiler : IBM xlc_r Failed test case ( Also attached) : If it is not recreatable for you, try to increase the comment lines and run the script. # cat use.t #!/usr/bin/env perl -w # Copyright (C) 2003 Hajimu UMEMOTO . # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. Neither the name of the project nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # $Id: use.t,v 1.2 2005/08/27 16:10:54 ume Exp $ use strict; use Test; use Socket; BEGIN { plan tests => 3 } use Socket6; ok(1); my @tmp = getaddrinfo("localhost", "", AF_INET, SOCK_STREAM, 0, 0); if ($#tmp >= 1) { ok(2); } print "SSSSSSSSSSSS"; my($family, $socktype, $protocol, $sin, $canonname) = splice(@tmp, $[, 5); print "KK \n\n"; print "$family \n\n"; print "$protocol \n\n"; my($addr, $port) = getnameinfo($sin,NI_NUMERICHOST | NI_NUMERICSERV); print "PORT = $port"; if ($addr eq "127.0.0.1") { if ($port eq "0") { ok(3); } } exit; __END__ Thanks & Regards, DIVAKAR ADARI, IIT KHARAGPUR -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- # cat use.t #!/usr/bin/env perl -w # Copyright (C) 2003 Hajimu UMEMOTO . # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. Neither the name of the project nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # $Id: use.t,v 1.2 2005/08/27 16:10:54 ume Exp $ use strict; use Test; use Socket; BEGIN { plan tests => 3 } use Socket6; ok(1); my @tmp = getaddrinfo("localhost", "", AF_INET, SOCK_STREAM, 0, 0); if ($#tmp >= 1) { ok(2); } print "SSSSSSSSSSSS"; my($family, $socktype, $protocol, $sin, $canonname) = splice(@tmp, $[, 5); print "KK \n\n"; print "$family \n\n"; print "$protocol \n\n"; my($addr, $port) = getnameinfo($sin,NI_NUMERICHOST | NI_NUMERICSERV); print "PORT = $port"; if ($addr eq "127.0.0.1") { if ($port eq "0") { ok(3); } } exit; __END__