Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > File handeling

Reply
Thread Tools

File handeling

 
 
Truthless
Guest
Posts: n/a
 
      12-11-2003
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

 
Reply With Quote
 
 
 
 
Truthless
Guest
Posts: n/a
 
      12-11-2003
Carsten Aulbert wrote:
> 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.

 
Reply With Quote
 
 
 
 
Erik Tank
Guest
Posts: n/a
 
      12-11-2003
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


On Thu, 11 Dec 2003 05:38:38 +0000, Truthless <(E-Mail Removed)>
wrote:

>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


 
Reply With Quote
 
Carsten Aulbert
Guest
Posts: n/a
 
      12-11-2003
Hi nameless one ,

Truthless wrote:

> 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
 
Reply With Quote
 
Helgi Briem
Guest
Posts: n/a
 
      12-11-2003
On Thu, 11 Dec 2003 06:14:19 +0000, Truthless <(E-Mail Removed)>
wrote:

>> 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.


>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.
 
Reply With Quote
 
James Willmore
Guest
Posts: n/a
 
      12-11-2003
On Thu, 11 Dec 2003 05:38:38 +0000
Truthless <(E-Mail Removed)> wrote:
>
> 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
 
Reply With Quote
 
Erik Tank
Guest
Posts: n/a
 
      12-11-2003
IMHO - Perl is the best language that attempts to garauntee that you
don't have to reinvent the wheel. Check out this article from Randal
Schwartz' Web Techniques articles;
http://www.stonehenge.com/merlyn/Web...ues/col01.html


On Thu, 11 Dec 2003 06:14:19 +0000, Truthless <(E-Mail Removed)>
wrote:

>Carsten Aulbert wrote:
>> 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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
handeling very large dictionaries mclovin Python 3 06-29-2009 05:54 AM
SqlDataSource is doing an Update after handeling an Insert excepti masmith ASP .Net Web Controls 1 02-20-2009 06:15 PM
Question on Exception Handeling in webservices? ltnats@yahoo.com.au ASP .Net Web Services 2 07-08-2006 06:26 PM
[question] Event Handeling Between Two wxPanles in A wxNotebook support.services.complaints@gmail.com Python 4 03-21-2005 06:26 AM
Handeling connection timeout GMK ASP .Net Security 0 02-26-2005 09:43 AM



Advertisments