why doesn't this work

2001-09-03 Thread dan radom
I'm very new to perl. I have been trying to reweite some of my shell scripts to learn the language. Here's what I've got... #!/usr/local/bin/perl -w if ( $#ARGV+1 !=2 ) { print "\n"; print "usage cat.pl port up\/down\n"; print "\n"; exit; } chomp( $port = $ARG

Why doesn't this work?

2004-11-09 Thread Brian Gehrke
The following subroutine should take an input path (Dir0), process that directory by recursively calling itself on subdirectories or processing any files it contains. The problem I am experiencing is that in the following example file structure it process Dir1 correctly, but after it returns t

Why doesn't this work?

2004-11-09 Thread Li, Aiguo (NIH/NCI)
Hello, I have the following dataset and want to calculate a P/A ratio for each replicates in the dataset. In this case, treatment 1 has 4 replicats and treatment2 has 3 replicates. The P/A = [((#of P)*2) + (# of M)]/# of replicates. The output should be two columns of P/A ratios for two treatment

Re: why doesn't this work

2001-09-03 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 3, dan radom said: >if ( $#ARGV+1 !=2 ) { That's better written as: if (@ARGV != 2) { >print "\n"; >print "usage cat.pl port up\/down\n"; >print "\n"; >exit; >} >#if (( $status ne 1 ) || ( $status ne 2 )) { >#print "\n"; >#print "port s

RE: why doesn't this work

2001-09-03 Thread John Edwards
icking in. If status was 2, it would still fail because it didn't equal 1. The above says "unless status equals 1 or 2, fail", which is what you need. HTH John -Original Message- From: dan radom [mailto:[EMAIL PROTECTED]] Sent: 03 September 2001 17:00 To: [EMAIL PROTECT

Re: why doesn't this work

2001-09-03 Thread dan radom
Thanks. That got it. dan * Jeff 'japhy/Marillion' Pinyan ([EMAIL PROTECTED]) wrote: > On Sep 3, dan radom said: > > >if ( $#ARGV+1 !=2 ) { > > That's better written as: > > if (@ARGV != 2) { > > >print "\n"; > >print "usage cat.pl port up\/down\n"; > >print "\n"; >

RE: why doesn't this work

2001-09-03 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 3, John Edwards said: >unless ( $status == (1 || 2) ) { >print "\nport status must be either up or down\n\n"; >exit; >} else { > system("/usr/bin/snmpset hostname password >interfaces.ifTable.ifEntry.ifAdminStatus.$port i $status"); >} > >The above says "unless status

Re: why doesn't this work

2001-09-03 Thread smoot
> dan radom <[EMAIL PROTECTED]> said: You have a logic error. The if test should be: if (! ( $status eq 1 || $status eq 2)) { > #if (( $status ne 1 ) || ( $status ne 2 )) { A few other "style" pointers follow: You can replace this: if ( $#ARGV+1 !=2) { with if ( @ARGV != 2) { @arrayname

Re: why doesn't this work

2001-09-03 Thread smoot
> [EMAIL PROTECTED] said: > > dan radom <[EMAIL PROTECTED]> said: > > You have a logic error. The if test should be: > > if (! ( $status eq 1 || $status eq 2)) { Well, I know better than that. Should be "=" not "eq". -- Smoot Carl-Mitchell Consultant -- To unsubscribe, e-mail: [EMAIL PR

Re: why doesn't this work

2001-09-05 Thread brian d foy
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > > [EMAIL PROTECTED] said: > > > dan radom <[EMAIL PROTECTED]> said: > > You have a logic error. The if test should be: > > if (! ( $status eq 1 || $status eq 2)) { > > Well, I know better than that. Should be "=" not "eq". the nume

RE: Why doesn't this work?

2004-11-09 Thread Jim
> The following subroutine should take an input path (Dir0), > process that directory by recursively calling itself on > subdirectories or processing any files it contains. The > problem I am experiencing is that in the following example > file structure it process Dir1 correctly, but after

RE: Why doesn't this work?

2004-11-09 Thread Ajey Kulkarni
If you are running this on *NIX box, plain old 'find' command is enough too. ~A On Tue, 9 Nov 2004, Jim wrote: > > > The following subroutine should take an input path (Dir0), > > process that directory by recursively calling itself on > > subdirectories or processing any files it contains. T

Re: Why doesn't this work?

2004-11-11 Thread Zeus Odin
"Aiguo Li" <[EMAIL PROTECTED]> wrote in message... > Hello, Hello. > I have the following dataset and want to calculate a P/A ratio for each > replicates in the dataset. In this case, treatment 1 has 4 replicats and > treatment2 has 3 replicates. The P/A = [((#of P)*2) + (# of M)]/# of > replicat

RE: Why doesn't this work?

2004-11-11 Thread Li, Aiguo (NIH/NCI)
s the # of replicates in each treatment. Thanks, Aiguo -Original Message- From: Zeus Odin [mailto:[EMAIL PROTECTED] Sent: Thursday, November 11, 2004 8:08 AM To: [EMAIL PROTECTED] Subject: Re: Why doesn't this work? "Aiguo Li" <[EMAIL PROTECTED]> wrote in messag

Re: Why doesn't this work?

2004-11-11 Thread Zeus Odin
"Aiguo Li" <[EMAIL PROTECTED]> wrote in message ... > Probe id Treat1 Treat2 > AffX-BioB-5_at (2p +M)/4 =2 (2*3+0)/3=2 > FFX-BioB-M_at (2*3+0)/4 =1.7 (2*3+0)/3=2 > AFFX-BioB-3_at (2*2+0)/4 =1 (2*2+0)/3=1.3 > AFFX-BioC-5_at (2*2+1)/4 =1.25 (2*1+1)/3=1 > AFFX-BioC-3_at (2*1+1)/4 = 0.75 (2*2+1)/3=1.

RE: Why doesn't this work?

2004-11-13 Thread Zeus Odin
L. Schwartz and Tom Phoenix is excellent. http://www.bestwebbuys.com/Learning_Perl-ISBN_0596001320.html?isrc=b-search. You should get the two Perl bibles: _Programming Perl 3rd Ed_ by Larry Wall and _Perl Cookbook_ by by Tom Christiansen and Nathan Torkington. > I > hope that I made myself cl

Why doesn't this work: trinary operator?

2008-01-11 Thread Zembower, Kevin
When I execute this line: $type eq "unknown" ? $type="human" : $type="both"; $type is always "both". But executing this line: if ($type eq "unknown") {$type="human"} else {$type="both"}; $type is "human", which is want I want and expect. The context for these statements in my program is pasted

Why doesn't this work: matching capturing

2008-02-26 Thread Zembower, Kevin
I have a data file that looks like this: uSF1 MD1500 0092149355224510209 0101001 88722397N0720900 116759 0Block Group 1 S 1158 662+39283007-076574503 uSF1 MD1500 0092150355224510209 0101002 88722397N0720900 109338

Re: Why doesn't this work: trinary operator?

2008-01-11 Thread Stephen Kratzer
On Friday 11 January 2008 16:16:27 Zembower, Kevin wrote: > When I execute this line: > > $type eq "unknown" ? $type="human" : $type="both"; > > $type is always "both". But executing this line: > > if ($type eq "unknown") {$type="human"} else {$type="both"}; > > $type is "human", which is want I wa

Re: Why doesn't this work: trinary operator?

2008-01-11 Thread John W. Krahn
Zembower, Kevin wrote: When I execute this line: $type eq "unknown" ? $type="human" : $type="both"; $type is always "both". PRECEDENCE! ?: has higher precedence than = You want to do it like this: $type = $type eq 'unknown' ? 'human' : 'both'; John -- Perl isn't a toolbox, but a small m

Re: Why doesn't this work: trinary operator?

2008-01-11 Thread Rob Dixon
John W. Krahn wrote: Zembower, Kevin wrote: When I execute this line: $type eq "unknown" ? $type="human" : $type="both"; $type is always "both". PRECEDENCE! ?: has higher precedence than = You want to do it like this: $type = $type eq 'unknown' ? 'human' : 'both'; Your code parses as:

Re: Why doesn't this work: trinary operator?

2008-01-12 Thread davidfilmer
On Jan 11, 1:16 pm, [EMAIL PROTECTED] (Kevin Zembower) wrote: > $type eq "unknown" ? $type="human" : $type="both"; You're trying to use the trinary like you would an if-then-else. You want to instead use it in an assignment: $type = ($type eq 'unknown') ? 'human' : 'both'; -- The best way to

Re: Why doesn't this work: matching capturing

2008-02-26 Thread Paul Lalli
On Feb 26, 1:19 pm, [EMAIL PROTECTED] (Kevin Zembower) wrote: > I have a data file that looks like this: > uSF1  MD1500  009214935522451020                9  0101001 > 88722397N0720900 > 116759             0Block Group 1 > S      1158      662+39283007-076574503 > > uSF1  MD1500  009215

RE: Why doesn't this work: matching capturing

2008-02-26 Thread Zembower, Kevin
8 3:41 PM To: beginners@perl.org Subject: Re: Why doesn't this work: matching capturing On Feb 26, 1:19 pm, [EMAIL PROTECTED] (Kevin Zembower) wrote: > I have a data file that looks like this: > uSF1  MD1500  009214935522451020                9  0101001 > 88722397N0720900 >

Why doesn't this work: perl -e "@s=([1,2],[3,4]); print $s[0][0];"

2008-10-31 Thread Zembower, Kevin
(This should probably be an easy one for someone.} Why doesn't this work: [EMAIL PROTECTED]:/usr/local/src/rrd$ perl -e "@s=(["a","b"],["c","d"]);print $s[0][0];" syntax error at -e line 1, near "][" Execution of -e aborted due to

Re: Why doesn't this work: perl -e "@s=([1,2],[3,4]); print $s[0][0];"

2008-10-31 Thread Paul Johnson
On Fri, Oct 31, 2008 at 01:34:05PM -0400, Zembower, Kevin wrote: > (This should probably be an easy one for someone.} > > Why doesn't this work: > [EMAIL PROTECTED]:/usr/local/src/rrd$ perl -e "@s=(["a","b"],["c","d"]);print > $s

RE: Why doesn't this work: perl -e "@s=([1,2],[3,4]); print $s[0][0];"

2008-10-31 Thread Zembower, Kevin
Oh, it was that simple. Thanks so much, Paul. -Kevin -Original Message- From: Paul Johnson [mailto:[EMAIL PROTECTED] Sent: Friday, October 31, 2008 1:42 PM To: Zembower, Kevin Cc: 'beginners@perl.org' Subject: Re: Why doesn't this work: perl -e "@s=([1,2],[3,4]); prin

Re: Why doesn't this work: perl -e "@s=([1,2],[3,4]); print $s[0][0];"

2008-10-31 Thread John W. Krahn
Zembower, Kevin wrote: (This should probably be an easy one for someone.} Why doesn't this work: [EMAIL PROTECTED]:/usr/local/src/rrd$ perl -e "@s=(["a","b"],["c","d"]);print $s[0][0];" syntax error at -e line 1, near "][&quo