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
On Wed, Aug 14, 2013 at 6:09 PM, Alexey Mishustin wrote:
> 2013/8/15 Uri Guttman :
> > On 08/14/2013 04:22 PM, Jim Gibson wrote:
> >>
> >>
> >> On Aug 14, 2013, at 12:30 PM, Alexey Mishustin wrote:
> >>
> >>> Testing a value and assigning it - I have never done this at the same
> >>> time...
> >>
2013/8/15 Uri Guttman :
> On 08/14/2013 04:22 PM, Jim Gibson wrote:
>>
>>
>> On Aug 14, 2013, at 12:30 PM, Alexey Mishustin wrote:
>>
>>> Testing a value and assigning it - I have never done this at the same
>>> time...
>>
>>
>>
>> Doing both in while statements is very common:
>>
>>while( my $
On 08/14/2013 04:22 PM, Jim Gibson wrote:
On Aug 14, 2013, at 12:30 PM, Alexey Mishustin wrote:
Testing a value and assigning it - I have never done this at the same time...
Doing both in while statements is very common:
while( my $line = <$fh> ) {
...
}
Try to write that loop
On Aug 14, 2013, at 12:30 PM, Alexey Mishustin wrote:
> Testing a value and assigning it - I have never done this at the same time...
Doing both in while statements is very common:
while( my $line = <$fh> ) {
...
}
Try to write that loop with two separate statements, one an assignment
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
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
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 $
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
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
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/
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
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
13 matches
Mail list logo