Re: Concatenating Strings

2008-03-25 Thread Bobby
Thanks for all your input, using a hash does make things a lot easier for me. Rob Dixon <[EMAIL PROTECTED]> wrote: kens wrote: > > # Or if you must use a counter > > my $count = 0; > > while ( defined($strA[$count]) ) > { >print "$strA[$count++]\n"; > } for my $count (0 .. $#strA) { p

Re: Concatenating Strings

2008-03-24 Thread Rob Dixon
kens wrote: # Or if you must use a counter my $count = 0; while ( defined($strA[$count]) ) { print "$strA[$count++]\n"; } for my $count (0 .. $#strA) { print "[$count] = $strA[$count]\n"; } **OR** my $count = 0; foreach (@strA) { print "[$count] = $strA[$count]\n"; $count++; }

Re: Concatenating Strings

2008-03-24 Thread Randal L. Schwartz
> "Bobby" == Bobby <[EMAIL PROTECTED]> writes: Bobby> I'm trying to write a simple do until loop to print out the value of Bobby> $strA0 through $striA3. If your variable names are named sequentially, you've almost always done something wrong. Please rethink your problem, keeping data struc

Re: Concatenating Strings

2008-03-24 Thread Rob Dixon
Bobby wrote: Hi all, I'm trying to write a simple do until loop to print out the value of > $strA0 through $striA3. What i'm doing is replacing the value of 0 > through 3 in the $strA by joining two strings (my $strB = "strA". > $count;). Right now my script is printing $strB as below. How do i

Re: Concatenating Strings

2008-03-24 Thread Gunnar Hjalmarsson
yitzle wrote: IIRC, Perl does not let you use a string to build a variable name like PHP does. Then you do not remember it correctly. If you do this: $myVar = 123; $varName = "myVar"; print "$varName"; You get "myVar" and not "123" Sure, but if you replace the last line with prin

Re: Concatenating Strings

2008-03-24 Thread kens
On Mar 24, 12:09 pm, [EMAIL PROTECTED] (Bobby) wrote: > Hi all, > > I'm trying to write a simple do until loop to print out the value of $strA0 > through $striA3. What i'm doing is replacing the value of 0 through 3 in the > $strA by joining two strings (my $strB = "strA" . $count;). Right now m

Re: Concatenating Strings

2008-03-24 Thread Gunnar Hjalmarsson
Bobby wrote: I'm trying to write a simple do until loop to print out the value of $strA0 through $striA3. What i'm doing is replacing the value of 0 through 3 in the $strA by joining two strings (my $strB = "strA" . $count;). Right now my script is printing $strB as below. How do i get perl t

Re: Concatenating Strings

2008-03-24 Thread Jenda Krynicky
> Bobby wrote: > Hi all, > > I'm trying to write a simple do until loop to print out the value of > $strA0 through $striA3. What i'm doing is replacing the value of 0 > through 3 in the $strA by joining two strings (my $strB = "strA" . > $count;). Right now my script is printing $strB as b

Re: Concatenating Strings

2008-03-24 Thread Wolf
Grab a perl book or search the web for concatenating variables together... Unfortunately the current place I am in doesn't have perl on the server for me to try and play around more, but the gist is the same. Your problem arise from setting it up as string during the concatination process. Set

Re: Concatenating Strings

2008-03-24 Thread Bobby
Thanks for both of your suggestions. I've tried them both but still getting same result. Any other suggestions? Thanks. Wolf <[EMAIL PROTECTED]> wrote: Bobby wrote: > Wolf, > > I still don't understand, so set my $strB = "$strA($count)"; ? That didn't > worked. > > Wolf wrote:

Re: Concatenating Strings

