Re: Arrays, Dates, Indexing and Initialisation

2009-09-29 Thread Dr.Ruud
r...@i.frys.com wrote: Soham Das wrote: int a[125]; for(i=0;i125;i++) a[i]=0; my @array; $array[$_] = 0 for 0..125; s/125/124/ -- Ruud -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail:

Re: Arrays, Dates, Indexing and Initialisation

2009-09-29 Thread Dr.Ruud
Soham Das wrote: a... How do I initialise an array of a definite size with zero. Say the C equivalent of such a statement will be: int a[125]; for(i=0;i125;i++) a[i]=0; You easily can, but why would you? It is often a sign of

Re: Arrays, Dates, Indexing and Initialisation

2009-09-28 Thread rkb
Soham Das wrote: Hello All, I wanted some guidance with these questions of mine: a.. How do I initialise an array of a definite size with zero. Say the C equivalent of such a statement will be: int a[125]; for(i=0;i125;i++) a[i]=0;

Re: Arrays, Dates, Indexing and Initialisation

2009-09-28 Thread Jenda Krynicky
Date sent: Mon, 28 Sep 2009 09:11:02 -0700 Subject:Re: Arrays, Dates, Indexing and Initialisation From: r...@i.frys.com To: Soham Das soham...@yahoo.co.in Copies to: beginners@perl.org Soham Das wrote: Hello All

Re: Arrays, Dates, Indexing and Initialisation

2009-09-28 Thread Shawn H Corey
Soham Das wrote: a.. How do I initialise an array of a definite size with zero. Say the C equivalent of such a statement will be: int a[125]; for(i=0;i125;i++) a[i]=0; Not needed. Perl assume zero if a non-existing element is

Re: Arrays, Dates, Indexing and Initialisation

2009-09-28 Thread Soham Das
Wow! sweet! Hi Jenda, thanks for the help. And I guess, for the dates problem I have to use hashes, eh? Soham - Original Message From: Jenda Krynicky je...@krynicky.cz To: beginners@perl.org Sent: Monday, 28 September, 2009 9:50:40 PM Subject: Re: Arrays, Dates, Indexing

Re: Arrays, Dates, Indexing and Initialisation

2009-09-28 Thread Soham Das
Thanks Shawn, yes hashes I guess will be the way to go forward. Soham - Original Message From: Shawn H Corey shawnhco...@gmail.com To: Soham Das soham...@yahoo.co.in Cc: beginners@perl.org Sent: Monday, 28 September, 2009 9:50:18 PM Subject: Re: Arrays, Dates, Indexing

Re: Arrays, Dates, Indexing and Initialisation

2009-09-28 Thread Uri Guttman
JK == Jenda Krynicky je...@krynicky.cz writes: a.. How do I initialise an array of a definite size with zero. Say the C equivalent of such a statement will be: my @array; $array[$_] = 0 for 0..125; JK my @array = (0) x 126; and a question for the OP is why do you need

Re: Arrays, Dates, Indexing and Initialisation

2009-09-28 Thread Uri Guttman
SHC == Shawn H Corey shawnhco...@gmail.com writes: SHC Soham Das wrote: a.. How do I initialise an array of a definite size with zero. Say the C equivalent of such a statement will be: int a[125]; for(i=0;i125;i++)a[i]=0; SHC Not needed. Perl assume zero if a

Re: Arrays, Dates, Indexing and Initialisation

2009-09-28 Thread Shawn H Corey
Uri Guttman wrote: only for ++/-- and +=/-= will that work with no warnings. if he uses an undef value in another arithmetic expression it will warn. Also, undef values work in if/unless and while/until conditions. Usually when you see indexes used with arrays, it is because the programmer

Re: Arrays, Dates, Indexing and Initialisation

2009-09-28 Thread Soham Das
Message From: Shawn H Corey shawnhco...@gmail.com To: Uri Guttman u...@stemsystems.com Cc: Soham Das soham...@yahoo.co.in; beginners@perl.org Sent: Monday, 28 September, 2009 10:45:33 PM Subject: Re: Arrays, Dates, Indexing and Initialisation Uri Guttman wrote: only

Re: Arrays, Dates, Indexing and Initialisation

