Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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

by blue_cowdawg (Prior)
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


Comment on Re: process a file and reading a line and passing the values to another sub function
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1008566]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2014-07-25 12:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (171 votes), past polls