Re: Checking if a website is up doesn't work correctly

2018-02-24 Thread David Precious
On Sat, 17 Feb 2018 18:21:26 +0100 Manfred Lotz wrote: > Thanks. The attached program does better as https://notabug.org > works. Only http://scripts.sil.org doesn't work. It seems there are > special checks active on that site. Yeah, some sites block user-agents recognised as robots, scripts

Re: Checking if a website is up doesn't work correctly

2018-02-17 Thread Manfred Lotz
On Thu, 15 Feb 2018 05:46:33 -0600 Mike Flannigan wrote: > See if some version of the attached program > gives the results you expect. > > > Mike > > Thanks. The attached program does better as https://notabug.org works. Only http://scripts.sil.org doesn't work.

Re: Checking if a website is up doesn't work correctly

2018-02-15 Thread Mike Flannigan
See if some version of the attached program gives the results you expect. Mike On 2/13/2018 8:33 PM, beginners-digest-h...@perl.org wrote: I tried WWW::Mechanize, and (of course) got also 403. Really strange. Is there another tool I could use for checking? I mean some tool in the Perl

Re: Checking if a website is up doesn't work correctly

2018-02-13 Thread Andy Bach
; > > > > On Tue, Feb 13, 2018 at 11:33 AM, Manfred Lotz > > wrote: > > > > > On Tue, 13 Feb 2018 10:47:42 -0600 > > > Andy Bach wrote: > > > > > > > The site doesn't like 'head' requests? get works > > > &g

Re: Checking if a website is up doesn't work correctly

2018-02-13 Thread Manfred Lotz
On Tue, 13 Feb 2018 10:47:42 -0600 > > Andy Bach wrote: > > > > > The site doesn't like 'head' requests? get works > > > #!/usr/bin/perl > > > > > > use strict; > > > use warnings; > > > > > > use LWP::Simple

Re: Checking if a website is up doesn't work correctly

2018-02-13 Thread Andy Bach
t;https://shlomif.github.io/";; > > my $url="http://www.notabug.org/";; > > print "$url is ", ( > > (! get($url)) ? "DOWN" > > : "up" > > ), "\n"; > > > >

Re: Checking if a website is up doesn't work correctly

2018-02-13 Thread Manfred Lotz
my $url="http://www.notabug.org/";; > print "$url is ", ( > (! get($url)) ? "DOWN" > : "up" > ), "\n"; > > $ is_it_up.pl > http://www.notabug.org/ is up > You are right.

Re: Checking if a website is up doesn't work correctly

2018-02-13 Thread Andy Bach
ot;DOWN" : "up" ), "\n"; $ is_it_up.pl http://www.notabug.org/ is up On Tue, Feb 13, 2018 at 5:25 AM, Manfred Lotz wrote: > Hi there, > Somewhere I found an example how to check if a website is up. > > Her

Re: Checking if a website is up doesn't work correctly

2018-02-13 Thread Shlomi Fish
Hi Manfred! On Tue, 13 Feb 2018 12:25:31 +0100 Manfred Lotz wrote: > Hi there, > Somewhere I found an example how to check if a website is up. > > Here my sample: > > #! /usr/bin/perl > > use strict; > > use LWP::Simple; > my $url="https://notabug.

Checking if a website is up doesn't work correctly

2018-02-13 Thread Manfred Lotz
Hi there, Somewhere I found an example how to check if a website is up. Here my sample: #! /usr/bin/perl use strict; use LWP::Simple; my $url="https://notabug.org";; if (! head($url)) { die "$url is DOWN" } Running above code I get https://notabug.org is DOWN!!

Re: Equivalents statements using if and unless

2017-03-29 Thread SSC_perl
> On Mar 28, 2017, at 1:58 PM, Uri Guttman wrote: > > the only difference i see is using defined in the 2nd line. Thanks, Uri. Yeah, I got overly aggressive there. > also i would test $field ne 'categories' first as if that is true why even > test $out-

Re: Equivalents statements using if and unless

