[6315] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 937 Volume: 7

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 13 03:17:20 1997

Date: Thu, 13 Feb 97 00:00:25 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 13 Feb 1997     Volume: 7 Number: 937

Today's topics:
     "scalar each"  - what does it mean? (Thomas Andrews)
     Re: Appending to the top of a document... (Nathan V. Patwardhan)
     Choosing Good Subject Lines [Periodic Posting] (Dean Roehrich)
     compiling perl <Morten@everyday.no>
     Date manipulations -- handy functions. (David Tweed)
     DBfile verses no DBfile (Geoffrey Hebert)
     Re: Does Net::FTP modules work under Win32 Perl5 ? (Nathan V. Patwardhan)
     Re: Help with Redirect Script (Nathan V. Patwardhan)
     Re: Help with Redirect Script (Tad McClellan)
     Re: How to do this using perl? (Tom Limoncelli)
     Re: Perl Compiler for a large project (Steven L. Kunz)
     Re: PERL FOR WINDOWS (Nathan V. Patwardhan)
     PING in Perl for Win32 (Paul Downing)
     Re: PING in Perl for Win32 (Nathan V. Patwardhan)
     REQ: Getting the amount of files in a certain directory <nathanr@k2.ashpool.com>
     REQ: Getting the amount of files in a certain directory (Nathan V. Patwardhan)
     Re: REQ: Getting the amount of files in a certain direc (Nathan V. Patwardhan)
     Re: REQ: Getting the amount of files in a certain direc (Nathan V. Patwardhan)
     Re: REQ: Getting the amount of files in a certain direc <egwong@netcom.com>
     Test (Laurie Cowcher)
     Test2 (Laurie Cowcher)
     Re: Using $ENV{'QUERY_STRING'} (Donald H. Locker)
     Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 12 Feb 1997 17:00:02 -0800
From: thomaso@best.com (Thomas Andrews)
Subject: "scalar each"  - what does it mean?
Message-Id: <5dtp2i$6k@shellx.best.com>

My Perl 5 Camel book has the following code in the TIEHASH example
(on pg 315):

    sub NEXTKEY {
        carp &whowasi if $DEBUG;
        my $self=shift;
        return scalar each %{ $self->{CONTENTS} };
    }

For the life of me, I couldn't figure out what the "scalar" is doing
here.  I thought "each" returned a perl list of two elements - a
key and value.  And when you evaluate the list in "scalar" context
it returns the number of elements, which would be 2 if we are still
processing, and 0 otherwise.

Am I missing something?  The doc on "each" in chapter 3 doesn't list
anything special about how it evaluates in a scalar context...


        
-- 
==
Thomas Andrews         thomaso@best.com         http://www.best.com/~thomaso/
  "In the end, Bork's book does raise questions, but the principal
   one is:  What planet does he live on?" - David Cole, Wash. Monthly


------------------------------

Date: 13 Feb 1997 01:31:57 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Appending to the top of a document...
Message-Id: <5dtqud$fgb@fridge-nf0.shore.net>

ubiquitous (Jonathan Eisenman) (ubiquitous@beachside.com) wrote:
: ...is it possible?  I once saw it done (I think it is what they were doing)
: with a for statement, but I like to be original, and after all, quoting
[snip]

I've always done something using read/write mode.

$logfile = '/path/logfile.log';

open(LOG, "+<$logfile") || print("NO: $!\n"); ###open in read/write mode
@lines = <LOG>; ### slurp lines in an array
seek(LOG,0,0); ### start at the beginning of the file
print LOG "New text here.\n";

### now put the old stuff back.
foreach $line (@lines) {
   print LOG $line; ### output the line back into the logfile
}
close(LOG);

HTH!

--
Nathan V. Patwardhan
nvp@shore.net
"Lane, this is pure snow!
Do you have any idea what
the street value of this mountain is?"
	--Charles Demar from _Better Off Dead_


------------------------------

