Hi Ben,

I am _not_ an expert, but...

>>1. How can I get a directory listing ONLY?

Try File::Find (search www.CPAN.org for the package documentation - It
should be in your Perl distribution by default.

#!/usr/bin/perl
#
#       File:Find recursive directory search example example
#

use strict;
use warnings;
use File::Find;

my @DIRS = ('.', );     # list of starting directories for 'find'

        find (\&process_file, @DIRS);

sub process_file
{
# routine is entered in the file's (in $_) directory.
# do whatever to the file here. use the -X operator to determine
# what flavor the file is...

        print "text:" if -T $_;
        print " bin:" if -B $_;
        print "$_ -> $File::Find::name\n"; # print name and full path
# add to array, etc. here
}

See http://www.perldoc.com/perl5.6/pod/perlfunc.html for further
documentation on the -X (file test) operator.

>>3. How do I do a pattern search that looks for capital
>>words only?

Try this:

        my $test = "Test: HELLO my name is BEAU Cox";
        $_ = $test;
        my @cap_words = /\s*([A-Z0-9\.@_]+?)\s+/g;
        print "@cap_words\n";

NOTE: the search is for A-Z, 0-9, ., @, and _. Add (subtract) as required.
Don't forget to "escape" (\) the regex "magic" characters.

Well, that's it for me. I'm a Win32 guy and someone else can help you with
your Unix/Linux file system questions.

Aloha - Beau.

-----Original Message-----
From: Ben Crane [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 25, 2001 9:35 PM
To: [EMAIL PROTECTED]
Subject: Directories, Arrays


Hi all,

I have a couple of questions: I am new to perl, but
have had programming experience before; I am trying to
put together a perl program that fixes Mapinfo
Workspaces by replacing dud file links with working
links. The workspace is text based so perl is a good
bet. Workspaces are made up of links to other network
drives/files, so moving one file means the workspace
crashes. Usually it's a pain staking process to fix. I
want to automate it.

1. How can I get a directory listing ONLY? Also, can I
get perl to give me ALL my drives, eg. network drives?
I want to put them into an array so I can search
directories and sub-directories for files.

2. I use a pattern matching operator to determine
directories and files, it's not reliable-but once I've
gone through the directory listing and isolated the
directories, how do I put this into an array for the
same reason as in (1)??? I keep getting blank arrays.

3. How do I do a pattern search that looks for capital
words only?

4. Descending a treet directory...fraught with
problems...any ideas.

5. Last question (I promise :) Once I find my files
and put them into an array. How can I modify the
search/replace function to loop through the entire
array and replace the text in the workspace with the
text in the array?

Thanx a million, I know I've asked for a ton of stuff,
but I don't have a good perl book and the web examples
aren't clear enough...I'm spending a lot of time
learning stuff not knowing whether I'm heading in the
right direction...which is good of course...but also
bad :)

Ben Crane ([EMAIL PROTECTED])
Wokingham DC

__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to