2017-03-29 Thread Илья Рассадин
Hi! First of all, using unless with complex logic inside the condition, especially using negatives (unless not...) is much harder to read and understand than using if. See http://stackoverflow.com/a/3048787 and of course see original adwise from Conway's perl best practices

Re: Equivalents statements using if and unless

2017-03-28 Thread Uri Guttman
On 03/28/2017 04:46 PM, SSC_perl wrote: I could use another set of eyes on this. Could someone please double check these two sets of conditions and let me know if the first is equivalent to the second? I believe they are, but I don’t want to take any chances. # Both of these should

Equivalents statements using if and unless

2017-03-28 Thread SSC_perl
I could use another set of eyes on this. Could someone please double check these two sets of conditions and let me know if the first is equivalent to the second? I believe they are, but I don’t want to take any chances. # Both of these should be equivalent. $out->{$field} =~ s/``

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 $

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 t

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 >

Re: if element exists in an array

2016-08-18 Thread Chris Fedde
llo, > > 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 > => fa

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 -- T

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

if element exists in an array

2016-08-18 Thread kpeng
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 => false irb(main):004:0> quit I

Re: Perl sort for reverse numeric if numbers and text are in a string, numbers first

2016-03-09 Thread Brock Wilcox
t;); my @b = sort { $a <=> $b } @a; say join("\n",@b)' 12 hi 37 b 123 c 187 a You can scope this if you like: my @result; { no warnings 'numeric'; @result = sort { $a <=> $b } @source; } You could also force the strin

Re: Perl sort for reverse numeric if numbers and text are in a string, numbers first

2016-03-08 Thread Shawn H Corey
On Tue, 8 Mar 2016 13:29:40 -0800 Kenneth Wolcott wrote: > How do I call the built-in Perl sort function on an array of strings > where the string is composed of one or more digits, followed by a tab > which is followed by a string and I want the results to be sorted in > reverse numeric order?

Re: Perl sort for reverse numeric if numbers and text are in a string, numbers first

2016-03-08 Thread Andrew Solomon
://perldoc.perl.org/functions/sort.html and I still > don't know the right answer to this question. I suppose if I disable > warnings, then it works ok? > > The GNU sort (Cygwin/Linux) function does not complain about numbers > followed by strings for the data when requested with reve

Perl sort for reverse numeric if numbers and text are in a string, numbers first

2016-03-08 Thread Kenneth Wolcott
and I still don't know the right answer to this question. I suppose if I disable warnings, then it works ok? The GNU sort (Cygwin/Linux) function does not complain about numbers followed by strings for the data when requested with reverse sort and just does it. The "$b <=> $a

What is the Perl equivalent of "net user username \domain" if I am on Linux or Mac?

2016-03-07 Thread Kenneth Wolcott
Hi; What is the Perl equivalent of "net user username \domain" if I am on Linux or Mac? None of our Linux or Mac machines are a member of the specific domain in question. Do have to obtain the name of the AD/LDAP server and obtain some kind of credentials for me to inqui

Re: sure would be nice if Perl had trace command built-in

2015-12-22 Thread Dermot
I tend to use Strawberry perl these days and would certainly recommend it. Regarding the file paths you mentioned, the double back slash is correct but also difficult to read. I change my windows scripts to use File::Spec paths whenever I have to revisit them. This makes paths portable and easy on

Re: sure would be nice if Perl had trace command built-in

2015-12-12 Thread Mike Flannigan
On 12/10/2015 5:40 AM, beginners-digest-h...@perl.org wrote: On Mon, Dec 7, 2015 at 6:33 PM, Brock Wilcox wrote: >Give devel::trace or devel::tracemore a try:) Is it possible to install this from Active State repository without having an-up-date ActiveState Perl DevKit license? Thanks,

Re: sure would be nice if Perl had trace command built-in

2015-12-08 Thread Ken Slater
dead code and duplicate code. There are weird dependencies here > > and there on Cygwin. Apparently there was an earlier (still present?) > > dependency on MKTools. Some scripts need to be modified prior to > > first build on a new branch. The builds sometimes work fine and &g

Re: sure would be nice if Perl had trace command built-in

