Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

I am very new to Perl, and don't know how to debug this error

There are checklists for that , I use them all the time (don't be fooled by the titles), Basic debugging checklist , brian's Guide to Solving Any Perl Problem, CGI Help Guide , Troubleshooting Perl CGI scripts ... More generic advice :) On debugging, verify everything, talk to teddybear ... checklists and more , perltrap, perltrap, Common Perl Pitfalls / perltrap

"permission denied" is about as clear as it can get: Q: can I have this cookie? A: No.

its because readdir does NOT return the complete path and you forgot to chdir

readdir is very low level, if you use Path::Tiny it can even do the die-ing for you, ex

$ perl -e " use Path::Tiny qw/ path /; path(qw/./)->openrw_raw; " Error open (+<:raw) on '.': Permission denied at -e line 1.

Then you can write functions that take arguments like this

#!/usr/bin/perl -- use strict; use warnings; use POSIX(); use Path::Tiny qw/ path /; Main( @ARGV ); exit( 0 ); sub Main { my $date = POSIX::strftime('%Y-%m-%d', localtime); my $dirp = path( 'f:/lawprod/law/prd9/work/COMDATAFILE/IN/' ); my $diri = $dirp->iterator( { qw/ recurse 0 / }); while( my $file = $diri->() ){ if( $file =~ /^\Q$threenodes\E/ ){ FrobnicateInnoculate( $file->openrw_raw ); } } } sub FrobnicateInnoculate { my( $filehandle ) = @_; ... close $filehandle; }

cpan Path::Tiny

perlintro#Simple matching, quotemeta, eq for string comparison not == (because perlnumber), http://p3rl.orrg/POSIX#strftime

chromatics free book Modern Perl a loose description of how experienced and effective Perl 5 programmers work....You can learn this too.
Learn Perl in about 2 hours 30 minutes
Beginning Perl (free) Chapter 6: Files and Data


In reply to Re: error on file open by Anonymous Monk
in thread error on file open by maynard517

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (10)
    As of 2014-09-19 17:20 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (143 votes), past polls