Войти

Показать полную графическую версию : Скрипт на Perl


Termo27
19-05-2010, 15:46
а кто perl знает?
поправьте, пожалуйста, синтаксис.


#!/usr/bin/perl -w

#this script search for frag on a fs
use strict;

#number of files
my $files = 0;
#number of fragment
my $fragments = 0;
#number of fragmented files
my $fragfiles = 0;

#search fs for all file
open (FILES, "find " . $ARGV[0] . " -xdev -type f -print0 |");

$/ = "\0";

while (defined (my $file = )) {
open (FRAG, "-|", "filefrag", $file);
my $res = ;
if ($res =~ m/.*:\s+(\d+) extents? found/) {
my $fragment = $1;
$fragments += $fragment;
if ($fragment > 1) {
$fragfiles++;
}
$files++;
} else {
print ("$res : not understand for $file.\n");
}
close (FRAG);
}
close (FILES);

print ( $fragfiles / $files * 100 . "% non contiguous files, " . $fragments / $files . " average fragments.\n");


ошибки при исполнении:
syntax error at ./frag.pl line 18, near "= )"
Global symbol "$file" requires explicit package name at ./frag.pl line 19.
syntax error at ./frag.pl line 20, near "= ;"
Global symbol "$file" requires explicit package name at ./frag.pl line 29.
syntax error at ./frag.pl line 32, near "}"

kim-aa
19-05-2010, 16:38
Termo27,

1) Образец файла, который скрипт должен обработать приведите, что бы можно было проверить.
2) Опишите, что вообще делает данный скрипт.

Termo27
20-05-2010, 06:24
это и есть сам файл.
он проверяет разделы и выводит количество фрагментированных файлов.
я разобрался, можно закрывать...




© OSzone.net 2001-2012