How to optimize perl code for directory exists or not ?

Posted by SCNCN2010 on Stack Overflow See other posts from Stack Overflow or by SCNCN2010
Published on 2010-06-18T16:30:29Z Indexed on 2010/06/18 16:43 UTC
Read the original article Hit count: 152

Filed under:
    sub DirectoryExists {
        my $param = shift;

        # Remove first element of the array
        shift @{$param};

        # Loop through each directory to see if it exists
        foreach my $directory (@{$param}) {
            unless (-e $directory && -d $directory) {
                return 0;
            }
        }

        # True
        return 1;

}

is there any way to optimize this code ?

is there any good way to optimize this code

© Stack Overflow or respective owner

Related posts about perl