Date: 13 Feb 1997 03:02:18 GMT
From: roehrich@cray.com (Dean Roehrich)
Subject: Choosing Good Subject Lines [Periodic Posting]
Message-Id: <subjects_855802917@cray.com>

NAME
     subject_lines - Choosing Good Subject Lines

DESCRIPTION
     The quality of your article's subject line will dictate the
     quality of the responses you receive.  Choose your subject
     lines wisely.

GOOD SUBJECT LINES
     These subject lines indicate exactly what the article will
     be about and are therefore quality subject lines.

             Putting Commas in a number
             Can I print "~" (tilde) in a format?
             Assigning to an @array and undefined value.
             Printing/calling date/time using unix gmtime
             How to install individual modules like CGI-Lite?
             getpwnam() & Solaris's /etc/shadow file


BAD SUBJECT LINES
     These subject lines say nothing about the content in the
     article.

             Where do I start???!! :-(
             How hard would this job be?
             Can YOU solve this simple problem?!
             Testing.
             04]?
             Simple split question

     These subject lines use negative-flash words.  See the
     section on NEGATIVE-FLASH WORDS.

             Perl newbie with cgi script problem
             Newbie needs help
             Total Beginner Reqs. Help - Please.
             Simple split question
             Can YOU solve this simple problem?!


NO SUBJECT LINE
     Many of the people who give high-quality responses will tend
     to ignore posts which have no subject line at all.

NEGATIVE-FLASH WORDS
     The following words are guaranteed to make large numbers of
     people deliberately ignore your article.  I call these
     negative-flash words.

     beginner  Many people ignore articles which have these words
               in their subject lines.

     emergency News propagation is too slow.  By the time anyone
               gets to read it your condition has probably been
               upgraded to catastrophic.  By the time you get
               their response you'll be dead.  Don't waste other
               people's time with this stuff.

     expert    See guru.

     girl      The people who can give you the highest-quality
               responses probably aren't in the mood for this
               sort of trolling.

     guru      The truth is that it's probably a non-guru
               question.  Most gurus will ignore any article that
               has this word in its subject line.

     help      It sounds like you've given up, or, more likely,
               haven't tried.  Omit this word and the rest of
               your subject line will probably be a high-quality
               attention-getter.

     newbie    See beginner.

     novice    See beginner.

     please    Don't beg.  It's a turn-off.

     question  It's too obvious, and probably answered in the
               manpages or the FAQ.

     sex       See girl.

     simple    This word should tell you something--that you need
               to look at the manpages a little harder.  Don't
               waste other people's time with this stuff.

     stupid    It's just plain derogatory.  People don't like to
               waste their time on things that are stupid.  Hint:
               don't tell them it's stupid, and you will get a
               higher-quality response.

     urgent    See emergency.

     woman     See girl.

NEGATIVE-FLASH EFFECTS
     The following effects, like the above list of negative-flash
     words, are guaranteed to make large numbers of people
     deliberately ignore your article.

     ALL CAPITALS
               Do not use all capital letters in your subject
               line.  Many people find the effect annoying or
               equate it with newcomers.  In either case they
               will ignore the posting.  Hint: There's nothing
               wrong with being a newcomer--we all were at one
               time--just don't advertise it.

     Multiple bangs!!!!!
               Multiple bangs (exclamation points) and multiple
               question marks come across as either over-zealous
               or literarily ignorant, and both effects tend to
               chase away the people who can give the highest-
               quality responses.

BAD, BARELY
     This brings us to the next category of subject lines:  Those
     which are bad but could be good with only a slight
     adjustment.

             HELP: Perl 5.002, SunOS 5.5, gcc 2.7.2, dynamic loading
             HELP: Converting text to binary


GRINCH
     Dean Roehrich,  July 26, 1996.



------------------------------

Date: Wed, 12 Feb 1997 21:28:41 +0100
From: Morten Kristiansen <Morten@everyday.no>
Subject: compiling perl
Message-Id: <330227F9.14F3@everyday.no>

Hello,

