Leser: 2
![]() |
|< 1 2 3 4 5 >| | ![]() |
44 Einträge, 5 Seiten |
1
2
3
4
5
6
7
8
9
10
11
#! /usr/bin/perl
use strict;
use warnings;
use Getopt::Std;
use Data::Dumper;
my %opts;
getopts('f:hd:',\%opts);
print Dumper(\%opts);
opendir(DIR,$dir) or die $!;
1
2
3
4
5
rootcris@ingo:~/scripts$ ./filesize.pl -d /home/rootcris/filme/
Use of uninitialized value in hash element at ./filesize.pl line 82.
Use of uninitialized value in sort at ./filesize.pl line 86.
Use of uninitialized value in sort at ./filesize.pl line 86.
Use of uninitialized value in hash element at ./filesize.pl line 91.
$for{$file} = $_;
my @sort = sort { $a <=> $b } @size;
if (-f "$for{$_}")
$hash{$_} = (-s $_);
QuoteUnd wenn ich "." öffne, wird nicht das aktuelle Verzeichniss geöffnet, sondern das Verzeichniss, in dem das script liegt...
1
2
3
4
5
6
7
8
9
10
11
12
~/test/foo/bar> touch bla
~/test/foo/bar> ls -a
. .. bla
~/test/foo/bar> cat > ~/perl/test/opendirtest.pl
#!/usr/bin/perl -l
opendir DIR, '.' or die $!;
print for readdir DIR;
~/test/foo/bar> chmod +x ~/perl/test/opendirtest.pl
~/test/foo/bar> ~/perl/test/opendirtest.pl
.
..
bla
QuoteDas mit dem
hat sich erledigt, ich habe getopts vorher vergessen zu machen...
QuoteEs muss deshalb gemacht werden, damit das script auch weiß, nach welcehm Schalter eine Eingabe erwartet wird...
QuoteDer Schalter -d /path/to/dir/ geht immer noch nicht.
QuoteAber wenn es kein verzeichniss ist, gibt es ordnungsgemäß eine Fehleremldung aus... :(
my $file = -s File::Spec->catfile($dir, $_);
$_ = $dir$_ if($opts{d});
/home/rootcris/filme/$_
1
2
3
4
5
6
7
8
rootcris@ingo:~/scripts$ ./filesize.pl -d /home/rootcris/filme/
Scalar found where operator expected at ./filesize.pl line 80, near "$dir$_"
(Missing operator before $_?)
"my" variable @sort masks earlier declaration in same statement at ./filesize.pl line 89.
syntax error at ./filesize.pl line 80, near "$dir$_ "
syntax error at ./filesize.pl line 82, near ");"
Can't use global $_ in "my" at ./filesize.pl line 92, near "{$_"
Execution of ./filesize.pl aborted due to compilation errors.
![]() |
|< 1 2 3 4 5 >| | ![]() |
44 Einträge, 5 Seiten |