2015-12-07 Thread Kenneth Wolcott
this from Active State repository without >> having an-up-date ActiveState Perl DevKit license? Hi Brock; Thanks so much for the tip! It helps a lot! I think I'll have to thank the author directly. Now if the code was only in Perl instead of a chain of bash to Perl t

Re: sure would be nice if Perl had trace command built-in

2015-12-07 Thread Brock Wilcox
I don't know. But I think that worst case you can just download the single file from this library and add it to your application directly. It requires no compilation or anything. https://metacpan.org/source/MJD/Devel-Trace-0.12/Trace.pm --Brock On Mon, Dec 7, 2015 at 9:39 PM, Kenneth Wolcott wr

Re: sure would be nice if Perl had trace command built-in

2015-12-07 Thread Kenneth Wolcott
On Mon, Dec 7, 2015 at 6:33 PM, Brock Wilcox wrote: > Give devel::trace or devel::tracemore a try :) Is it possible to install this from Active State repository without having an-up-date ActiveState Perl DevKit license? Thanks, Ken Wolcott -- To unsubscribe, e-mail: beginners-unsubscr...@perl.

Re: sure would be nice if Perl had trace command built-in

2015-12-07 Thread Kenneth Wolcott
there was an earlier (still present?) > dependency on MKTools. Some scripts need to be modified prior to > first build on a new branch. The builds sometimes work fine and > sometimes fail in strange ways. > > It would be nice if there was a trace facility built-in to Perl that &

Re: sure would be nice if Perl had trace command built-in

2015-12-07 Thread Brock Wilcox
s here > and there on Cygwin. Apparently there was an earlier (still present?) > dependency on MKTools. Some scripts need to be modified prior to > first build on a new branch. The builds sometimes work fine and > sometimes fail in strange ways. > > It would be nice if there w

sure would be nice if Perl had trace command built-in

2015-12-07 Thread Kenneth Wolcott
o first build on a new branch. The builds sometimes work fine and sometimes fail in strange ways. It would be nice if there was a trace facility built-in to Perl that I could enable that would tell me each line number of each script that was currently executing. I'd love to replace al

Re: why is if (! @ARGV) skipped

2014-12-06 Thread Harry Putnam
Brandon McCaig writes: > Hope that helps. Yes it does. Thanks for the continuing review and criticism much needed in my case... -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: why is if (! @ARGV) skipped

2014-11-29 Thread Brandon McCaig
On Fri, Nov 28, 2014 at 9:40 AM, Brandon McCaig wrote: > # Protip: I'm not sure which is better, interpolating $status > # into the format string, or passing it as an argument. I'm > # sure it's negligible in this case. > printf "<%-60s> $status\n", $abs_path; I lied. To be safe $

Re: why is if (! @ARGV) skipped

2014-11-28 Thread Brandon McCaig
On Tue, Nov 18, 2014 at 05:46:15PM -0500, Harry Putnam wrote: > #!/usr/bin/perl > > use strict; > use warnings; > > if (!@ARGV) { Alternatively to the @ARGV == 0 suggested by others, there's always: unless(@ARGV) { ... } It's a matter of taste. Nothing really w

Re: why is if (! @ARGV) skipped

2014-11-19 Thread Kent Fredric
d up copy-pasting it not fully understanding what it does. Usually my workflow is a) See if there's a CPAN module that does it b) Talk to somebody who knows better. Don't be afraid of asking questions, its just asking the right questions and the right people where it gets complicated =)

Re: why is if (! @ARGV) skipped

2014-11-19 Thread Harry Putnam
Harry Putnam writes: > Carl Inglis writes: > >> Interesting - in perl 5.10.1 on my system it works as expected. >> >> One point to note, your "$myscript" in your usage should be escaped >> otherwise you get an error. > > No. That changed in some previous version a while ago I > believe... any w

Re: why is if (! @ARGV) skipped

