Re: Help with String/Array manipulation

2008-12-10 Thread Sanju Shah
Thanks. I was able to accomplish it using unpack command. On Tue, Dec 9, 2008 at 7:26 AM, Rob Dixon <[EMAIL PROTECTED]> wrote: > sanju.shah wrote: >> >> I am looking for some suggestions on any advanced functions Perl might >> have that i might be missing. >> >> Basically, I have an array with col

Re: Help with String/Array manipulation

2008-12-09 Thread John W. Krahn
sanju.shah wrote: I am looking for some suggestions on any advanced functions Perl might have that i might be missing. Basically, I have an array with column widths. Next I have a string. I would like to extract the number of characters based on the column- widths in the array. I have already tr

Re: Help with String/Array manipulation

2008-12-09 Thread Rob Dixon
sanju.shah wrote: > > I am looking for some suggestions on any advanced functions Perl might > have that i might be missing. > > Basically, I have an array with column widths. Next I have a string. I > would like to extract the number of characters based on the column- > widths in the array. I hav

Re: Help with String/Array manipulation

2008-12-09 Thread Chas. Owens
On Mon, Dec 8, 2008 at 13:54, sanju.shah <[EMAIL PROTECTED]> wrote: > I am looking for some suggestions on any advanced functions Perl might > have that i might be missing. > > Basically, I have an array with column widths. Next I have a string. I > would like to extract the number of characters ba

Help with String/Array manipulation

2008-12-09 Thread sanju.shah
I am looking for some suggestions on any advanced functions Perl might have that i might be missing. Basically, I have an array with column widths. Next I have a string. I would like to extract the number of characters based on the column- widths in the array. I have already tried using substr but

Re: Array manipulation