I'm having trouble compiling undump program. The errormsg I get is:
	undump.c:206: structure has no member named `u_tsize'

Line 206 says:
	datacnt += u.u_tsize;

u is a variable og type user and user is defined in user.h, which is
included in undump.

u is defined like this:
	struct user u;

Why does I get an error like this ?

The problem I originally have, is that I have a cgi script written in
Perl, and when I set the permissions to --x--x--x, it wont execute. I
have to set the permissions to r-xr-xr-x to make it execute. The problem
then is that the script can be read by anyone, and I don't want that.

By running the perlscript with option -u I get a core file, wich I can
turn into an executable file by using undump, if I manage to compile the
undump program.

Does anyone have any suggestions or other ways to resolve my original
problem (running a perl-cgi script that can't be read by anyone).

Thanks in advance.
-- 

************************************************************************
*                    ()_/         Morten Kristiansen                   *
*            ____    /|           Tele 2 Norge AS                      *
*             --    // \          email: morten.kristiansen@tele2.no   *
*\_                ._\__\_,       Phone: +47 2291 9015                 *
*..\          __                  Fax  : +47 2291 9100                 *
*...\________/..\                                                      *
************************************************************************


------------------------------

Date: Thu, 13 Feb 97 09:05:36 GMT
From: dtweed@ma.ultranet.com (David Tweed)
Subject: Date manipulations -- handy functions.
Message-Id: <5du441$sp@decius.ultra.net>
Keywords: date, zeller

I really don't understand what the big deal is. Most date manipulations
need nothing more than a reversible, one-to-one mapping from dates to a
sequence of integers; it doesn't really matter what the origin of the
integer sequence is, as long as you can subtract two integers to get "days
between dates" or do a MOD 7 to get a day-of-week.

So, here is a tiny module I wrote back in Perl 3 days. "zeller()"
converts a date into an integer, "unzeller()" converts an integer back
into a date, and "is_dst()" is a bonus function that returns true if the
given date and hour falls within Daylight Savings Time as currently
defined in the US.

BTW, the name "zeller" comes from the fact that I first heard of this
algorithm (or one like it) called "Zeller's Congruence" some 20 years
ago.

------ cut here ------

# zeller.pl -- common code for cal, wt, etc.

# Returns a number representing the number of days since March 1 in the
# hypothetical year 0, not counting the calendar correction that occured
# in the 18th century. This number MOD 7 gives the day of week, where
# 0 = Saturday and 6 = Friday.

sub zeller {
    local ($year, $month, $day) = @_;

    $year += int(($month+9)/12) - 1;
    $month = ($month+9) % 12;
    $year*365 + int($year/4) - int($year/100) + int($year/400) +
        $month*30 + int((6*$month+5)/10) + $day + 1;
}

sub unzeller {
    local ($day) = @_;
    local ($year, $month);

    $day -= 2;
    $year = int (($day+1) * 400 / 146097);
    $day -= $year*365 + int($year/4) - int($year/100) + int($year/400);
    $month = int (($day+0.5) / 30.6);
    $day -= $month*30 + int((6*$month+5)/10);
    $year += int (($month+2)/12);
    $month = ($month+2) % 12 + 1;
    ($year, $month, $day+1);
}

# Daylight Savings Time is true starting at 02:00:00 on the first Sunday in
# April up to (but not including) 02:00:00 on the last Sunday in October.
# The input arguments are assumed to represent local standard time.

sub is_dst {
    local ($y, $mo, $md, $h) = @_;

    if ($mo<4 || $mo>10) {
        # No DST if before April or after October
        0;
    } elsif ($mo>4 && $mo<10) {
        # DST May through September
        1;
    } else {
        local ($now) = &zeller ($y, $mo, $md) * 24 + $h;
        if ($mo==4) {
            # April; find first Sunday and compare
            local ($start) = &zeller ($y, 3, 31);
            $start += 7 - ($start+1)%7;
            $start = $start*24 + 2;
            $start <= $now;
        } else {
            # October; find last Sunday and compare
            local ($end) = &zeller ($y, 10, 24);
            $end += 7 - ($end+1)%7;
            $end = $end*24 + 2;
            $now < $end;
        }
    }
}

1;

------ cut here ------


------------------------------

Date: Thu, 13 Feb 1997 03:46:29 GMT
From: soccer@microserve.net (Geoffrey Hebert)
Subject: DBfile verses no DBfile
Message-Id: <5du220$9be$1@news3.microserve.net>

Proplem:  50 online internet users using an application.  Count each
application access by user.  Each user has a user-id.

Everyone uses DBfile.  But why?  

Why not - Have an individual file for each user id with a count to
increment.  Here I have a simple directory lookup, increment without
lock, open file, increment counter, write, and close.  Simple with
minimal system resources.

I can see no reason not to do it this way, of course, I am new to
UNIX.

Now, how does it change as the volume goes up.  Say, I have 30,000
users.   Looks to me, that the individual file solution becomes even
more favorable.  What do you think?

email please  heberts@microserve.net





------------------------------

Date: 13 Feb 1997 01:25:48 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Does Net::FTP modules work under Win32 Perl5 ?
Message-Id: <5dtqis$fgb@fridge-nf0.shore.net>

Wei Wu (wwu@fis028.fis.lehman.com) wrote:

: I have a perl program that uses Net::FTP under unix. I am tring to
: move the program to Win32. I am not sure if any of the Net:: modules
: work under Win32 Perl5.

If you're using NTPerl 5.003 from Activeware, why not give it a try?
If you're using an older version, get the new one: http://www.activeware.com

--
Nathan V. Patwardhan
nvp@shore.net
"Lane, this is pure snow!
Do you have any idea what
the street value of this mountain is?"
	--Charles Demar from _Better Off Dead_


------------------------------

Date: 13 Feb 1997 01:22:08 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Help with Redirect Script
Message-Id: <5dtqc0$fgb@fridge-nf0.shore.net>

Tom Hill (tom@tomagic.com) wrote:
: I am creating a page with bookmarks to the names of all 50 States. What I
: want is a dropdown menu containing thses names so that when a user selects
: a name from the menu, he/she will be taken to the appropiate bookmark.

Perl doesn't have any bookmarks.  ;-)  You should post this question
to comp.infosystems.www.authoring.cgi.

--
Nathan V. Patwardhan
nvp@shore.net
"Lane, this is pure snow!
Do you have any idea what
the street value of this mountain is?"
	--Charles Demar from _Better Off Dead_


------------------------------

Date: Wed, 12 Feb 1997 18:17:25 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Help with Redirect Script
Message-Id: <limtd5.a15.ln@localhost>

Tom Hill (tom@tomagic.com) wrote:
: I am creating a page with bookmarks to the names of all 50 States. What I
: want is a dropdown menu containing thses names so that when a user selects
: a name from the menu, he/she will be taken to the appropiate bookmark.

: Any help would be appreciated.
  ^^^

Here's some help: ask CGI questions in the CGI newsgroup!

comp.infosystems.www.authoring.cgi


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


------------------------------

Date: 13 Feb 1997 00:26:15 -0500
From: tal@plts.org (Tom Limoncelli)
Subject: Re: How to do this using perl?
Message-Id: <5du8ln$rj8@plts.org>

In <E5BL6H.2F4@midway.uchicago.edu> Tim Pierce <twpierce+usenet@mail.bsd.uchicago.edu> writes:

>In article <32FABCA6.372A@emarket.com>,
>Devin Ben-Hur  <dbenhur@emarket.com> wrote:

>>Well, Tom, you are welcome to be intentionally perverse, but
>>anyone who regularly works with multiple operating systems
>>will avoid a fairly broad assortment of special characters in
>>their filenames.

>Anyone who writes production code will not depend upon the user
>"avoiding" special or unusual characters in filenames.  I bet you
>use two-digit dates, too.

wow... nothing like ending a Usenet post with an insult
that only nerds would understand.

:-)

--tal
-- 
     Tom Limoncelli -- http://mars.superlink.net/user/tal --  tal@plts.org

   "You can not solve the problem of people being annoying with technology."


------------------------------

Date: 12 Feb 1997 22:18:38 GMT
From: skunz@iastate.edu (Steven L. Kunz)
Subject: Re: Perl Compiler for a large project
Message-Id: <5dtfju$7ui$1@news.iastate.edu>

In <5dp52h$dqq@park.interport.net> aimee@interport.net (Aimee Schneider) writes:


> Has anyone out there used the perl compiler (either perl->C or
>perl->bytecode) on a large-ish perl project and succeeded? Are there any
>common pitfalls you could relate? Or conversely, if you wound up
>abandoning it for reasons of complexity or whatever, those experiences
>would be helpful too.

I've compiled a large Perl script (over 10,000 lines of code) into a single
module.  Used the "alpha3" compiler built into Perl5.003 with the Curses
extension.  I was building a large program that uses my "PerlMenu" module.
Anyway, it was not easy but it works, and now that the work is done I can
crank out revisions pretty fast.  I ended up using the GNU compiler (the
MIPS one will not work - keeps running out of memory). Had to make some mods
to Willam Setzer's "Curses" extension (which he has incorporated in the
latest version of his package) and code around a few things.  In the end,
however, it works.  On DEC Ultrix 4.3a (on a MIPS box) the binary ended up
being over 5 meg!

One big thing I ran into was that you need to split your code into several
"modules" with different name-spaces (i.e. have several "packages").  If you
don't (and leave it all in "main") the thing will compile, but when you try
to run the resultant binary it will not be able to find all the labels and
subroutine names.  It just says they are "undefined".  As soon as I split it
up into multiple packages (a bit of code-rewriting) it went away.

I used to do this same thing with "undump" on Perl4.  It created a module
that was smaller and ran faster, but I cannot do that anymore since I need
to produce the same program on OSF and SGI systems (and who knows what else
in the future).  The same process works on all platforms using the Perl5
compiler.  Bigger, slower, but it works.
-- 
Steven L. Kunz
Networked Applications  --  Project Manager, Microcomputer Networked Services
Iowa State University Computation Center, Iowa State University, Ames, Iowa
E-mail: skunz@iastate.edu


------------------------------

Date: 13 Feb 1997 01:24:36 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: PERL FOR WINDOWS
Message-Id: <5dtqgk$fgb@fridge-nf0.shore.net>

help (college@tbaytel.net) wrote:
: What is the perl for Windows newsgroup, and has perl 
: been ported to Windows NT 4.0 yet?

No, Perl hasn't been ported to Windows, yet, and my wagon broke down on
my way to the general store.  :-)

Ye prayers have been answered!  http://www.activeware.com  get the Perl
distribution 5.003_07 (make sure you get Perl, NOT Perlscript).

HTH!

--
Nathan V. Patwardhan
nvp@shore.net
"Lane, this is pure snow!
Do you have any idea what
the street value of this mountain is?"
	--Charles Demar from _Better Off Dead_


------------------------------

Date: Thu, 13 Feb 1997 00:57:51 GMT
From: enc@pobox.com (Paul Downing)
Subject: PING in Perl for Win32
Message-Id: <33026611.2668880@207.126.101.80>

I am trying to get a simple little Perl script to work. In fact it is
the example out of the "Programming Perl" book. 

>#!/usr/local/bin/perl

>use Net::Ping;

>$hostname = 'mail.premier.net';
>$timeout = 10;
>print ("Mail.premier.net is alive.\n") if pingecho($hostname, &timeout);

This is the script. I am working on a 486 DX/133 (AMD), 16 MB, and
Win95 OSR2. I have also tried it on NT 3.51 and 4.0 to no avail. I
keep getting this message:  "Error: Parse exception". Yes, the address
exists :)

Can someone please help me?



Paul Downing
------------------------------------------------------------
Enterprise Network Consulting / owner	
Baker, Louisiana			
E-mail: enc@pobox.com   
-------------------------------------------------------------  


------------------------------

Date: 13 Feb 1997 01:40:26 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: PING in Perl for Win32
Message-Id: <5dtrea$fgb@fridge-nf0.shore.net>

Paul Downing (enc@pobox.com) wrote:

: >use Net::Ping;

: >$hostname = 'mail.premier.net';
: >$timeout = 10;
: >print ("Mail.premier.net is alive.\n") if pingecho($hostname, &timeout);

Syntax error, mon.  Bad kid, weren't using perl -w.  :-) You are calling a 
function "timeout," when you mean $timeout.   Also make sure that your Unix
server's /usr/local/bin/perl is Perl 5.  Do a /usr/local/bin/perl -v to
check this.

The fix:
print ("Mail.premier.net is alive.\n") if pingecho($hostname, $timeout);

--
Nathan V. Patwardhan
nvp@shore.net
"Lane, this is pure snow!
Do you have any idea what
the street value of this mountain is?"
	--Charles Demar from _Better Off Dead_


------------------------------

Date: Wed, 12 Feb 1997 20:35:35 -0500
From: Nathan D Richards <nathanr@k2.ashpool.com>
To: CGI-L <CGI-L@VM.EGE.EDU.TR>
Subject: REQ: Getting the amount of files in a certain directory.
Message-Id: <Pine.LNX.3.94.970212203247.16806B-100000@k2.ashpool.com>

I need to know how many *.D files there are in a certain directory.
Is there anyway to do this in a CGI script?

Where the output woul be something like:

There are xxx files.

Thank you very much.



------------------------------

Date: 13 Feb 1997 03:02:16 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: REQ: Getting the amount of files in a certain directory.
Message-Id: <5du07o$k4c@fridge-nf0.shore.net>

Nathan D Richards (nathanr@k2.ashpool.com) wrote:
: I need to know how many *.D files there are in a certain directory.
: Is there anyway to do this in a CGI script?

Even better (I could kick myself for the last, two assinine suggestions):

$dir '/path/dir';
$entry = '' unless $entry;

opendir(DIR, "$dir");
@entries = grep(/\.D$/, sort(readdir(DIR)));
closedir(DIR);

foreach $entry (@entries) {
    $i++ if $entry;
}

print("There were $i entries with a .D extension.\n");

--
Nathan V. Patwardhan
nvp@shore.net
"Lane, this is pure snow!
Do you have any idea what
the street value of this mountain is?"
	--Charles Demar from _Better Off Dead_


------------------------------

Date: 13 Feb 1997 02:49:28 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: REQ: Getting the amount of files in a certain directory.
Message-Id: <5dtvfo$k4c@fridge-nf0.shore.net>

Nathan D Richards (nathanr@k2.ashpool.com) wrote:
: I need to know how many *.D files there are in a certain directory.
: Is there anyway to do this in a CGI script?

Not the best way to do it, but will give you some ideas:

#!/usr/local/bin/perl5 -w

#Method #1: this is inaccurate if you have files named foo.DIR
$count_dir = '/home1/n/nvp/Perl/Log/Count/Files';
$entry = '' unless $entry;
$i = 0;

opendir(COUNT, "$count_dir") || die("No: $!\n");
@entries = readdir(COUNT);
closedir(COUNT);

foreach $entry (@entries) {
    if ($entry =~ /.t/) {
        $i++;
    }
}

print("There were $i entries with a .d extension.\n");

#Method #2: Accurate, but kludgy
$count_dir = '/home1/n/nvp/Perl/Log/Count/Files';
$entry = '' unless $entry;
$base = '' unless $base;
$ext = '' unless $ext;
$i = 0;

opendir(COUNT, "$count_dir") || die("No: $!\n");
@entries = readdir(COUNT);
closedir(COUNT);

foreach $entry (@entries) {
    ($base, $ext) = split(/\./, $entry);
    if ($ext eq '.D') {
        $i++;
    }
}

print("There were $i entries with a .d extension.\n");

--
Nathan V. Patwardhan
nvp@shore.net
"Lane, this is pure snow!
Do you have any idea what
the street value of this mountain is?"
	--Charles Demar from _Better Off Dead_


------------------------------

Date: 13 Feb 1997 02:50:43 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: REQ: Getting the amount of files in a certain directory.
Message-Id: <5dtvi3$k4c@fridge-nf0.shore.net>

Nathan V. Patwardhan (nvp@shore.net) wrote:

Correction! .t should be .D (sorry, I tried this on another system :\ )

foreach $entry (@entries) {
    if ($entry =~ /.D/) {
        $i++;
    }
}

--
Nathan V. Patwardhan
nvp@shore.net
"Lane, this is pure snow!
Do you have any idea what
the street value of this mountain is?"
	--Charles Demar from _Better Off Dead_


------------------------------

Date: Thu, 13 Feb 1997 06:57:58 GMT
From: Eric Wong <egwong@netcom.com>
Subject: Re: REQ: Getting the amount of files in a certain directory.
Message-Id: <egwongE5J4oM.LFH@netcom.com>

Nathan D Richards <nathanr@k2.ashpool.com> wrote:
NDR>  I need to know how many *.D files there are in a certain directory.
NDR>  Is there anyway to do this in a CGI script?

NDR>  Where the output woul be something like:

NDR>  There are xxx files.

NDR>  Thank you very much.

You could use the glob() function.
  $num = (@temp = glob("*.D"));

Where $num holds the number of files and @temp is just
a temporary, junk variable.  I'm sure there's some way
you could do without @temp, but I can't think of it at
the moment (can anyone help?)

The glob() function is, of course, documented in the
perlfunc manpage.

[ cc'd ]


------------------------------

Date: Thu, 13 Feb 1997 06:30:51 GMT
From: cowcher@melbpc.org.au (Laurie Cowcher)
Subject: Test
Message-Id: <3303b516.164287895@news.melbpc.org.au>




------------------------------

Date: Thu, 13 Feb 1997 06:31:32 GMT
From: cowcher@melbpc.org.au (Laurie Cowcher)
Subject: Test2
Message-Id: <3306b531.164314545@news.melbpc.org.au>




------------------------------

Date: Thu, 13 Feb 1997 00:26:09 GMT
From: dhl@mrdog.msl.com (Donald H. Locker)
Subject: Re: Using $ENV{'QUERY_STRING'}
Message-Id: <E5IMJM.GD0@mrdog.msl.com>

Yes, he's sure it will work.  As am I.  Environment variables are
inherited, as you know, and can't affect the _invoking_ processes'
environment, but the remainder of the script and all of its children
of will inherit the new environment variable.  That's how it works.
(And not just on Solaris 2.5.1!; it did this at least back as far as
1981 on System III (where I cut my teeth).)

In article <smzeodG00YUu1IJoA0@andrew.cmu.edu>,
Gautam Srikanth  <morpheus+@andrew.cmu.edu> wrote:
>Excerpts from netnews.comp.lang.perl.misc:
>9-Feb-97 Re: Using $ENV{'QUERY_STRING'} by Tad McClellan@flash.net 
>
>> 2) to set an _environment_ variable form a _perl_ variable:
>>  
>> $ENV{'QUERY_STRING'} = $quy;
>
>Tad, are you sure that'll work?  I just tried setting an environment
>variable from inside a Perl script, and it doesn't carry through to the
>calling environment (Solaris 2.5.1).
>
>I've been under the understanding that no program can modify the calling
>environment under Unix.  Is there indeed some way to do so?

I haven't found one.  But then I haven't really Really REALLY tried.
-- 
Donald.
These opinions were formulated by a trained professional.
              DO NOT TRY THIS AT HOME!
      At the time, the tone will be ... BEEP!


------------------------------

Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Jan 97)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V7 Issue 937
*************************************

home help back first fref pref prev next nref lref last post