2009-09-28 Thread Shawn H Corey
Soham Das wrote: My agenda actually is two pronged. I have read Beginning Perl and a bit of Intermediate Perl, though was able to solve individual problems, but I was not sure,if I can code myself out of a wet paperbag. So I thought, lets chuck theory. Its better to get hands dirty with some

Re: Arrays and Lists

2007-10-28 Thread Jeff Pang
On 10/29/07, Tom Phoenix [EMAIL PROTECTED] wrote: An array is the kind of variable which holds a list; a list is the kind of data which is stored in an array. You can use the list contained in an array, and you can store a list into an array. But the array is the container, and the list is

Re: arrays and chomp function

2007-07-29 Thread Mr. Shawn H. Corey
Bryan Harris wrote: Hi, I'm not sure I understand why this is happening. Maybe someone can explain it to me. No matter how many times I use the chomp() function on my array, when I print the array it always prints the newlines. But I have another array, which will print without the newlines.

Re: arrays and chomp function

2007-07-29 Thread Rob Dixon
Bryan Harris wrote: I'm not sure I understand why this is happening. Maybe someone can explain it to me. No matter how many times I use the chomp() function on my array, when I print the array it always prints the newlines. But I have another array, which will print without the newlines. In

Re: arrays and chomp function

2007-07-29 Thread Bryan Harris
On 7/30/07, Rob Dixon [EMAIL PROTECTED] wrote: Bryan Harris wrote: I'm not sure I understand why this is happening. Maybe someone can explain it to me. No matter how many times I use the chomp() function on my array, when I print the array it always prints the newlines. But I have

Re: arrays

2005-03-14 Thread Grant
Thanks guys, I've almost got it. I need to save the title and URL of each result in the array to a different scratch variable so I can use it outside of the script. The following works great, but of course it only saves the last set of results from the loop. foreach my

Re: arrays

2005-03-14 Thread Jay Savage
On Mon, 14 Mar 2005 03:50:19 +0100, John Doe [EMAIL PROTECTED] wrote: Am Montag, 14. März 2005 03.30 schrieb Grant: Thanks guys, I've almost got it. I need to save the title and URL of each result in the array to a different scratch variable so I can use it outside of the script.

Re: arrays

2005-03-13 Thread John Doe
Am Sonntag, 13. März 2005 23.47 schrieb Grant: I've got an array returned from Google's API and I need to get the data out of it. The best I can do right now is: ARRAY(0x8262e088) What you got is an reference to an array (an arrayref); printed out it looks linke something above. To access

RE: arrays

2005-03-13 Thread Charles K. Clarkson
Grant mailto:[EMAIL PROTECTED] wrote: : I've got an array returned from Google's API and I need to : get the data out of it. The best I can do right now is: : : ARRAY(0x8262e088) : : Can anyone help me out? Looks like you are printing a reference to an array. You can examine all its

Re: arrays

2005-03-13 Thread Grant
I've got an array returned from Google's API and I need to get the data out of it. The best I can do right now is: ARRAY(0x8262e088) What you got is an reference to an array (an arrayref); printed out it looks linke something above. To access the array referenced to it must be

Re: arrays

2005-03-13 Thread John Doe
Am Montag, 14. März 2005 02.16 schrieb Grant: [...] Thanks guys, I've almost got it. I need to save the title and URL of each result in the array to a different scratch variable so I can use it outside of the script. The following works great, but of course it only saves the last set of

Re: arrays

2005-03-13 Thread Grant
Thanks guys, I've almost got it. I need to save the title and URL of each result in the array to a different scratch variable so I can use it outside of the script. The following works great, but of course it only saves the last set of results from the loop. foreach my $result

Re: arrays

2005-03-13 Thread John Doe
Am Montag, 14. März 2005 03.30 schrieb Grant: Thanks guys, I've almost got it. I need to save the title and URL of each result in the array to a different scratch variable so I can use it outside of the script. The following works great, but of course it only saves the last set of

Re: arrays/hashes

2004-02-19 Thread Rob Dixon
Hi Jeffrey. There are several questions here, so I've answered in-line. Jeffrey N Dyke wrote: I had a simple array in mind, but as i got reacquainted with PERL, with the help of the list, i realized i was thinking to small. (that's always dangerous) On the contrary, I think thinking BIG is