2014-11-19 Thread Harry Putnam
e. [...] Kent Fredric writes: > On 19 November 2014 11:46, Harry Putnam wrote: > >> Only thing I did to debug was to make sure `use File::Find; comes >> after if (!@ARGV), but that seems not to matter. >> > > That will be because 'use' is processed during BE

Re: why is if (! @ARGV) skipped

2014-11-18 Thread Rob Dixon
On 18/11/2014 22:46, Harry Putnam wrote: I'll probably be battered for general poor perlmanship but still risking posting my whole script (fairly brief). The problem I'm having with it, that I don't see how to debug is that it breaks out on code inside Find.pm instead of breakin

Re: why is if (! @ARGV) skipped

2014-11-18 Thread Kent Fredric
On 19 November 2014 11:46, Harry Putnam wrote: > Only thing I did to debug was to make sure `use File::Find; comes > after if (!@ARGV), but that seems not to matter. > That will be because 'use' is processed during BEGIN { }, while your condition is during the main executi

Re: why is if (! @ARGV) skipped

2014-11-18 Thread Carl Inglis
don't see how to debug is that > it breaks out on code inside Find.pm instead of breaking out on the > if clause designed to catch the advent of user forgetting to supply a > target directory. > > The `if (!@ARGV) {[...] bleh; exit}' thing. > > I'm pretty sure it is

why is if (! @ARGV) skipped

2014-11-18 Thread Harry Putnam
I'll probably be battered for general poor perlmanship but still risking posting my whole script (fairly brief). The problem I'm having with it, that I don't see how to debug is that it breaks out on code inside Find.pm instead of breaking out on the if clause designed to catc

Re: Argument isn't numeric warning in if statement

2014-09-18 Thread Rob Dixon
On 18/09/2014 00:34, SSC_perl wrote: 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

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 doe

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

Re: Argument isn't numeric warning in if statement

2014-09-17 Thread Lawrence Statton
elf and it doesn't produce that warning, so it must be > something upstream that's causing it. > > Thanks, > Frank The code if (' ') { ... } will execute the block. The code if ('') { ...} will not Neither ' ' nor '' are numer

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'

if(defined(undef)) gives can't use undefined value as a SCALAR reference.

2014-08-30 Thread Dave Horner
Artifactory-Client: zero length file uploads https://rt.cpan.org/Public/Bug/Display.html?id=97772 'expect' => '100-continue' undefined value as a SCALAR reference #63 https://github.com/libwww-perl/libwww-perl/issues/63 if(defined($wbits)) is giving me can't use and

Re: check list if values meet criteria

2014-02-26 Thread Bill McCormick
On 2/25/2014 7:07 PM, Jim Gibson wrote: On Feb 25, 2014, at 2:30 PM, Bill McCormick wrote: What would be the perl'ish way using map or some other sugar to check if a list of values meet some criteria? Instead of doing something like my @issues = qq(123,456,a45); my $max = 999; for (@i

Re: check list if values meet criteria

2014-02-26 Thread Shlomi Fish
Hi all, On Tue, 25 Feb 2014 17:07:00 -0800 Jim Gibson wrote: > > On Feb 25, 2014, at 2:30 PM, Bill McCormick wrote: > > > What would be the perl'ish way using map or some other sugar to check if a > > list of values meet some criteria? Instead of doing something lik

Re: check list if values meet criteria

2014-02-25 Thread Rob Dixon
On 25/02/2014 23:46, Bill McCormick wrote: On 2/25/2014 4:36 PM, Bill McCormick wrote: On 2/25/2014 4:30 PM, Bill McCormick wrote: What would be the perl'ish way using map or some other sugar to check if a list of values meet some criteria? Instead of doing something like my @issues

Re: check list if values meet criteria

2014-02-25 Thread Jim Gibson
On Feb 25, 2014, at 2:30 PM, Bill McCormick wrote: > What would be the perl'ish way using map or some other sugar to check if a > list of values meet some criteria? Instead of doing something like > > my @issues = qq(123,456,a45); > my $max = 999; > > for (@iss

Re: check list if values meet criteria

2014-02-25 Thread Bill McCormick
On 2/25/2014 4:36 PM, Bill McCormick wrote: On 2/25/2014 4:30 PM, Bill McCormick wrote: What would be the perl'ish way using map or some other sugar to check if a list of values meet some criteria? Instead of doing something like my @issues = qq(123,456,a45); my $max = 999; for (@i

