Solved

Perl 5's glob() function

Posted on 1997-11-20
2
3,713 Views
Last Modified: 2006-11-17

I have just finished writing a script on my test machine making use of Perl 5's functionality and specifically, the GLOB function.

However, our production machine does not have Perl 5, but Perl 4 and therefore the code dependent upon the output of GLOB will not work.

Basically, the script itself will not work.

Is there an equivalent function to GLOB for Perl 4?  Or perhaps some code I could use to match this:

>
>@WorkingFiles = glob("$WorkingDir/$FileExt");
>
>open(LOG, '>>$LogFile');
>foreach $FileName (@WorkingFiles)

>

I'm working with files and filenames so the output of my script is dependent upon the data GLOB returns. :*(

It is very important that I am able to specify the files returned to me by wildcards (thus the usefulness of GLOB in this situation).

PLEASE ASSIST!!

JaTHaN
<o_/


0
Comment
Question by:jathan
  • 2
2 Comments
 

Accepted Solution

by:
kistler earned 70 total points
Comment Utility
@files = <$a/*>;
is the same as
@files = <$a/*>;
expect, that in the latter case "." and ".." may
show up as well.
But for perl4 <*> should work. If there is any problem,
you still have the "readdir" function.
0
 

Expert Comment

by:kistler
Comment Utility
I have tried another way around using the readdir like so:

opendir(WORKDIR, "$WorkingDir");

local(@WorkingFiles) = readdir(WORKDIR);
closedir(WORKDIR);

foreach $FileName (@WorkinDir) { ... }

The only problem with this approach is I have no way of specifying the extensions I want to work with.  Specifically, this script is table-driven and pulls the values for the strings $WorkingDir and $FileExt from said table.  

It is intended to perform a user-specified action (i.e, move, compress, delete) on files of extensions matching $FileExt in the directory $WorkingDir.  Does this help?

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Perl Tutorial 6 125
perl to mysql 5 127
Connecting to linux server using Net::Telnet module 25 207
Bash one liner, start and end time calculation 13 93
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now