Woran erkennt man einen Bug
bearbeitet von Christian KruseHallo pl,
deine Arroganz finde ich wirklich unerträglich.
> > Das ist kein Perl-Bug, sondern ein pl-Bug. Es fehlt das `use IO::File` in deinem Beispiel.
> >
>
> Falsch! Selbst wenn es fehlen würde, […]
Nicht würde. Es fehlt.
> […] es würde eine andere Fehlermeldung kommen. Weil nämlich das ganze Erbe von IO::Handle fehlt!
Nein. Das wird implizit mit importiert durch das `use IO::File`-Statement.
> Und @dedlfix behaupet ja
>
> > IO::Handle: bad open mode: O_CREAT at - line 4.
>
> sei die Fehlermeldung, […]
Das ist keine Behauptung, sondern Fakt.
~~~
ckruse@sunshine:~$ cat test.pl
#!/usr/bin/perl -w
my $fh = IO::File->new;
chdir "/tmp";
my $filename = "files/asdf";
$fh->open($filename, O_CREAT) or die $!;
ckruse@sunshine:~$ ./test.pl
IO::Handle: bad open mode: O_CREAT at ./test.pl line 6.
ckruse@sunshine:~$ perl -v
This is perl 5, version 26, subversion 1 (v5.26.1) built for x86_64-linux-gnu-thread-multi
(with 63 registered patches, see perl -V for more detail)
Copyright 1987-2017, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
ckruse@sunshine:~$
~~~
Mehr Bescheidenheit stünde dir gut zu Gesicht.
> also daß sie von IO::Handle kommt. Wenn das jedoch nicht eingebunden ist, wie bitte kann es dann einen Fehler melden!?
Durch das `use`-Statement wird implizit `IO::Handle` als Abhängigkeit von `IO::File` importiert.
~~~
ckruse@sunshine:~$ cat test.pl
#!/usr/bin/perl -w
use Data::Dumper;
print Dumper \%INC;
my $fh = IO::File->new;
chdir "/tmp";
my $filename = "files/asdf";
$fh->open($filename, O_CREAT) or die $!;
ckruse@sunshine:~$ ./test.pl
$VAR1 = {
'warnings.pm' => '/usr/share/perl/5.26/warnings.pm',
'bytes.pm' => '/usr/share/perl/5.26/bytes.pm',
'XSLoader.pm' => '/usr/share/perl/5.26/XSLoader.pm',
'constant.pm' => '/usr/share/perl/5.26/constant.pm',
'Data/Dumper.pm' => '/usr/lib/x86_64-linux-gnu/perl/5.26/Data/Dumper.pm',
'Exporter.pm' => '/usr/share/perl/5.26/Exporter.pm',
'warnings/register.pm' => '/usr/share/perl/5.26/warnings/register.pm',
'strict.pm' => '/usr/share/perl/5.26/strict.pm',
'Carp.pm' => '/usr/share/perl/5.26/Carp.pm'
};
IO::Handle: bad open mode: O_CREAT at ./test.pl line 10.
ckruse@sunshine:~$ cat test1.pl
#!/usr/bin/perl -w
use Data::Dumper;
use IO::File;
print Dumper \%INC;
my $fh = IO::File->new;
chdir "/tmp";
my $filename = "files/asdf";
$fh->open($filename, O_CREAT) or die $!;
ckruse@sunshine:~$ ./test1.pl
$VAR1 = {
'strict.pm' => '/usr/share/perl/5.26/strict.pm',
'Symbol.pm' => '/usr/share/perl/5.26/Symbol.pm',
'IO/Seekable.pm' => '/usr/lib/x86_64-linux-gnu/perl/5.26/IO/Seekable.pm',
'IO/File.pm' => '/usr/lib/x86_64-linux-gnu/perl/5.26/IO/File.pm',
'SelectSaver.pm' => '/usr/share/perl/5.26/SelectSaver.pm',
'IO.pm' => '/usr/lib/x86_64-linux-gnu/perl/5.26/IO.pm',
'constant.pm' => '/usr/share/perl/5.26/constant.pm',
'bytes.pm' => '/usr/share/perl/5.26/bytes.pm',
'Fcntl.pm' => '/usr/lib/x86_64-linux-gnu/perl/5.26/Fcntl.pm',
'Exporter.pm' => '/usr/share/perl/5.26/Exporter.pm',
'XSLoader.pm' => '/usr/share/perl/5.26/XSLoader.pm',
'Data/Dumper.pm' => '/usr/lib/x86_64-linux-gnu/perl/5.26/Data/Dumper.pm',
'IO/Handle.pm' => '/usr/lib/x86_64-linux-gnu/perl/5.26/IO/Handle.pm',
'Carp.pm' => '/usr/share/perl/5.26/Carp.pm',
'warnings/register.pm' => '/usr/share/perl/5.26/warnings/register.pm',
'warnings.pm' => '/usr/share/perl/5.26/warnings.pm'
};
No such file or directory at ./test1.pl line 11.
ckruse@sunshine:~$
~~~
> Also bitte mal Gehirn einschalten!
Mein lieber Freund und Kupferstecher, wie wäre es, wenn du dir mal an die eigene Nase fasst?
> > Übrigens: wenn man das ergänzt, bekommt man wie erwartet die Fehlermeldung `No such file or directory at ./test.pl line 8.` - denn das Verzeichnis `files` existiert nicht in `/tmp`.
> >
>
> Logisch.
Nix logisch. Deine Behauptung war, dass der path separator ein Teil des Dateinamens sein kann. Das sieht hier nicht danach aus (und widerspräche auch der Doku).
LG,
CK
--
<https://wwwtech.de/about>