Re: check list if values meet criteria

2014-02-25 Thread Jing Yu
Data::Constraint is an alternative if you are thinking to add more different types of constraints. On 25 Feb 2014, at 22:36, Bill McCormick wrote: > On 2/25/2014 4:30 PM, Bill McCormick wrote: >> What would be the perl'ish way using map or some other sugar to check if >> a

Re: check list if values meet criteria

2014-02-25 Thread Ron Bergin
Bill McCormick wrote: > On 2/25/2014 4:30 PM, Bill McCormick wrote: >> What would be the perl'ish way using map or some other sugar to check if >> a list of values meet some criteria? Instead of doing something like >> >> my @issues = qq(123,456,a45); >

Re: check list if values meet criteria

2014-02-25 Thread Shawn H Corey
On Tue, 25 Feb 2014 16:30:35 -0600 Bill McCormick wrote: > I want to check if each list item is numeric and > 0 but less than > $max. See `perldoc Scalar::Util` and search for looks_like_number(). http://perldoc.perl.org/Scalar/Util.html -- Don't stop where the ink does.

Re: check list if values meet criteria

2014-02-25 Thread Bill McCormick
On 2/25/2014 4:30 PM, Bill McCormick wrote: What would be the perl'ish way using map or some other sugar to check if a list of values meet some criteria? Instead of doing something like my @issues = qq(123,456,a45); my $max = 999; for (@issues) { die if $_ < 0 or $_ > $max; }

check list if values meet criteria

2014-02-25 Thread Bill McCormick
What would be the perl'ish way using map or some other sugar to check if a list of values meet some criteria? Instead of doing something like my @issues = qq(123,456,a45); my $max = 999; for (@issues) { die if $_ < 0 or $_ > $max; } I want to check if each list item is numeric

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 wo

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 tha

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 1

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 $

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

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 va

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:

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

Re: close file if it's open

2012-08-28 Thread John W. Krahn
lina wrote: Thanks Jim and John. btw, what does the fileno mean? mean file-not-open? It means file number. For example, STDIN is file number 0, STDOUT is file number 1, STDERR is file number 2 and the next file opened is file number 3, etc. John -- Any intelligent fool can make things bi

Re: close file if it's open

2012-08-27 Thread Praveen Kumar
Hi, On Tue, Aug 28, 2012 at 12:15 PM, lina wrote: > Thanks Jim and John. > > btw, what does the fileno mean? mean file-not-open? > perldoc -f fileno > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org

Re: close file if it's open

2012-08-27 Thread lina
Thanks Jim and John. btw, what does the fileno mean? mean file-not-open? -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: close file if it's open

2012-08-27 Thread John W. Krahn
7;<', $fn; my $ofh; while(my $line =<$fh>){ if($line =~ /MODEL \s+(3|5|80|89|459)$/){ my $model = $1; open $ofh, '>', "extracted_$model.pdb"; print $ofh $_; } if($line =~ /ENDMDL/){

Re: close file if it's open

2012-08-27 Thread Jim Gibson
On Aug 27, 2012, at 9:30 PM, lina wrote: > Hi, > > I don't know which is the best way to "check whether this file is open > or not," In general, you don't have to worry about it, because: 1. If a file handle goes out of scope, the file will be closed. 2. If

close file if it's open

