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:
find::file module



May 22, 2000, 2:55 AM

Post #1 of 2 (576 views)
find::file module Can't Post


I use this module to find the sub dirs and files in the sub dirs.

use File::Find;
find( sub{push @files,$File::Find::name if -f; unshift @dirs,$File::Find::name if -d}, $BackupSystem );

This will result in @dirs with contains all the sub directories and @files with contains all the files in the dir and sub dir.

The result is a complete path:
something like this:

foreach (@file) {
print "$_",

result will be:


Is it possible to use the File::Find module so that the result will not be the complete path but oonly the part without the mainpart: $BackupSystem.

$BackupSystem: "/data1/";

foreach (@file) {
print "$_",

result will be:


Peter Van Hoecke

May 22, 2000, 3:17 AM

Post #2 of 2 (576 views)
Re: find::file module [In reply to] Can't Post

Perhaps this helps... probeably not, it doesn't change your find command, but if always have the $backupsystem variable, then you could do this...

(sorry if I misunderstood the wuestion...)

use strict;

my(@input, $bla, $file);
$input[0] = "/data1/";
$input[1] = "/data1/";
$bla = "/data1/";
foreach $file (@input)
($_ = $file) =~ s/$bla//;
print $_ . "\n";


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

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