Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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


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 making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2015-07-08 07:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (96 votes), past polls