Re: if element exists in an array

2016-08-19 Thread Chas. Owens
On Fri, Aug 19, 2016 at 2:22 PM Chas. Owens wrote: > Truth. If you are checking in lots of things exist a hashset might be a > better way to go: > > my %hashset = map { ($_ => undef) } (3,1,4,2,9,0); > > my $found = exists $hashset{4} || 0; > my $not_found = exists $hashset{10} || 0; > > By sett

Re: if element exists in an array

2016-08-19 Thread Chas. Owens
Truth. If you are checking in lots of things exist a hashset might be a better way to go: my %hashset = map { ($_ => undef) } (3,1,4,2,9,0); my $found = exists $hashset{4} || 0; my $not_found = exists $hashset{10} || 0; By setting the value of the hash to be undef, you take up less space than s

Re: if element exists in an array

2016-08-19 Thread wagsworld48 via beginners
But does it need to be an array. Rethink into hash and life could be a little bit easier... Wags ;) WagsWorld Hebrews 4:15 Ph: 408-914-1341 On Aug 18, 2016, 19:41 -0700, kp...@freenet.de, wrote: > Thanks for all the replies. > Yes I found List::Util is a useful toolset. > > > On 2016/8/19 10:00,

Re: if element exists in an array

2016-08-18 Thread kpeng
Thanks for all the replies. Yes I found List::Util is a useful toolset. On 2016/8/19 10:00, Chas. Owens wrote: The any function from List::Util will also do what you want. perldoc List::Util http://perldoc.perl.org/List/Util.html#any my $found = any { $_ == 4 } (3, 1, 4, 2, 9, 0); # true my

Re: if element exists in an array

2016-08-18 Thread Chas. Owens
On Thu, Aug 18, 2016 at 9:39 PM wrote: > Hello, > > What's the better way to decide if an element exists in an array? > Something like what ruby does, > > irb(main):001:0> x=[3,1,4,2,9,0] > => [3, 1, 4, 2, 9, 0] > irb(main):002:0> x.include? 4 > => true > irb(main):003:0> x.include? 10 > => fals

Re: if element exists in an array

2016-08-18 Thread Chris Fedde
Here is one approach using a perl repl. re.pl $ my @x = qw(3 1 4 2 9 0) $VAR1 = 3; $VAR2 = 1; $VAR3 = 4; $VAR4 = 2; $VAR5 = 9; $VAR6 = 0; $ grep {$_ == 4} @x and 'true' grep {$_ == 10} @x and 'true' or 'false' On Thu, Aug 18, 2016 at 7:35 PM, wrote: > Hello, > > What's the better way to decide

Re: if element exists in an array

2016-08-18 Thread Kent Fredric
On 19 August 2016 at 13:45, Kent Fredric wrote: >if ( first { $item == 4 } @items ) { >say "Yes"; >} > Ugh, my bad. if ( first { $_ == 4 } @items ) { say "Yes"; } -- Kent KENTNL - https://metacpan.org/author/KENTNL -- To unsubscribe, e-mail: beginners-unsub

Re: if element exists in an array

2016-08-18 Thread Kent Fredric
On 19 August 2016 at 13:35, wrote: > > What's the better way to decide if an element exists in an array? > Something like what ruby does, > > irb(main):001:0> x=[3,1,4,2,9,0] > => [3, 1, 4, 2, 9, 0] > irb(main):002:0> x.include? 4 > => true > irb(main):003:0> x.include? 10 > => false > irb(main)

Re: if else elsif

2011-03-18 Thread Katie T
It would help if you could clarify what you expect the following chunk of code to achieve: my @data = ( split /;/ )[31,32,38,39,261]; if (@data[39] =~ /15/) { 2 } else { 1 }

RE: if else elsif

2011-03-17 Thread Wagner, David --- Senior Programmer Analyst --- CFS
>-Original Message- >From: Chris Stinemetz [mailto:cstinem...@cricketcommunications.com] >Sent: Thursday, March 17, 2011 14:16 >To: beginners >Subject: if else elsif > >I am trying to return new values based on if else. I understand the idea of >using if else, but I am not sure I have place

Re: if else elsif

2011-03-17 Thread Rob Dixon
On 17/03/2011 20:16, Chris Stinemetz wrote: I am trying to return new values based on if else. I understand the idea of using if else, but I am not sure I have placed in the right place. I was assuming I would want to insert it before the array is sorted. Thank you in advance. This mailing list

