Re: Any alternative for substr() function

2013-04-12 Thread Charles DeRykus
On Fri, Apr 12, 2013 at 4:23 AM, kavita kulkarni wrote: > Thanks all, got many ideas from you.. > > My script took ~7 min to run with data file of ~50,000 lines with > substr()/unpack() enabled and same script took ~2 min after disabling > substr()/unpack(). > ... > > For "Devel::NYTProf", I need

Re: Any alternative for substr() function

2013-04-12 Thread Michael Rasmussen
On Fri, Apr 12, 2013 at 04:53:52PM +0530, kavita kulkarni wrote: > Thanks all, got many ideas from you.. > > My script took ~7 min to run with data file of ~50,000 lines with > substr()/unpack() enabled and same script took ~2 min after disabling > substr()/unpack(). No one has asked what kind of

Re: Any alternative for substr() function

2013-04-12 Thread Paul Johnson
On Wed, Apr 10, 2013 at 03:46:00PM +0530, kavita kulkarni wrote: > Hi All, Hello. > I want to extract certain char sets (e.g. char 4 to 9, char 11 to 14 etc.) > from each line of my file and store them in separate variables for further > processing. > My file size can vary from thousand to millio

Re: Any alternative for substr() function

2013-04-12 Thread Rob Dixon
On 12/04/2013 12:23, kavita kulkarni wrote: Thanks all, got many ideas from you.. My script took ~7 min to run with data file of ~50,000 lines with substr()/unpack() enabled and same script took ~2 min after disabling substr()/unpack(). That led me to the conclusion that substr/unpack is taking

Re: Any alternative for substr() function

2013-04-12 Thread kavita kulkarni
Thanks all, got many ideas from you.. My script took ~7 min to run with data file of ~50,000 lines with substr()/unpack() enabled and same script took ~2 min after disabling substr()/unpack(). That led me to the conclusion that substr/unpack is taking maximum of my time (and that I should reduce).

Re: Any alternative for substr() function

2013-04-10 Thread Rob Dixon
On 10/04/2013 16:45, Bob goolsby wrote: G'Mornin' Kavita -- Before you go off on a goose chase, how do you know that substr() is going to be a problem for you? Have you bench-marked it? If your file is as large as you say, I strongly suspect that your bottleneck is going to be I/O and any diff

Re: Any alternative for substr() function

2013-04-10 Thread Ken Slater
As others have mentioned, you should profile the program to get an idea of what code is taking up time. That said, here are a couple of comments: When you have that many arguments, it is usually preferrable (may be a little faster) to use the following (rather than shifts): my ($self, $data, $sta

Re: Any alternative for substr() function

2013-04-10 Thread David Precious
On Wed, 10 Apr 2013 08:45:40 -0700 Bob goolsby wrote: > Before you go off on a goose chase, how do you know that substr() is > going to be a problem for you? Have you bench-marked it? If your > file is as large as you say, I strongly suspect that your bottleneck > is going to be I/O and any dif

Re: Any alternative for substr() function

2013-04-10 Thread Bob goolsby
G'Mornin' Kavita -- Before you go off on a goose chase, how do you know that substr() is going to be a problem for you? Have you bench-marked it? If your file is as large as you say, I strongly suspect that your bottleneck is going to be I/O and any differences between unpack() and substr() will

Re: Any alternative for substr() function

2013-04-10 Thread kavita kulkarni
Data file has the lines with same length and so the field positions I am interested in (so unpack works for me). Tried with "unpack" as well & it takes almost same time as substr(). Here is sample code: Below function is called for each line of input data file.. sub extractFieldValue { my $self

Re: Any alternative for substr() function

2013-04-10 Thread Jenda Krynicky
From: timothy adigun <2teezp...@gmail.com> > On 10 Apr 2013 11:30, "Chankey Pathak" wrote: > > > > Hi Kavita, > > > > You may try unpack (http://perldoc.perl.org/functions/unpack.html) > > > unpack would not work if the OP has varying length of lines. Nope. It would work just fine as long as the

Re: Any alternative for substr() function

2013-04-10 Thread timothy adigun
Hi, On 10 Apr 2013 11:30, "Chankey Pathak" wrote: > > Hi Kavita, > > You may try unpack (http://perldoc.perl.org/functions/unpack.html) > unpack would not work if the OP has varying length of lines. > Also read these: http://www.perlmonks.org/?node_id=308607, > http://stackoverflow.com/questions/

Re: Any alternative for substr() function

2013-04-10 Thread Chankey Pathak
Hi Kavita, You may try unpack (http://perldoc.perl.org/functions/unpack.html) Also read these: http://www.perlmonks.org/?node_id=308607, http://stackoverflow.com/questions/1083269/is-perls-unpack-ever-faster-than-substr On Wed, Apr 10, 2013 at 3:46 PM, kavita kulkarni wrote: > Hi All, > > I wa

Any alternative for substr() function

2013-04-10 Thread kavita kulkarni
Hi All, I want to extract certain char sets (e.g. char 4 to 9, char 11 to 14 etc.) from each line of my file and store them in separate variables for further processing. My file size can vary from thousand to millions of lines. If I use perl in-built function substr() to data extraction, it has hu