2008-03-24 Thread yitzle
IIRC, Perl does not let you use a string to build a variable name like PHP does. If you do this: $myVar = 123; $varName = "myVar"; print "$varName"; You get "myVar" and not "123" which seems to be what you want. However, I think you might be able to use hashes and get what you want. $hash{"

Re: Concatenating Strings

2008-03-24 Thread Wolf
Bobby <[EMAIL PROTECTED]> wrote: > Wolf, > > I still don't understand, so set my $strB = "$strA($count)"; ? That didn't > worked. > > Wolf <[EMAIL PROTECTED]> wrote: > Bobby wrote: > > Hi all, > > > > I'm trying to write a simple do until loop to print out the value of $strA0 >

Re: Concatenating Strings

2008-03-24 Thread Bobby
Wolf, I still don't understand, so set my $strB = "$strA($count)"; ? That didn't worked. Wolf <[EMAIL PROTECTED]> wrote: Bobby wrote: > Hi all, > > I'm trying to write a simple do until loop to print out the value of $strA0 > through $striA3. What i'm doing is replacing the value of 0

Re: Concatenating Strings

2008-03-24 Thread Wolf
Bobby <[EMAIL PROTECTED]> wrote: > Hi all, > > I'm trying to write a simple do until loop to print out the value of $strA0 > through $striA3. What i'm doing is replacing the value of 0 through 3 in the > $strA by joining two strings (my $strB = "strA" . $count;). Right now my > script i

Re: Concatenating arrays from arrays of arrays

2008-03-15 Thread John W. Krahn
John Sampson wrote: Hello - Hello, I am trying to accumulate items in a flat list (array) by concatenating on to it the scalars contained in arrays which in turn are contained in arrays. The data is to be read in from a file rather than existing as literals in my code. Everything I try eithe

Re: Concatenating arrays from arrays of arrays

2008-03-15 Thread Rob Dixon
John Sampson wrote: Hello - I am trying to accumulate items in a flat list (array) by concatenating on to it the scalars contained in arrays which in turn are contained in arrays. The data is to be read in from a file rather than existing as literals in my code. Everything I try either crashes

Re: Concatenating arrays from arrays of arrays

2008-03-15 Thread Gunnar Hjalmarsson
John Sampson wrote: I am trying to accumulate items in a flat list (array) by concatenating on to it the scalars contained in arrays which in turn are contained in arrays. Is this what you are talking about? my @arr1 = ( [ 1, 2 ], [ 3, 4 ] ); my @arr2 = ( [ 5, 6 ], [ 7, 8 ] ); my

Re: Concatenating arrays from arrays of arrays

2008-03-15 Thread Chas. Owens
On Sat, Mar 15, 2008 at 6:14 PM, John Sampson <[EMAIL PROTECTED]> wrote: > Hello - > > I am trying to accumulate items in a flat list (array) by > concatenating on to it > the scalars contained in arrays which in turn are contained in arrays. The > data > is to be read in from a file rather th

Re: Concatenating line into array problem

2004-06-11 Thread Zeus Odin
This works: ---BEGIN CODE--- #!/usr/bin/perl use warnings; use strict; $/ = '>'; while () { s/(.*?\n.*?)\n/$1/s; print; } __DATA__ > YNL331C CAATATGCGAGGGACCTACATGTTGA CATGACAATGAATTCTATTGAA > YKL071W ATAATTATTCCTGTTTCTTTAACCTG GTGTACAAACACTTAAGC ---END CODE---

Re: Concatenating line into array problem

2004-06-11 Thread John W. Krahn
"John W. Krahn" wrote: > > This should do what you want: > > $/ = '>'; > while ( <> ) { > next unless s/\s+\S.*//; > chomp; > tr/\n//d; > print "$_\n"; > } After seeing your data file change that to: $/ = '>'; while ( <> ) { next unless s/\S+.*\n//; chomp; tr/\n/

Re: Concatenating line into array problem

2004-06-11 Thread John W. Krahn
Edward Wijaya wrote: > > Hi groups, Hello, > I have a file which contain many many of this line (Fasta Format): > > > YNL331C > CAATATGCGAGGGACCTACATGTTGA > CATGACAATGAATTCTATTGAA > > > YKL071W > ATAATTATTCCTGTTTCTTTAACCTG > GTGTACAAACACTTAAGC > > What I would like to do is to con

RE: Concatenating line into array problem

2004-06-10 Thread Charles K. Clarkson
From: Edward Wijaya wrote: :: How about: :: :: my @crseq; :: while ( <> ) { :: next unless/^[ACGT]/; :: chomp; :: push @crseq, $_ . scalar <>; :: } :: print @crseq; :: : : Hi Charles, : : Thanks for your reply. : : Your code works for my example in e

Re: Concatenating line into array problem

2004-06-10 Thread Edward Wijaya
How about: my @crseq; while ( <> ) { next unless/^[ACGT]/; chomp; push @crseq, $_ . scalar <>; } print @crseq; Hi Charles, Thanks for your reply. Your code works for my example in email, but not the file with more lines, (please see attached file). So sorry if I didn't give precise

RE: Concatenating line into array problem

2004-06-10 Thread Charles K. Clarkson
From: Edward Wijaya wrote: : #---My Code -- : while (<>) { : if (/^>/) { : next; : } : chomp; : $line .= $_; : } : push (@crseq, $line); : print join("\n", @crseq), "\n"; How about: my @crseq; while ( <> ) { next unless

Re: Concatenating line into array problem

2004-06-10 Thread Edward Wijaya
On Thu, 10 Jun 2004 21:19:17 -0700, Tim Johnson <[EMAIL PROTECTED]> wrote: while (<>) { if (/^>/) { push (@crseq, $line); next; } chomp; $line .= $_; } shift @crseq; print join("\n", @crseq), "\n"; #

RE: Concatenating line into array problem

2004-06-10 Thread Tim Johnson
This might be closer to what you want. Just push the line onto the array every time you come to the '>' character. You'll get one empty line at the beginning, that's why I put the shift line in. while (<>) { if (/^>/) { push (@crseq, $line);

Re: Concatenating , the final time

2002-04-29 Thread drieux
On Sunday, April 28, 2002, at 06:57 , james poni wrote: > How would i modify this program in order to do so ? Do i need a time hash > eg time = (12:00 =>1,12:30=>2,13:00=>3,13:30=>4 ..) ? why not a simple two stage sort routine? having solved for the day value split the 'time' field into

Re: Concatenating Again

2002-04-28 Thread John W. Krahn
James Poni wrote: > > Hello again > > I slightly changed the input but icant seem to get the output like this > below: > bbb beta sun 1,1 > aaa aplha mon 2,2 > ddd delta tue 3,3 > ccc gamma wed 4,4 > > How would i modify this program in order to do so ? > > THIS I THE PROGRAM use warnings; us

Re: Concatenating

2002-04-27 Thread John W. Krahn
James Poni wrote: > > Hello Hello, > I have 3 text files and i want to perform concatenation from each line of > the 3 files. > > I want the output to look like this: > > aaa mon 1 > bbb wed 2 > ccc sun 3 > ddd tue 4 > > Is it possible to sort the days column in order of the week? Eg > > cc