find command

Discussion in 'Perl Misc' started by julia, Mar 8, 2005.

  1. julia

    julia Guest

    This command doesn't seem to be correct.

    find \&lsRuleFiles, "$rulesPath";

    Does someone can give me examples of the right syntax to use find command ?
    julia, Mar 8, 2005
    #1
    1. Advertising

  2. * julia wrote:
    >
    > This command doesn't seem to be correct.
    >
    > find \&lsRuleFiles, "$rulesPath";


    To me, this seems to be a simple call to File::Find's find-method. And
    if that agrees to your code (search for the string "use File::Find") I
    cannot see any problem with the one line above (except the needless
    quotes about $rulesPath).

    >
    > Does someone can give me examples of the right syntax to use find
    > command ?


    Have you already read the docs, e.g. at

    http://search.cpan.org/~nwclark/perl-5.8.6/lib/File/Find.pm

    ? Perhaps you'll consider to show us some more lines of your code, and
    explain what your code shall do.

    regards,
    fabian
    Fabian Pilkowski, Mar 8, 2005
    #2
    1. Advertising

  3. julia

    Guest

    julia wrote:
    >
    > This command doesn't seem to be correct.
    >
    > find \&lsRuleFiles, "$rulesPath";
    >
    > Does someone can give me examples of the right
    > syntax to use find command ?



    That looks correct to me -- providing you're using the find()
    function from the File::Find module. I'll even include that exact line
    in a small Perl script to demontrate that it is correct.

    All this Perl script does is print out the names of all files and
    directories found inside '.' (the current directory):


    #!/usr/bin/perl
    use strict;
    use warnings;

    use File::Find;

    sub lsRuleFiles
    {
    print "Found $File::Find::name\n";
    }

    my $rulesPath = '.'; # the current directory

    find \&lsRuleFiles, "$rulesPath";

    __END__


    So the line of code you provided works perfectly as is. If you
    still have a problem, you'll have to provide us with a small program
    that we can run to reproduce your exact problem. Once we can reproduce
    your problem and see the exact error message(s) that you see, then we
    can figure out what needs correcting.

    I hope this helps, Julia.

    -- Jean-Luc Romano
    , Mar 8, 2005
    #3
  4. julia

    Henry Law Guest

    On 8 Mar 2005 13:32:22 -0800, (julia) wrote:

    >This command doesn't seem to be correct.
    >
    > find \&lsRuleFiles, "$rulesPath";
    >
    >Does someone can give me examples of the right syntax to use find command ?


    perldoc file::find

    NAME
    File::Find - Traverse a directory tree.

    SYNOPSIS
    use File::Find;
    find(\&wanted, @directories_to_search);
    sub wanted { ... }

    If that's not enough then you'll have to follow the posting
    guidelines: create a small complete program that shows your problem
    and post it, saying what behaviour you expected and what actually
    happened.
    Henry Law, Mar 8, 2005
    #4
  5. julia <> wrote:

    > This command doesn't seem to be correct.

    ^^^^^^^^^^^^


    What did you observe that led you to belive that?

    You should provide one or more symptoms if you hope for a diagnosis.


    > find \&lsRuleFiles, "$rulesPath";
    >
    > Does someone can give me examples of the right syntax to use find command ?



    The above _is_ the right syntax to use the find command
    (apart from the useless use of quotes, don't do that)


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Mar 8, 2005
    #5
    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. San Diego Guy
    Replies:
    0
    Views:
    544
    San Diego Guy
    Aug 7, 2003
  2. Lucas Cowald
    Replies:
    4
    Views:
    1,050
    Tohid
    Oct 23, 2003
  3. Wybo Dekker
    Replies:
    1
    Views:
    352
    Yukihiro Matsumoto
    Nov 15, 2005
  4. vdvorkin
    Replies:
    0
    Views:
    399
    vdvorkin
    Feb 10, 2011
  5. vdvorkin
    Replies:
    3
    Views:
    808
    vdvorkin
    Feb 14, 2011
Loading...

Share This Page