File handeling

Discussion in 'Perl Misc' started by Truthless, Dec 11, 2003.

  1. Truthless

    Truthless Guest

    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
     
    Truthless, Dec 11, 2003
    #1
    1. Advertising

  2. Truthless

    Truthless Guest

    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.
     
    Truthless, Dec 11, 2003
    #2
    1. Advertising

  3. Truthless

    Erik Tank Guest

    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 <>
    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
     
    Erik Tank, Dec 11, 2003
    #3
  4. 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
     
    Carsten Aulbert, Dec 11, 2003
    #4
  5. Truthless

    Helgi Briem Guest

    On Thu, 11 Dec 2003 06:14:19 +0000, Truthless <>
    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.
     
    Helgi Briem, Dec 11, 2003
    #5
  6. On Thu, 11 Dec 2003 05:38:38 +0000
    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 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
     
    James Willmore, Dec 11, 2003
    #6
  7. Truthless

    Erik Tank Guest

    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/WebTechniques/col01.html


    On Thu, 11 Dec 2003 06:14:19 +0000, Truthless <>
    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.
     
    Erik Tank, Dec 11, 2003
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    4
    Views:
    456
    F. GEIGER
    Mar 21, 2005
  2. mclovin

    handeling very large dictionaries

    mclovin, Jun 29, 2009, in forum: Python
    Replies:
    3
    Views:
    327
    Joseph Turian
    Jun 29, 2009
  3. GMK

    Handeling connection timeout

    GMK, Feb 26, 2005, in forum: ASP .Net Security
    Replies:
    0
    Views:
    111
  4. masmith
    Replies:
    1
    Views:
    944
    masmith
    Feb 20, 2009
  5. Replies:
    2
    Views:
    148
Loading...

Share This Page