Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: process a file and reading a line and passing the values to another sub function

by blue_cowdawg (Monsignor)
on Dec 12, 2012 at 18:38 UTC ( #1008566=note: print w/replies, xml ) Need Help??


in reply to process a file and reading a line and passing the values to another sub function

As mentioned elsewhere you can use find2perl to create a skeleton program for you that does the job very well. But here's a piece of code I have laying around that may or may not work for what you want to do.

#!/usr/bin/perl -w ###################################################################### +## use strict; my $start="/some/path/to/some/where"; crawl($start); exit(0); sub crawl { my $dir = shift; opendir(my $dh,$dir) or die "$dir: $!"; while (my $entry=readdir($dh)){ next if ($entry eq '.') || ($entry eq '..'); printf "%s\n",$entry; if ( -d $entry ) { crawl($dir . "/" . $entry); } } closedir($dh); }
Now... them's the basics...

Embelish the output or actions as you need. For instance if I were to use this "real time" I'd add an indentation element or even ASCII art elements to it to make the output more useful.

HTH


Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1008566]
help
Chatterbox?
[haukex]: Corion: I once wrote an automated thingy for that here
[haukex]: here's the code that uses it
[Corion]: haukex: Hmm - maybe I can reuse that. I see that it uses Pod::Parser, which I think was one of the more fragile parsers. But if I'm statically (re)generating the tests instead of doing that "live" on the client/tester machines, that's a much smaller...
[Corion]: ... problem space than trying to cater to all versions of Pod::Parser(s)
[haukex]: I think you're right, I think Pod::Simple is the preferred parser now
[haukex]: But I was just using it as an author test anyway
[Corion]: haukex: Aaah - I thought you were still running these tests on every machine, but you only run these as author or Devel::Cover tests
[Corion]: haukex: Yeah, I think back then I used Test::Inline, which used a pod parser that was going through some changes and I didn't want to cater for all the various versions and thus stopped testing the Pod completely

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (10)
As of 2017-02-27 12:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (385 votes). Check out past polls.