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

Read Dir

Expand Messages
  • ROB Technology
    Hello. I need help with the readdir function. I have the following piece of coding: $tdir = /mydir ; opendir(THUMBS, $tdir ) || die ( Can t open directory:
    Message 1 of 3 , Mar 30, 2002
    • 0 Attachment
      Hello. I need help with the readdir function. I have the following piece of
      coding:

      $tdir = "/mydir";
      opendir(THUMBS, "$tdir") || die ("Can't open directory: $tdir because $!");
      @AllFiles = readdir(THUMBS);
      foreach $Thumb (@AllFiles){
      if(-d $Thumb){ next }
      }

      How do I modify that piece of coding so that it prints a list of the files
      with a radio button next to them so a user can select which one they want.
      Thanks.
      -Rob
    • ROB Technology
      Thank you so much! It worked! ... From: coo_t2 [mailto:coo_t2@yahoo.com] Sent: Sunday, March 31, 2002 4:35 AM To: perl-beginner@yahoogroups.com Subject: [PBML]
      Message 2 of 3 , Mar 30, 2002
      • 0 Attachment
        Thank you so much! It worked!

        -----Original Message-----
        From: coo_t2 [mailto:coo_t2@...]
        Sent: Sunday, March 31, 2002 4:35 AM
        To: perl-beginner@yahoogroups.com
        Subject: [PBML] Re: Read Dir


        I just put a post up, but I need to modify something in it, so I
        deleted it
        and am reposting this one. Just in case anyone gets two similar
        posts in their
        email. This is the one I wanted to post!!
        ------------

        It really depends on what you
        need to get done.
        But this will give you a radio button next to the file name.
        The file name will be the value for each field.

        It seems that in my experience, you have to provide the full path
        when using a file test operator like -d or -e or -f or whatever.
        That's why I modified that part.
        Also have to closedir() when you're done with it.

        ------ START CODE ------


        print qq|<form method="post" action="script_name.cgi">|;

        $tdir = 'mydir/';
        opendir(THUMBS, "$tdir") || die ("Can't open directory: $tdir because
        $!");
        @AllFiles = readdir(THUMBS) || die "Can't open dir: $!<BR>";
        foreach $Thumb (@AllFiles){
        if(-d "$tdir$Thumb"){ next; }
        print qq|<input type="radio" name="the_file" value="$Thumb">$Thumb
        <BR>|;

        }

        closedir(THUMBS);


        print qq|<input type="submit" value="submit">
        </form>|;

        ----- END CODE --------


        hth,
        --ed


        --- In perl-beginner@y..., "ROB Technology" <rob@r...> wrote:
        > Hello. I need help with the readdir function. I have the following
        piece of
        > coding:
        >
        > $tdir = "/mydir";
        > opendir(THUMBS, "$tdir") || die ("Can't open directory: $tdir
        because $!");
        > @AllFiles = readdir(THUMBS);
        > foreach $Thumb (@AllFiles){
        > if(-d $Thumb){ next }
        > }
        >
        > How do I modify that piece of coding so that it prints a list of
        the files
        > with a radio button next to them so a user can select which one
        they want.
        > Thanks.
        > -Rob



        Unsubscribing info is here:
        http://help.yahoo.com/help/us/groups/groups-32.html

        Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
      • coo_t2
        I just put a post up, but I need to modify something in it, so I deleted it and am reposting this one. Just in case anyone gets two similar posts in their
        Message 3 of 3 , Mar 31, 2002
        • 0 Attachment
          I just put a post up, but I need to modify something in it, so I
          deleted it
          and am reposting this one. Just in case anyone gets two similar
          posts in their
          email. This is the one I wanted to post!!
          ------------

          It really depends on what you
          need to get done.
          But this will give you a radio button next to the file name.
          The file name will be the value for each field.

          It seems that in my experience, you have to provide the full path
          when using a file test operator like -d or -e or -f or whatever.
          That's why I modified that part.
          Also have to closedir() when you're done with it.

          ------ START CODE ------


          print qq|<form method="post" action="script_name.cgi">|;

          $tdir = 'mydir/';
          opendir(THUMBS, "$tdir") || die ("Can't open directory: $tdir because
          $!");
          @AllFiles = readdir(THUMBS) || die "Can't open dir: $!<BR>";
          foreach $Thumb (@AllFiles){
          if(-d "$tdir$Thumb"){ next; }
          print qq|<input type="radio" name="the_file" value="$Thumb">$Thumb
          <BR>|;

          }

          closedir(THUMBS);


          print qq|<input type="submit" value="submit">
          </form>|;

          ----- END CODE --------


          hth,
          --ed


          --- In perl-beginner@y..., "ROB Technology" <rob@r...> wrote:
          > Hello. I need help with the readdir function. I have the following
          piece of
          > coding:
          >
          > $tdir = "/mydir";
          > opendir(THUMBS, "$tdir") || die ("Can't open directory: $tdir
          because $!");
          > @AllFiles = readdir(THUMBS);
          > foreach $Thumb (@AllFiles){
          > if(-d $Thumb){ next }
          > }
          >
          > How do I modify that piece of coding so that it prints a list of
          the files
          > with a radio button next to them so a user can select which one
          they want.
          > Thanks.
          > -Rob
        Your message has been successfully submitted and would be delivered to recipients shortly.