Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Open a directory and recursively process files

by ww (Bishop)
on Jan 09, 2013 at 14:36 UTC ( #1012501=note: print w/ replies, xml ) Need Help??


in reply to Open a directory and recursively process files

As Ln 14 is written, $line is a count of the elements in @line Processing that -- which is always a "1" as written is not quite the same as "bombs out." Precise description of the failures your code produces helps us help you.

Writing Ln 14 in any of the following fashions does PART of what you appear to intend (with respect to the FILENAME, ONLY*):

my $line = $_[0]; my $line = shift; (my $line) = @_;

The first specifies that $line should be assigned the value (content) of element zero of @_
The second does the same (cf perldoc -f shift)
The third makes the assignment in the appropriate context (qv in "Learning Perl," http://perldoc.perl.org/perldata.html#Context, Context tutorial, or any number of other places).

*However, since you seem to want to split the contents of each text file into an array of words, you'll have to do a good bit more in your sub -- namely, read the file whose name you've passed (slurping if the file is not overly large) and do the appropriate processing on that file --- all within the existing sub.


Comment on Re: Open a directory and recursively process files
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2014-12-25 18:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (162 votes), past polls