CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:


New User

May 7, 2010, 6:33 AM

Post #1 of 2 (944 views)
Perl Can't Post

#!/usr/bin/perl -w 
use strict;

#Verificar argumentos

if (@ARGV != 1) {die("Precisar de entrar um argumento,sendo ele uma directoria")}

#Verificar se o argumento é directoria

if (!-d $ARGV[0]) {die("O argumento não é directoria");}

#abertura da directoria

opendir(DIR,"$ARGV[0]") || die ("Erro ao abrir directoria");
my @dir = readdir(DIR);
chomp (@dir);
close (DIR);

my $fich;
my $emptyfile;

foreach my $i (@dir){

if ($i eq "."){next;}
if ($i eq ".."){next;}

if (-f $i){

if (-z $i){
print "$emptyfile é ficheiro vazio \n";



print " Total Ficheiros: $fich \n Total FichVazios: $emptyfile \n";

The objective of this code is to count the number of files and the number of empty files of the directory that we called as a argument.In the final the terminal will show(for example) this when we write ./ files/:

Total files:6
Total empty files:2

Where is the script(code) and files/ the directory(first and unique argument).
What is wrong in this code?

Best Wishes,

André Barradas


May 9, 2010, 9:00 AM

Post #2 of 2 (922 views)
Re: [andrebarradas] Perl [In reply to] Can't Post

Cross post. Already answered elsewhere.


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives