Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Perl 5's glob() function

Posted on 1997-11-20
2
Medium Priority
?
3,758 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 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
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

730 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