Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Stopping empty files from been pushed into an array.

by roboticus (Chancellor)
on May 13, 2015 at 19:49 UTC ( [id://1126593]=note: print w/replies, xml ) Need Help??


in reply to Stopping empty files from been pushed into an array.

ogbalex:

Sure, just don't push the file onto the array if they're empty:

push @array, $file_name unless length($file_contents) < 1;

Update: Corrected len to length. (Too much Python today at work...)

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Replies are listed 'Best First'.
Re^2: Stopping empty files from been pushed into an array.
by Your Mother (Archbishop) on May 13, 2015 at 20:38 UTC

    What is len()? :P

      Why, it is of course:

      sub len{ return do { local(@ARGV, $/) = $_[0]; <> } =~ y===c; }

      :P

      Disclaimer: use -s $filename. This code is ineficient and ment as a timtoady

      Your Mother:

      len() is a function that gives you the length of things....


      ...in python

      ...roboticus

      When your only tool is a hammer, all problems look like your thumb.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-04-24 07:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found