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

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

Re: Any alternative for substr() function

2013-04-12 Thread Paul Johnson
rom thousand to millions of lines. > If I use perl in-built function substr() to data extraction, it has huge > impact on performance. Compared to what? > Is there any alternative for this? Perhaps unpack() or regular expressions, but I doubt either would be much faster, if at all. -- Paul

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

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

Re: Any alternative for substr() function

2013-04-10 Thread Ken Slater
p/ /g; ... } HTH, Ken On Wed, Apr 10, 2013 at 8:02 AM, kavita kulkarni wrote: > 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

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

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()

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 extractFieldVa

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
p://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 want to extract certain char sets (e.g. char 4 to 9, char 11 to 14 etc.) > > from

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, &g

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

Re: Assigning to Substr

2011-09-08 Thread Rob Dixon
On 07/09/2011 20:49, Emeka wrote: On Wed, Sep 7, 2011 at 8:00 PM, Rob Dixon wrote: On Wed, Sep 7, 2011 at 8:08 PM, Emeka wrote: On 06/09/2011 13:04, Emeka wrote: Could someone explain what Perl does behind here? Assign to Substring.. substr($string, 0 , 5) = 'Greetings'; W

Re: Assigning to Substr

2011-09-07 Thread Shlomi Fish
Hi Emeka, On Wed, 7 Sep 2011 20:49:44 +0100 Emeka wrote: > Rob, > > Which C file should check out? > > Emeka > Please look at the function definition starting from «PP(pp_substr)» in pp.c in the Perl 5 distribution: https://github.com/mirrors/perl/blob/blead/pp.c It seems pretty complicate

Re: Assigning to Substr

2011-09-07 Thread Emeka
gt; On 06/09/2011 13:04, Emeka wrote: >> >>> >>> Could someone explain what Perl does behind here? >>> >>> Assign to Substring.. >>> substr($string, 0 , 5) = 'Greetings'; >>> >> >> What do you want to know Emeka? >> >> T

Re: Assigning to Substr

2011-09-07 Thread Emeka
Rob, I want to check out the C code. Kindly mail it to my box. Have a great day! Emeka On Wed, Sep 7, 2011 at 8:00 PM, Rob Dixon wrote: > On 06/09/2011 13:04, Emeka wrote: > >> >> Could someone explain what Perl does behind here? >> >> Assign to Substr

Re: Assigning to Substr

2011-09-07 Thread Rob Dixon
On 06/09/2011 13:04, Emeka wrote: Could someone explain what Perl does behind here? Assign to Substring.. substr($string, 0 , 5) = 'Greetings'; What do you want to know Emeka? There is no copy of the 'old' string, and substr behaves as documented. I have the C code of s

Re: Assigning to Substr

2011-09-06 Thread Shawn H Corey
On 11-09-06 08:32 AM, Emeka wrote: I asked what Perl does behind.. Is it an alias or what? I want internal detailsor something technical. See `perldoc -f substr` and search for /lvalue/. -- Just my 0.0002 million dollars worth, Shawn Confusion is the first step of understanding

Re: Assigning to Substr

2011-09-06 Thread Emeka
On Tue, Sep 6, 2011 at 1:19 PM, Shawn H Corey wrote: > On 11-09-06 08:04 AM, Emeka wrote: > >> Hello All, >> >> Could someone explain what Perl does behind here? >> >> Assign to Substring.. >> substr($string, 0 , 5) = 'Greetings'; >&

Re: Assigning to Substr

2011-09-06 Thread Shawn H Corey
On 11-09-06 08:04 AM, Emeka wrote: Hello All, Could someone explain what Perl does behind here? Assign to Substring.. substr($string, 0 , 5) = 'Greetings'; Regards, Emeka It replaces the first 5 characters in $string with 'Greetings'. #!/usr/bin/env perl use stric

Assigning to Substr

2011-09-06 Thread Emeka
Hello All, Could someone explain what Perl does behind here? Assign to Substring.. substr($string, 0 , 5) = 'Greetings'; Regards, Emeka -- *Satajanus Nig. Ltd *

Re: about substr

2010-05-04 Thread Petr Šabata
On Sat, 28 Nov 2037 10:04:37 +0800, billy wrote: > when i user substr,i find "Tab" key is calculated as 1,but i want to set > it as 8,what will i do? thks. Tab doesn't mean a fixed space between the content before and after it on a line. If you want that, use spaces inste

