* This one time, at band camp, George Vieira said:
> Hi all,
>
> Can someone help me with a perl script as I'm a n00b at this..
>
> I have a directory (news/) which contains files which are dated eg.
> 011213.txt and inside it contains HTML code.
>
> I want to be able to look inside this directory and grab each file and print
> the contents of all of them. I can do some of this code but I don't know how
> to get it to select every file.
> Each file needs processing before printing so it's not like doing a `cat
> ./news/*.txt` in bash because I need to add some HTML code around each file
> before printing it.
> So the bash equivalent would need to be something like below but in Perl:
my $dir = "news/*txt";
my $files = glob("$dir");
foreach my $file (@files)
{
open(FILE,$file) || warn "Cannot open $file";
while (<FILE>)
{
print "$_<B>\n";
}
close (FILE);
}
You'll need to customise it to your requirements, but that should get
you started. Give me a shout off list if you need any more help.
>
> ls -lt ./new/*.txt | while read FILE
> do
> process $FILE
> done
>
> Another thing I need to know how to delete a file in Perl, I looked up the
> Perl Docs' on perl.com but the delete command talks about hashed file
> records and so on and no to do a basic DEL FILE...????
unlink($file) should help you out there.
>
> Hope some guru can help me..
>
Anyone who calls themselves a guru, usually isn't......
HTH
Greeno
--
Greeno <[EMAIL PROTECTED]>
GnuPG Key : 1024D/B5657C8B
Key fingerprint = 9ED8 59CC C161 B857 462E 51E6 7DFB 465B B565 7C8B
Imagine working in a secure environment and finding the string
_NSAKEY in the OS binaries without a good explanation
-Alan Cox 04/05/2001
--
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug