Re: Reading a variable file name

2004-07-14 Thread JupiterHost.Net
[EMAIL PROTECTED] wrote:
Lee,
Hello,
A couple of questions:
Ok, but please post to the list so everyone can share :)
1. I get an error on the use File::Slurp line.  I have been  looking in 
the "Camel" book and can't seem to find much.  Is this a module that I 
need to download.
Yes,
 perl -MCPAN -e 'install File::Slurp;'
shoudl do it
2. If I comment out the Slup line, my next error is on the read_dir 
line.  It thinks that this is a subroutine.
It is a subroutine, exported by File::Slurp; which you need to install
3. I would assume that the append_file line will have the same problem 
as the read_dir line, but I haven't gotten to it yet.
Correct same as #2
Many thanks for your help.
No problem! If you want to show your appreciation you could always 
signup for hosting at JupiterHost.Net and tell your friends - tell them 
Lee sent you :)

Richard Hug
HTH :)
Lee.M - JupiterHost.Net
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Reading a variable file name

2004-07-13 Thread JupiterHost.Net

[EMAIL PROTECTED] wrote:
Greetings,
Hello,
Would someone be kind enough to point me in the right direction to solve this 
problem?
I'll try :)
An application creates XML files in a subdirectory, which I then convert to 
EDI.  That part is now working fine.  My problem is that the application 
creates files during the day, with slightly different names.  For example:

File0001.xml
File0002.xml
File0244.xml
The file names vary based on what part of the application creates them.  
There seems to be no pattern of the number after the alpha characters.  I need to 
read each of these files, and concatenate them into a single EDI file.  The 
only files in the subdirectory need to be processed;  and all of the files in 
the subdirectory need to be processed.

Could someone point me in the right direction?
Not sure about how the filename effects if you want to incude it or not 
 but:

#!/usr/bin/perl
use strict;
use warnings;
use File::Slurp;
for(read_dir('/xml/files')) {
   if($_ =~ m/\.xml$/) {
   my $xml = read_file("/xml/files/$_");
   append_file('/xml/together.edi',$xml);
   }
}
Thanks for your help.
No problem :)
Lee.M - JupiterHost.Net
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Reading a variable file name

2004-07-13 Thread James Edward Gray II
On Jul 13, 2004, at 8:31 AM, [EMAIL PROTECTED] wrote:
Greetings,
Howdy.
Would someone be kind enough to point me in the right direction to 
solve this
problem?
I'll sure try.
An application creates XML files in a subdirectory, which I then 
convert to
EDI.  That part is now working fine.  My problem is that the 
application
creates files during the day, with slightly different names.  For 
example:

File0001.xml
File0002.xml
File0244.xml
We can sure make a regex for that, right?
m/^File\d+\.xml$/
The file names vary based on what part of the application creates them.
There seems to be no pattern of the number after the alpha characters. 
 I need to
read each of these files, and concatenate them into a single EDI file.
Do you know how to read the listing of files in a directory?  Three 
steps:

opendir DIR, 'path/to/dir' or die "Directory error:  $!";  # open dir
my @files = grep m/^File\d+\.xml$/, readdir DIR;  # get file listing 
using earlier regex

closedir DIR;  # clean up after ourselves, as all good programmers 
should

# loop over @files down here...
The  only files in the subdirectory need to be processed;  and all of 
the files in
the subdirectory need to be processed.
Was that line English?You lost me here.  If I haven't 
solved your problem yet, try me again on this part.

Could someone point me in the right direction?
Hope that helps.
James
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Reading a variable file name

2004-07-13 Thread RHug505456
Greetings,

Would someone be kind enough to point me in the right direction to solve this 
problem?

An application creates XML files in a subdirectory, which I then convert to 
EDI.  That part is now working fine.  My problem is that the application 
creates files during the day, with slightly different names.  For example:

File0001.xml
File0002.xml
File0244.xml

The file names vary based on what part of the application creates them.  
There seems to be no pattern of the number after the alpha characters.  I need to 
read each of these files, and concatenate them into a single EDI file.  The 
only files in the subdirectory need to be processed;  and all of the files in 
the subdirectory need to be processed.

Could someone point me in the right direction?

Thanks for your help.

Richard Hug
New Tampa Consulting
813-361-7946