Re: Strange problem with substr() function and right aligned fields

2009-03-05 Thread Jenda Krynicky
From: "Bill Harpley" > My Comment: this is an obvious approach, with numerous advantages. > However, it requires installation of the BD:Oracle module, which can be > very tricky. > Basically, I started to install and configure all of this (Perl, > DBI,DB:Oracle) on HP-UX 11.31 but after 4 days I

Strange problem with substr() function and right aligned fields

2009-03-05 Thread Bill Harpley
eft-aligned to the field, except for > one column. > ... "Why do you write the SQL query results into a text file only to have to parse them out later? Run the SQL from the Perl script via DBI and you will not need any substr(). Jenda" = My Comment: this is an obvious

Re: Strange problem with substr() function and right aligned fields

2009-03-05 Thread Jenda Krynicky
eld, except for one > column. > ... Why do you write the SQL query results into a text file only to have to parse them out later? Run the SQL from the Perl script via DBI and you will not need any substr(). Jenda = je...@krynicky.cz === http://Jenda.Krynicky.cz = When it comes to

Re: Strange problem with substr() function and right aligned fields

2009-03-03 Thread John W. Krahn
the output of the SQ query, the right-aligned colum looks like this: NODE_UL = 146 281 985 So both the data and Field Title are right-aligned to the column. I am using a function cal of the form: $field_value=substr( $input_line , $field_start, $field_width ) ; Where

Strange problem with substr() function and right aligned fields

