Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Perl 5's glob() function

Posted on 1997-11-20
2
Medium Priority
?
3,779 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 210 total points
ID: 1208815
@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
ID: 1208816
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
Six Sigma Control Plans

927 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