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
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
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
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
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
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";
>
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
> 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
> [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
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
> 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
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
"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
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
"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.
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
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
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
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
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
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:
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
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
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
>
(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
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
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
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
28 matches
Mail list logo