File handeling

T

Truthless

Hello All,

While I am familiar with programing concepts I am quite new to perl. I
am trying to find out what methods does perl use to retrieve file
information. For example the size of a file and search for files over a
certain size.

I am looking for something similar to the bash command:

find /home/*/*-mail/ -size +10000k

I use that in a bash script for compressing large mail boxes.

Could someone please point me in the right direction? Perhaps provide me
with a small example?

Thanks in advance for any avice.


Truthless
 
T

Truthless

Carsten said:
Hi nameless one ;-),

I think a good starting point would be to look at 'perldoc -f -s' which
should list you possible operators to get info about a file, e.g. -s
$filename will return you the size of a file in bytes.

Secondly, the standard module File::Find ('perldoc File::Find') will
help you emulating some parts of the find program.

HTH

CA

Hello,

Thanks for the info all who replied.

Guess I need to learn more about the include modules. No sense
reinventing the wheel.
 
E

Erik Tank

I would use the File::Find module to find all files and then you can
use the stat function to get the size and other attribute information
about the files. To get information about each:
File::Find - man File::Find
if you don't have it install you can get it from CPAN
stat - perldoc -f stat
also check out perldoc -f -x
 
C

Carsten Aulbert

Hi nameless one ;-),
While I am familiar with programing concepts I am quite new to perl. I
am trying to find out what methods does perl use to retrieve file
information. For example the size of a file and search for files over a
certain size.

I think a good starting point would be to look at 'perldoc -f -s' which
should list you possible operators to get info about a file, e.g. -s
$filename will return you the size of a file in bytes.

Secondly, the standard module File::Find ('perldoc File::Find') will help
you emulating some parts of the find program.

HTH

CA
 
H

Helgi Briem

Guess I need to learn more about the include modules. No sense
reinventing the wheel.

Exactly.

The first step in learning Perl is to learn to use the
tools and documentation that come with it.

Now to find out what the File::Find module does for you,
open a command line and type the following:

perldoc File::Find

This will tell you a lot.

To study the documentation for a function, use

perldoc -f FUNCTION_NAME

To search for a word in the headings of various
Frequently Asked Questions, type

perldoc -q KEYWORD

To learn more, have a look at:

perldoc perl
perldoc perldoc
perldoc perlrun
perldoc perltoc

I hope this helps.
 
J

James Willmore

While I am familiar with programing concepts I am quite new to perl.
I am trying to find out what methods does perl use to retrieve file
information. For example the size of a file and search for files
over a certain size.

I am looking for something similar to the bash command:

find /home/*/*-mail/ -size +10000k

I use that in a bash script for compressing large mail boxes.

Could someone please point me in the right direction? Perhaps
provide me with a small example?

Since you already have what you want to find all worked out, you could
use find2perl - which is a nice little app developed from .... the
File::Find module :)

perldoc find2perl -or- man find2perl

Read up on the File::Find module usage to interpret the results.

HTH

--
Jim

Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.

a fortune quote ...
Democracy is a form of government in which it is permitted to
<wonder aloud what the country could do under first-class
<management. -- Senator Soaper
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top