Re: arrays/hashes

2004-02-19 Thread jeffrey_n_Dyke
Hi Jeffrey. There are several questions here, so I've answered in-line. Rob, thanks a ton. that worked perfectly, as has the rest of the processing of the larger hash. Thought i'd address the build portion below, to see if i'm not utilizing PERL's strengths correctly. First PERL i've

Re: arrays/hashes

2004-02-19 Thread James Edward Gray II
On Feb 19, 2004, at 1:25 PM, [EMAIL PROTECTED] wrote: Thought i'd address the build portion below, to see if i'm not utilizing PERL's strengths correctly. First PERL i've written in 3+ years. Perl. The language you are relearning is called Perl, not PERL. ;) James -- To unsubscribe,

RE: arrays

2003-08-14 Thread jonathan . musto
PROTECTED] Sent: Monday, August 04, 2003 11:50 To: [EMAIL PROTECTED] Subject: Re: arrays Hi, if we have @routers. you can do this my ($c, $line); $c=0; foreach $line(@routers){ $line = $line. P *NULL*; push @newrouters, $line; } or to use the $c foreach $line (@routers

RE: arrays

2003-08-04 Thread Marcos . Rebelo
@array = map {$_ P *NULL*} (@array); -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, August 04, 2003 12:18 PM To: [EMAIL PROTECTED] Subject: arrays Hi there, I've got an array of lines, split up by spaces as follows: Sun-router rack1.2 leeds

Re: arrays

2003-08-04 Thread awarsd
Hi, if we have @routers. you can do this my ($c, $line); $c=0; foreach $line(@routers){ $line = $line. P *NULL*; push @newrouters, $line; } or to use the $c foreach $line (@routers){ @routers[$c] = $line. P *NULL*; $c++; } Jonathan Musto [EMAIL PROTECTED] wrote in

Re: arrays

2003-08-04 Thread awarsd
Hi, sorry my last post but actually this is quite good and better @array = map {$_ P *NULL*} (@array); Award -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: arrays

2003-08-04 Thread Charles K. Clarkson
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: : @array = map {$_ P *NULL*} (@array); That solution makes a nice subroutine: my @array = ( 'Sun-router rack1.2 leeds', 'Cisco-router rack3.2 skem', 'Sun-switch rack2.3 manchester', ); concat_array( ' P *NULL*', [EMAIL PROTECTED] );

Re: arrays

2003-08-04 Thread John W. Krahn
Jonathan Musto wrote: Hi there, Hello, I've got an array of lines, split up by spaces as follows: Sun-router rack1.2 leeds Cisco-router rack3.2 skem Sun-switch rack2.3 manchester etc. How can i add the following to the end of each line, P *NULL*?... e.g. Sun-router rack1.2

Re: arrays and hashes

2003-06-07 Thread Rob Dixon
R. Joseph Newton wrote: Rob Dixon wrote: James Edward Gray II wrote: On Friday, June 6, 2003, at 03:32 AM, R. Joseph Newton wrote: The player's name IS the number. No other numbering system is needed. The players name is NEVER stored in the hash, AFAIK. The name is used

Re: arrays and hashes

2003-06-07 Thread Rob Dixon
R. Joseph Newton wrote: Rob Dixon wrote: James Edward Gray II wrote: On Friday, June 6, 2003, at 03:32 AM, R. Joseph Newton wrote: The player's name IS the number. No other numbering system is needed. The players name is NEVER stored in the hash, AFAIK. The name is used

Re: arrays and hashes

2003-06-07 Thread James Edward Gray II
On Friday, June 6, 2003, at 07:05 PM, R. Joseph Newton wrote: The point here is that the essential purpose of the key is that of a pointer, rather thanas data in itself. There are applications of a Perl hash where one does not even need to use the value, finding all the unique words in a

Re: arrays and hashes

2003-06-06 Thread R. Joseph Newton
Stuart White wrote: Right now my array is just like that, minus the numbers. So what I want to do is assign the array to a hash. If I were to do that, my understanding is that the names would be keys and the numbers values, and doing such an assignment in a loop would cause some entries

Re: arrays and hashes

2003-06-06 Thread R. Joseph Newton
Stuart White wrote: Hey, thanks that worked! --- James Edward Gray II [EMAIL PROTECTED] wrote: snip I don't seen any reason to use the array at all, so I've removed it. If you had one that I just didn't know about, send it on back. That's how I tried to solve this piecewise, I

Re: arrays and hashes

2003-06-06 Thread R. Joseph Newton
Stuart White wrote: Ok, I think I get it. the $_ is printing the player name, (though I don't know why I'm not using $1 $1 is a special-purpose variable used only in relation to regexes. The default variable for looping structures will be contained in $_. instead for that) and the

Re: arrays and hashes

2003-06-06 Thread R. Joseph Newton
Stuart White wrote: This does make it clearer, but not entirely. Is this what is happening: the loop starts, and goes immediately into the if statement. when the regex finds a line with Jump Shot it stores that in $2, and the player name in $1. The next thing it does, and I'm not quite

Re: arrays and hashes

2003-06-06 Thread James Edward Gray II
On Friday, June 6, 2003, at 03:32 AM, R. Joseph Newton wrote: The player's name IS the number. No other numbering system is needed. The players name is NEVER stored in the hash, AFAIK. The name is used to feed a hashing function, which renders an index into the storage of the hash structure.

Re: arrays and hashes

2003-06-06 Thread Rob Dixon
James Edward Gray II wrote: On Friday, June 6, 2003, at 03:32 AM, R. Joseph Newton wrote: The player's name IS the number. No other numbering system is needed. The players name is NEVER stored in the hash, AFAIK. The name is used to feed a hashing function, which renders an index into

Re: arrays and hashes

2003-06-06 Thread R. Joseph Newton
R. Joseph Newton wrote: Stuart White wrote: This does make it clearer, but not entirely. Is this what is happening: the loop starts, and goes immediately into the if statement. when the regex finds a line with Jump Shot it stores that in $2, and the player name in $1. The next

Re: arrays and hashes

2003-06-06 Thread R. Joseph Newton
James Edward Gray II wrote: On Friday, June 6, 2003, at 03:32 AM, R. Joseph Newton wrote: The player's name IS the number. No other numbering system is needed. The players name is NEVER stored in the hash, AFAIK. The name is used to feed a hashing function, which renders an index into

Re: arrays and hashes

2003-06-06 Thread R. Joseph Newton
Rob Dixon wrote: James Edward Gray II wrote: On Friday, June 6, 2003, at 03:32 AM, R. Joseph Newton wrote: The player's name IS the number. No other numbering system is needed. The players name is NEVER stored in the hash, AFAIK. The name is used to feed a hashing function,

Re: arrays and hashes

2003-06-04 Thread James Edward Gray II
On Monday, June 2, 2003, at 08:10 PM, Stuart White wrote: Ok, I think I get it. the $_ is printing the player name, (though I don't know why I'm not using $1 instead for that) $1 contains the first capture of the last match we did. When you're using match variables like that, store them

Re: arrays and hashes

2003-06-04 Thread James Edward Gray II
On Monday, June 2, 2003, at 10:06 PM, Stuart White wrote: This does make it clearer, but not entirely. Is this what is happening: the loop starts, and goes immediately into the if statement. when the regex finds a line with Jump Shot it stores that in $2, and the player name in $1. Yes, this

Re: arrays and hashes

2003-06-04 Thread Stuart White
This is good explanation. Thanks. Hi Stuart, This is so useful and easy that it's worth really understanding. Here's a non-programming metaphor: As each player makes a shot he calls out his name ($1): smith. The scorekeeper says, ah, smith ($score{smith}) - let's add 1 to Smith's

More Jump Shots ;-) [Was Re: arrays and hashes]

