Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: path-names [a very easy question of a true beginner]

by Khen1950fx (Canon)
on Oct 02, 2010 at 03:56 UTC ( #863036=note: print w/ replies, xml ) Need Help??


in reply to path-names [a very easy question of a true beginner]

As regards File::Find::Rule, since you are dealing with a bunch of files, you'll get better results if you do a foreach. For example,

#!/usr/bin/perl use strict; use warnings; use diagnostics; use File::Find::Rule; my @files = File::Find::Rule->file() ->name('*.html') ->in( '/usr/local/apache/cgi-bin' ); foreach my $file(@files) { print $file, "\n"; }


Comment on Re: path-names [a very easy question of a true beginner]
Download Code
Re^2: path-names [a very easy question of a true beginner]
by Perlbeginner1 (Scribe) on Oct 02, 2010 at 09:15 UTC
    Hello khen1950fx

    many thanks for the reply - great to hear form you!

    my question is regarding the I-O handle and the path names. I have to find the right path names. Names and conventions that match the linux conventions...My machine runs OpenSuse-Linux version 11.3.

    i took your example and made some slight corrections...

    i took your hints and made this:

    #!/usr/bin/perl use strict; use warnings; use diagnostics; use File::Find::Rule; my @files = File::Find::Rule->file() ->name('*.html') ->in( 'home/usr/perl/html.files' ); foreach my $file(@files) { print $file, "\n"; }



    response:

    suse-linux:/usr/perl # perl perl_script_two.pl
    Can't stat home/usr/html.files: No such file or directory at /usr/lib/perl5/site_perl/5.12.1/File/Find/Rule.pm line 594
    suse-linux:/usr/perl #


    love to hear from you and appreciate any and all help!
    perlbeginner1
      You're using a relative path. I tried it, but I got the same result. Use the absolute path, and it works:).
      #!/usr/bin/perl use strict; use warnings; use diagnostics; use File::Find::Rule; my @files = File::Find::Rule->file() ->name('*.html') ->in( '/home/usr/perl/html.files' ); foreach my $file(@files) { print $file, "\n"; }
        hello dear Khen1950fx

        many many thanks for the quick reply: i am very happy to hear from you! i changed the paths also to absolut -but i did not have the good results here....

        >
        i found out that i made some mistakes while talking bout the html-files: Note: there are more than 20 000 Html files in the directory that is called htmlfiles Note i renamed it to htmlfiles - instead of html.files but the files itself are all named like the following sheme:

        einzelergebnis1...
        einzelergebnis2...
        einzelergebnis3a...
        einzelergebnis3b...
        einzelergebnis3d...

        and so forth...
        so my question is: how is the convention to call it here in this line:

        ->name('*.einzel')

        how to name this line

        -> name('*.einzel')

        or -> name('einzel*.')

        I ask this question - since i guess that perl does not find the files - since i have the wrong naming convention...

        Here the code that might run for you - as you have put some files into the folder - that are named with html*
        #!/usr/bin/perl use strict; use warnings; use diagnostics; use File::Find::Rule; my @files = File::Find::Rule->file() ->name('*.einzel') ->in( '/home/usr/htmlfiles' ); foreach my $file(@files) { print $file, "\n"; }
        i love to hear from you!
        Btw - if i have to clear my question and ask more precisely - then let me know!

        regards
        perlbeginner1
      hello dear Now it is clear i misunderstood the german Word Basisordner

      The german word Basisordner in OpenSuseLinux was the directory that i thought is exactly the HOME

      That is not true: The Basisordner ist not "/home" but "/"

      Accordingly i leave /home in in the Skript ;)

      then we have:

      suse-linux:/usr/perl # ls -al /usr/perl/htmlfiles/


      results: <code>

      -rwxrwxrwx 1 root root 16855 Sep 22 02:37 einzelergebnisedf8.html
      -rwxrwxrwx 1 root root 16893 Sep 22 04:27 einzelergebnisedfe.html
      -rwxrwxrwx 1 root root 17035 Sep 22 02:55 einzelergebnisee02.html
      -rwxrwxrwx 1 root root 16926 Sep 22 03:38 einzelergebnisee05-2.html
      -rwxrwxrwx 1 root root 17042 Sep 22 01:03 einzelergebnisee05.html
      -rwxrwxrwx 1 root root 16986 Sep 22 03:10 einzelergebnisee06.html
      -rwxrwxrwx 1 root root 17784 Sep 22 03:43 einzelergebnisee08-2.html
      -rwxrwxrwx 1 root root 17016 Sep 21 23:55 einzelergebnisee08.html
      -rwxrwxrwx 1 root root 17456 Sep 22 00:08 einzelergebnisee0c.html
      -rwxrwxrwx 1 root root 17176 Sep 22 03:36 einzelergebnisee15.html
      -rwxrwxrwx 1 root root 17568 Sep 22 03:45 einzelergebnisee16.html
      -rwxrwxrwx 1 root root 17216 Sep 21 23:56 einzelergebnisee18.html
      -rwxrwxrwx 1 root root 17011 Sep 22 04:21 einzelergebnisee1b.html
      -rwxrwxrwx 1 root root 16898 Sep 22 01:02 einzelergebnisee24.html
      -rwxrwxrwx 1 root root 16992 Sep 22 04:32 einzelergebnisee29.html
      -rwxrwxrwx 1 root root 16898 Sep 22 04:13 einzelergebnisee2d.html
      -rwxrwxrwx 1 root root 17051 Sep 22 03:14 einzelergebnisee31.html
      -rwxrwxrwx 1 root root 16922 Sep 22 04:22 einzelergebnisee35.html
      -rwxrwxrwx 1 root root 17104 Sep 22 00:42 einzelergebnisee3d.html
      -rwxrwxrwx 1 root root 17113 Sep 22 03:03 einzelergebnisee3e.html
      -rwxrwxrwx 1 root root 16961 Sep 22 04:29 einzelergebnisee3f.html
      -rwxrwxrwx 1 root root 17040 Sep 22 03:40 einzelergebnisee45.html
      -rwxrwxrwx 1 root root 17027 Sep 22 00:03 einzelergebnisee4c.html
      -rwxrwxrwx 1 root root 16850 Sep 22 02:56 einzelergebnisee4f-2.html
      -rwxrwxrwx 1 root root 17053 Sep 22 03:55 einzelergebnisee4f-3.html
      -rwxrwxrwx 1 root root 17159 Sep 22 00:56 einzelergebnisee4f.html
      -rwxrwxrwx 1 root root 19650 Sep 21 23:49 einzelergebnisee55.html


      and so forth ----.. more than 20 000 lines...

      suse-linux:/usr/perl # cd usr/QUOTE


      now we are a step ahead. That is great!

      perlbeginner1

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (12)
As of 2014-10-22 16:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (119 votes), past polls