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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
find::file module

 



mmcw
User

May 22, 2000, 2:55 AM

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

Hello,

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:

/data1/hypermart.net/mmcw/cgi-bin/DCShop/Backup/System/Div/vatcode.txt

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/hypermart.net/mmcw/cgi-bin/DCShop/Backup/System/";

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

result will be:

Div/vatcode.txt



Peter Van Hoecke
Deleted

May 22, 2000, 3:17 AM

Post #2 of 2 (461 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...)

#!perl.exe
use strict;

my(@input, $bla, $file);
$input[0] = "/data1/hypermart.net/mmcw/cgi-bin/DCShop/Backup/System/Div/vatcode.txt";
$input[1] = "/data1/hypermart.net/mmcw/cgi-bin/DCShop/Backup/System/Div/pintcode.txt";
$bla = "/data1/hypermart.net/mmcw/cgi-bin/DCShop/Backup/System/";
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