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

Re: Looking for small csv files script question

by dasgar (Deacon)
on Dec 04, 2013 at 06:57 UTC ( #1065540=note: print w/ replies, xml ) Need Help??


in reply to Looking for small csv files script question

I'm not saying the other suggestions are wrong, but those suggestions are using some syntax that I personally don't understand - at least not without looking up documentation and/or doing some testing. That's why I would prefer going with something that I find easier to read and understand. Just a personal preference.

I haven't tested this, but the code below is something that I believe should accomplish what you're wanting to do and is something that I personally find much easier to read and understand.

use strict; use warnings; use File::Find::Rule; my $target = 'C:\temp'; my $rule = File::Find::Rule->new; $rule->file; # Look for files (-f test) $rule->name('*.csv'); # Look for filenames ending in .csv $rule->size(<5500); # Look for a size of less than 5500 bytes my @files = $rule->in($target); # The @files array will have the files that meet the 'rules' above.

I realize that this doesn't go well with your comment that you "can't install other File:Find module alternatives". Out of curiosity, why are you limited by not installing any modules?


Comment on Re: Looking for small csv files script question
Download Code
Re^2: Looking for small csv files script question
by PerlPlay (Novice) on Dec 04, 2013 at 08:45 UTC

    Hi Dasgar, thanks for your example. It looks simple enough, unfortunately it's a battle with our I.T Dept to get anything installed hence the File::Find only option.

      I'm not advocating that you should totally disregard's your employer's IT policies, but if your system at work has access to the internet and/or has a USB port that you can use, you can still get use Perl and "install" other modules.

      Since the path in your example code was "C:\Temp", I'm assuming that you're on Windows. In that case, I'd recommend checking out Strawberry Perl. It comes with everything you need to install modules from CPAN. They also have a portable version, which doesn't actually install Perl onto your system. Instead, you need to run a batch file that they provide in order to use their portable version.

      So if you really want to use other modules, I'd agree with Tux that there are ways to get that done.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2014-08-01 22:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (51 votes), past polls