2003-06-04 Thread Kevin Pfeiffer
Since it seemed like a nice exercise to work on I played with this some myself. Goals being to try to avoid global variables, use subroutines and keep MAIN 'uncluttered' and pass arguments to subs as needed. I think I did okay (holding breath), but I'm wondering about things like: my

Re: More Jump Shots ;-) [Was Re: arrays and hashes]

2003-06-04 Thread Tassilo von Parseval
On Tue, Jun 03, 2003 at 08:36:05PM +0200 Kevin Pfeiffer wrote: Since it seemed like a nice exercise to work on I played with this some myself. Goals being to try to avoid global variables, use subroutines and keep MAIN 'uncluttered' and pass arguments to subs as needed. I think I did okay

Re: More Jump Shots ;-) [Was Re: arrays and hashes]

2003-06-04 Thread Kevin Pfeiffer
In article [EMAIL PROTECTED], Tassilo Von Parseval wrote: [...] If you from then on referred to elements of the hash with something like $score_ref-{ key }; then this would be it. It depends on what you want. By dereferencing the whole data-structure you're essentially creating a copy.

Re: arrays and hashes

2003-06-03 Thread James Edward Gray II
On Monday, June 2, 2003, at 04:02 PM, Stuart White wrote: Also, to get the numbers to the right of the colon, I'd have to have a count for each occurrence of each player, how might I do that? Perhaps with something like: my %hash; $hash{ (split /:/, $_)[0] }++ foreach (@array); That just walks

