in reply to Schizophrenic var
for sure in your resarch you read create-your-own-dualvars. It tells $! is already dualvar:
perl -le "for (0..42){local $!; $! = $_; print 0 + $!, qq( - $!)}" 0 - 1 - Operation not permitted 2 - No such file or directory 3 - No such process 4 - Interrupted function call 5 - Input/output error 6 - No such device or address 7 - Arg list too long 8 - Exec format error 9 - Bad file descriptor 10 - No child processes 11 - Resource temporarily unavailable 12 - Not enough space 13 - Permission denied 14 - Bad address 15 - Unknown error 16 - Resource device 17 - File exists 18 - Improper link 19 - No such device 20 - Not a directory 21 - Is a directory 22 - Invalid argument 23 - Too many open files in system 24 - Too many open files 25 - Inappropriate I/O control operation 26 - Unknown error 27 - File too large 28 - No space left on device 29 - Invalid seek 30 - Read-only file system 31 - Too many links 32 - Broken pipe 33 - Domain error 34 - Result too large 35 - Unknown error 36 - Resource deadlock avoided 37 - Unknown error 38 - Filename too long 39 - No locks available 40 - Function not implemented 41 - Directory not empty 42 - Illegal byte sequence
> but I did not find any way of driving an existing variable into schizophrenic behaviour.
All scalars are already schizophrenic (but using strict they claim for a psychologic support, not sure if for the compiler or for the programmer ;)
perl -wle "use strict; for my $x(@ARGV){ print qq(I was: $x); print qq +(adding 1 I'm: ),$x + 1; print $x > 0 ? qq(I'm more than zero! ) : qq +(I'm less than or zero! ); print $\ }" 0z 42A I was: 0z Argument "0z" isn't numeric in addition (+) at -e line 1. adding 1 I'm: 1 I'm less than zero! I was: 42A Argument "42A" isn't numeric in addition (+) at -e line 1. adding 1 I'm: 43 I'm more than zero!
perl -wle "$x = q(a); print ++$x" prints b
L*
PS
This is even more weird.. I want to see if the numeric part of a filehandle was the same of what fileno returned.. it would be fun.. but no fileno
perl -lwe "open my $fh, '>', 'test'; print 0 + $fh; print + $fh" 16950176 GLOB(0x102a3a0) # ..and no: 16950176 is not the sum of numerical values of characters perl -wle "$str = q!GLOB(0x102a3a0)!; for (split '',$str){ print qq($_ + = ),ord($_);$res += ord($_);} print $res" G = 71 L = 76 O = 79 B = 66 ( = 40 0 = 48 x = 120 1 = 49 0 = 48 2 = 50 a = 97 3 = 51 a = 97 0 = 48 ) = 41 981
PPS perl -wle "$x = q(a); print ++$x" prints b but not all chars are numeric, sorry I'm not JAPH, but J1PH1 :)
perl -we "print ++$_ for 'I@OG+' =~ /./g" Argument "@" isn't numeric in preincrement (++) at -e line 1. Argument "+" treated as 0 in increment (++) at -e line 1. J1PH1
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Schizophrenic var
by eyepopslikeamosquito (Archbishop) on Dec 06, 2022 at 10:39 UTC | |
by marioroy (Prior) on Jul 01, 2023 at 05:58 UTC | |
by eyepopslikeamosquito (Archbishop) on Jul 01, 2023 at 09:43 UTC | |
by marioroy (Prior) on Jul 01, 2023 at 14:58 UTC | |
by marioroy (Prior) on Jul 27, 2023 at 14:19 UTC | |
| |
Re^2: Schizophrenic var
by Haarg (Priest) on Dec 06, 2022 at 13:36 UTC | |
Re^2: Schizophrenic var
by Tux (Canon) on Dec 07, 2022 at 08:37 UTC |