Loading ...
Sorry, an error occurred while loading the content.

In the directory...know the prob...not the soln :-(

Expand Messages
  • dgds sdfsdf
    ok...I know what is happening now. this is my code. #! perl -w print directory please: ; chomp ($dir= ); $dir=~ (s/ / /); print file name: ; chomp
    Message 1 of 2 , Aug 31, 2001
    • 0 Attachment
      ok...I know what is happening now.

      this is my code.

      #! perl -w

      print "directory please: ";
      chomp ($dir=<>);
      $dir=~ (s/\\/\\\\/);

      print "file name: ";
      chomp ($file=<>);


      opendir (DIR, "$dir")|| die "could not open";
      if (defined ($file=readdir DIR)) {
      print "got it";
      }

      I know now that what is happening is that it is just
      looking for ANYTHING which is in the <DIR> filehandle,
      not refrencing back to my original $file scaler.

      how do I refrence it back to my original $file scaler?

      Thanks
      Ray



      ____________________________________________________________
      Do You Yahoo!?
      Get your free @... address at http://mail.yahoo.co.uk
      or your free @... address at http://mail.yahoo.ie
    • Jenda Krynicky
      ... I think you meant if ( $file eq readdir DIR) { though I don t know why don t you just print file name: ; chomp ($file= ); if (-e $dir $file ) {
      Message 2 of 2 , Aug 31, 2001
      • 0 Attachment
        > #! perl -w
        >
        > print "directory please: ";
        > chomp ($dir=<>);
        > $dir=~ (s/\\/\\\\/);
        >
        > print "file name: ";
        > chomp ($file=<>);
        >
        >
        > opendir (DIR, "$dir")|| die "could not open";
        > if (defined ($file=readdir DIR)) {

        I think you meant

        if ( $file eq readdir DIR) {

        though I don't know why don't you just

        print "file name: ";
        chomp ($file=<>);

        if (-e "$dir\\$file") {
        print "got it\n";
        }

        Jenda


        == Jenda@... == http://Jenda.Krynicky.cz ==
        : What do people think?
        What, do people think? :-)
        -- Larry Wall in <199808071736.KAA12738@...>
      Your message has been successfully submitted and would be delivered to recipients shortly.