2008-11-16 Thread John W. Krahn
hotkitty wrote: Hi, Hello, I have two arrays, as follows: Array1=( date 11/01/2008 newstuff1, date 10/27/2008 newstuff2, date 10/24/2008 newstuff3 ) Array2=( date 11/01/2008 oldstuff1, date 10/31/2008 oldstuff2, date 10/30/2008 oldstuff3, date 10/29/2008 oldstuff4, date 10/28/2008 oldstuff5

Re: Array manipulation

2008-11-16 Thread Mr. Shawn H. Corey
On Sun, 2008-11-16 at 08:35 -0800, hotkitty wrote: > How do I combine the arrays so that the the "newstuff" in array1 gets > appended only to an item in array2 if the dates match? Create a hash of lists with the dates as its keys. Go through Array2 and push each oldstuff on the list stored in the

Array manipulation

2008-11-16 Thread hotkitty
Hi, I have two arrays, as follows: Array1=( date 11/01/2008 newstuff1, date 10/27/2008 newstuff2, date 10/24/2008 newstuff3 ) Array2=( date 11/01/2008 oldstuff1, date 10/31/2008 oldstuff2, date 10/30/2008 oldstuff3, date 10/29/2008 oldstuff4, date 10/28/2008 oldstuff5, date 10/27/2008 oldstuff6,

Re: Array Manipulation newbie

2007-10-29 Thread Greg
Thank you, Tom, that is exactly what I was looking for!! Thanks again! -Greg -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Array Manipulation

2007-10-27 Thread John W . Krahn
On Thursday 25 October 2007 11:03, [EMAIL PROTECTED] wrote: > Hi Hello, Please do not top-post, TIA. > This will do what you want:- > > perl -le '@test=(1,2,3,4,5);print join "\n",@test;' > > The -l option ensures a final newline after the last element of the > array is printed. The order of t

Re: Array Manipulation newbie

2007-10-25 Thread Tom Phoenix
On 10/25/07, Greg <[EMAIL PROTECTED]> wrote: > my @record = split (/\|/,$_); #split on '|' characters > My question comes in, how do I put the |'s back in the line in memory > so that I can continue with my working script? I think you're looking for join(), maybe something like this: my $li

Array Manipulation newbie

2007-10-25 Thread Greg
I have a similar issue as the other person with the same subject but with a twist.. I am reading an input file in that is pipe delimited and want to do manipulation on one of the fields. So far I have (and I'm only going to give you bits and pieces... unless requested) my @record = split (/\|/,

Re: Array Manipulation

2007-10-25 Thread Greg
Similar issue here, but with a twist. I have an input file that I'm reading in that is pipe delimited. (HL7 actually) So far I have my @record = split (/\|/,$_); I want to take $record[16] and replace it with $record[16] / $record[7] ONLY if $record[7] is not empty. I have this accomplished by $co

Re: Array Manipulation

2007-10-25 Thread asmith9983
Hi This will do what you want:- perl -le '@test=(1,2,3,4,5);print join "\n",@test;' The -l option ensures a final newline after the last element of the array is printed. The order of the options is important as changing it to "el" wouldn't work. -- Andrew Edinburgh,Scotland On Thu, 25 Oct

Re: Array Manipulation

2007-10-25 Thread [EMAIL PROTECTED]
On Oct 25, 4:21 pm, [EMAIL PROTECTED] (Ron Bergin) wrote: > > print $_,$/ for @test; Nothing wrong with that, but I usually write: print "$_\n" for @test; TMTOWTDI! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Array Manipulation

2007-10-25 Thread Ron Bergin
On Oct 25, 1:59 am, [EMAIL PROTECTED] (Irfan Sayed) wrote: > Hi All, > > I have one array say my @test=(1,2,3,4,5); > if I print this array it will print like this > print "@test\n"; > and the output is > 1 2 3 4 5 > > now my req. is that I want to store these array values in another array > in suc

RE: Array Manipulation

2007-10-25 Thread Sayed, Irfan (Irfan)
r reference. Please guide. Thanks in Advance. Regards Irfan. -Original Message- From: Gunnar Hjalmarsson [mailto:[EMAIL PROTECTED] Sent: Thursday, October 25, 2007 5:06 PM To: beginners@perl.org Subject: Re: Array Manipulation Sayed, Irfan (Irfan) wrote: > I have one array say my

Re: Array Manipulation

2007-10-25 Thread Gunnar Hjalmarsson
Sayed, Irfan (Irfan) wrote: I have one array say my @test=(1,2,3,4,5); if I print this array it will print like this print "@test\n"; and the output is 1 2 3 4 5 now my req. is that I want to store these array values in another array in such a fashion where I can print like 1 2 3 4 5 so I me

Re: Array Manipulation

2007-10-25 Thread Dyana Wu
On 25 Oct 2007, at 4:59 PM, Sayed, Irfan (Irfan) wrote: Hi All, I have one array say my @test=(1,2,3,4,5); if I print this array it will print like this print "@test\n"; and the output is 1 2 3 4 5 so I mean to say that if I type print "@test1\n"; then output should come as 1 2 3 4 5 Try ma

Array Manipulation

2007-10-25 Thread Sayed, Irfan (Irfan)
Hi All, I have one array say my @test=(1,2,3,4,5); if I print this array it will print like this print "@test\n"; and the output is 1 2 3 4 5 now my req. is that I want to store these array values in another array in such a fashion where I can print like 1 2 3 4 5 so I mean to say that if I t

Re: FW: Array manipulation

2007-02-13 Thread Jeff Pang
-Original Message- >From: "Sayed, Irfan (Irfan)" <[EMAIL PROTECTED]> >Sent: Feb 13, 2007 7:12 PM >To: beginners@perl.org >Subject: FW: Array manipulation > > >Hi All, > >I have one array having values as follows > >User [EMAIL PROTECTE

Re: FW: Array manipulation

2007-02-13 Thread Jeff Pang
> >@a = (1,2,3,4,2,3,5); > >print "---> @a\n"; >my %b = undef; >foreach (@a){ > >print "--- $_"; > $b{$_} =undef; >} > >@a = keys(%b); > >print "\n### @a"; > Hmm,that will break the order of the original array. -- Jeff Pang EMAIL: [EMAIL PROTECTED] AIM: jeffpang -- To unsubscribe, e-mai

Re: FW: Array manipulation

2007-02-13 Thread kilaru rajeev
I got the output like .. P:\>"C:\Documents and Settings\rkilaru\Desktop\prog.pl" ---> 1 2 3 4 2 3 5 --- 1--- 2--- 3--- 4--- 2--- 3--- 5 ### 4 1 3 2 5 P:\> Rajeev On 2/13/07, kilaru rajeev <[EMAIL PROTECTED]> wrote: Hi Irfan, Please find the following way. @a = (1,2,3,4,2,3,5); prin

Re: FW: Array manipulation

2007-02-13 Thread kilaru rajeev
Hi Irfan, Please find the following way. @a = (1,2,3,4,2,3,5); print "---> @a\n"; my %b = undef; foreach (@a){ print "--- $_"; $b{$_} =undef; } @a = keys(%b); print "\n### @a"; rgds, Rajeev Kilaru On 2/13/07, Sayed, Irfan (Irfan) <[EMAIL PROTECTED]> wrote: Hi All, I have

FW: Array manipulation

2007-02-13 Thread Sayed, Irfan \(Irfan\)
Hi All, I have one array having values as follows User [EMAIL PROTECTED] User [EMAIL PROTECTED] User [EMAIL PROTECTED] Now I formatted above array as per your suggession as follows in order to remove duplicate value "User" @test = grep { ++$hash{$_} < 2 } @test; but output is as follows which

Re: Array manipulation

2007-02-10 Thread Dr.Ruud
Jeff Pang schreef: > [un-double] > @test = grep { ++$hash{$_} < 2 } @test; Alternative: @test = grep { !$hash{$_}++ } @test; -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Array manipulation

2007-02-10 Thread Jeff Pang
> >I have one array say @test = (1,2,3,2,5). Now if you observe 2 is >repeating in this array on second position and fourth position. > >My requirement is that if such value is repeating twice then i just want >to remove one value and keep other value. > >So my array should look like @test = (1

Re: Array manipulation

2007-02-09 Thread Tom Phoenix
On 2/9/07, Sayed, Irfan (Irfan) <[EMAIL PROTECTED]> wrote: I have one array say @test = (1,2,3,2,5). Now if you observe 2 is repeating in this array on second position and fourth position. My requirement is that if such value is repeating twice then i just want to remove one value and keep othe

Array manipulation

2007-02-09 Thread Sayed, Irfan \(Irfan\)
Hi All, I have one array say @test = (1,2,3,2,5). Now if you observe 2 is repeating in this array on second position and fourth position. My requirement is that if such value is repeating twice then i just want to remove one value and keep other value. So my array should look like @test = (1,

Re: math module and array manipulation

2006-08-16 Thread chen li
--- David Greenberg <[EMAIL PROTECTED]> wrote: > I'm sure there's an easier/better way of doing this, > but in the interest of > simplicity, let's look at this approach: > > First, a red flag goes up when you say that you have > an array of 12 > numbers. Will it always be twelve? > > The seco

Re: math module and array manipulation

2006-08-15 Thread David Greenberg
I'm sure there's an easier/better way of doing this, but in the interest of simplicity, let's look at this approach: First, a red flag goes up when you say that you have an array of 12 numbers. Will it always be twelve? The second red flag is that you are splitting the array into quarters based

Re: math module and array manipulation

2006-08-15 Thread JupiterHost.Net
I have an array contains 12 numbers. I want to calculate the mean and standard deviation for very three numbers. I just wonder which math module is available to do the job. Wonder no longer :) Find out for sure: http://search.cpane.org/ I think you meant http://search.cpan.org. :) Inde

RE: math module and array manipulation

2006-08-14 Thread Timothy Johnson
-Original Message- From: JupiterHost.Net [mailto:[EMAIL PROTECTED] Sent: Monday, August 14, 2006 4:48 PM To: beginners@perl.org Subject: Re: math module and array manipulation > chen li wrote: >> Dear all, >> >> I have an array contains 12 numbers. I want to >

Re: math module and array manipulation

2006-08-14 Thread JupiterHost.Net
chen li wrote: Dear all, I have an array contains 12 numbers. I want to calculate the mean and standard deviation for very three numbers. I just wonder which math module is available to do the job. Wonder no longer :) Find out for sure: http://search.cpane.org/ -- To unsubscribe, e-mail:

math module and array manipulation

2006-08-14 Thread chen li
Dear all, I have an array contains 12 numbers. I want to calculate the mean and standard deviation for very three numbers. I just wonder which math module is available to do the job. Thanks, Li __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the

Re: Perl Help: Array Manipulation

2003-12-25 Thread u235sentinel
Ahhh.. Ok. I see the mistake. I've purchased Oreilly's "Learning Perl" 3rd Edition and have been steadily plugging through it. There is an example on page 45 which shows another way to populate an array. Here is one such example they give. @numbers = 1..1e5; So basically if you didn't want

Re: Perl Help: Array Manipulation

2003-12-25 Thread Randy W. Sims
On 12/25/2003 12:18 PM, u235sentinel wrote: But wouldn't the original initilization also work? @array1[0..5] = 1; No. Think of this in terms of parallel assignment, ignoring for the moment that we are talking of arrays, the above is equivalent to: ($e0, $e1, $e2, $e3, $e4, $e5) = 1; which is e

Re: Perl Help: Array Manipulation

2003-12-25 Thread Randy W. Sims
nts as a group. Randy. - Original Message - From: Randy W. Sims To: Duong Nguyen Cc: [EMAIL PROTECTED] Sent: Thursday, December 25, 2003 3:02 AM Subject: Re: Perl Help: Array Manipulation On 12/25/2003 2:51 AM, Duong Nguyen wrote: > From: Randy W. Sims

Re: Perl Help: Array Manipulation

2003-12-25 Thread u235sentinel
Understood. I guess I was trying to show him ( the senec route) that basically no running total was being compiled. Also that wasn't the total. I guess it was too late at night for a simple response from me :-) Charles K. Clarkson wrote: u235sentinel <[EMAIL PROTECTED]> wrote: [snippe

Re: Perl Help: Array Manipulation

2003-12-25 Thread R. Joseph Newton
u235sentinel wrote: > I'm a newbie to perl also. Been workign with it for a whole 2 weeks > now. Actually.. make that 3 ::grinz:: > > Warning.. lengthy email below.. I beg forgiveness in advance :-) Length isn't a problem. There are some problems here, though, because you are not addressing th

Re: Perl Help: Array Manipulation

2003-12-25 Thread u235sentinel
But wouldn't the original initilization also work? @array1[0..5] = 1; This seemed to populate the array just fine. Randy W. Sims wrote: On 12/25/2003 2:51 AM, Duong Nguyen wrote: From: Randy W. Sims > On 12/25/2003 12:59 AM, Duong Nguyen wrote: > Hello everyone, > > Sorry for the

Re: Perl Help: Array Manipulation

2003-12-25 Thread John W. Krahn
Duong Nguyen wrote: > > Hello everyone, Hello, > Sorry for the spam, Why do you think that this is spam? > I am new to Perl and am having a hard time manipulating > arrays. Below is the sample code that I am working on: You should have warnings and strictures enabled while you are developing

RE: Perl Help: Array Manipulation

2003-12-25 Thread Charles K. Clarkson
u235sentinel <[EMAIL PROTECTED]> wrote: [snipped valiant attempt] : : So now you see on the left the sum of each container in the array. : : Ok.. I await the flogging. Someone is bound to have done a better job : explaining this. At least I can blame it on being up after : midnight ;-)

RE: Perl Help: Array Manipulation

2003-12-25 Thread Charles K. Clarkson
Duong Nguyen <[EMAIL PROTECTED]> wrote: : : Thanks for the response. I discovered that it was my : @array1[0..5] =1; initialization. : So I manually allocated values to the array to see if it : would work, much to my surprise, the correct "total" was : being printed. Here's what I did: : : c

Re: Perl Help: Array Manipulation

2003-12-25 Thread Randy W. Sims
On 12/25/2003 2:51 AM, Duong Nguyen wrote: From: Randy W. Sims > On 12/25/2003 12:59 AM, Duong Nguyen wrote: > Hello everyone, > > Sorry for the spam, I am new to Perl and am having a hard time manipulating arrays. Below is the sample code that I am working on: > > @array1[0..5]

Re: Perl Help: Array Manipulation

2003-12-25 Thread Duong Nguyen
@array1[0] = 1; @array1[1] = 1; @array1[2] = 1; This works well. - Original Message - From: u235sentinel To: Duong Nguyen ; [EMAIL PROTECTED] Sent: Thursday, December 25, 2003 2:40 AM Subject: Re: Perl Help: Array Manipul

Re: Perl Help: Array Manipulation

2003-12-25 Thread Randy W. Sims
On 12/25/2003 12:59 AM, Duong Nguyen wrote: Hello everyone, Sorry for the spam, I am new to Perl and am having a hard time manipulating arrays. Below is the sample code that I am working on: @array1[0..5] = 1; @total[0] = 0; for($i=0; $i<4; $i++) { if($i == 0) { @total[$i] =

Re: Perl Help: Array Manipulation

2003-12-25 Thread u235sentinel
I'm a newbie to perl also. Been workign with it for a whole 2 weeks now. Actually.. make that 3 ::grinz:: Warning.. lengthy email below.. I beg forgiveness in advance :-) Ok. Here is what I did. #!/usr/bin/perl @array1[0..5] = 1; @total[0] = 0; for($i=0; $i<4; $i++) { if($i == 0) {

Perl Help: Array Manipulation

2003-12-24 Thread Duong Nguyen
Hello everyone, Sorry for the spam, I am new to Perl and am having a hard time manipulating arrays. Below is the sample code that I am working on: @array1[0..5] = 1; @total[0] = 0; for($i=0; $i<4; $i++) { if($i == 0) { @total[$i] = @array1[$i]; print @total[$i];