Re: if else elsif

2011-03-17 Thread Uri Guttman
> "CS" == Chris Stinemetz writes: CS> I am trying to return new values based on if else. I understand CS> the idea of using if else, but I am not sure I have placed in the CS> right place. I was assuming I would want to insert it before the CS> array is sorted. Thank you in advance.

Re: IF... OR... not working

2009-11-24 Thread Robert Wohlfarth
On Tue, Nov 24, 2009 at 11:12 AM, Chad Morland wrote: > I figured AND(&&) operators had to match both conditions in order to be > true, hence me trying to use OR(||). I guess it's the opposite? > > On Tue, Nov 24, 2009 at 12:03 PM, Steve Bertrand wrote: > > > Chad Morland wrote: > > > my $vhost_

Re: IF... OR... not working

2009-11-24 Thread Shawn H Corey
Chad Morland wrote: > Thanks Steve, that seemed to do the trick. > > Perhaps my reading comprehension was not up to par when I was reading up on > these operators. > > I figured AND(&&) operators had to match both conditions in order to be > true, hence me trying to use OR(||). I guess it's the o

Re: IF... OR... not working

2009-11-24 Thread Chad Morland
Thanks Steve, that seemed to do the trick. Perhaps my reading comprehension was not up to par when I was reading up on these operators. I figured AND(&&) operators had to match both conditions in order to be true, hence me trying to use OR(||). I guess it's the opposite? -CM On Tue, Nov 24, 200

Re: IF... OR... not working

2009-11-24 Thread Steve Bertrand
Chad Morland wrote: > I have a feeling I am missing something basic so I am looking to this list > for help. > > Assume the following: > > my $vhost_server_name = qw(somedomain.com); > my @vhost_server_alias_array = qw(www.somedomain.com *.somedomain.com > sub.somedomain.com); > > foreach my $vh

Re: if loop problem

