Solved

Perl 5's glob() function

Posted on 1997-11-20
2
3,724 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 

Accepted Solution

by:
kistler earned 70 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

Suggested Solutions

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…

735 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