Re: arrays and hashes

2003-06-03 Thread Stuart White
Hmm, this might actually be more productive I showed less abstract example lines. (I couldn't do this before as I didn't have the code in front of me.) Here is an example of the lines that my code is selecting and then extracting a player name and jump shot attempt(working on this part) then

Re: arrays and hashes

2003-06-03 Thread royce . wells
PROTECTED]To: [EMAIL PROTECTED] m cc: Subject: Re: arrays

Re: arrays and hashes

2003-06-03 Thread Stuart White
: Subject: Re: arrays and hashes 06/02/2003 05:12

Re: arrays and hashes

2003-06-03 Thread Stuart White
You should probably use an array to keep the correct order and a hash to keep the count: I don't really understand what you mean. __ Do you Yahoo!? Yahoo! Calendar - Free online calendar with sync to Outlook(TM). http://calendar.yahoo.com -- To

Re: arrays and hashes

2003-06-03 Thread James Edward Gray II
On Monday, June 2, 2003, at 05:12 PM, Stuart White wrote: Hmm, this might actually be more productive I showed less abstract example lines. Not sure I understand perfectly yet, but I'll give it another go. I don't seen any reason to use the array at all, so I've removed it. If you had one

Re: arrays and hashes

2003-06-03 Thread Stuart White
Hey, thanks that worked! --- James Edward Gray II [EMAIL PROTECTED] wrote: snip I don't seen any reason to use the array at all, so I've removed it. If you had one that I just didn't know about, send it on back. That's how I tried to solve this piecewise, I thought an array was necessary,

Re: arrays and hashes

2003-06-03 Thread Stuart White
Hey, thanks that worked! --- James Edward Gray II [EMAIL PROTECTED] wrote: snip I don't seen any reason to use the array at all, so I've removed it. If you had one that I just didn't know about, send it on back. That's how I tried to solve this piecewise, I thought an array was necessary,

Re: arrays and hashes

2003-06-03 Thread Stuart White
One more thing, if I want to sort the hash alphabetically by key where do I put the sort function? I tried it before the while loop that does the printing and on the each function (sort(each(%linehash))) and that just gave me numbers first, colon, player names. and I figure that it wouldn't

Re: arrays and hashes

2003-06-03 Thread James Edward Gray II
On Monday, June 2, 2003, at 06:54 PM, Stuart White wrote: I don't understand this syntax: $linehash{$1}++; Could you explain it to me? Absolutely. This is a common Perl technique, often used with a hash named '%seen' because that's exactly what it's keeping track of. $1 is where you were

Re: arrays and hashes

2003-06-03 Thread James Edward Gray II
Print it like this, it's easier: print $_ : $linehash{$_}\n foreach (sort keys %linehash); James On Monday, June 2, 2003, at 07:03 PM, Stuart White wrote: One more thing, if I want to sort the hash alphabetically by key where do I put the sort function? I tried it before the while loop that

Re: arrays and hashes

2003-06-03 Thread Stuart White
Ok, I think I get it. the $_ is printing the player name, (though I don't know why I'm not using $1 instead for that) and the $linehash{$_} means, in English, the value of the key stored in $_ is that right? Thanks for all your help. --- James Edward Gray II [EMAIL PROTECTED] wrote: Print it

Re: arrays and hashes

