「Illegal octal digit(8 進数で 8 か 9 を使いました。)」というエラーが出るときはどんなとき?
初めて見たエラーだったので、実験して遊びました。
※遊び&実験なので、そんなこと普通はしないだろう、的なことをしています。そこら辺は突っ込まないでください。
[abyss@abyss web1]$ perl $a = "08"; $b = 2; print $a+$b; print "\n"; 10 [abyss@abyss web1]$ perl $a = "08"; $b = 2; print $a.$b; print "\n"; 082 [abyss@abyss web1]$ perl $a = 08; $b =2; $c = $a+$b; print $c; print "\n"; Illegal octal digit '8' at - line 1, at end of line Execution of - aborted due to compilation errors.
↑これらの結果から分かることは、どうも、08を10進数の数字として四則演算したい時は、08を""で囲まないとダメみたい。
[abyss@abyss web1]$ perl $a = 008; int ($a); print $a."\n"; Illegal octal digit '8' at - line 1, at end of line Execution of - aborted due to compilation errors. [abyss@abyss web1]$ perl $a = 08; int ($a); print $a; print "\n"; Illegal octal digit '8' at - line 1, at end of line Execution of - aborted due to compilation errors.
↑そりゃそうですよね。int関数の挙動を考えると。
[abyss@abyss web1]$ perl $a = 01; $b = 2; $c = $a+$b; print $c; print "\n"; 3D [abyss@abyss web1]$ perl $a = 02; $b = 2; $c = $a+$b; print $c; print "\n"; 4D
んふふ。おもしろいね。
また時間ができたら続きをします。
というか、久しぶりの更新がこんな変な内容ですみません。。。
人事異動になっちゃって、前に比べたら全然勉強できてないけどこれからもほそぼそと続けて行こうと思います。
やっぱり、軽くエンジニアの知識はあった方がいろいろと仕事しやすいので。