Re: array assignement

2007-07-23 Thread John W. Krahn
jeevs wrote: Hi forum! Hello, I just wanted to know what does the following line do @{$args{owner}} = qw(hero wierd); You are assigning a list to the anonymous array in $args{owner}. lets assume $args{owner} = 'sachin'; 'sachin' is a scalar value. Then it would mean @{sachin} =

RE: Array of Array refs

2007-05-30 Thread Andrew Curry
Enough Is enough, can we leave this thread be now. This just puts people off posting questions looking for help in fear of joining some flame war. -Original Message- From: Brian [mailto:[EMAIL PROTECTED] Sent: 29 May 2007 19:30 To: beginners@perl.org; [EMAIL PROTECTED] Subject: Re

Re: Array of Array refs

2007-05-29 Thread Brian
On May 29, 6:06 am, [EMAIL PROTECTED] (Paul Lalli) wrote: > On May 29, 4:58 am, [EMAIL PROTECTED] (Brian) wrote: > > > On May 28, 6:14 pm, [EMAIL PROTECTED] (Paul Lalli) wrote: > > > > > oh yes, more important than all that minutiae... the push did not > > > > work for me in the working code. > >

Re: Array of Array refs

2007-05-29 Thread Chas Owens
On 29 May 2007 13:04:42 -0700, Paul Lalli <[EMAIL PROTECTED]> wrote: On May 29, 3:21 pm, [EMAIL PROTECTED] (Dr.Ruud) wrote: > Brian schreef: > > > Changing @ to $ is confusing... > > Huh? @ means array, $ means scalar; there is nothing to change. Presumably, he meant that @array identifies the e

Re: Re: Array of Array refs @ 1180470274

2007-05-29 Thread Johan Meskens CS3 jmcs3
Intrah onat Diria .. , ** wrote "Revera y": > > > Changing @ to $ is confusing... this is different in perl6 , the following could be unreadable @ 1180470350 ::: hbeingspiel , 0::- , 1::',| , 0::| , 1::ver

Re: Array of Array refs

2007-05-29 Thread Paul Lalli
On May 29, 3:21 pm, [EMAIL PROTECTED] (Dr.Ruud) wrote: > Brian schreef: > > > Changing @ to $ is confusing... > > Huh? @ means array, $ means scalar; there is nothing to change. Presumably, he meant that @array identifies the entire array, while $array[0] identifies the first element of the array,

Re: Array of Array refs

2007-05-29 Thread Dr.Ruud
Brian schreef: > Changing @ to $ is confusing... Huh? @ means array, $ means scalar; there is nothing to change. -- 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 of Array refs

2007-05-29 Thread Paul Lalli
On May 29, 11:10 am, [EMAIL PROTECTED] (Paul Lalli) wrote: > On May 29, 10:16 am, [EMAIL PROTECTED] (Rob Dixon) wrote: > > > Brian wrote: > > I agree with you Brian. I have been posting on this list for around four > > years, and rarely have I seen 'help' that is expressed with such vitriol > > as

Re: Array of Array refs

2007-05-29 Thread Paul Lalli
On May 29, 10:16 am, [EMAIL PROTECTED] (Rob Dixon) wrote: > Brian wrote: > I agree with you Brian. I have been posting on this list for around four > years, and rarely have I seen 'help' that is expressed with such vitriol > as Paul's has been. I'm truly sorry you feel that way, Brian. My respons

Re: Array of Array refs

2007-05-29 Thread Rob Dixon
Brian wrote: Paul Lalli wrote: Brian wrote: my variable names end with A for array and H for hash, Pointless. Variable names in Perl identify what kind of variable they are. @ for arrays, % for hashes. [ ] for accessing an element of a hash, { } for accessing element of a hash. no, I

Re: Array of Array refs

2007-05-29 Thread Paul Lalli
On May 29, 4:58 am, [EMAIL PROTECTED] (Brian) wrote: > On May 28, 6:14 pm, [EMAIL PROTECTED] (Paul Lalli) wrote: > > > > > > oh yes, more important than all that minutiae... the push did not > > > work for me in the working code. > > > The push worked absolutely fine. It just didn't do what you w

Re: Array of Array refs

2007-05-29 Thread Paul Lalli
On May 29, 5:30 am, [EMAIL PROTECTED] (Brian) wrote: > On May 28, 6:04 pm, [EMAIL PROTECTED] (Paul Lalli) wrote: > > > On May 28, 3:22 pm, [EMAIL PROTECTED] (Brian) wrote: > > > > my variable names end with A for array and H for hash, > > > Pointless. Variable names in Perl identify what kind of v

Re: Array of Array refs

2007-05-29 Thread Brian
On May 28, 6:04 pm, [EMAIL PROTECTED] (Paul Lalli) wrote: > On May 28, 3:22 pm, [EMAIL PROTECTED] (Brian) wrote: > > > my variable names end with A for array and H for hash, > > Pointless. Variable names in Perl identify what kind of variable they > are. @ for arrays, % for hashes. [ ] for acces

Re: Array of Array refs

2007-05-29 Thread Brian
On May 28, 6:14 pm, [EMAIL PROTECTED] (Paul Lalli) wrote: > > > oh yes, more important than all that minutiae... the push did not > > work for me in the working code. > > The push worked absolutely fine. It just didn't do what you wanted it > to. Learning how to parse your problem should be your

Re: Array of Array refs

2007-05-28 Thread Paul Lalli
On May 28, 3:26 pm, [EMAIL PROTECTED] (Brian) wrote: > On May 27, 9:00 pm, [EMAIL PROTECTED] (Brian) wrote: > > > > > > > Hi All- > > I am trudging through some DBI, XML, etc.. I had a problem and was > > baffled by how to get at array elements out of a series of pushed > > array refs. But, by si

Re: Array of Array refs

2007-05-28 Thread Paul Lalli
On May 28, 3:22 pm, [EMAIL PROTECTED] (Brian) wrote: > my variable names end with A for array and H for hash, Pointless. Variable names in Perl identify what kind of variable they are. @ for arrays, % for hashes. [ ] for accessing an element of a hash, { } for accessing element of a hash. > ye

Re: Array of Array refs

2007-05-28 Thread Brian
On May 27, 9:00 pm, [EMAIL PROTECTED] (Brian) wrote: > Hi All- > I am trudging through some DBI, XML, etc.. I had a problem and was > baffled by how to get at array elements out of a series of pushed > array refs. But, by simplifying the problem, I found that the syntax I > used was in error. her

Re: Array of Array refs

2007-05-28 Thread Brian
On May 27, 9:00 pm, [EMAIL PROTECTED] (Brian) wrote: > Hi All- > I am trudging through some DBI, XML, etc.. I had a problem and was > baffled by how to get at array elements out of a series of pushed > array refs. But, by simplifying the problem, I found that the syntax I > used was in error. her

Re: Array of Array refs

2007-05-28 Thread Paul Lalli
On May 28, 12:00 am, [EMAIL PROTECTED] (Brian) wrote: > I am trudging through some DBI, XML, etc.. I had a problem and was > baffled by how to get at array elements out of a series of pushed > array refs. What's to be baffled by? Have you read: perldoc perlreftut perldoc perllol perldoc perlds

Re: Array of Array refs

2007-05-28 Thread Rob Dixon
Brian wrote: Hi All- I am trudging through some DBI, XML, etc.. I had a problem and was baffled by how to get at array elements out of a series of pushed array refs. But, by simplifying the problem, I found that the syntax I used was in error. here is the small sample, already debugged. Hope th

RE: array and hash patter matching

2007-05-08 Thread Tim Wolak
John, Below are ansewers to your questions. -Original Message- From: John W. Krahn [mailto:[EMAIL PROTECTED] Sent: Monday, May 07, 2007 12:57 PM To: Perl Beginners Subject: Re: array and hash patter matching Tim Wolak wrote: > Morning all, Hello, > I am working on a script that

Re: array and hash patter matching

2007-05-07 Thread Rene Schickbauer
> Morning all, > > I am working on a script that reads in /var/log/auth.log,, takes the ip > addresses puts them into a hash keeping track of how many times it finds > that address and compare it to addresses found in /etc/hosts.deny and > only write the addresses that are new in the file. So far

Re: array and hash patter matching

2007-05-07 Thread John W. Krahn
Tim Wolak wrote: > Morning all, Hello, > I am working on a script that reads in /var/log/auth.log,, takes the ip > addresses puts them into a hash keeping track of how many times it finds > that address and compare it to addresses found in /etc/hosts.deny and > only write the addresses that are n

Re: array and hash patter matching

2007-05-07 Thread Tom Phoenix
On 5/7/07, Tim Wolak <[EMAIL PROTECTED]> wrote: however I am struggling on how to compare the hash with an array for any duplicate addresses. What is the best approach to take with this? You want to know whether a given IP address matches any of a list of IP addresses, right? Probably I'd use

Re: Array to Hash

2007-04-18 Thread Rob Dixon
yitzle wrote: Any tips on compacting this sub? sub readFile($) { my $fileName = shift; open FILE, "<", $fileName; while () { my($name,$oldCount,$oldNum) = split /~/; $dHash{$name}{'oldCount'} = $oldCount; $dHash{$name}{'oldNum'} = $oldNum; } close FIL

Re: Array to Hash

2007-04-18 Thread Chas Owens
On 4/18/07, yitzle <[EMAIL PROTECTED]> wrote: Any tips on compacting this sub? sub readFile($) { my $fileName = shift; open FILE, "<", $fileName; while () { my($name,$oldCount,$oldNum) = split /~/; $dHash{$name}{'oldCount'} = $oldCount;

Re: array operation

2007-02-26 Thread John W. Krahn
Paul wrote: > > Another way to add to the many: > > #!/usr/bin/perl > use strict; > use warnings; > > my @test = (1,2,3,4,5); > > foreach (@test) { > my $testprint = (<@test>); > print "$testprint\n"; > } Really?? Do you actually know what that is doing? $ perl -MO=Deparse -e' my @te

Re: array operation

2007-02-26 Thread Paul
On Mon, February 26, 2007 4:05 am, Sayed, Irfan \(Irfan\) wrote: > Hi all, > > # /usr/bin/perl > use strict; > use warnings; > > my $CT = "/usr/atria/bin/cleartool"; > my @test = (1,2,3,4,5); > print "@test\n"; > > The output of the above script is > > 1 2 3 4 5 > > But i need output as > > 1 > 2

Re: array operation

2007-02-26 Thread Dosztál András
Hi, You may use the $, variable like this: $, = "\n"; print (1,2,3,4); The output will be: 1 2 3 4 Regards, Andras On Mon, 26 Feb 2007 12:27:56 +0100, Igor Sutton Lopes <[EMAIL PROTECTED]> wrote: Hi, On 2007/02/26, at 11:08, [EMAIL PROTECTED] wrote: The above code does not seem to w

Re: array operation

2007-02-26 Thread Igor Sutton Lopes
Hi, On 2007/02/26, at 11:08, [EMAIL PROTECTED] wrote: The above code does not seem to work for me. I get an error saying $" is unrecognised. do i need to include anything ? Actually, I'm using Perl 5.8.8. I don't know if 5.6 or lower has that variable. Actually, it does. If you are on unix

Re: array operation

2007-02-26 Thread Arun . S
Hi, On 2007/02/26, at 10:12, John W. Krahn wrote: print map "$_\n", @test; print "$_\n" for @test; Another solution is setting the $" variable: my @array = qw(1 2 3 4 5); {     local $" = "\n";     print "@array"; } The above code does not seem to work for me. I get an error say

Re: array operation

2007-02-26 Thread Igor Sutton Lopes
Hi, On 2007/02/26, at 10:12, John W. Krahn wrote: print map "$_\n", @test; print "$_\n" for @test; Another solution is setting the $" variable: my @array = qw(1 2 3 4 5); { local $" = "\n"; print "@array"; } HTH! -- Igor Sutton [EMAIL PROTECTED] PGP.sig Description: This

Re: array operation

2007-02-26 Thread John W. Krahn
Sayed, Irfan (Irfan) wrote: > Hi all, Hello, > # /usr/bin/perl > use strict; > use warnings; > > my $CT = "/usr/atria/bin/cleartool"; > my @test = (1,2,3,4,5); > print "@test\n"; > > The output of the above script is > > 1 2 3 4 5 > > But i need output as > > 1 > 2 > 3 > 4 > 5 > > I

Re: array operation

2007-02-26 Thread Jeff Pang
> >my $CT = "/usr/atria/bin/cleartool"; >my @test = (1,2,3,4,5); >print "@test\n"; > >The output of the above script is > > 1 2 3 4 5 > >But i need output as > >1 >2 >3 >4 >5 Hello, The simple way, print join "\n",@test; But when @test is large,using join is not good. It can write then:

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

Re: array searching

2007-01-14 Thread John W. Krahn
Jim Canon wrote: > > On 1/14/07, John W. Krahn <[EMAIL PROTECTED]> wrote: >> >> Jim Canon wrote: >> > >> > Thank you very much for the response, it has helped me begin to >> > understand how regular expressions work. I see that /(\d+)$/ >> > matches the numbers until the end of line in >> > >> >

Re: array searching

2007-01-14 Thread Jim Canon
By numbers in front I am referring to word1 word2 job2006 in the element: word1 word2 job2006 three four five six community job555 It seems that /(\d+)$/ matches word1 word2 job2006 job555 I was reviewing http://perldoc.perl.org/perlre.html but am having trouble determining the best way to match j

Re: array searching

2007-01-14 Thread John W. Krahn
Jim Canon wrote: > > Thank you very much for the response, it has helped me begin to understand > how regular expressions work. I see that /(\d+)$/ matches the numbers > until the end of line in > > @job1 = qw( > job555 > job572 > job8433 > job873 > job594 > job4663 > job2221 > job2223 >

Re: Array Referrences

2007-01-13 Thread John W. Krahn
Jeff Pang wrote: >> If I have 'my $aryRef = [EMAIL PROTECTED]' can do 'push $aryRef, $aValue'? >> Does this >> place the value of $aValue directly into @array or do I need to figure out >> another way to do that? >> > > You can't do 'push' like this way since $aryRef is a scalar but 'push' expec

Re: Array Referrences

2007-01-13 Thread Mathew Snyder
Jeff Pang wrote: >> If I have 'my $aryRef = [EMAIL PROTECTED]' can do 'push $aryRef, $aValue'? >> Does this >> place the value of $aValue directly into @array or do I need to figure out >> another way to do that? >> > > You can't do 'push' like this way since $aryRef is a scalar but 'push' expec

Re: Array Referrences

2007-01-13 Thread Jeff Pang
>If I have 'my $aryRef = [EMAIL PROTECTED]' can do 'push $aryRef, $aValue'? >Does this >place the value of $aValue directly into @array or do I need to figure out >another way to do that? > You can't do 'push' like this way since $aryRef is a scalar but 'push' expect a list as its first argume

Re: array searching

2007-01-12 Thread Rob Dixon
Jim Canon wrote: > Hi, > > This is my first question, I appreciate any information you provide. I want > to compare the numbers after : in @jn to the numbers after job in @job1 and > @job2. > > > @jn = > JN.2007:555 > JN.2007:8433 > JN.2007:594 > JN.2007:111 > JN.2007:4663 > JN.2007.321 > JN.2007:

Re: array searching

2007-01-11 Thread John W. Krahn
Jim Canon wrote: > Hi, Hello, > This is my first question, I appreciate any information you provide. I want > to compare the numbers after : in @jn to the numbers after job in @job1 and > @job2. > > [ snip ] > > I want to put what is missing in @jn compared to @job1 and @job2 in > @jobMissing :

Re: array help

2006-09-21 Thread John W. Krahn
Sayed, Irfan (Irfan) wrote: > Here is my code > > # Perl script to change the replica name > > use strict; > use warnings; > > > # my $fname = "/tmp/vob_list1"; > # open FILE,">",$fname or die $!; > # my $fname1 = "/tmp/repl_list1"; > # open FILE1,">",$fname1 or die $!; > > my $CT = '/

RE: array help

2006-09-21 Thread Lee Goddard
> if i use one array in foreach loop then can i use same array > in another part of the code. What do you think? Have you actually tried to do this? Perhaps you could submit the smallest possible piece of code illustrate your prediciment? -- http://www.bbc.co.uk/ This e-mail (and any attachm

RE: array help

2006-09-20 Thread Sayed, Irfan \(Irfan\)
lice(my @repl1, -50); print @vob_rep; #close FILE1; I already declared the @repl1 in foreach loop. Please help Regards Irfan _ From: Igor Lopes [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 20, 2006 11:02 PM To: Sayed, Irfan (Irfan) Cc: beginners@perl.org Subject: R

Re: array help

2006-09-20 Thread Igor Lopes
Global symbol "@repl1" requires explicit package name at ch_repl_name.pl line 24. It seems you are using strict, but not declaring @repl1 anywhere. If you post your code will be easier to help. -- Igor Lopes <[EMAIL PROTECTED]>

RE: array help

2006-07-20 Thread Timothy Johnson
-Original Message- From: Dr.Ruud [mailto:[EMAIL PROTECTED] Sent: Thursday, July 20, 2006 4:18 PM To: beginners@perl.org Subject: Re: array help >> my @test = ("/test" , "/playground"); >> print @test; >> >> >> >> i need t

Re: array help

2006-07-20 Thread Dr.Ruud
"Sayed, Irfan (Irfan)" schreef: > I have written following line. but i am getting error Which error? > my @test = ("/test" , "/playground"); > print @test; > > i am getting output as follows > > /test/playground > > i need the output in following fasion > > /test > /playground > > can you plea

Re: array help

2006-07-20 Thread Chad Perrin
On Thu, Jul 20, 2006 at 10:51:58PM +0800, Sayed, Irfan (Irfan) wrote: > Hi, > > I have written following line. but i am getting error > > my @test = ("/test" , "/playground"); > print @test; > > i am getting output as follows > > /test/playground > > i need the output in following fasion

Re: array help

2006-07-20 Thread Maxim
Hi, Use foreach smth like foreach $i (@test) { print "$i\n"; } On Thu, Jul 20, 2006 at 10:51:58PM +0800, Sayed, Irfan (Irfan) wrote: > Hi, > > I have written following line. but i am getting error > > my @test = ("/test" , "/playground"); > print @test; > > i am getting

Re: array help

2006-07-20 Thread Hal Wigoda
#!/usr/bin/perl my @test = ("/test" , "/playground"); print @test; print "\n"; print @test[0],"\n"; print @test[1],"\n"; you must print each array item with a \n On Jul 20, 2006, at 9:33 AM, Sayed, Irfan ((Irfan)) wrote: Hi, I have written following line. but i am getting error my @test =

Re: array help

2006-07-20 Thread Hal Wigoda
you have to add a "\n" between the 2 elements in the array. On Jul 20, 2006, at 9:51 AM, Sayed, Irfan ((Irfan)) wrote: Hi, I have written following line. but i am getting error my @test = ("/test" , "/playground"); print @test; i am getting output as follows /test/playground i need the o

RE: array help

2006-07-20 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Sayed, Irfan (Irfan) wrote: > Hi, > > I have written following line. but i am getting error > > my @test = ("/test" , "/playground"); > print @test; > > i am getting output as follows > > /test/playground > > i need the output in following fasion > > /test > /playground > > can you please t

Re: array question

2006-05-10 Thread M. Kristall
for (my $i = 0; $i < @arry; $i++) { splice (@arry, $i, 1, split (' ', $arry[$i], 2)); } If one of the elements of @arry contains "one two three" then using "2" will add the two elements "one" and "two three" instead of the three elements "one", "two" and "three" so you may still be left with

Re: array question

2006-05-10 Thread John W. Krahn
M. Kristall wrote: > John W. Krahn wrote: >>> for (my $i = 0; $i < @arry; $i++) { >>> splice (@arry, $i, 1, split (' ', $arry[$i], 1)); >>> } >> >> How does that populate the @new_array variable? > > Mine doesn't populate @new_array. It takes the original array and > replaces it with the equiv

Re: array question

2006-05-10 Thread Dr.Ruud
"Timothy Johnson" schreef: > if I had my way, I'd remove > [...] the default variable $_. But why would you want that? #!/usr/bin/perl use strict; use warnings; sub say { print +(@_ ? @_ : $_), $/ ; 1 } say for 'A' .. 'Z' ; for ( 'a' .. 'z' ) { say } ; for my $c ( 'A' .. 'Z' ) { say $c

Re: array question

2006-05-10 Thread M. Kristall
John W. Krahn wrote: for (my $i = 0; $i < @arry; $i++) { splice (@arry, $i, 1, split (' ', $arry[$i], 1)); } How does that populate the @new_array variable? Mine doesn't populate @new_array. It takes the original array and replaces it with the equivalent of everyone else's @new_array :-)

Re: array question

2006-05-09 Thread Chad Perrin
On Tue, May 09, 2006 at 11:52:26AM -0700, Timothy Johnson wrote: > > As much as I would hate to make you cry, if I had my way, I'd remove > that as well as the default variable $_. It would be like the first > time you had to convert all of your scripts to use the strict pragma, > but in the end

Re: array question

2006-05-09 Thread Mr. Shawn H. Corey
On Tue, 2006-09-05 at 14:54 -0700, Bryan R Harris wrote: > Regarding Timothy's thoughts, I tend to believe perl wouldn't be as popular > if the "use strict" pragma defaulted to on. I don't code in C because it's > too hard to get all the little details right. Perl is very forgiving, and > for my

Re: array question

2006-05-09 Thread Bryan R Harris
> On Tue, 2006-09-05 at 11:52 -0700, Timothy Johnson wrote: >> It's the Perl >> equivalent of having to remember 'I before E except after C...'. > > '.. except where it's not.' > > E.g: > height > weight > sex > > (OK, I included 'sex' just to get your attention.) On some platforms:

Re: array question

2006-05-09 Thread Dr.Ruud
"Mr. Shawn H. Corey" schreef: > Dr.Ruud: >> One exception: the pattern / / does not work like the pattern ' '. > > But it should, that's my point. Not for / / vs. ' ', because that is a special case. It is far too late to change the special case to undef or whatever. I like your example that sh

RE: array question

2006-05-09 Thread Mr. Shawn H. Corey
On Tue, 2006-09-05 at 11:52 -0700, Timothy Johnson wrote: > It's the Perl > equivalent of having to remember 'I before E except after C...'. '.. except where it's not.' E.g: height weight sex (OK, I included 'sex' just to get your attention.) -- __END__ Just my 0.0002 million dolla

RE: array question

2006-05-09 Thread Timothy Johnson
-Original Message- From: Bryan R Harris [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 09, 2006 11:24 AM To: Beginners Perl Subject: Re: array question >> On Tue, 2006-09-05 at 18:33 +0200, Dr.Ruud wrote: >>> One exception: the pattern / / does not work like the pattern &#x

Re: array question

2006-05-09 Thread Mr. Shawn H. Corey
On Tue, 2006-09-05 at 11:23 -0700, Bryan R Harris wrote: > Are you proposing that the special case be removed? If so, PLEASE NO! I > use that special case in almost every script I write, and if they removed it > I would probably shed tears over it. Don't worry; they won't. Well, maybe in Perl6;

Re: array question

2006-05-09 Thread Bryan R Harris
> On Tue, 2006-09-05 at 18:33 +0200, Dr.Ruud wrote: >> One exception: the pattern / / does not work like the pattern ' '. > > But it should, that's my point. Are you proposing that the special case be removed? If so, PLEASE NO! I use that special case in almost every script I write, and if t

Re: array question

2006-05-09 Thread John W. Krahn
Mr. Shawn H. Corey wrote: > On Tue, 2006-09-05 at 09:05 -0700, John W. Krahn wrote: >>I don't understand what you are trying to say. > > I saying this should work: > > split '+', 'this+is+a+test'; > > Yes, I know how to fix it. I'm saying it _should_ work, not that it > does. If split is follo

Re: array question

2006-05-09 Thread Mr. Shawn H. Corey
On Tue, 2006-09-05 at 09:44 -0700, chen li wrote: > split /PATTERN/,EXPR,LIMIT > split /PATTERN/,EXPR > split /PATTERN/ > split > > 1. I check the perldoc -f split but I am not quite > sure what EXPR really means. Does it refer to a > string, or a scalar variable contaning a string, or an > ar

Re: array question

2006-05-09 Thread Mr. Shawn H. Corey
On Tue, 2006-09-05 at 18:33 +0200, Dr.Ruud wrote: > One exception: the pattern / / does not work like the pattern ' '. But it should, that's my point. -- __END__ Just my 0.0002 million dollars worth, --- Shawn "For the things we have to learn before we can do them, we learn by doing t

Re: array question

2006-05-09 Thread Mr. Shawn H. Corey
On Tue, 2006-09-05 at 09:05 -0700, John W. Krahn wrote: > I don't understand what you are trying to say. I saying this should work: split '+', 'this+is+a+test'; Yes, I know how to fix it. I'm saying it _should_ work, not that it does. If split is followed by a string, the string should be quot

Re: array question

2006-05-09 Thread John W. Krahn
chen li wrote: > > --- "John W. Krahn" <[EMAIL PROTECTED]> wrote: >> >>$ perl -le' >>my $string = q[ a b c d ]; >>print join "\t", map "<$_>", split q[\s+], >>qq[$string], q[4]; >>print join "\t", map "<$_>", split /\s+/, >>$string,4; >>' >><> >><> >> >

Re: array question

2006-05-09 Thread Dr.Ruud
Mr. Shawn H. Corey" schreef: > John W. Krahn: >> Anything used as a pattern is a string. See the "Quote and >> Quote-like Operators" section of perlop: > > Huh? > > Do you mean all strings can be used as a pattern? > > split( quotemeta( $split_string ), $data_string ); > > > Or that patterns ar

Re: array question

2006-05-09 Thread chen li
--- "John W. Krahn" <[EMAIL PROTECTED]> wrote: > Mr. Shawn H. Corey wrote: > > On Tue, 2006-09-05 at 01:33 +0200, Paul Johnson > wrote: > >>Um, that's not quite correct. > >> > >>See `perldoc -f split` for details. > > > > Oh, yes, a special case. I have long ago abandoned > special cases since

Re: array question

2006-05-09 Thread John W. Krahn
Mr. Shawn H. Corey wrote: > On Tue, 2006-09-05 at 01:30 -0700, John W. Krahn wrote: >>Anything used as a pattern is a string. See the "Quote and Quote-like >>Operators" section of perlop: > > Huh? > > Do you mean all strings can be used as a pattern? A pattern is a string. Perl does string int

Re: array question

2006-05-09 Thread John W. Krahn
M. Kristall wrote: > chen li wrote: I have an arry like this: @arry=('AA bb','BB','CC AG') How do I turn it into new array like this: > TMTOWTDI @new_array=('AA','bb','BB','CC','AG') >>> my @new_array = split ' ', "@arry"; >> >> Both line codes work perfectly: >>

Re: array question

2006-05-09 Thread M. Kristall
chen li wrote: I have an arry like this: @arry=('AA bb','BB','CC AG') How do I turn it into new array like this: TMTOWTDI @new_array=('AA','bb','BB','CC','AG') my @new_array = split ' ', "@arry"; Both line codes work perfectly: my @new_array = map { split } @arry; or my @new_array = spl

Re: array question

2006-05-09 Thread Mr. Shawn H. Corey
On Tue, 2006-09-05 at 01:30 -0700, John W. Krahn wrote: > Anything used as a pattern is a string. See the "Quote and Quote-like > Operators" section of perlop: Huh? Do you mean all strings can be used as a pattern? split( quotemeta( $split_string ), $data_string ); Or that patterns are buil

Re: array question

2006-05-09 Thread John W. Krahn
Mr. Shawn H. Corey wrote: > On Tue, 2006-09-05 at 01:33 +0200, Paul Johnson wrote: >>Um, that's not quite correct. >> >>See `perldoc -f split` for details. > > Oh, yes, a special case. I have long ago abandoned special cases since > they lead to errors. Note that `perldoc -f split` starts with: >

Re: array question

2006-05-08 Thread Bryan Harris
> Oh, yes, a special case. I have long ago abandoned special cases since > they lead to errors. Note that `perldoc -f split` starts with: > > split /PATTERN/,EXPR,LIMIT > split /PATTERN/,EXPR > split /PATTERN/ > split > > Note: no strings. Strings do not work well when used as the patte

Re: array question

2006-05-08 Thread John W. Krahn
Mr. Shawn H. Corey wrote: > On Mon, 2006-08-05 at 15:15 -0700, chen li wrote: >>Both line codes work perfectly: >> >>my @new_array = map { split } @arry; >>or >>my @new_array = split ' ', "@arry"; > > The second statement will work perfectly if every element has only one > space character separat

Re: array question

2006-05-08 Thread Mr. Shawn H. Corey
On Tue, 2006-09-05 at 01:33 +0200, Paul Johnson wrote: > Um, that's not quite correct. > > See `perldoc -f split` for details. > Oh, yes, a special case. I have long ago abandoned special cases since they lead to errors. Note that `perldoc -f split` starts with: split /PATTERN/,EXPR,LIMIT s

Re: array question

2006-05-08 Thread Dr.Ruud
Mr. Shawn H. Corey schreef: > chen li: >> Both line codes work perfectly: >> >> my @new_array = map { split } @arry; >> or >> my @new_array = split ' ', "@arry"; > > The second statement will work perfectly if every element has only one > space character separating its components and has no leadin

Re: array question

2006-05-08 Thread Paul Johnson
On Mon, May 08, 2006 at 07:07:14PM -0400, Mr. Shawn H. Corey wrote: > On Mon, 2006-08-05 at 15:15 -0700, chen li wrote: > > Both line codes work perfectly: > > > > my @new_array = map { split } @arry; > > or > > my @new_array = split ' ', "@arry"; > > The second statement will work perfectly if

Re: array question

2006-05-08 Thread Mr. Shawn H. Corey
On Mon, 2006-08-05 at 15:15 -0700, chen li wrote: > Both line codes work perfectly: > > my @new_array = map { split } @arry; > or > my @new_array = split ' ', "@arry"; The second statement will work perfectly if every element has only one space character separating its components and has no lead

Re: array question

2006-05-08 Thread chen li
> > I have an arry like this: > > > > @arry=('AA bb','BB','CC AG') > > > > How do I turn it into new array like this: > > > > @new_array=('AA','bb','BB','CC','AG') > > my @new_array = split ' ', "@arry"; Both line codes work perfectly: my @new_array = map { split } @arry; or my @new_array =

Re: array question

2006-05-08 Thread John W. Krahn
chen li wrote: > Hi all, Hello, > I have an arry like this: > > @arry=('AA bb','BB','CC AG') > > How do I turn it into new array like this: > > @new_array=('AA','bb','BB','CC','AG') my @new_array = split ' ', "@arry"; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMA

Re: array question

2006-05-08 Thread Mr. Shawn H. Corey
On Mon, 2006-08-05 at 22:35 +0200, Dani Pardo wrote: > On 5/8/06, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote: > > > Do you mean to break the elements on whitespace? > > > > my @new_array = map { split } @arry; > > Sorry but, can you explain the brackets? I just don't get it. Wich is > the diff

Re: array question

2006-05-08 Thread Mr. Shawn H. Corey
On Mon, 2006-08-05 at 12:58 -0700, chen li wrote: > Hi all, > > I have an arry like this: > > @arry=('AA bb','BB','CC AG') > > How do I turn it into new array like this: > > @new_array=('AA','bb','BB','CC','AG') Do you mean to break the elements on whitespace? my @new_array = map { split } @a

RE: array question

2006-05-08 Thread Timothy Johnson
You could cycle through the array and use split() to split each element by whitespace and then append the result to the @new_array array using push(); -Original Message- From: chen li [mailto:[EMAIL PROTECTED] Sent: Monday, May 08, 2006 12:58 PM To: beginners@perl.org Subject: array qu

RE: array help

2006-04-13 Thread Ankur Gupta
Irfan J Sayed scribbled on Thursday, April 13, 2006 9:46 AM: > Hi, > > I am executing following command. > > my @activity = system "cleartool lsactivity -short -view > Admin_Irfan_Project_int"; > > but the output of this command is not storing in the array. array is

Re: array help

2006-04-13 Thread Tom Phoenix
On 4/13/06, Irfan J Sayed <[EMAIL PROTECTED]> wrote: > I am executing following command. > > my @activity = system "cleartool lsactivity -short -view > Admin_Irfan_Project_int"; You seem to want backticks, also known as qx// . You can find it in the perlop manpage, in the section on "Quote and Qu

Re: array

2006-04-13 Thread Jeff Pang
It's simple to do that in Perl.For example,if you want to capture the unix command pwd's output,you just do: my @pwd = `pwd`; print @pwd; just good as you input 'pwd' command under unix shell. -Original Message- >From: Irfan J Sayed <[EMAIL PROTECTED]> >Sent: Apr 13, 2006 11:44 AM >To:

Re: Array of arrays

2006-02-28 Thread Tommy Grav
Disregard my previous email as it was another error further up in the program. Typical beginners mistake I guess :) Cheers Tommy [EMAIL PROTECTED] http://homepage.mac.com/tgrav/ "Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a

Re: Array of arrays

2006-02-28 Thread Bob Showalter
Tommy Grav wrote: print $refstars[1][0] ; # <- This is line 38 However this code returns an error I do not understand Missing right curly or square bracket at refstar.pl line 38, at end of line syntax error at refstar.pl line 38, at EOF Execution of refstar.pl aborted due to

RE: Array of arrays

2006-02-28 Thread Timothy Johnson
The code you posted does not return any errors. Check the parts you didn't post. -Original Message- From: Tommy Grav [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 28, 2006 1:48 PM To: beginners@perl.org Cc: Tommy Grav Subject: Array of arrays I have a file of numbers that I want to

Re: array getting scalar value

2006-02-20 Thread The Ghost
Actually, it was some of HTML::Mason's caching. So I'd get inconsistent results. Anyway, thanks for the replies! Ryan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: array getting scalar value

2006-02-20 Thread Tom Phoenix
On 2/20/06, The Ghost <[EMAIL PROTECTED]> wrote: > my @columns = @{$self->{columns}}; > foreach (@{$self->{columns}}) {print qq{self->col: $_\n};} # prints > the 3 columns > foreach (@columns) {print qq{col: $_\n};} #prints 3 > > Why? I can't say why your code does anything unexpected for you; it

Re: array getting scalar value

2006-02-20 Thread JupiterHost.Net
The Ghost wrote: my @columns = @{$self->{columns}}; foreach (@{$self->{columns}}) {print qq{self->col: $_\n};} # prints the 3 columns foreach (@columns) {print qq{col: $_\n};} #prints 3 Why? Well, it must be some magic with $self because Perl does not indeed act the way you've described

<    1   2   3   4   5   6   7   8   >