2003-06-03 Thread Stuart White
This does make it clearer, but not entirely. Is this what is happening: the loop starts, and goes immediately into the if statement. when the regex finds a line with Jump Shot it stores that in $2, and the player name in $1. The next thing it does, and I'm not quite sure how, is it populates a

Re: arrays and hashes

2003-06-03 Thread Kevin Pfeiffer
In article [EMAIL PROTECTED], Stuart White wrote: This does make it clearer, but not entirely. Is this James wrote: This is a common Perl technique, often used with a hash named '%seen' because that's exactly what it's keeping track of. $1 is where you were capturing your names, I just

Re: arrays and hashes

2003-06-03 Thread Janek Schleicher
John W. Krahn wrote at Mon, 02 Jun 2003 14:44:41 -0700: You should probably use an array to keep the correct order and a hash to keep the count: Or to use Tie::IxHash. Greetings, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: arrays and subroutines

2003-03-17 Thread R. Joseph Newton
David Newman wrote: Greetings. I have a newbie question about passing arrays into a subroutine (and getting return values as well). Hi David, I can't help much as far as passing or returning whole arrays, but there is a much better way to access arrays from inside a function. I'll show you

Re: arrays and subroutines

2003-03-16 Thread Victor Tsang
You need to pass the array to the function by reference, here's the fix. spin([EMAIL PROTECTED]); sub spin { $arr = shift; for (; $count 0; $count--) { push(@$arr, $start++); } } but if all you want to do is to populate your array with value between 1025 to 1035, here's a

Re: arrays and references etc....

2002-12-13 Thread Sudarshan Raghavan
Kris Gaethofs wrote: Hi, I could use some help with the following problem: I have this input file that looks like this (after some processing): %1%MO%1s%.%-.0003%.%.0003%.0002%.0006%-.0005%.0020%-.0035%.0006 %2%MO%1s%-.0001%-.0021%-.0003%.0018%.0015%.0042%-.0034%.0136%-.0234%.0042

Re: arrays lists

2002-11-23 Thread Jason Purdy
I know I am missing a lot in my knowledge, but I'm trying to figure something out seemingly am in a hole... MySQL can do a lot of this for you, I believe... You want a random record from the database and retrieve a particular field from that record: # Untested, but you would call this

Re: arrays lists

2002-11-23 Thread james lundeen
here is an example of MySQL code to pick a random record using some select criteria. i use it in a homepage for an online store where my client has random items from his catalog displayed as featured items (really nothing more than picking a random record from the 10,000+ items!)...

Re: arrays lists

2002-11-22 Thread Octavian Rasnita
First I need to tell you that I am not a MySQL specialist and my opinion might be wrong butI think that: 1. You'll better use where day=$day and where month=$month because it works faster than using the like operator. 2. I think MySQL has a function for returning random numbers, so you better

RE: Arrays inside

