Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Open a directory and recursively process files

by ww (Archbishop)
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,", 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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1012501]
and not a whimper to be heard...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2018-05-25 19:39 GMT
Find Nodes?
    Voting Booth?