SPUG: RE: Simple program - gone wrong

Can Subaykan cansubaykan at hotmail.com
Wed Jul 10 12:17:52 CDT 2002


try this, to only get .htm and .html files from the upper directory:


$dir = "../";
$log = "./path/to/your/list_file.txt";

opendir DIR, $dir or die "ow! $!";
@files = grep { /^[^.].*\.html?$/ and -f "$dir/$_" } readdir DIR;
closedir DIR;

$i = 1;  # to start numbering at 1

open LOG, ">$log" or die "ow! $!";

for (@files) {

   print LOG "$i | $_ \n";
   $i++;

}

close LOG;




__END__
# John


PS.  one of you fellows' example opened a directory with opendir, and closed 
it with close (instead of closedir).  not a big deal. just being picky ;)







----Original Message Follows----
From: "Sweethomes" <sweetsue at sweethomes.com>
To: <spug-list at pm.org>
Subject: RE: SPUG: RE: Simple program - gone wrong
Date: Mon, 8 Jul 2002 11:44:57 -0700

Ok, this almost works.  The numbering doesn't seem right.  What it's doing
is listing all files as it should but the first set is all marked with "0",
then it repeats the file listing each with "1" in front of it.  This repeats
to "100" at which point it stops.  I need it to number each file like so:

1 | index.html
2 | black_line.gif
3 | counter.php
4 | counter.txt
5 | formmail.php
6 | logo.gif
7 | favicon.ico
8 | help.html
9 | main.html

etc.  From here I can figure out how to filter out the .txt and the .gif
etal leaving the .html files only.

Thanks - you guys are great!

Susanne

-----Original Message-----
From: owner-spug-list at pm.org [mailto:owner-spug-list at pm.org]On Behalf Of
Chris Wilkes
Sent: Monday, July 08, 2002 11:02 AM
To: spug-list at pm.org
Subject: Re: SPUG: RE: Simple program - gone wrong


On Mon, Jul 08, 2002 at 10:47:38AM -0700, Chris Wilkes wrote:
 >   for my $num (0..100) {
 >     foreach (@files) {
 >       print RDIR, "$num | $_\n";
 >     }
 >   }

Arg there shouldn't be a comma in there.  Should just be:
	print RDIR "$num | $_\n";

Chris

  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
       Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
   Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
  For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
      Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org


  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
       Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
   Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
  For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
      Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org




_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx


 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org




More information about the spug-list mailing list