2002-09-06 Thread Bob Showalter
-Original Message- From: Tobin, Elliot [mailto:[EMAIL PROTECTED]] Sent: Friday, September 06, 2002 9:55 AM To: '[EMAIL PROTECTED]' Subject: Arrays inside I have the following as my data inside a package: my $dataBlock = { isInsertable= $isInsertable,

RE: Arrays inside

2002-09-06 Thread Nikola Janceski
see inline comments: -Original Message- From: Tobin, Elliot [mailto:[EMAIL PROTECTED]] Sent: Friday, September 06, 2002 9:55 AM To: '[EMAIL PROTECTED]' Subject: Arrays inside I have the following as my data inside a package: my $dataBlock = { isInsertable=

Re: Arrays inside

2002-09-06 Thread James Edward Gray II
On Friday, September 6, 2002, at 08:54 AM, Tobin, Elliot wrote: I have the following as my data inside a package: my $dataBlock = { isInsertable= $isInsertable, fields = undef, fields =

Re: Arrays inside

2002-09-06 Thread Jeff 'japhy' Pinyan
On Sep 6, Tobin, Elliot said: sub setFields { my ($inBlock, @fieldList) = @_; foreach my $i (@fieldList) { push($inBlock-{'fields'}, $i); You'd need to say push @{ $inBlock-{fields} }, $i; } return $inBlock; } But given your current function, it's far faster

RE: arrays + split

2002-02-26 Thread Wagner-David
I thank you will have to use substr since you have daffygoofy and you have nothing to split on, so use substr to get the data. Wags ;) -Original Message- From: Stuart Clark [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 26, 2002 19:57 To: perllist Subject: arrays + split

Re: arrays + split

2002-02-26 Thread Jeff 'japhy' Pinyan
On Feb 27, Stuart Clark said: Hi All, How do i gather an array of data from a line which has no delimiters. The data is put into positions relative to the start of the line. #string 1 will be position 1-5 on the line #string 2 will be position 6-15 on the line #string 3 will be position 16-23

Re: @arrays and more

2002-02-25 Thread Jeff 'japhy' Pinyan
On Feb 25, Carlo Sayegh said: print \nPlease state below your duties as $function adminstrator. Press enter then^D twice when done.\n\n; while () { if ( (/^DONE/) ) { last; } } @data1 = STDIN; chomp (@data1); Uh do you know what that while loop is

Re: arrays and refs...argh!

2002-02-16 Thread Andrea Holstein
In article [EMAIL PROTECTED] wrote Ron Goral [EMAIL PROTECTED]: Can someone please tell me why the following code only returns the last element in the referenced array? If I put the foreach routine inside the while loop, I get a printout of each element in both the $sqlRes reference and

Re: Arrays 1x3 or 3x1 - The real questions

2002-02-12 Thread Brett W. McCoy
On Tue, 12 Feb 2002, Steven M. Klass wrote: Let's start off with some simple code.. my $arg = SomeFunction ( my @arry = qw/one two three/) sub SomeFunction { my @array = @_[0]; No, you are only grabbing the first element of @_. You should either pass the array as a reference

Re: Arrays 1x3 or 3x1 - The real questions

2002-02-12 Thread Jonathan E. Paton
Hi all, Let's start off with some simple code.. my $arg = SomeFunction ( my @arry = qw/one two three/) sub SomeFunction { my @array = @_[0]; for (my $i =0; i @array; i ++ ) { print $array[0][$i] } } Ok now I understand what the problem is, but I don't know how to fix it.

Re: Arrays 1x3 or 3x1 - The real questions

2002-02-12 Thread Steven M. Klass
how does shift work? In other words what if I do this Somefunction($var1, \@arry) sub SomeFunction { my $var = $_[0] my $array = shift; foreach(@{$array}) { print $_\n; } } How does the shift operator know which is which? I called it specifically

RE: Arrays 1x3 or 3x1 - The real questions

2002-02-12 Thread Timothy Johnson
. McCoy Cc: [EMAIL PROTECTED] Subject: Re: Arrays 1x3 or 3x1 - The real questions how does shift work? In other words what if I do this Somefunction($var1, \@arry) sub SomeFunction { my $var = $_[0] my $array = shift; foreach(@{$array}) { print $_\n

Re: Arrays 1x3 or 3x1 - The real questions

2002-02-12 Thread Tanton Gibbs
; then $var2 will be an array reference to @arry. HTH, Tanton - Original Message - From: Steven M. Klass [EMAIL PROTECTED] To: Brett W. McCoy [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Tuesday, February 12, 2002 4:20 PM Subject: Re: Arrays 1x3 or 3x1 - The real questions how does shift work

Re: Arrays 1x3 or 3x1 - The real questions

2002-02-12 Thread Jeff 'japhy' Pinyan
On Feb 12, Steven M. Klass said: Somefunction($var1, \@arry) sub SomeFunction { my $var = $_[0];# XXX you were missing a ; here my $array = shift; Uh, $array and $var have the same value now. shift() removes the first element from an array (defaulting to @_) and returns it.

Re: Arrays 1x3 or 3x1 - The real questions

2002-02-12 Thread Steven M. Klass
[EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Tuesday, February 12, 2002 4:20 PM Subject: Re: Arrays 1x3 or 3x1 - The real questions how does shift work? In other words what if I do this Somefunction($var1, \@arry) sub SomeFunction { my $var = $_[0] my $array = shift; foreach

Re: Arrays and use strict question

2002-01-13 Thread Jeff 'japhy' Pinyan
On Jan 13, Keith Nasman said: @a = qw/this is the text/; $a = three; print The third word is ${a}[2]\n; print The third word is $a[2]\n; produce this: The third word is three[2] The third word is the The reason three is printed is because ${a}[2] is another way of writing $a . [2] -- that is,

Re: arrays

2001-10-22 Thread Andrea Holstein
Prasanthi Tenneti wrote: In my prog ,I have 6 different arrays.And all first elemnts should do something.ANd all 2nd elements in arrays should do something and so on . Iam unable to write code in perl for this.PLs help me. Let's assume, the 6 different arrays are declared as array1 ..

Re: arrays and hashes

2001-10-01 Thread Michael Fowler
On Sat, Sep 29, 2001 at 11:08:11AM -0400, Darfler, Jim (J.E.) wrote: How would I go about sending to a file the volume names and dates sorted by the date? Open the file, iterate through your data structure, write what data you want to the file, close the file. I had thought to put the

Re: arrays and hashes

2001-10-01 Thread Bradford Ritchie
Hi Jim, I'm not entirely clear on what you have in the first array, but it sounds like it won't be of much use since you already have a hash with all the information you need. You're probably going to have to create a new data structure that keys off of the date so you can search/sort based on

Re: arrays

2001-09-25 Thread Jeff 'japhy' Pinyan
On Sep 25, [EMAIL PROTECTED] said: are there multi-dimensional arrays in perl? There are multi-dimensional data structures (arrays and hashes) in Perl. I wrote something for perl.com a while ago that you might want to read in conjunction with the standard docs:

Re: arrays

2001-09-25 Thread Brett W. McCoy
On Tue, 25 Sep 2001 [EMAIL PROTECTED] wrote: are there multi-dimensional arrays in perl? Yes, but not exactly, if you are thinking in terms of multi-dimensional arrays as they are in C. In Perl, we build up complex data structures by using references: my @multiarray = ( [1, 2, 3, 4], [5, 6,

Re: arrays

2001-07-31 Thread Matija Papec
Troy Denkinger [EMAIL PROTECTED] wrote: which indicates that the first array is empty. The problem is the undef of @temp. What you've put into @array is a reference to @temp. When you undef it, you're undefing the array that the reference in array points to. In any event, I can't figure out

Re: arrays

2001-07-31 Thread Matija Papec
Michael Fowler [EMAIL PROTECTED] wrote: @data[0] = (, , ); #and @data[1] = (1, 2, 3); This notation is almost certainly incorrect, what you probably meant to say is: $data[0] = [, , ]; $data[1] = [ 1, 2, 3]; You're right, I wrote a wrong syntax. I want to make @data[0] on the

RE: arrays

2001-07-30 Thread John Edwards
Can you explain what your trying to achieve?? You want an array called @data which consists of all the elements from @dataumi2? Where does the second array with empty element values come from, why is it needed? to assign @data with all the elements from @dataumi2 do this @data = @dataumi2;

Re: arrays

2001-07-30 Thread Jeff 'japhy/Marillion' Pinyan
On Jul 30, Matija Papec said: my $i; my (@datumi2) = (1..100); my (@temp, @data); # block for optimization for $i (0..$#datumi2) { push @temp, } push @data, \@temp; undef @temp; # end of block for optimization push @data, \@datumi2; You can use the length of an array with the x

Re: arrays

2001-07-30 Thread Troy Denkinger
On Monday 30 July 2001 12:05, Matija Papec wrote: Program below works fine but I wander how to optimize this; it looks very ugly. The final result have to be @data which contains two arrays. First array have to be equal size of second array(@datumi2) and all their values have to be . Hmmm,

Re: arrays

2001-07-30 Thread Matija Papec
John Edwards [EMAIL PROTECTED] wrote: Can you explain what your trying to achieve?? You want an array called @data which consists of all the elements from @dataumi2? Where does the second array with empty element values come from, why is it needed? ok, to simplify let's suppose that @datumi2 =

Re: arrays

2001-07-30 Thread Michael Fowler
On Mon, Jul 30, 2001 at 08:02:58PM +0200, Matija Papec wrote: ok, to simplify let's suppose that @datumi2 = (1, 2, 3); #so final result should look like this: @data[0] = (, , ); #and @data[1] = (1, 2, 3); This notation is almost certainly incorrect, what you probably meant to say is:

  1   2   >