Professional Web Applications Themes

not sure what I did ? - PERL Beginners

This script was running just fine before I changes the files in the directory handle. What I don't understand is why the file names are showing up when I run the script.... very confused. use strict; use Regexp::Common qw /URI/; my $dir = "/Program Files/OptiPerl/test_files"; opendir (TEST, $dir) or die "Can't open $dir: $!"; # ----------- load ARGV for <> operator below --------------- ARGV = grep { !/^\./ } readdir TEST; # ----------- $1 returns the entire URL {-keep} -------------- while (<>) { print "$ARGV $1\n" and close(ARGV) and next if /$RE{URI}{HTTP}{-keep}/; } closedir (TEST); Can't open 00047.TXT: No such ...

  1. #1

    Default not sure what I did ?

    This script was running just fine before I changes the files in the
    directory handle. What I don't understand is why the file names are showing
    up when I run the script.... very confused.

    use strict;
    use Regexp::Common qw /URI/;

    my $dir = "/Program Files/OptiPerl/test_files";
    opendir (TEST, $dir) or die "Can't open $dir: $!";

    # ----------- load ARGV for <> operator below ---------------

    ARGV = grep { !/^\./ } readdir TEST;

    # ----------- $1 returns the entire URL {-keep} --------------

    while (<>) {
    print "$ARGV $1\n" and close(ARGV) and next
    if /$RE{URI}{HTTP}{-keep}/;
    }

    closedir (TEST);

    Can't open 00047.TXT: No such file or directory
    Can't open 00311.TXT: No such file or directory
    Can't open 00324.TXT: No such file or directory

    Thanks!

    Brian

    Brian Guest

  2. #2

    Default RE: not sure what I did ?

    here is something even weirder... I just ran the script another dir and
    here is what it returned. The two files that it work on were the files that
    I was testing the script on....

    Can't open bcv_test.txt: No such file or directory at C:\Program
    Files\OptiPerl\test_web.pl line 28.
    Can't open 30691.txt: No such file or directory at C:\Program
    Files\OptiPerl\test_web.pl line 28.
    Can't open 03585.txt: No such file or directory at C:\Program
    Files\OptiPerl\test_web.pl line 28.
    Can't open 30711.txt: No such file or directory at C:\Program
    Files\OptiPerl\test_web.pl line 28.
    Can't open 30712.txt: No such file or directory at C:\Program
    Files\OptiPerl\test_web.pl line 28.
    Can't open 30714.txt: No such file or directory at C:\Program
    Files\OptiPerl\test_web.pl line 28.
    Can't open 8533-1.txt: No such file or directory at C:\Program
    Files\OptiPerl\test_web.pl line 28.
    Can't open rinsefree.txt: No such file or directory at C:\Program
    Files\OptiPerl\test_web.pl line 28.
    70072.txt
    http://www.spartanchemical.com/sfa/MSDSRep.nsf/docid/68674917D62B62C3852567D
    8004E39BE?OpenDoent
    70070.txt
    http://www.spartanchemical.com/sfa/MSDSRep.nsf/docid/0BA3D2C7AF46CE8D852567D
    3004E6108?OpenDoent

    really confused!

    Brian 
    Brian Guest

  3. #3

    Default Re: not sure what I did ?

    On Jul 15, 2004, at 3:34 PM, Brian Volk wrote:
     

    I'm betting that test file directory isn't the same one your code is
    running from. Reading the directory only gets you a name. You'll need
    to prepend a path, if needed.

    James

    James Guest

  4. #4

    Default RE: not sure what I did ?

    Brian Volk <com> wrote:

    :: This script was running just fine before I changes the files in the
    :: directory handle. What I don't understand is why the file names are
    :: showing up when I run the script.... very confused.
    ::
    :: use strict;
    :: use Regexp::Common qw /URI/;
    ::
    :: my $dir = "/Program Files/OptiPerl/test_files";
    :: opendir (TEST, $dir) or die "Can't open $dir: $!";
    ::
    :: # ----------- load ARGV for <> operator below ---------------
    ::
    :: ARGV = grep { !/^\./ } readdir TEST;
    ::
    :: # ----------- $1 returns the entire URL {-keep} --------------
    ::
    :: while (<>) {
    :: print "$ARGV $1\n" and close(ARGV) and next
    :: if /$RE{URI}{HTTP}{-keep}/;
    :: }
    ::
    :: closedir (TEST);
    ::
    :: Can't open 00047.TXT: No such file or directory
    :: Can't open 00311.TXT: No such file or directory
    :: Can't open 00324.TXT: No such file or directory

    Do 00047.TXT, 00311.TXT, and open 00324.TXT actually
    exist in the directory in which you tried to open them?


    : here is something even weirder... I just ran the script
    : another dir and here is what it returned. The two files
    : that it work on were the files that I was testing the
    : script on....
    :
    : Can't open bcv_test.txt: No such file or directory at C:\Program
    Files\OptiPerl\test_web.pl line 28.
    : Can't open 30691.txt: No such file or directory at C:\Program
    Files\OptiPerl\test_web.pl line 28.
    : Can't open 03585.txt: No such file or directory at C:\Program
    Files\OptiPerl\test_web.pl line 28.
    : Can't open 30711.txt: No such file or directory at C:\Program
    Files\OptiPerl\test_web.pl line 28.
    : Can't open 30712.txt: No such file or directory at C:\Program
    Files\OptiPerl\test_web.pl line 28.
    : Can't open 30714.txt: No such file or directory at C:\Program
    Files\OptiPerl\test_web.pl line 28.
    : Can't open 8533-1.txt: No such file or directory at C:\Program
    Files\OptiPerl\test_web.pl line 28.
    : Can't open rinsefree.txt: No such file or directory at C:\Program
    Files\OptiPerl\test_web.pl line 28.
    : 70072.txt
    : http://www.spartanchemical.com/sfa/MSDSRep.nsf/docid/68674917D
    : 62B62C3852567D 8004E39BE?OpenDoent
    : 70070.txt
    : http://www.spartanchemical.com/sfa/MSDSRep.nsf/docid/0BA3D2C7A
    : F46CE8D852567D 3004E6108?OpenDoent
    :
    : really confused!


    Here's something weird. The errors are on line 28,
    but the script you gave us is only 18 lines long. How's
    about showing us the first 40 lines of the script. Then
    tell us which line you changed and what that line looked
    like each time you changed it.

    HTH,

    Charles K. Clarkson
    --
    Mobile Homes Specialist
    254 968-8328



    Charles Guest

  5. #5

    Default Re: not sure what I did ?

    Brian Volk wrote: 

    As I told you in another thread, that just grabs the file names, while
    you likely need the full paths.
    http://www.mail-archive.com/beginners%40perl.org/msg59814.html

    Why do you keep starting new threads about this topic instead of
    posting follow-ups?? And was "not sure what I did?" the most useless
    subject you were able to find for this new thread? :(

    Try:

    ARGV = map { "$dir/$_" } grep { !/^\./ } readdir TEST;

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Guest

  6. #6

    Default RE: not sure what I did ?

    Gunnar Hjalmarsson wrote:
     

    Yes, you did. I actually just wanted the file name, but hey, your way
    works, so I'll stick w/ that.
     


    I posted the new thread because the script was working fine w/

    ARGV = grep { !/^\./ } readdir TEST;

    until I changed the directory. I thought it was a new problem hence a new
    thread, but I see your point... and yes I will try and use more usefull
    subject line.

    Thank you for you help.

    Brian Volk

    -----Original Message-----
    From: Gunnar Hjalmarsson [mailto:cc]
    Sent: Thursday, July 15, 2004 5:17 PM
    To: org
    Subject: Re: not sure what I did ?


    Brian Volk wrote: 

    As I told you in another thread, that just grabs the file names, while
    you likely need the full paths.
    http://www.mail-archive.com/beginners%40perl.org/msg59814.html

    Why do you keep starting new threads about this topic instead of
    posting follow-ups?? And was "not sure what I did?" the most useless
    subject you were able to find for this new thread? :(

    Try:

    ARGV = map { "$dir/$_" } grep { !/^\./ } readdir TEST;

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl

    --
    To unsubscribe, e-mail: org
    For additional commands, e-mail: org
    <http://learn.perl.org/> <http://learn.perl.org/first-response>


    Brian Guest

  7. #7

    Default Re: not sure what I did ?

    Brian Volk wrote: 
    >
    > Yes, you did. I actually just wanted the file name, but hey, your
    > way works, so I'll stick w/ that.[/ref]

    If you only want the file names in ARGV, setting the working
    directory before the while loop is an alternative:

    chdir $dir;

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Guest

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139