> 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: > ls -lt ./new/*.txt | while read FILE > do > process $FILE > done opendir, readdir, closedir. > 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. > Hope some guru can help me.. this isn't guru level stuff :) perldoc -f for each of opendir, readdir, closedir, and unlink will tell you all you need to know. The same function names are how you would do it in C; many times it helps with Perl by wondering how you would do the same job in C; although other times it helps by wondering how you would do the same job in shell. hope this helps, Stuart. --- Linux- it's a kernel, an operating system and a political movement. -- SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/ More Info: http://lists.slug.org.au/listinfo/slug