2012-08-27 Thread lina
$fn; my $ofh; while(my $line = <$fh>){ if($line =~ /MODEL \s+(3|5|80|89|459)$/){ my $model = $1; open $ofh, '>', "extracted_$model.pdb"; print $ofh $_; } if($line =~ /ENDMDL/){ close($ofh) if

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

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

Re: Re : Re: Re : Re: Re : Re: Check if words are in uppercase?

2011-06-21 Thread Rob Dixon
On 21/06/2011 15:01, Bob McConnell wrote: From: Paul Johnson On Tue, Jun 21, 2011 at 05:57:22AM -0700, Beware wrote: Hi to all, First of all, sorry for the late of my answer. Thank for all your sentence. Here's my solution (for now) : for my $w (@keywords) { if ( /\

Re: Re : Re: Re : Re: Re : Re: Check if words are in uppercase?

2011-06-21 Thread Paul Johnson
all your sentence. > >> > >> Here's my solution (for now) : > >> > >> for my $w (@keywords) > >> { > >> if ( /\b$w\b/ and !/\buc($w)\b/ ) > >> { > >> print "Keyword '$w' no

RE: Re : Re: Re : Re: Re : Re: Check if words are in uppercase?

2011-06-21 Thread Bob McConnell
From: Paul Johnson > On Tue, Jun 21, 2011 at 05:57:22AM -0700, Beware wrote: > > > Hi to all, >> >> First of all, sorry for the late of my answer. >> Thank for all your sentence. >> >> Here's my solution (for now) : >> >> for my $w

Re: Re : Re: Re : Re: Re : Re: Check if words are in uppercase?

2011-06-21 Thread Paul Johnson
On Tue, Jun 21, 2011 at 05:57:22AM -0700, Beware wrote: > Hi to all, > > First of all, sorry for the late of my answer. > Thank for all your sentence. > > Here's my solution (for now) : > > for my $w (@keywords) > { >

Re : Re: Re : Re: Re : Re: Check if words are in uppercase?

2011-06-21 Thread Beware
Hi to all, First of all, sorry for the late of my answer. Thank for all your sentence. Here's my solution (for now) : for my $w (@keywords) { if ( /\b$w\b/ and !/\buc($w)\b/ ) { print "Keyword '$w' not uppercase line $.\n";

Re: Re : Re: Re : Re: Check if words are in uppercase?

2011-06-17 Thread Brandon McCaig
On Wed, Jun 15, 2011 at 12:09 PM, Jim Gibson wrote: > '$w eq $w' is always true. It certainly is more sane when that holds true, but to have a little fun there is overload. ;D use strict; use warnings; use overload '==' => sub { return 0; }; my $foo = bless {}; print $foo == $foo; __END__

Re: Re : Re: Re : Re: Check if words are in uppercase?

2011-06-15 Thread Rob Dixon
On 15/06/2011 17:09, Jim Gibson wrote: On 6/15/11 Wed Jun 15, 2011 8:20 AM, "Rob Dixon" scribbled: I am afraid that will not work. $w is extracted from the input line and may contain lower-case letters. You must compare $w to uc $w to see if it contains any lower-case letters. &#x

Re: Re : Re: Re : Re: Check if words are in uppercase?

2011-06-15 Thread Jim Gibson
example. >>>> >>>> (I prefer my keywords to be in lowercase.) >>>> >>>> >>>> #!/usr/bin/perl >>>> >>>> use strict; >>>> use warnings; >>>> >>>> my @keywords = qw >>&g

Re: Re : Re: Re : Re: Check if words are in uppercase?

2011-06-15 Thread Rob Dixon
ntity exit file for function generate generic group guarded if impure in inertial inout is label library linkage literal loop map mod nand new next nor not null of on open or others out package port postponed procedure process pure range record register reject return rol ror select severity signal sha

Re: Re : Re: Re : Re: Check if words are in uppercase?

2011-06-15 Thread Jim Gibson
le for function generate generic group guarded if impure in inertial inout is label library linkage literal loop map mod nand new next nor not null of on open or others out package port postponed procedure process pure range record register reject return rol ror select severit

Re: Re : Re: Re : Re: Check if words are in uppercase?

2011-06-15 Thread John W. Krahn
exit file for function generate generic group guarded if impure in inertial inout is label library linkage literal loop map mod nand new next nor not null of on open or others out package port postponed procedure process pure range record register reject return rol ror select severity signal shared

Re: Re : Re: Re : Re: Check if words are in uppercase?

2011-06-15 Thread Rob Dixon
r/bin/perl use strict; use warnings; my @keywords = qw ( abs access after alias all and architecture array assert attribute begin block body buffer bus case component configuration constant disconnect downto else elsif end entity exit file for function generate generic group guard

  1   2   3   4   5   6   7   8   9   10   >