Re: Argument isn't numeric warning in if statement

2014-09-18 Thread Rob Dixon
I correct in thinking that Perl evaluates an inline 'if' from right to left - meaning that if $item->{optionprice} is NOT true, then the addition will not even be seen? Or does Perl look at the entire line before performing it? I'm not clear what you mean by an *inline* i

Re: Argument isn't numeric warning in if statement

2014-09-17 Thread SSC_perl
On Sep 17, 2014, at 3:32 PM, Rob Dixon wrote: > As you have presented them, those code fragments are identical in meaning. That was my understanding as well, but the inline 'if' gave an error while the block didn't. Running the code by itself in TextWrangler does not produce the warning

Re: Argument isn't numeric warning in if statement

2014-09-17 Thread Rob Dixon
On 17/09/2014 01:37, SSC_perl wrote: I just ran across something puzzling. Why are these two statements not equivalent when it comes to warnings? if ($item->{'optionprice'}) { $item->{'unitprice'} += $item->{'optionprice'}; } and $item->{'unitprice'} += $item->{'optionprice'}

Re: Argument isn't numeric warning in if statement

2014-09-17 Thread Lawrence Statton
On 09/17/2014 12:46 PM, SSC_perl wrote: > On Sep 16, 2014, at 6:58 PM, > wrote: >> Are you sure you've quoted the code (that's producing the warning) correctly? > > Yes, I did. I double-checked it just to be certain. However, I ran > the code by itself and it doesn't produce that warni

Re: Argument isn't numeric warning in if statement

2014-09-17 Thread SSC_perl
On Sep 16, 2014, at 6:58 PM, wrote: > Are you sure you've quoted the code (that's producing the warning) correctly? Yes, I did. I double-checked it just to be certain. However, I ran the code by itself and it doesn't produce that warning, so it must be something upstream that's caus

Re: Argument isn't numeric warning in if statement

2014-09-16 Thread sisyphus1
-Original Message- From: SSC_perl Sent: Wednesday, September 17, 2014 10:37 AM To: Perl Beginners Subject: Argument isn't numeric warning in if statement I just ran across something puzzling. Why are these two statements not equivalent when it comes to warnings? if (

Argument isn't numeric warning in if statement

2014-09-16 Thread SSC_perl
I just ran across something puzzling. Why are these two statements not equivalent when it comes to warnings? if ($item->{'optionprice'}) { $item->{'unitprice'} += $item->{'optionprice'}; } and $item->{'unitprice'} += $item->{'optionprice'} if ($item->{'optionprice'});

Re: Single equals operator inside an if statement

2013-08-14 Thread Alexey Mishustin
2013/8/15 Brian Fraser : > On Wed, Aug 14, 2013 at 6:09 PM, Alexey Mishustin >> I'm sorry only that there is no built-in option with which one could >> enable/disable easily assignments inside `if'. (E.g., like re 'eval'/ >> no re 'eval'). It would "provide choices"... >> > > It might not be too

Re: Single equals operator inside an if statement

2013-08-14 Thread Brian Fraser
igning it - I have never done this at the same > >>> time... > >> > >> > >> > >> Doing both in while statements is very common: > >> > >>while( my $line = <$fh> ) { > >> ... > >>} > >>

Re: Single equals operator inside an if statement

2013-08-14 Thread Alexey Mishustin
gt; Doing both in while statements is very common: >> >>while( my $line = <$fh> ) { >> ... >>} >> >> Try to write that loop with two separate statements, one an >> assignment > > and the other an if statement, and you may see the

Re: Single equals operator inside an if statement

2013-08-14 Thread Uri Guttman
t loop with two separate statements, one an assignment and the other an if statement, and you may see the advantage of the currently-allowed syntax. The general policy is that assignment statements return a value that may be further used or tested. i have a common idiom when dealing with a

Re: Single equals operator inside an if statement

2013-08-14 Thread Jim Gibson
s, one an assignment and the other an if statement, and you may see the advantage of the currently-allowed syntax. The general policy is that assignment statements return a value that may be further used or tested. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional command

Re: Single equals operator inside an if statement

