Hi Monks: I get an error that says "readdir() attempted on invalid dirhandle DH" from the code below, so what do I do, Thanks, Chet:
#!/usr/bin/perl use strict; use warnings; my $outputfile ="Test_PDB_ID_list.txt"; my $four_char_PDB_ID=''; open (PDB_IDs,">", "$outputfile"); my $PDB_ID= ''; my $dir_to_process= ''; print "What is the directory to process?"; $dir_to_process = <STDIN>; #$dir_to_process = "Targets-IonChannel";-if I used this #line it would + work #open the folder unless (opendir(DH, $dir_to_process)){ print "Cannot open folder $dir_to_process!\n"; } print "$dir_to_process\n"; foreach $PDB_ID (readdir DH){ $four_char_PDB_ID =substr($PDB_ID,0,4); print PDB_IDs "$four_char_PDB_ID\n"; print "$four_char_PDB_ID \n"; }; exit;

What is the directory to process?

Targets-IonChannel

Cannot open folder

Targets-IonChannel

!

Targets-IonChannel

readdir() attempted on invalid dirhandle DH at C:\Users\cseligman\Documents\Eclipseworkspace\DrugTargets\GetPDBnames-1.pl line 21, <STDIN> line 1.

In reply to Get a DH from <STDIN>? by cseligman

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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.