2009-03-03 Thread Bill Harpley
query, the right-aligned colum looks like this: NODE_UL = 146 281 985 So both the data and Field Title are right-aligned to the column. I am using a function cal of the form: $field_value=substr( $input_line , $field_start

Re: substr help

2008-03-06 Thread John W. Krahn
Bobby wrote: "John W. Krahn" <[EMAIL PROTECTED]> wrote: Bobby wrote: Bobby wrote: open EXCLUDE, '<', $exclude_psc or die "Could not open '$exclude_psc' $!"; while ( ) { next if $. == 1; # exclude header chomp; my ($excpsc,$keyword) = split /\|/; %ex_psc = (exclpsc=>$excps

Re: substr help

2008-03-06 Thread Bobby
printing to out file. Thanks. $newpsc = substr($PSC,0,$count); if (uc($ex_psc{exclpsc}) eq uc($newpsc)){ $_= join '|',$base_no,$ex_psc{exclpsc},$ex_psc{exkeyword}; print OUT; You are assigning to the hash so it will only contain data from the last record in the 'excl

Re: substr help

2008-03-06 Thread Bobby
That works, thanks Tom! Tom Phoenix <[EMAIL PROTECTED]> wrote: On Thu, Mar 6, 2008 at 8:31 AM, Bobby wrote: > Use of uninitialized value in concatenation (.) or string at generatePsc.pl > line 48, line 5. Is this what you seek? next unless defined $PSC; It can also be quite educational

Re: substr help

2008-03-06 Thread Tom Phoenix
On Thu, Mar 6, 2008 at 8:31 AM, Bobby <[EMAIL PROTECTED]> wrote: > Use of uninitialized value in concatenation (.) or string at generatePsc.pl > line 48, line 5. Is this what you seek? next unless defined $PSC; It can also be quite educational to use the Perl debugger to step through a pr

Re: substr help

2008-03-06 Thread Bobby
CTED]> wrote: Bobby wrote: > Could someone please tell me what's wrong with my use of the > substr function below? I keep on getting "use of uninitialized > value in substr". Thanks. > > $newpsc = substr($PSC,0,$count); > > Here's the complete

Re: substr help

2008-03-06 Thread Bobby
Below is what i get when i tried to print just the $PSC variable. So the $PSC column has the value of (PSC, FCSD2, ADEK1, ADEZ2). I did put in a check for alphanumeric in $PSC if ($PSC =~ /^[a-zA-Z0-9]+$/) before doing the substr but still have same issue. What i'm trying to do is to

Re: substr help

2008-03-06 Thread Chas. Owens
On Wed, Mar 5, 2008 at 11:57 PM, Richard Lee <[EMAIL PROTECTED]> wrote: snip > Also, can you explain why below is wrong? snip > func([EMAIL PROTECTED]); > sub func { > my $aref = shift; > my $oref = "$aref"; # WRONG <- why is it wrong? > }

Re: substr help

2008-03-05 Thread Richard Lee
*What not just like below? As long as you have unique key, it would retain all the information.* $ex_psc{"$excpsc"} = "$keyword"; $ex_psc{"$excpsc"} is superfluous because *all* hash keys are strings. perldoc -q quoting What’s wrong with always quoting "$vars"? John Thank you

Re: substr help

2008-03-05 Thread John W. Krahn
Richard Lee wrote: open EXCLUDE, '<', $exclude_psc or die "Could not open '$exclude_psc' $!"; while ( ) { next if $. == 1; # exclude header chomp; my ($excpsc,$keyword) = split /\|/; %ex_psc = (exclpsc=>$excpsc,exkeyword =>$keyword ); *What not just like below? As lo

Re: substr help

2008-03-05 Thread Richard Lee
open EXCLUDE, '<', $exclude_psc or die "Could not open '$exclude_psc' $!"; while ( ) { next if $. == 1; # exclude header chomp; my ($excpsc,$keyword) = split /\|/; %ex_psc = (exclpsc=>$excpsc,exkeyword =>$keyword ); *What not just like below? As long as you have unique

Re: substr help

2008-03-05 Thread John W. Krahn
Bobby wrote: Could someone please tell me what's wrong with my use of the substr function below? I keep on getting "use of uninitialized value in substr". Thanks. $newpsc = substr($PSC,0,$count); Here's the complete code: #!/usr/bin/perl use strict; use warnin

Re: substr help

2008-03-05 Thread Nobody Imparticular
[..snip..] > > while () { > my ($base_no, $name, $description, $PSC) = split > /\|/; > Are you absolutely sure that $PSC is getting a value here? If you "print $PSC" do you get a value? It might also help to see the data stream... -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additio

Re: substr help

2008-03-05 Thread Bobby
Sorry, i've left out some details in my previous email. I've isolated the code and it works without the substr function. Thanks in advance for any suggestions. Bobby <[EMAIL PROTECTED]> wrote: Could someone please tell me what's wrong with my use of the substr func

substr help

2008-03-05 Thread Bobby
Could someone please tell me what's wrong with my use of the substr function below? I keep on getting "use of uninitialized value in substr". Thanks. $newpsc = substr($PSC,0,$count); Here's the complete code: #!/usr/bin/perl use strict; use warnings; my $exclude_psc = &

Re: Use of uninitialized value in substr

2007-07-06 Thread Tom Phoenix
On 7/6/07, elavazhagan perl <[EMAIL PROTECTED]> wrote: While executing the mutate.pl pgrogram,the diagnostic msg obtained as "Use of uninitialized value in substr at mutate.pl line 31, line 1." I almost defined all the variables. Would you kindly provide some remedy to thi

Use of uninitialized value in substr

2007-07-06 Thread elavazhagan perl
Hai While executing the mutate.pl pgrogram,the diagnostic msg obtained as "Use of uninitialized value in substr at mutate.pl line 31, line 1." I almost defined all the variables. Would you kindly provide some remedy to this…… This is the mutate

Re: substr question

2006-06-27 Thread Rob Dixon
David Gilden wrote: > I am not sure I have the syntax quite right here, any suggestions would be > welcome. > > $line = "Friday, June 23, 2006 12:30 PM" ; > > $last_updated = substr($line, 0, (length($line) -9)); # remove the time > part of time stamp > # the a

Re: substr question

2006-06-25 Thread John W. Krahn
David Gilden wrote: > Hello, Hello, > I am not sure I have the syntax quite right here, any suggestions would be > welcome. > > > $line = "Friday, June 23, 2006 12:30 PM" ; > > $last_updated = substr($line, 0, (length($line) -9)); > # remove the time par

Re: substr question

2006-06-25 Thread Tom Phoenix
On 6/25/06, David Gilden <[EMAIL PROTECTED]> wrote: I am not sure I have the syntax quite right here, any suggestions would be welcome. You can find the syntax for substr, as with any of Perl's built-in functions, in the perlfunc manpage. You should be able to use this comma

Re: substr question

2006-06-25 Thread Chad Perrin
On Sun, Jun 25, 2006 at 01:16:13PM -0500, David Gilden wrote: > Hello, > > I am not sure I have the syntax quite right here, any suggestions would be > welcome. > > > $line = "Friday, June 23, 2006 12:30 PM" ; > > $last_updated = substr($line, 0, (lengt

substr question

2006-06-25 Thread David Gilden
Hello, I am not sure I have the syntax quite right here, any suggestions would be welcome. $line = "Friday, June 23, 2006 12:30 PM" ; $last_updated = substr($line, 0, (length($line) -9)); # remove the time part of time stamp # the above line is throwing an error Thx, Dave Gil

search and replace with a temp file at a certain substr position

2005-07-20 Thread DBSMITH
All, I need to search a file for a string then set a variable using substr b/c it is at a certain position, then finally replace the string with another string. Here is my test code: my $gpg=qq(/home/gpghrp/.gnupg); open (GPG, "gpg --finger

Re: Choosing between Regexp and Substr

2005-01-06 Thread John W. Krahn
Edward Wijaya wrote: Seems that John's regex approaches are (much) faster: Rate HD_string HD_jkrahn2 HD_jkrahn1 HD_string 203251/s -- -18% -76% HD_jkrahn2 247033/s22% -- -71% HD_jkrahn1 848840/s 318% 244% -- [snip] sub h

Re: Choosing between Regexp and Substr

2005-01-06 Thread Edward Wijaya
n = length ($a); my $num_match=0; for (my $i=0; $i<$len; $i++) { # assume that the lists are of same length ++$num_match if substr($a, $i, 1) eq substr($b, $i, 1); } #my $weight = $num_match/$len; return $num_match; } sub hamming

Re: Choosing between Regexp and Substr

2005-01-03 Thread Jenda Krynicky
From: "John W. Krahn" <[EMAIL PROTECTED]> > Peter Scott wrote: > > In article <[EMAIL PROTECTED]>, > > [EMAIL PROTECTED] (Edward Wijaya) writes: > > > >>BTW, can you explain what's the difference between these two? > >> > >>>sub hamming_distance_string { ( $_[0] ^ $_[1] ) =~ tr/\0// } > > > > In

Re: Choosing between Regexp and Substr

2005-01-03 Thread John W. Krahn
Peter Scott wrote: In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Edward Wijaya) writes: BTW, can you explain what's the difference between these two? sub hamming_distance_string { ( $_[0] ^ $_[1] ) =~ tr/\0// } In a scalar context, tr/// returns the count of the number of characters seen. sub

Re: Choosing between Regexp and Substr

2005-01-03 Thread Peter Scott
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Edward Wijaya) writes: >BTW, can you explain what's the difference between these two? > >> >> sub hamming_distance_string { ( $_[0] ^ $_[1] ) =~ tr/\0// } In a scalar context, tr/// returns the count of the number of characters seen. >> sub hamm

Re: Choosing between Regexp and Substr

2005-01-03 Thread Edward Wijaya
Thanks so much for the reply John, On Mon, 03 Jan 2005 04:07:05 -0800, John W. Krahn <[EMAIL PROTECTED]> wrote: I don't know if I am a master but I wouldn't use a regular expression. In my eyes, you certainly is a master! BTW, can you explain what's the difference between these two? sub hamming_di

Re: Choosing between Regexp and Substr

2005-01-03 Thread Jenda Krynicky
From: "Octavian Rasnita" <[EMAIL PROTECTED]> > If you can use substr(), use it, because it works much faster than > regexp. > > Teddy Nope. One substr() will of course be quicker than one regexp application, but a loop containing substr() will most of the time slowe

Re: Choosing between Regexp and Substr

2005-01-03 Thread John W. Krahn
Edward WIJAYA wrote: Dear friends, Hello, After a couple of months dwelling into Perl scripting especially in manipulating strings, I found myself resorting to use "substr" function a lot. I had a feeling that the most of the "substr" function can be replaced with rege

Re: Choosing between Regexp and Substr

2005-01-03 Thread Octavian Rasnita
If you can use substr(), use it, because it works much faster than regexp. Teddy - Original Message - From: "Edward WIJAYA" <[EMAIL PROTECTED]> To: Sent: Sunday, January 02, 2005 5:08 PM Subject: Choosing between Regexp and Substr > Dear friends, > > After a

Choosing between Regexp and Substr

2005-01-02 Thread Edward WIJAYA
Dear friends, After a couple of months dwelling into Perl scripting especially in manipulating strings, I found myself resorting to use "substr" function a lot. I had a feeling that the most of the "substr" function can be replaced with regexp in any cases. For example t

Re: substr

2004-10-31 Thread Robert Citek
On Saturday, Oct 30, 2004, at 21:46 US/Central, [EMAIL PROTECTED] wrote: My earlier post was not quite clear. I will explain my problem in detail here. I have a string whose length is say 5. I need to copy another string into this string but from an offset of 10. I tried using substr but this is a

Re: substr

2004-10-30 Thread Chasecreek Systemhouse
f 10. > I tried using substr but this is a limitation of substr and it gave me > a fatal error. > Is there any other function, method which will allow me to do so ? > > Manas. Yes, "rindex" is what (I think) you want; here is a small example of its use: my($ne

Re: substr

2004-10-30 Thread mk76
My earlier post was not quite clear. I will explain my problem in detail here. I have a string whose length is say 5. I need to copy another string into this string but from an offset of 10. I tried using substr but this is a limitation of substr and it gave me a fatal error. Is there any

Re: substr

2004-10-30 Thread John W. Krahn
[EMAIL PROTECTED] wrote: Hi All, Hello, I need to copy a substring in a string which is completely out of the primary string (in terms of the offset). substr does not allow me to do so. Do you mean like this: $ perl -le' $_ = q/abc/; substr( $_, 20 ) = q/def/; print' substr outside of st

substr

2004-10-30 Thread mk76
Hi All, I need to copy a substring in a string which is completely out of the primary string (in terms of the offset). substr does not allow me to do so. Is there any other way in which I can do that ? Thanks, Manas. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail

Re: substr complexities

2004-09-01 Thread Jeff 'japhy' Pinyan
tured, and all the others remove all the $DIGIT variables. If you do: for (split /\n/, $EDM_nonactive_tapelist) { print "$1\n" if !/\*Orig/ and /st_9840_acs_0/ and /\((E\d+)/; } The problem you're having with substr() is that the third argument is the LENGTH of the substring

substr complexities

2004-09-01 Thread DBSMITH
All, can anyone provide some help? my current output is E00854), Seq #: 000595 in TLU: st_ and all I want is the E string and cannot get my substr working Here is my code: foreach (split /\n/, $EDM_nonactive_tapelist ) { if (( /\((E\d+)/ ) && ( !

RE: How to Sort on a substr

2004-07-16 Thread Bob Showalter
umns from 1: @rows = sort { substr($a, 20, 5) cmp substr($b, 20, 5) || substr($a, 49, 10) cmp substr($b, 49, 10) } @rows; If you're numbering columns from 0, adjust the offsets above. The general concept for multi key sorting is to combine the comparisons with a logical &quo

Re: How to Sort on a substr

2004-07-15 Thread John W . Krahn
? This should work: my @sorted = map substr( $_, 15 ), sort map substr( $_, 20, 5 ) . substr( $_, 39, 10 ) . $_, @unsorted; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED

Re: How to Sort on a substr

2004-07-15 Thread Rob Benton
Jeff Westman wrote: Hi, I need to do a sort on a couple of column ranges. I want to be able to do a primary sort, on say, columns 21-25 and then a secondary sort on columns 40-49. Any ideas on how to approach this? TIA /j __ Do you Yahoo!? Yahoo!

Re: How to Sort on a substr

2004-07-15 Thread Gunnar Hjalmarsson
Jeff Westman wrote: I need to do a sort on a couple of column ranges. I want to be able to do a primary sort, on say, columns 21-25 and then a secondary sort on columns 40-49. Any ideas on how to approach this? Yes. 1. Check out the docs for the sort() function. 2. Check the Perl FAQ: perldoc

How to Sort on a substr

2004-07-15 Thread Jeff Westman
Hi, I need to do a sort on a couple of column ranges. I want to be able to do a primary sort, on say, columns 21-25 and then a secondary sort on columns 40-49. Any ideas on how to approach this? TIA /j __ Do you Yahoo!? Yahoo! Mail - You ca

Re: using substr... is this efficient

2004-02-20 Thread Rob Dixon
Luke Bakken wrote: > > From: Larry Sandwick [mailto:[EMAIL PROTECTED] > > > > I have a scripted I wrote that uses *substr* on a file that has fixed > > fields. I have to parse the file before I upload into MYSQL. > > > > Is there a more efficient way other than

RE: using substr... is this efficient

2004-02-20 Thread Bakken, Luke
> -Original Message- > From: Larry Sandwick [mailto:[EMAIL PROTECTED] > > I have a scripted I wrote that uses *substr* on a file that has fixed > fields. I have to parse the file before I upload into MYSQL. > > Is there a more efficient way other than *substr*, I l

Re: using substr... is this efficient

2004-02-20 Thread Rob Dixon
Larry Sandwick wrote: > > I have a scripted I wrote that uses *substr* on a file that has fixed > fields. I have to parse the file before I upload into MYSQL. > > Is there a more efficient way other than *substr*, I looked a *pack* and > *unpack* . it did not make any sense to

RE: using substr... is this efficient

2004-02-20 Thread Paul Kraus
> > Is there a more efficient way other than *substr*, I looked a *pack* and > > *unpack* . it did not make any sense to me. Unpack is what I would use. Perldoc unpack. $item = substr($the_line,0,10); $ldesc= substr($the_line,11,40); $page = substr($the_lin

using substr... is this efficient

2004-02-20 Thread Larry Sandwick
I have a scripted I wrote that uses *substr* on a file that has fixed fields. I have to parse the file before I upload into MYSQL. Is there a more efficient way other than *substr*, I looked a *pack* and *unpack* . it did not make any sense to me. Here is my code, and any suggestions

Re: substr parsing mask

2003-09-29 Thread Jeff 'japhy' Pinyan
On Sep 29, [EMAIL PROTECTED] said: >I got it to work after adding a new var in apache modperl environment. > >This works: > $acct_no = $xgi->param("acct_no"); > print substr($acct_no, 0, 4, "x" x (length($acct_no)-4)); > >This did NOT work: > p

Re: substr parsing mask

2003-09-29 Thread perl
I got it to work after adding a new var in apache modperl environment. This works: $acct_no = $xgi->param("acct_no"); print substr($acct_no, 0, 4, "x" x (length($acct_no)-4)); This did NOT work: print substr($xgi->param("acct_no"), length($xgi->param(&

Re: substr parsing mask

2003-09-27 Thread Jeff 'japhy' Pinyan
234 which shows only the last four. >> >>I know how to use the substr but what about replacing the preceding values >>with ? > >You could use a regex: > > $string = "1234567890"; > $string =~ s/.(?=.{4})/x/g; You could also use: $string =~ s/(.*)(.{4}

Re: substr parsing mask

2003-09-27 Thread Jeff 'japhy' Pinyan
On Sep 26, [EMAIL PROTECTED] said: >Does anyone have a short routine for displaying mask on some values and >displaying the value of the last four? For example, alot of site display >credit card numbers like 1234 which shows only the last four. > >I know how to use the substr

substr parsing mask

2003-09-26 Thread perl
Does anyone have a short routine for displaying mask on some values and displaying the value of the last four? For example, alot of site display credit card numbers like 1234 which shows only the last four. I know how to use the substr but what about replacing the preceding values with

Re: about substr

2002-11-27 Thread Michael Kelly
On Sat, Nov 28, 2037 at 10:04:37AM +0800, billy wrote: > when i user substr,i find "Tab" key is calculated as 1,but i want to set it as >8,what will i do? > thks. I'm not sure what you mean. Are you saying you want to replace the tab character with 8 spaces? In tha

Re: about substr

2002-11-27 Thread Weijie Ding
Hi, billy, 2002-11-28 10:38:19 I think change s to s will be a great help. === At 2037-11-28, 10:04:00 you wrote: === >when i user substr,i find "Tab" key is calculated as 1,but i want to set it as 8,wha

about substr

2002-11-27 Thread billy
when i user substr,i find "Tab" key is calculated as 1,but i want to set it as 8,what will i do? thks.

Re: substr or anything like that

2002-09-05 Thread zanardi2k2
James Edward Gray II wrote: > If you have fixed width values, separated by spaces and with no spaces > in the values, you could use the super simple: > > @list_of_values = split ' ', $fixed_width_line; No, unfortunately i do have spaces in values. Felix suggestion seems the right way to do it

Re: substr or anything like that

2002-09-04 Thread Jeff 'japhy' Pinyan
On Sep 4, zanardi2k2 said: >I extract data from an AS/400 table, and i am not able to get a decent >CSV format. So i have to choose a fixed-width format. Now i have to get >all values. Is there something better than: > >$var1=substr($_, 0, 10) >$var2=substr($_, 11, 16) >$

Re: substr or anything like that

2002-09-04 Thread James Edward Gray II
o in my spare time, so i am > sorry if my question is about a very simple thing. > > I extract data from an AS/400 table, and i am not able to get a decent > CSV format. So i have to choose a fixed-width format. Now i have to > get > all values. Is there something better than: >

Re: substr or anything like that

2002-09-04 Thread Felix Geerinckx
on Wed, 04 Sep 2002 16:00:06 GMT, Zanardi2k2 wrote: > Is there something better than: > > $var1=substr($_, 0, 10) > $var2=substr($_, 11, 16) > $var3=... See perldoc -f pack perldoc -f unpack If you have e.g. the following layout: my $string = "12

substr or anything like that

2002-09-04 Thread zanardi2k2
something better than: $var1=substr($_, 0, 10) $var2=substr($_, 11, 16) $var3=... to do this? Thank you in advance. -- Zanardi2k2 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Problem with substr

2002-08-02 Thread Pablo Jejcic
ue in substr at ./outlook-grabber.pl line 232. And line 232 looks like: for ($cnt=0; $cnt") { $ignore = 2; } } return $newtext; } --- End Message --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

substr eq to string [was (incorrectly) Re: Summarizing tables]

2001-12-14 Thread Michael R. Wolf
"Lance Prais" <[EMAIL PROTECTED]> writes: > if (substr($line, 42, 7) eq'"Running"') #if statment to see if "Running" is if (substr($line, 42, 7) eq "Running" ) Because you had single quotes, you were looking for the string &qu

Re: substr and =~ as one liner

2001-11-27 Thread Jenda Krynicky
From: Frank Newland <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Subject: substr and =~ as one liner Date sent: Tue, 27 Nov 2001 11:55:32 -0600 > How can I express the following two lines as a

substr and =~ as one liner

2001-11-27 Thread Frank Newland
How can I express the following two lines as a one liner? === $left_trim = substr($_,85,13); $left_trim =~ s/^\s+// ; ## Remove leading spaces === tia frank -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

join, substr(), concatenate, print not behaving. perl broken?

2001-11-01 Thread John Griessen
Whoops, the first time I sent this it still had a part in it that needs a subdir called dnb. i took that outof this and tested it again. And while i was there, I made one more change as a sanity check, where I had first used my ($formfill, $formfill1, $formfill2, $formfill3); to declare and

join, substr(), concatenate, print not behaving. perl broken?

2001-11-01 Thread John Griessen
arch_company_name, "\n"; print STDOUT "formfill3 = ", $formfill3, "\n"; print STDOUT "formfill2 3x = ", $formfill2, $formfill2, $formfill2, "\n"; print STDOUT "formfill1 follows ", "\n"; print STDOUT $formfill1, "\n"; pr

join, substr(), concatenate, print not behaving. perl broken?

2001-11-01 Thread John Griessen
t;$search_company_name"; $formfill2 = join "", "&st=", "$search_state", "&city=", "$search_city"; $formfill1 = join "XX", $formfill3, $formfill2; print STDOUT "co name = ", $search_company_name, "\n"

Re: substr (help,help,help);

2001-06-28 Thread Craig S Monroe
[EMAIL PROTECTED]> To: "Craig S Monroe" <[EMAIL PROTECTED]>; "Beginners@Perl (E-mail)" <[EMAIL PROTECTED]> Sent: Wednesday, June 27, 2001 5:45 PM Subject: Re: substr (help,help,help); > > while (){ > > if (m/\/nic\/login/){ > > this just say

Re: substr (help,help,help);

2001-06-27 Thread Michael Fowler
On Wed, Jun 27, 2001 at 05:30:11PM -0400, Craig S Monroe wrote: > open (SOURCE, "< $filename"); > > while (){ > if (m/\/nic\/login/){ > substr ($_,28,4); > print; > } > } That substr is a no-op, meaning it does nothing. If warnings had been turned on

  1   2   >