[roch-pm] Help with File handle.

echo dev echo_dev at hotmail.com
Sun Feb 23 00:05:17 CST 2003


Here is the sub with errors.

Thanks
hde

sub code_base_conf
{
    my @file_contents;
    my $start_dir = shift;
    my @dir_contents;
    my $cwd = $start_dir;
    my $old_cwd;

    open (CONFIG_FILE, ">/home/hde/code_serv.conf")
	or die "Can't create config file : $!\n";

    chdir ($start_dir) or
	die "Can't cd to $start_dir : $!\n";

    opendir (DIR, $start_dir)
	or die "Can't open $start_dir : $!\n";

    @dir_contents = readdir (DIR)
	or die "Can't read dir $start_dir : $!\n";

    closedir (DIR) or
	die "Can't close dir $start_dir : $!\n";

    select CONFIG_FILE;

    for my $file_or_dir (@dir_contents)
    {
        next if ($file_or_dir eq qq{.});
        next if ($file_or_dir eq qq{..});

        if (-d $file_or_dir)                 # If the file is a directory.
        {
            next if (-l $file_or_dir);

            $cwd = &cwd;
	    $old_cwd = $cwd;
	    $cwd =~ s{(/.*/)+}{}g;

	    printf ("%s %s %s\n", $cwd, "=>", $old_cwd);
	    $cwd = &cwd;

            chdir (qq{$cwd/$file_or_dir}) or
                die "Can't cd to $cwd/$file_or_dir : $!\n";

            opendir (DIR, qq{$cwd/$file_or_dir}) or
                die "Can't open dir $file_or_dir : $!\n";

            code_base_conf ((readdir (DIR)));

            closedir (DIR);

            chdir ($cwd) or
                die "Can't cd to $cwd : $!\n";

            next;
        }

    }
    chdir ("/home/hde/code_base/perl/code_base_Backup");
    #clean_conf ("./code_serv.conf");
}

_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*.  
http://join.msn.com/?page=features/featuredemail

--
For information on unsubscribing from this list, please visit
http://rochester.pm.org



More information about the Rochester-pm mailing list