2013-08-14 Thread Alexey Mishustin
Thanks to all, 2013/8/14 Jim Gibson : > The problem is that the construct > > if( $foo = $bar ) { > ... > > is not always a typo. It means: "assign value of $bar to variable $foo and > test if the result is logically true", which is perfectly valid. If that were > not allowed, then you wo

Re: Single equals operator inside an if statement

2013-08-14 Thread Jing Yu
Or maybe he can write a perl script to check the "if/while" conditionals of his perl script... while(<>){ say '= is detected where == is expected at line ',"$." if /if\s*\(\S+?=[^=]/; } On 15 Aug 2013, at 03:02, Rob Dixon wrote: > On 14/08/2013 18:21, Alexey Mishustin wrote: >> >> If

Re: Single equals operator inside an if statement

2013-08-14 Thread Jing Yu
Hi Alex, I guess it would be very difficult and error-prone to do it. Here's my thought: my $bar = 3; my $assign = (my $foo = $bar); if($assign){ say '$assign=',$assign; } my $equal = ($foo == $bar); if($equal){ say '$equal=',$equal; } output: $ perl tst.pl $assign=3 $equal=1 But if $

Re: Single equals operator inside an if statement

2013-08-14 Thread Rob Dixon
On 14/08/2013 18:21, Alexey Mishustin wrote: If I make a typo and write a single "equals" operator here: if ($foo = 2) { print "yes\n"; } ...then the "warnings" pragma works OK and tells me "Found = in conditional, should be ==..." But if I make the same typo and write a single "equal

Re: Single equals operator inside an if statement

2013-08-14 Thread Jim Gibson
On Aug 14, 2013, at 11:34 AM, Alexey Mishustin wrote: > Hi Jing, > > Thanks for the reply. > > So, there is no built-in way to catch these typos? The problem is that the construct if( $foo = $bar ) { ... is not always a typo. It means: "assign value of $bar to variable $foo and test i

Re: Single equals operator inside an if statement

2013-08-14 Thread Alexey Mishustin
Hi Jing, Thanks for the reply. So, there is no built-in way to catch these typos? -- Regards, Alex -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Single equals operator inside an if statement

2013-08-14 Thread Jing Yu
Hi there, Allow me to correct myself, the value of the assignment is the new value of the variable. But in the end it is the same. The compiler won't be able to see what $bar is when used in if ($foo=$bar), therefore won't throw any warnings. Cheers, Jing On 15 Aug 2013, at 01:21, Alexey Mishus

Re: Single equals operator inside an if statement

2013-08-14 Thread Jing Yu
Hi Alexey, If I remember correctly, when you assign a value to an lvalue like this: $foo = 1; The value of the assignment is the value on the right hand side of the equal sign. So when you do something like: if ($foo=2){...} It has the same effect as this: $foo=2; If (2){...} The condition

Single equals operator inside an if statement

2013-08-14 Thread Alexey Mishustin
Hello all, If I make a typo and write a single "equals" operator here: #!/usr/bin/perl use strict; use warnings; my $foo = 1; my $bar = 2; if ($foo = 2) { print "yes\n"; } else { print "no\n"; } ...then the "warnings" pragma works OK and tells me "Found = in conditional, shoul

Re: using cmp for if statement comparisons

2012-03-14 Thread Shawn H Corey
On 12-03-14 12:35 AM, John W. Krahn wrote: cmp is a binary operator just like eq, ne, gt, lt, ge and le. See `perldoc perlop` and search for /Equality Operators/ -- Just my 0.0002 million dollars worth, Shawn Programming is as much about organization and communication as it is about co

Re: using cmp for if statement comparisons

2012-03-13 Thread John W. Krahn
Noah wrote: Hi there, Hello, I am trying to get two conditions matched how can I get if ( ($source_location eq $destination_location ) && ( $source_device < $destination_device ) ) { That should be: if ( $source_location eq $destination_location && $source_device lt $destination_device )

using cmp for if statement comparisons

2012-03-13 Thread Noah
Hi there, I am trying to get two conditions matched how can I get if ( ($source_location eq $destination_location ) && ( $source_device < $destination_device ) ) { and if ( ($source_location eq $destination_location ) && ( $source_device > $destination_device ) ) {

Re: current record number with if statement

2010-09-20 Thread Shlomi Fish
On Monday 20 September 2010 12:30:55 Raj wrote: > Hi, > > I am a newbie for perl. > > It would be fine if some explain how the following code prints first > 10 lines of the file. > My question here is, how/what if condition match happens? Is there > anything related to current record number ($.

current record number with if statement

2010-09-20 Thread Raj
Hi, I am a newbie for perl. It would be fine if some explain how the following code prints first 10 lines of the file. My question here is, how/what if condition match happens? Is there anything related to current record number ($.) variable? while () { print if 1 .. 10; } Regards, Raj

Re: if statement being ignored

2009-04-15 Thread Robert Citek
On Wed, Apr 15, 2009 at 6:33 AM, John W. Krahn wrote: > Robert Citek wrote: >> >> You probably want ($Lang == "fr") > > Probably not. You are using a numerical comparison on a string which will > convert the string to a number so that is the same as saying: ($Lang == 0) You are correct. Serves

Re: if statement being ignored

2009-04-15 Thread Chas. Owens
On Wed, Apr 15, 2009 at 07:33, John W. Krahn wrote: > Robert Citek wrote: >> >> On Wed, Apr 15, 2009 at 12:08 AM, Brian wrote: >>> >>> could someone please help me with this little problem? >>> I am trying to include an if statement part way through

Re: if statement being ignored

2009-04-15 Thread John W. Krahn
Robert Citek wrote: On Wed, Apr 15, 2009 at 12:08 AM, Brian wrote: could someone please help me with this little problem? I am trying to include an if statement part way through printing. When the program reaches the line if ($Lang = fr ) { print " that line gets ignored and the cgi

Re: if statement being ignored

2009-04-15 Thread Robert Citek
You probably want ($Lang == "fr") Regards, - Robert On Wed, Apr 15, 2009 at 12:08 AM, Brian wrote: > could someone please help me with this little problem? > I am trying to include an if statement part way through printing. > When the program reaches the line if ($Lang = fr

Re: AW: if statement being ignored

2009-04-15 Thread Brian
Thomas Bätzler wrote: Brian wrote: could someone please help me with this little problem? I am trying to include an if statement part way through printing. When the program reaches the line if ($Lang = fr ) { print " that line gets ignored and the cgi keeps going to the end. thanks

AW: if statement being ignored

2009-04-14 Thread Thomas Bätzler
Brian wrote: > could someone please help me with this little problem? > I am trying to include an if statement part way through printing. > When the program reaches the line if ($Lang = fr ) { print " > that line gets ignored and the cgi keeps going to the end. &g

if statement being ignored

2009-04-14 Thread Brian
Hi, could someone please help me with this little problem? I am trying to include an if statement part way through printing. When the program reaches the line if ($Lang = fr ) { print " that line gets ignored and the cgi keeps going to the end. thanks Brian #! c:\perl\bin\perl.exe -

Re: inserting what was matched in regex without going through if statement

2009-03-07 Thread Chas. Owens
On Sat, Mar 7, 2009 at 13:44, Octavian Râşniţă wrote: > From: "Rick" >> >>    my ($data) = $test_s =~ /(\[(.+)\]/; > > I think it contains a "(" that shouldn't be there (after =~ /). > >>> The code above assumes you want what is between the first and last >>> brackets in $test_s.  If the string c

Re: inserting what was matched in regex without going through if statement

2009-03-07 Thread Octavian Râşniţă
From: "Rick" my ($data) = $test_s =~ /(\[(.+)\]/; I think it contains a "(" that shouldn't be there (after =~ /). The code above assumes you want what is between the first and last brackets in $test_s. If the string contains more than one set of brackets you may want to say this instead

Re: inserting what was matched in regex without going through if statement

2009-03-07 Thread Rick
ork $data = ($test_s =~ m/\[.+\]/); but does not work.. I tried @data too but still don't work.. I want to assign what was matched directly into the variable without going through if statement. A regex returns all captures found when it is in list context, so if you add a capture to your rege

Re: inserting what was matched in regex without going through if statement

2009-03-07 Thread Chas. Owens
s hoping something like this would work > > $data = ($test_s =~ m/\[.+\]/);   but does not work.. I tried @data too but > still don't work.. > I want to assign what was matched directly into the variable without going > through if statement. A regex returns all captures found when

inserting what was matched in regex without going through if statement

2009-03-07 Thread Rick
a too but still don't work.. I want to assign what was matched directly into the variable without going through if statement. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: How to get a computed string to act as a re in if statement

2008-07-30 Thread John W. Krahn
}, substr( $guide{ $guides }->{ 'start1' }, 0, 16 ), $guide{ $guides }->{ 'start' }, substr( $guide{ $guides }->{ 'stop1' }, 0, 16 ), $guide{ $guides }->{ 'stop' }, $guide{ $guides }->

Re: How to get a computed string to act as a re in if statement

2008-07-30 Thread Rob Dixon
guide{$guides}->{'Channel'}, substr($guide{$guides}->{'start1'},0,16), $guide{$guides}->{'start'}, substr($guide{$guides}->{'stop1'},0,16), $guide{$guides}->{'stop'}, $guide{$guides}->{'name'},

How to get a computed string to act as a re in if statement

2008-07-30 Thread Mike Martin
} keys %guide){ push @{$listings},[$guide{$guides}->{'id'},$guide{$guides}->{'Channel'},substr($guide{$guides}->{'start1'},0,16),$guide{$guides}->{'start'},substr($guide{$guides}->{'stop1'},0,16),$guide{$guides}->{'stop&

Re: using mysql NULL with IF statement

2008-07-14 Thread Huub
if (! defined($myvar)) { The NULL in the database is mapped to an undef. Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery Thank yo

RE: using mysql NULL with IF statement

2008-07-13 Thread Thomas Bätzler
Huub <[EMAIL PROTECTED]> asked: > I'm adapting a Perl script using MySQL connectivity, and have > to compare a variable, e.g. $myvar, with the value NULL from > the database. In MySQL, I have to use the query 'where myvar > is null', which works great. > But when I try this in Perl, like 'if ($

Re: using mysql NULL with IF statement

2008-07-13 Thread Jenda Krynicky
From: Huub <[EMAIL PROTECTED]> > I'm adapting a Perl script using MySQL connectivity, and have to compare > a variable, e.g. $myvar, with the value NULL from the database. In > MySQL, I have to use the query 'where myvar is null', which works great. > But when I try this in Perl, like 'if ($myva

using mysql NULL with IF statement

2008-07-13 Thread Huub
Hi, I'm adapting a Perl script using MySQL connectivity, and have to compare a variable, e.g. $myvar, with the value NULL from the database. In MySQL, I have to use the query 'where myvar is null', which works great. But when I try this in Perl, like 'if ($myvar == null)' or 'if ($myvar is nu

Re: Recognizing integer as string for if statement

2007-08-14 Thread John W. Krahn
Jesse Farrell wrote: Is there a way to have a variable recognized as a string even if it contains a valid integer? I have a script that is taking strings from a file that can be numbers, including zero. I have an if statement to simply see if the variable exists (otherwise I need to throw an

RE: Recognizing integer as string for if statement

2007-08-14 Thread Jesse Farrell
arrell Cc: beginners@perl.org Subject: RE: Recognizing integer as string for if statement Unless im being very stupid in what your requirements are If(defined $variable && $variable ne "0") { } -Original Message- From: Jesse Farrell [mailto:[EMAIL PROTECTED] Sent: 14 Au

RE: Recognizing integer as string for if statement

2007-08-14 Thread Andrew Curry
Unless im being very stupid in what your requirements are If(defined $variable && $variable ne "0") { } -Original Message- From: Jesse Farrell [mailto:[EMAIL PROTECTED] Sent: 14 August 2007 21:18 To: beginners@perl.org Subject: Recognizing integer as string for if s

Recognizing integer as string for if statement

2007-08-14 Thread Jesse Farrell
Is there a way to have a variable recognized as a string even if it contains a valid integer? I have a script that is taking strings from a file that can be numbers, including zero. I have an if statement to simply see if the variable exists (otherwise I need to throw an error), and if the

Re: help with syntax using an if statement

2007-07-05 Thread Daluk
On 5 Jul, 00:24, [EMAIL PROTECTED] (Ken Foskey) wrote: > On Wed, 2007-07-04 at 19:00 +0200, Martin Barth wrote: > > Hi > > > > if (($DeviceType eq "Switch") || ($DeviceType eq "Router") || > > > ($DeviceType eq "Hub") || ($DeviceType eq "Access point")) > > > > what i would like to do is check each

Re: help with syntax using an if statement

2007-07-04 Thread Ken Foskey
On Wed, 2007-07-04 at 19:00 +0200, Martin Barth wrote: > Hi > > > if (($DeviceType eq "Switch") || ($DeviceType eq "Router") || > > ($DeviceType eq "Hub") || ($DeviceType eq "Access point")) > > > > > > what i would like to do is check each device type with where the first > > letter is uppercas

Re: help with syntax using an if statement

2007-07-04 Thread Paul Lalli
On Jul 4, 3:46 am, [EMAIL PROTECTED] (Daluk) wrote: > I have a some code that reads in a file, and then i have some if > statements. The if statement i want to change is > > if (($DeviceType eq "Switch") || ($DeviceType eq "Router") || > ($DeviceType eq &quo

Re: help with syntax using an if statement

2007-07-04 Thread Martin Barth
Hi > if (($DeviceType eq "Switch") || ($DeviceType eq "Router") || > ($DeviceType eq "Hub") || ($DeviceType eq "Access point")) > > > what i would like to do is check each device type with where the first > letter is uppercase or lowercase this should help: if( $DeviceType =~ m/^([Ss]witch|[Rr

help with syntax using an if statement

2007-07-04 Thread Daluk
Hi ppl, I have a some code that reads in a file, and then i have some if statements. The if statement i want to change is if (($DeviceType eq "Switch") || ($DeviceType eq "Router") || ($DeviceType eq "Hub") || ($DeviceType eq "Access point")) what i wo

Re: TWO loops and ONE if statement

2007-07-03 Thread Randal L. Schwartz
>>>>> ""Amichai" == "Amichai Teumim" <[EMAIL PROTECTED]> writes: "Amichai> I need to sort the @array from lowest to highest using TWO loops and "Amichai> ONE if statement. That's why it's so confusing. "Amichai> I

Re: TWO loops and ONE if statement

2007-07-03 Thread Chas Owens
On 7/3/07, Amichai Teumim <[EMAIL PROTECTED]> wrote: I forgot to add what I have done so far. I did: #!/usr/bin/perl use strict; use warnings; my @array = (5,3,2,1,4); my $n = @array; for my $i (0 .. $n-1) { for my $j (0 .. $n-1) { if ($array[$j+1] < $array[$j]) { #compare the two

Re: Fwd: TWO loops and ONE if statement

2007-07-03 Thread Gary Stainburn
On Tuesday 03 July 2007 11:55, you wrote: > OK. So I remove temp and I get this: > > Use of uninitialized value in numeric lt (<) at ./obj8-2.pl line 11. > Use of uninitialized value in numeric lt (<) at ./obj8-2.pl line 11. > Use of uninitialized value in numeric lt (<) at ./obj8-2.pl line 11. > U

Re: TWO loops and ONE if statement

2007-07-03 Thread Mumia W.
On 07/03/2007 02:53 AM, Amichai Teumim wrote: Hi guys Hello Amichai. [...] I need to sort the @array from lowest to highest using TWO loops and ONE if statement. That's why it's so confusing. I could use a one liner to do all this. I need to do it however as above mentioned. Ho

Re: TWO loops and ONE if statement

2007-07-03 Thread Martin Barth
Hi maybe this wikipedia article can show you different sorting algorithems: http://en.wikipedia.org/wiki/Sorting_algorithm#Summaries_of_popular_sorting_algorithms there are examples in pseudocode. HTH, Martin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL

Re: Fwd: TWO loops and ONE if statement

2007-07-03 Thread Gary Stainburn
On Tuesday 03 July 2007 10:43, Amichai Teumim wrote: > I forgot to add what I have done so far. I did: > > #!/usr/bin/perl > > use strict; > use warnings; > > my @array = (5,3,2,1,4); > my $n = @array; > > for my $i (0 .. $n-1) { >for my $j (0 .. $n-1) { >if ($array[$j+1] < $array[$j])

Fwd: TWO loops and ONE if statement

2007-07-03 Thread Amichai Teumim
I forgot to add what I have done so far. I did: #!/usr/bin/perl use strict; use warnings; my @array = (5,3,2,1,4); my $n = @array; for my $i (0 .. $n-1) { for my $j (0 .. $n-1) { if ($array[$j+1] < $array[$j]) { #compare the two neighbors $tmp = $array[$j]; # swap

Re: TWO loops and ONE if statement

2007-07-03 Thread Jeff Pang
reach $elem (@array){ print "$elem"; } I need to sort the @array from lowest to highest using TWO loops and ONE if statement. That's why it's so confusing. I could use a one liner to do all this. I need to do it however as above mentioned. How can I do this? Why not Perl's

Re: TWO loops and ONE if statement

2007-07-03 Thread Paul Johnson
!/usr/bin/perl > > @array = (5,3,2,1,4); > > ## include your code here ## > > foreach $elem (@array){ > print "$elem"; > } > > I need to sort the @array from lowest to highest using TWO loops and > ONE if statement. That's why it's so confusin

TWO loops and ONE if statement

2007-07-03 Thread Amichai Teumim
print "$elem"; } I need to sort the @array from lowest to highest using TWO loops and ONE if statement. That's why it's so confusing. I could use a one liner to do all this. I need to do it however as above mentioned. How can I do this? Thanks for all your help Amihai

Re: IF statement and multiple options

2006-10-19 Thread Tom Phoenix
On 10/19/06, Robert Hicks <[EMAIL PROTECTED]> wrote: I am currently building the IF statement like: if ($project_name eq 'Proj1' || $project_name eq '' && $task_name eq '') Because logical-and is higher precedence than logical-or, that conditi

Re: IF statement and multiple options

2006-10-19 Thread Rob Dixon
Robert Hicks wrote: > I am currently building the IF statement like: > > if ($project_name eq 'Proj1' || $project_name eq '' && $task_name eq '') > > > That works but I was wondering if I can do this: > > if ($project_name eq (

IF statement and multiple options

2006-10-19 Thread Robert Hicks
I am currently building the IF statement like: if ($project_name eq 'Proj1' || $project_name eq '' && $task_name eq '') That works but I was wondering if I can do this: if ($project_name eq ('Proj1' || '') && $task_name eq

Re: GnuPG again: problem with if statement evaluation

2006-05-25 Thread John W. Krahn
Jason Balicki wrote: > > This is a piece of code taken from a larger program. > > I'm trying to determine that the encryption succeded, but when > I try to evaluate the code, it always evaluates false even though > the encryption works and produces an encrypted file. > > Here's the specific bit

Re: GnuPG again: problem with if statement evaluation

2006-05-25 Thread Anthony Ettinger
ps...you're checking if it has a value, 256 (a typical error return code) would pass that test. On 5/25/06, Anthony Ettinger <[EMAIL PROTECTED]> wrote: check $? or $! $gp->foo() or die "$!"; my $output = $gp->foo(); print "return code: $?"; see perldoc perlvar On 5/25/06, Jason Balicki

Re: GnuPG again: problem with if statement evaluation

2006-05-25 Thread Anthony Ettinger
check $? or $! $gp->foo() or die "$!"; my $output = $gp->foo(); print "return code: $?"; see perldoc perlvar On 5/25/06, Jason Balicki <[EMAIL PROTECTED]> wrote: I'm back. This is a piece of code taken from a larger program. I'm trying to determine that the encryption succeded, but when

GnuPG again: problem with if statement evaluation

2006-05-25 Thread Jason Balicki
I'm back. This is a piece of code taken from a larger program. I'm trying to determine that the encryption succeded, but when I try to evaluate the code, it always evaluates false even though the encryption works and produces an encrypted file. Here's the specific bit I'm concerned with: if ($g

Re: Problem with Foreach in If Statement...

2005-06-04 Thread Frank Lee
please try this one: #tested in linux #!/usr/bin/perl -w use strict; my @names = qw( fred barney betty wilma dino ); print "Enter some numbers 1 to 5, one per line, then press ctrl D:\n"; chomp (my @numbers = ); foreach (@numbers){ if ($_ < 6){ print "$names[$_ - 1]\n"; }else{

Re: Problem with Foreach in If Statement...

2005-06-04 Thread John W. Krahn
Hakim Singhji wrote: Hi All, Hello, This is my first post at beginners. I am working with Learning Perl (Llama!) and I like to tweak some of the problems and create more creative solutions to some things. I cannot figure out why this is not working. Can anyone point out an error in my code.

Problem with Foreach in If Statement...

2005-06-04 Thread Hakim Singhji
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi All, This is my first post at beginners. I am working with Learning Perl (Llama!) and I like to tweak some of the problems and create more creative solutions to some things. I cannot figure out why this is not working. Can anyone point out an erro

RE: beginner "if statement" question

2003-06-15 Thread Rai,Dharmender
> or u can use : > > if($password =~ /^howard$/) > { > ## logic goes here > } > > -- > From: James Edward Gray II[SMTP:[EMAIL PROTECTED] > Sent: Saturday, June 14, 2003 8:58 PM > To: deborah > Cc: [EMAIL PROTECTED] > S

Re: beginner "if statement" question

2003-06-15 Thread Peter Scott
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Deborah) writes: >In the same line as my last question once I tried to understand how >Perl was interpreting string comparisons, I started experimenting with >different strings. > >What is Perl doing here? Why d

Re: beginner "if statement" question

2003-06-14 Thread James Edward Gray II
On Saturday, June 14, 2003, at 10:01 AM, deborah wrote: In the same line as my last question once I tried to understand how Perl was interpreting string comparisons, I started experimenting with different strings. What is Perl doing here? Why doesn't it use the "if"

Re: beginner "if statement" question

2003-06-14 Thread John W. Krahn
Deborah wrote: > > In the same line as my last question once I tried to understand how > Perl was interpreting string comparisons, I started experimenting with > different strings. > > What is Perl doing here? Why doesn't it use the "if" statement as a >

beginner "if statement" question

2003-06-14 Thread deborah
In the same line as my last question once I tried to understand how Perl was interpreting string comparisons, I started experimenting with different strings. What is Perl doing here? Why doesn't it use the "if" statement as a condition? It reassigns the variable value inst

Re: Compound if statement.

2003-01-30 Thread Rob Dixon
Duane Koble wrote: > I am working on a program that requires that three statement be true > in order to set a hash. The problem I am having is getting the if > statement to work correctly. I seems to me that if two of the > statements are true it proceeds through the if statement.

RE: Compound if statement.

2003-01-30 Thread Le Blanc, Kerry (Kerry)
-Original Message- From: Duane Koble [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 30, 2003 10:34 AM To: [EMAIL PROTECTED] Subject: Compound if statement. I am working on a program that requires that three statement be true in order to set a hash. The problem I am having is getting the if

Re: Compound if statement.

2003-01-30 Thread Christopher D. Lewis
On Thursday, January 30, 2003, at 09:33 AM, Duane Koble wrote: I am working on a program that requires that three statement be true in order to set a hash. The problem I am having is getting the if statement to work correctly. I seems to me that if two of the statements are true it

Compound if statement.

2003-01-30 Thread Duane Koble
I am working on a program that requires that three statement be true in order to set a hash. The problem I am having is getting the if statement to work correctly. I seems to me that if two of the statements are true it proceeds through the if statement. I need all three to be true before it

Re: If Statement Nested Regular Exp.

2002-12-19 Thread Jenda Krynicky
From: "Paul Kraus" <[EMAIL PROTECTED]> > Any ideas why this fails. If I remove if /aged/ and just have the if > /Reports ... then everything works ok. > > Code > #!/usr/bin/perl > my @files; > my %age; > push (@files, glob "Aged*"); > push (@files, glob "Receipts*"); > > foreach (@files){ >

RE: If Statement Nested Regular Exp.

2002-12-19 Thread Wagner, David --- Senior Programmer Analyst --- WGO
]] Sent: Thursday, December 19, 2002 09:12 To: Perl Subject: If Statement Nested Regular Exp. Any ideas why this fails. If I remove if /aged/ and just have the if /Reports ... then everything works ok. Code #!/usr/bin/perl my @files; my %age; push (@files, glob "Aged*"); push (@f

If Statement Nested Regular Exp.

2002-12-19 Thread Paul Kraus
Any ideas why this fails. If I remove if /aged/ and just have the if /Reports ... then everything works ok. Code #!/usr/bin/perl my @files; my %age; push (@files, glob "Aged*"); push (@files, glob "Receipts*"); foreach (@files){ open FILE,"<$_"; print "$_\n"; while(){ if (

Re: if statement not validating properly

2002-11-27 Thread Rob Dixon
} else { &generate_form("NOT A VALID LOCATION"); exit; } Cheers, Rob - Original Message - From: "Larry Sandwick" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, November 27, 2002 6:17 PM Subject: if statement not

Re: if statement not validating properly

2002-11-27 Thread John W. Krahn
Larry Sandwick wrote: > > In the program below the if statement that qualifies the IP address > never evaluates to be false, for what ever reason the form is always > processed. Can anybody help me with this problem? > > The code should only allow computers with certain IP'

if statement not validating properly

2002-11-27 Thread Larry Sandwick
In the program below the if statement that qualifies the IP address never evaluates to be false, for what ever reason the form is always processed. Can anybody help me with this problem? The code should only allow computers with certain IP's to access the data to be processed. I kn

Re: if statement

2002-08-12 Thread John W. Krahn
Javeed Sar wrote: > > I have a small doubt; > > My script is given below: > What it is doing is once the first condition is satisfied it is dieing, that > is if (($check_out == 0) > > I want the if statement to compare this also: > (($var5 == "Soarian_Con

Re: if statement

2002-08-12 Thread Sudarshan Raghavan
On 12 Aug 2002, Felix Geerinckx wrote: > If you initialize your hash-values with '1', you don't need the > 'exists', which makes the statement even more readable: > > if (!$check_out && $cannot_co{$var5}) { > die "..."; > } Right, should have noticed that. Thanks :-) -- To

Re: if statement

2002-08-12 Thread Felix Geerinckx
on Mon, 12 Aug 2002 13:45:21 GMT, [EMAIL PROTECTED] (Sudarshan Raghavan) wrote: > Instead of these multiple conditions why not create a hash of files > that cannot be checkedout. Something like, > my %cannot_co = ( comEPRHelp => 1, ); > > After this your condition will be > if (($check_ou

Re: if statement

2002-08-12 Thread Sudarshan Raghavan
On Mon, 12 Aug 2002, Javeed SAR wrote: > > > I have a small doubt; > > > My script is given below: > What it is doing is once the first condition is satisfied it is dieing, that > is if (($check_out == 0) > > I want the if statement to

Re: if statement

2002-08-12 Thread Felix Geerinckx
on Mon, 12 Aug 2002 07:32:48 GMT, [EMAIL PROTECTED] (Javeed Sar) wrote: > I want the if statement to compare this also: > (($var5 == "Soarian_Context_Sensitive_Coordination_File") | > ($var5 == > "comEPRHelp") | ($var5 == > "CDMS_Context_Sensitiv

if statement

2002-08-12 Thread Javeed SAR
I have a small doubt; My script is given below: What it is doing is once the first condition is satisfied it is dieing, that is if (($check_out == 0) I want the if statement to compare this also: (($var5 == "Soarian_Context_Sensitive_Coordination_File") | ($var5 == "comEPR

RE: if-statement and grep in one go

2002-06-25 Thread Marco Antonio Valenzuela Escárcega
On Tue, 2002-06-25 at 03:28, David vd Geer Inhuur tbv IPlib wrote: > > Hello, > > Thanks for the solution Bob. > Changed some stuff and have 2 questions open. > > my $line; > my (%u, %g); > open(FILE, "< ${dir}/user.perm") or print "Failed opening file $!"; ## 1 > while ($line =

RE: if-statement and grep in one go

2002-06-25 Thread Bob Showalter
> -Original Message- > From: David vd Geer Inhuur tbv IPlib > [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, June 25, 2002 6:28 AM > To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; > [EMAIL PROTECTED] > Subject: RE: if-statement and grep in one go > > > > Hello,

RE: if-statement and grep in one go

2002-06-25 Thread Felix Geerinckx
on Tue, 25 Jun 2002 10:28:07 GMT, [EMAIL PROTECTED] (David Vd Geer Inhuur Tbv Iplib) wrote: > Changed some stuff and have 2 questions open. > [code snipped] > 1) I don't like to die in my script as there are many files to >read. And if I can't open the current file I just want to >con

RE: if-statement and grep in one go

2002-06-25 Thread David vd Geer Inhuur tbv IPlib
quot;< ${dir}/user.perm"); > > my @users = ; > > close FILE; > > chomp (@users); > > > > my @out = grep {/$pwuser/} @users; > > my @out1 = grep {/$group/} @users; > > if ((!(@out)) && (!(@out1))) { print "Sorry $pwuser you have > >

Re: if-statement and grep in one go

2002-06-24 Thread drieux
On Monday, June 24, 2002, at 06:12 , Bob Showalter wrote: David's original file format info: >> an example of the file user.perm would be : >> >> user: vdgeerd, tester >> group: none, >> descr: all, > I think you need to parse this file into some structures rather > than using the simple regex a

  1   2   >