#!/usr/bin/perl use strict; use warnings; use Cwd; my $dir = getcwd; my %sizeindex; my %fileindex; my @sort; my $o; my @size; opendir(FILE, "$dir"); my @file = readdir(FILE); closedir(FILE); foreach(@file) { my $size = (-s, "$_"); push @size, $size; $sizeindex{$_} = $size; } foreach(@size) { my $i = 0; $fileindex{$i}=$sizeindex{$file[$i]}; $i++; } my $main = @file; @sort = sort { $a <=> $b } @size; format STDOUT_TOP = Dateiname Dateigroesse ==================================== . for($o = 0; $o == $main; $o = $o + 1) { if (-f "$_") { my $i = 0; if ($size[$i] < 1024) { $size[$i] .= " bytes"; } elsif ( $size[$i] > 1024 && $size[$i] < 1048576) { $size[$i] = sprintf("%.2f", $size[$i] / 1024); $size[$i] .= " kb"; } elsif ( $size[$i] > 1048576 && $size[$i] < 1099511627776) { $size[$i] = sprintf("%.2f", $size[$i] / 1048576); $size[$i] .= " mb"; } else { $size[$i] = sprintf("%.2f", $size[$i] / 1099511627776); $size[$i] .= " gb"; } format STDOUT = @<<<<<<<<<<<<<<<<< @>>>>>>>>>>>>>> $fileindex{$i}, $size[$i] . write; $i++; } }