2009-07-31 Thread Chas. Owens
On Fri, Jul 31, 2009 at 10:58, <98447...@student.ucc.ie> wrote: snip > [HMU09450], [1084175], [1085500], [ c], [putative thiophene snip This shows that your data is not quite what you think it is. This means one (or more) of the following things: 1. the program that is generating the file has a

Re: if loop problem

2009-07-31 Thread Shawn H. Corey
98447...@student.ucc.ie wrote: sample of the outout from perl -nle 'print join ", ", map { "[$_]" } split /\t/'datafile [HMU09420], [1082913], [1083629], [], [putative 1-acyl-SN-glycerol-3-phosphate acyltransferase] [HMU09430], [1083645], [1083860], [], [Putative hypothetical protein] [HMU09440

Re: if loop problem

2009-07-31 Thread 98447122
in, OxaA] [HMU09480], [1087848], [1088201], [ c], [Putative hypothetical protein] - Original Message - From: "Chas. Owens" To: 98447...@student.ucc.ie Cc: "Shawn H. Corey" , beginners@perl.org Subject: Re: if loop problem Date: Fri, 31 Jul 2009 10:38:26 -0400 >On

Re: if loop problem

2009-07-31 Thread Chas. Owens
On Fri, Jul 31, 2009 at 10:19, <98447...@student.ucc.ie> wrote: > This is what the file actually looks like. All fileds are > separated by tabs snip The following script has visibly correct data and works. This points to your data being the problem. Try this one-liner to see what you data really

Re: if loop problem

2009-07-31 Thread 98447122
putative secreted protein HMU0008073757617 c putative membrane protein HMU0009080729076 c UDP-glucose 4-epimerase - Original Message - From: "Shawn H. Corey" To: 98447...@student.ucc.ie Cc: beginners@perl.org Subject: Re: if loop pr

Re: if loop problem

2009-07-31 Thread Shawn H. Corey
98447...@student.ucc.ie wrote: Hi All, I am having a small problem with my if looops. I have written a small script to parse a file I have input: HMU0003025224840DNA gyrase subunit B HMU0004048415083putative membrane protein HMU000505080

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 printing. >>> When the program reaches the line

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 keeps g

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 ) { print " > that

Re: if (match) problem

2009-03-10 Thread Dermot
2009/3/10 Jim Gibson : > On 3/10/09 Tue  Mar 10, 2009  7:59 AM, "Dermot" > scribbled: > >> Hi, >> >> I am not getting the results that I expect from this test and I am not >> sure why. If I run the script below I get: >> >> 1..3 >> Line=???/FOO BAR, Name=Joe Smo M="???" >> ok 1 - handle_name ???/F

Re: if (match) problem

2009-03-10 Thread Jim Gibson
On 3/10/09 Tue Mar 10, 2009 7:59 AM, "Dermot" scribbled: > Hi, > > I am not getting the results that I expect from this test and I am not > sure why. If I run the script below I get: > > 1..3 > Line=???/FOO BAR, Name=Joe Smo M="???" > ok 1 - handle_name ???/FOO BAR > Line=change accordingly /

Re: if condition question

2008-10-16 Thread Tom Yarrish
On Oct 16, 2008, at 8:08 AM, "John W. Krahn" <[EMAIL PROTECTED]> wrote: sanket vaidya wrote: Hi all, This is the exact same question you asked 16 days ago. Did you not like the answer you got then? (Which is the same as the answers you are getting now.) John -- Perl isn't a toolbox

Re: if condition question

2008-10-16 Thread John W. Krahn
sanket vaidya wrote: Hi all, This is the exact same question you asked 16 days ago. Did you not like the answer you got then? (Which is the same as the answers you are getting now.) John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools

Re: if condition question

2008-10-16 Thread Paul Johnson
On Thu, Oct 16, 2008 at 03:20:13AM -0700, Jeff Pang wrote: > --- On Thu, 10/16/08, sanket vaidya <[EMAIL PROTECTED]> wrote: > > From: Chas. Owens [mailto:[EMAIL PROTECTED] > > > > > What you really want to say is > > > > > > print $string eq "test" ? "correct" : ""; print "correct" if $str eq "te

Re: if condition question

2008-10-16 Thread Chas. Owens
On Thu, Oct 16, 2008 at 06:12, sanket vaidya <[EMAIL PROTECTED]> wrote: snip > How can I write > > if ($string eq "test") { >print "correct" > } else { >die "others" > } > > In above way? snip In general, the ternary operator should only be used when choosing between two (or more in the ca

RE: if condition question

2008-10-16 Thread Jeff Pang
--- On Thu, 10/16/08, sanket vaidya <[EMAIL PROTECTED]> wrote: > From: sanket vaidya <[EMAIL PROTECTED]> > Subject: RE: if condition question > To: beginners@perl.org > Date: Thursday, October 16, 2008, 6:12 AM > -Original Message- > From: Chas. Owens [ma

RE: if condition question

2008-10-16 Thread sanket vaidya
-Original Message- From: Chas. Owens [mailto:[EMAIL PROTECTED] Sent: Thursday, October 16, 2008 2:36 PM To: sanket vaidya Cc: beginners@perl.org Subject: Re: if condition question On Thu, Oct 16, 2008 at 04:54, sanket vaidya <[EMAIL PROTECTED]> wrote: snip > Now when I write

Re: if condition question

2008-10-16 Thread Peter Scott
On Thu, 16 Oct 2008 14:24:56 +0530, sanket vaidya wrote: > use warnings; > use strict; Good! use warnings has shown you a bug in your code. > my $string = "test"; > > $string eq "test" ? print "correct" : ""; > > > Output: > > Correct > > Useless use of constant in void context at line 5.

Re: if condition question

2008-10-16 Thread Jeff Pang
--- On Thu, 10/16/08, sanket vaidya <[EMAIL PROTECTED]> wrote: > From: sanket vaidya <[EMAIL PROTECTED]> > Subject: if condition question > To: beginners@perl.org > Date: Thursday, October 16, 2008, 4:54 AM > Hi all, > > > > Kindly go through the below codes: > > > > use warnings; > >

Re: if condition question

2008-10-16 Thread Chas. Owens
On Thu, Oct 16, 2008 at 05:05, Chas. Owens <[EMAIL PROTECTED]> wrote: snip > What the ternary operator* is saying is roughly equivalant to snip Whoops, left out the footnote: * http://perldoc.perl.org/perlop.html#Conditional-Operator -- Chas. Owens wonkden.net The most important skill a program

Re: if condition question

2008-10-16 Thread Chas. Owens
On Thu, Oct 16, 2008 at 04:54, sanket vaidya <[EMAIL PROTECTED]> wrote: snip > Now when I write the same if condition in program as below, I get warning > along with output. snip > $string eq "test" ? print "correct" : ""; snip > Useless use of constant in void context at line 5. snip What the ter

Re: if condition question

2008-09-29 Thread John W. Krahn
sanket vaidya wrote: Hi all, Hello, Kindly go through the below codes: use warnings; use strict; my $string = "test"; if ($string eq "test") { print "correct"; } Output: Correct Now when I write the same if condition in program as below, I get warning along with output. use warnings; use

Re: If anyone doesn't mind helping me optimize this code...

2007-08-23 Thread eselk
Thanks to all who replied. I figured reading (and writing) one byte at a time was the bottleneck, but mostly I'm not familiar with perl's buffer handling functions/methods... I just knew enough to compare one byte at a time at least (and I guess even that wasn't optimal since I was using "eq" inst

Re: If anyone doesn't mind helping me optimize this code...

2007-08-23 Thread John W. Krahn
Rob Dixon wrote: John W. Krahn wrote: In perl you almost *never* need to use the eof() function. That is usually written as: while ( read IN, $buffer, $blksize ) { But even that doesn't report any errors that read() may encounter. while ( my $read = read IN, $buffer, $blksize ) {

Re: If anyone doesn't mind helping me optimize this code...

2007-08-23 Thread Rob Dixon
John W. Krahn wrote: In perl you almost *never* need to use the eof() function. That is usually written as: while ( read IN, $buffer, $blksize ) { But even that doesn't report any errors that read() may encounter. while ( my $read = read IN, $buffer, $blksize ) { defined $read

Re: If anyone doesn't mind helping me optimize this code...

2007-08-22 Thread John W. Krahn
[EMAIL PROTECTED] wrote: I'm a C/C++ programmer, with a perl script I'm trying to optimize. I don't know enough about perl syntax and string/buffer handling functions to feel comfortable doing this on my own. Perl's open()/read() functions are equivalent to C's fopen()/fread() and so the IO i

Re: If anyone doesn't mind helping me optimize this code...

2007-08-22 Thread Mr. Shawn H. Corey
[EMAIL PROTECTED] wrote: $hostname is set to whatever I need to inject by some code above this part, and $search is the data I need to replace with $hostname (they are always the same length, so it never changes the size of the downloaded file). The loop at the end is what I imagine needs to be

Re: if () VS while ()

2007-05-30 Thread jeevs
On May 29, 7:39 pm, [EMAIL PROTECTED] (Jeevs) wrote: > Yeah i tested it and it works manuaaly (dats the reason i used the > word automatically in my previous post) > Was wondering why dat dosnt work > Thanks TOM for the reply Thanks Paul That really helped.. -- To unsubscribe, e-mail: [

Re: if () VS while ()

2007-05-29 Thread jeevs
Yeah i tested it and it works manuaaly (dats the reason i used the word automatically in my previous post) Was wondering why dat dosnt work Thanks TOM for the reply -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: if () VS while ()

2007-05-29 Thread Paul Lalli
On May 29, 9:29 am, [EMAIL PROTECTED] (Jeevs) wrote: > If () ::: if doesn't not fill the $_ variable with contents of > files first line automatically. > While () ::: while do fill the $_ to content of the files first > line automatically. > > i.e > open FH, "name.txt" or die "cant open"; > if (){

Re: if () VS while ()

2007-05-29 Thread Tom Phoenix
On 29 May 2007 06:29:55 -0700, jeevs <[EMAIL PROTECTED]> wrote: If () ::: if doesn't not fill the $_ variable with contents of files first line automatically. It doesn't happen automatically, but you can do it manually. Do you want this? if (defined($_ = )) { ... } Hope this helps! --Tom P

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 condition is the same as this: $project_name eq 'Proj

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 ('Proj1' || '') && $task_name eq '') > > Less typing... : ) No. Because

Re: if you use a module does this happen?

2006-10-14 Thread Mumia W.
On 10/14/2006 12:03 PM, Jesse Engel wrote: [...] when i would call $ftp->rget() i would get an error that said basically there is no rget method with net::ftp. so my question is this: by using net::ftp::recursive, do you get all of the methods [...] Read the documentation for Net::FTP::Recur

Re: if you use a module does this happen?

2006-10-14 Thread lawrence
There was one e.e. cummings in the world. You're not him. Use mixed case. Whitespace is our friend. > I was using Net::FTP to do something, and it wasn't working because > I couldn't get a recursive listing of the files I wanted to > download, like you would with File::Find. Well, I found >

Re: if you use a module does this happen?

2006-10-14 Thread Tom Phoenix
On 10/14/06, Jesse Engel <[EMAIL PROTECTED]> wrote: by using net::ftp::recursive, do you get all of the methods (not really comfortable with oo programming yet so i hope i stated that right) included with net::ftp? It's not the case generally that loading module Foo::Bar::Baz also loads Foo::B

RE: if-clause again

2006-08-02 Thread Charles K. Clarkson
Dr. Claus-Peter Becke wrote: : first of all a question without respect to my problem. what does : HTH mean? Hope that helps or, sometimes here in Texas it means hotter than Hell. : i would like of having returned a string value as printed by : "print @row". That is in a loop. There may

Re: if-clause again

2006-08-01 Thread Mumia W.
On 08/01/2006 08:13 AM, Dr. Claus-Peter Becke wrote: databaserequest_noun($col, $table, $case) is a self written function based on the dbi manual's proposals. here's the code: sub databaserequest_noun { my ($col,$table,$case) = @_; my $database = "lexikon"; my $hostname = "localhost"; my $dsn

Re: if-clause again

2006-08-01 Thread Tom Phoenix
On 8/1/06, Dr. Claus-Peter Becke <[EMAIL PROTECTED]> wrote: databaserequest_noun($col, $table, $case) is a self written function based on the dbi manual's proposals. here's the code: sub databaserequest_noun { ... $dbh->disconnect; } maybe anybody detects the reason why the return value become

RE: if-clause again

2006-08-01 Thread Charles K. Clarkson
Dr. Claus-Peter Becke wrote: : maybe anybody detects the reason why the return value becomes 1 Perl returns values from subroutines implicitly and explicitly. A 'return' statement is used to send an explicit return. Otherwise, the return value of the last statement is returned implicitly. Exp

Re: if-clause again

2006-08-01 Thread Dr.Ruud
"Dr. Claus-Peter Becke" schreef: > databaserequest_noun($col, $table, $case) is a self written function > based on the dbi manual's proposals. here's the code: > > sub databaserequest_noun > { > my ($col,$table,$case) = @_ ; > my ($database, $hostname) = ('lexikon', 'localhost') ; > my

Re: if clause

2006-07-31 Thread Mumia W.
On 07/31/2006 11:29 AM, Dr. Claus-Peter Becke wrote: Mumia W. schrieb: On 07/31/2006 07:20 AM, Dr. Claus-Peter Becke wrote: dear mumia w, thank for your support. as you supposed the values aren't equal. the subroutine's argument is "1". had databaserequest_noun been interpreted in scalar con

Re: if clause

2006-07-31 Thread Mumia W.
On 07/31/2006 03:45 AM, Dr. Claus-Peter Becke wrote: dear members, using a subroutine's resulting argument in an if-clause i compare this string with another term. but although each of the term has the value of the other i don't achieve the result i'm looking for. if (($Q::partofspeech eq 'n

RE: if clause

2006-07-31 Thread Charles K. Clarkson
Dr. Claus-Peter Becke wrote: : although for example the values of &databaserequest_noun : and $Q::lexicalentry both are 'Italy' i get the resulting : message "the entry isn't part of the database". what's : going wrong? databaserequest_noun($col, $table, $case) and $Q::lexicalentry are not bo

Re: if(!defined construct

2006-03-01 Thread Tom Phoenix
On 3/1/06, David Gilden <[EMAIL PROTECTED]> wrote: > I can not seem to get the following script to return the correct response. > Could someone point where I am off. You forgot this line: return "the correct response"; # :-) Actually, now that my telepathy hat is on straight, I think y

Re: IF statements and modules - do they mix?

2005-07-29 Thread Scott R. Godin
John W. Krahn wrote: Scott R. Godin wrote: Dave Adams wrote: Does perl allow you to conditionally include a module? [snip] If you're using Perl 5.7.3 or later you can use if $DEBUG, diagnostics -verbose; details in 'perldoc if' :) And all you people who answered with something other

Re: IF statements and modules - do they mix?

2005-07-27 Thread John W. Krahn
Scott R. Godin wrote: > Dave Adams wrote: >> Does perl allow you to conditionally include a module? >> >> For example: >> >> #!/usr/bin/perl -w >> use strict; >> my $DEBUG = 0; >> if (DEBUG) { >> use diagnostics; >> } >> my $filename = "test$$.txt"; >> open (FH , ">$filename") || die "error: $!

Re: IF statements and modules - do they mix?

2005-07-27 Thread Scott R. Godin
Dave Adams wrote: Does perl allow you to conditionally include a module? For example: #!/usr/bin/perl -w use strict; my $DEBUG = 0; if (DEBUG) { use diagnostics; } my $filename = "test$$.txt"; open (FH , ">$filename") || die "error: $!"; print (FH "hi"); close (FH); Although this is a simp

RE: IF statements and modules - do they mix?

2005-07-27 Thread Bob Showalter
Charles K. Clarkson wrote: > Dave Adams wrote: > > > Does perl allow you to conditionally include a module? > > In general, you can load a module at runtime by using > 'require' and manually running its import() sub routine. > > require Module; > Module::import( 'I

RE: IF statements and modules - do they mix?

2005-07-27 Thread Charles K. Clarkson
Dave Adams wrote: : Does perl allow you to conditionally include a module? In general, you can load a module at runtime by using 'require' and manually running its import() sub routine. require Module; Module::import( 'Import list' ); : For example: : : #!/usr/bi

Re: IF statements and modules - do they mix?

2005-07-26 Thread John W. Krahn
Dave Adams wrote: > Does perl allow you to conditionally include a module? > > For example: > > #!/usr/bin/perl -w > use strict; > my $DEBUG = 0; > if (DEBUG) { > use diagnostics; > } > my $filename = "test$$.txt"; > open (FH , ">$filename") || die "error: $!"; > print (FH "hi"); > close (FH)

RE: RE: if else question

2005-04-28 Thread Brian Volk
> OK I get it now. I have made a few changes to your original, > particular because I don't liek to use @ARGV with in a > script. I also changes the way you store file, moving it into > a hash structure so comparisons are much faster. Feel free to > modifie as is. > > HTH, > Mark G. > > #!PER

Re: RE: if else question

2005-04-28 Thread mgoland
- Original Message - From: Brian Volk <[EMAIL PROTECTED]> Date: Thursday, April 28, 2005 12:45 pm Subject: RE: if else question > > > > Hi All, > > Hello, > > > > > > > > The first time I wrote this if else statement I wrote it &g

RE: if else question

2005-04-28 Thread Brian Volk
> > Hi All, > Hello, > > > > > The first time I wrote this if else statement I wrote it > > correctly... now > > I've confused myself... :~) > That will happen often ! > > > > If the "if" statement returns false the program writes that line > > in the file > > to $error_log for every $file

Re: if else question

2005-04-28 Thread mgoland
- Original Message - From: Brian Volk <[EMAIL PROTECTED]> Date: Thursday, April 28, 2005 11:27 am Subject: if else question > Hi All, Hello, > > The first time I wrote this if else statement I wrote it > correctly... now > I've confused myself... :~) That will happen often ! > > I

Re: If you´re in the mood, help me.

2004-12-10 Thread Randy W. Sims
[EMAIL PROTECTED] wrote: Hi guys, As you know, i´m having some problems to make this thing work. I have to write a script that automatically sends a code and get the some information according to that code. I mean, this script has to automatically fill in a formfield and get the result. But I just

Re: If you´re in the mood, help me.

2004-12-10 Thread Philipp Traeder
On Friday 10 December 2004 22:24, [EMAIL PROTECTED] wrote: > Hi guys, Hi Diogo, > > As you know, i´m having some problems to make this thing work. I have to > write a script that automatically sends a code and get the some > information according to that code. I mean, this script has to > automat

RE: if -s clause

2004-06-08 Thread DBSMITH
"'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]> cc: [EMAIL PROTECTED] Subject:RE: if -s clause [EMAIL PROTECTED] wrote: > ok so here is what I did and it is now working. > > one thing I do not fully understand is the diff between > my $s

RE: if -s clause

2004-06-08 Thread Bob Showalter
[EMAIL PROTECTED] wrote: > ok so here is what I did and it is now working. > > one thing I do not fully understand is the diff between > my $svsel = select; select OUT ; $|=1; > and > select (select(OUT), $| = 1 ) [0] ); > > the second line works while the first does not and > from my understandi

RE: if -s clause

2004-06-08 Thread DBSMITH
not open runfile: $!;" } close (RUNFILE); Derek B. Smith OhioHealth IT UNIX / TSM / EDM Teams 614-566-4145 "Wiggins d Anconia" <[EMAIL PROTECTED]> 06/08/2004 11:06 AM To: [EMAIL PROTECTED], [EMAIL PROTECTED] cc: Sub

Re: if -s clause

2004-06-08 Thread DBSMITH
yes -f is a typo! I want to use -s Derek B. Smith OhioHealth IT UNIX / TSM / EDM Teams 614-566-4145 "Wiggins d Anconia" <[EMAIL PROTECTED]> 06/08/2004 11:02 AM To: [EMAIL PROTECTED], [EMAIL PROTECTED] cc: Subject:Re: if -s clause Pl

RE: if -s clause

2004-06-08 Thread Wiggins d Anconia
Please bottom post > > ok I can take some blame! : ) I made some changes and I am still not > getting the print message. > You made *some* changes, but you still haven't listened to what Bob and I have said, and made the changes we have pointed out specifically. That is becoming tedious.

Re: if -s clause

2004-06-08 Thread Wiggins d Anconia
Please bottom post > > I have tried all three methods if -s OUT, if -f $filename and if -s > @arrayname with no evail. See Bob's e-mail too, but why did the -s all of a sudden become a -f in the above statement? If this is not a typo, the -f will be true on the file if it exists an

RE: if -s clause

2004-06-08 Thread DBSMITH
$| = 1; print OUT "@ftapes"; if ( -s OUT ) { print "file is greater than 0 bytes \n"; } Bob Showalter <[EMAIL PROTECTED]> 06/08/2004 09:45 AM To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTE

RE: if -s clause

2004-06-08 Thread Bob Showalter
[EMAIL PROTECTED] wrote: > I have tried all three methods if -s OUT, if -f $filename and if > -s @arrayname with no evail. > I did make a test.pl file so that I am just testing whether the file > is greater than 0 bytes. Here is the code. > autoflush is turned on. Is this the correct spot

Re: if -s clause

2004-06-08 Thread DBSMITH
| = 1; print OUT "@ftapes"; if ( -s OUT ) { print "file is greater than 0 bytes \n"; } "Wiggins d'Anconia" <[EMAIL PROTECTED]> 06/07/2004 10:36 PM To: [EMAIL PROTECTED] cc: [EMAIL

Re: if -s clause

2004-06-07 Thread Wiggins d'Anconia
Please bottom post. [EMAIL PROTECTED] wrote: I originally had if ( -s OUT ) { print "file is greater than 0 bytes \n"; } so is this what I want to use? Because I just ran it and it is still not printing this string. Well theoretically that might work since the def in the docs indicates

Re: if -s clause

2004-06-07 Thread Wiggins d Anconia
> > was hoping for some add'l assistance. I deleted the bulk of the code out > b/c I cannot get it to send me the results of the if clause. Any ideas? > I did verify the file is being appended to and is greater that 0 bytes. > The if -s on the array is running b/c my else clause is creating the

Re: if (!pipe_is_empty) { while(<>) {do_cool_stuff();} }

2004-03-18 Thread Randy W. Sims
On 03/19/04 02:30, Bryan Harris wrote: I have a handy-dandy script that replaces text in files. Very slick: % replace 'dog' 'cat' myfile.txt 1. myfile.txt (1 change) But I'd also like it to be able to act on a pipe if there is one: % cat myfile.txt | replace 'dog' 'cat' My cat has fleas. The pr

Re: if (-d .....

2003-10-08 Thread Tore Aursand
On Wed, 08 Oct 2003 12:39:40 +0200, Daniel Stellwagen wrote: > if (-d $file) > > What does it mean, and are there more Try 'perldoc -f -d'. -- Tore Aursand <[EMAIL PROTECTED]> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: if (-d .....

2003-10-08 Thread Daniel Stellwagen
Thank you Stephan :-) > > This will return 'true' is $file contains the location of a > directory. More information can be found on this in the > 'perlfunc' manpage in the 'Alphabetical Listing of Perl > Functions' section. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional command

RE: if (-d .....

2003-10-08 Thread Stephen Hardisty
> Hi EVERYBODY, Hi Dr Nick > > i saw this "-d" switch in an "if" statement. > > if (-d $file) > > What does it mean, and are there more > this kind of switches and where can I find information about them. This will return 'true' is $file contains the location of a directory. More informa

RE: if-else-statement

2003-09-03 Thread Dan Muey
> Hello Hello again. > > Below is a portion of a script that displays a table. The > argument passed by param() determines the number of rows the > table should display. > For some unknown reason, the value of param() seem to behave > strangely. It at times the value does not change; even

Re: if exists with array

2003-02-12 Thread Janek Schleicher
On Tue, 11 Feb 2003 17:31:42 +, Felix Geerinckx wrote: > on di, 11 feb 2003 17:22:20 GMT, Dan Muey wrote: > >> if(exists $hash{$key}) { ... } >> >> is there a way to do that with arrays? >> IE >> if there is an array element that is 'bob' then do this :: >> without having to do a foreach on

RE: if exists with array

2003-02-11 Thread Kipp, James
> > Unless the arrays become too big, > > grep is your friend > > (perldoc -f grep) > > According to the FAQ I mentioned in another reply, it isn't ;-) yep, i spoke to soon as well. grep has always worked well for me. so there is the quick and dirty way, then the right way :) from the faq: Ple

RE: if exists with array

2003-02-11 Thread Kipp, James
> if(exists $hash{$key}) { ... } > > is there a way to do that with arrays? > IE > if there is an array element that is 'bob' then do this :: > without having to do a foreach on the array > > basically an easier/better/faster/ way to do this : > > @search_for_these = > @search_me =

Re: if exists with array

2003-02-11 Thread Felix Geerinckx
on di, 11 feb 2003 15:54:36 GMT, Janek Schleicher wrote: > On Tue, 11 Feb 2003 11:22:20 -0600, Dan Muey wrote: > >> is there a way to do that with arrays? >> IE >> if there is an array element that is 'bob' then do this :: >> without having to do a foreach on the array > > Unless the arrays beco

Re: if exists with array

2003-02-11 Thread Felix Geerinckx
on di, 11 feb 2003 17:22:20 GMT, Dan Muey wrote: > if(exists $hash{$key}) { ... } > > is there a way to do that with arrays? > IE > if there is an array element that is 'bob' then do this :: > without having to do a foreach on the array See perldoc -q "array contains" in the Frequently

Re: if exists with array

2003-02-11 Thread Janek Schleicher
On Tue, 11 Feb 2003 11:22:20 -0600, Dan Muey wrote: > is there a way to do that with arrays? > IE > if there is an array element that is 'bob' then do this :: > without having to do a foreach on the array Unless the arrays become too big, grep is your friend (perldoc -f grep) If they become too

Re: if structure voiding string when condition not met?

2002-12-19 Thread Rob Dixon
You're quite right Ed, it's safer to copy the parameters at the start of a subroutine. Behind the scenes the parameter values are passed by reference, so modifying @_ directly will change the value used as the actual parameter in the calling code. Copying 'my @params = @_' will give you a local cop

Re: if structure voiding string when condition not met?

2002-12-19 Thread Paul Johnson
On Thu, Dec 19, 2002 at 02:32:15PM -0500, Paul Kraus wrote: > When I run this code > > &buildexcel("Age"); > ... > sub buildexcel{ > ... > my $sheet=$book->worksheets('AgeRaw') if ($_[0] eq "Age"); > my $sheet=$book->worksheets('ReceiptsRaw') if ($_[0] eq "Cash"); Get rid of the "my"

RE: if structure voiding string when condition not met?

2002-12-19 Thread Ed Christian
Correct me if I'm wrong group (I'm still a Perl novice myself), but whenever one passes an argument to a subroutine, shouldn't one always set local variables to $_[x]? Or at the very least add my @params = @_? Paul: My suggestion is to add "my $param = $_[0];" as the first line of sub buildexcel,

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){ >

  1   2   3   >