[9845] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3439 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 13 13:07:45 1998

Date: Thu, 13 Aug 98 10:01:35 -0700
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 Aug 1998     Volume: 8 Number: 3439

Today's topics:
    Re: Q: How to read all the file name in a directory <christina.burnhamN*O*S*P*A*M@fmr.com>
    Re: Q: How to read all the file name in a directory <rootbeer@teleport.com>
    Re: Read directory and not files (Tad McClellan)
    Re: retrieving hash name <rootbeer@teleport.com>
        searching a group of files with a specific last charact (Steve .)
    Re: Setting DOS environment variables in a perl script (Larry Rosler)
    Re: Setting DOS environment variables in a perl script <rootbeer@teleport.com>
    Re: using ssi-like in perl script <rootbeer@teleport.com>
        What is an lvalue (in perl)? <mgregory@asc.sps.mot.com>
    Re: What is the purpose of Perl <jdporter@min.net>
    Re: What is the purpose of Perl <jdporter@min.net>
    Re: What is the purpose of Perl <merlyn@stonehenge.com>
    Re: What is the purpose of Perl (Craig Berry)
    Re: Win NT Formmail and opening temporary files <comeng@erols.com>
    Re: X-file (?=...), case postponed. dgris@rand.dimensional.com
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Thu, 13 Aug 1998 11:23:59 -0400
From: PeanutGallery <christina.burnhamN*O*S*P*A*M@fmr.com>
Subject: Re: Q: How to read all the file name in a directory
Message-Id: <35D3050E.D8815264@fmr.com>

Here is how you would find all the files of type *.exe in /bin

while ($exe_filename = </bin/*.exe>)
{
   print "exe_filename = $exe_filename\n";
}


Ollie Cook wrote:

> I have written a counter script that is run off an SSI that stores the
> number of accesses of a file in a directory under that filename. e.g.
> if links.shtml was accessed 26 times then a file links.shtml in
> another directory would have 26 stored in it. What I would like to do
> is to complete the next step: to create another script that tells the
> webmaster how many times each page has been accessed. So I suppose
> what I need to do is to read in the names of all the files in that
> directory into an array, but I have no idea how to do this. you help
> would be greatly appreciated!
>
> Regards,
> Ollie
> ----
> Oliver COOK, Web Site Designer for
> Premiere Web Designs - Http://Www.Premiere.Uk.Com/
> +
> Webmaster of The Audio-Visual Archive
>  * over 900 images and 700 sounds, free
>  * Http://Www.Premiere.Uk.Com/ava/



--
=====================================================
- When replying to me remember to unmunge my anti-spam address -
The border between life and death is poorly guarded
-- from Due South




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

Date: Thu, 13 Aug 1998 15:42:14 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Q: How to read all the file name in a directory
Message-Id: <Pine.GSO.4.02.9808130841530.10161-100000@user2.teleport.com>

On Thu, 13 Aug 1998, Ollie Cook wrote:

> what I need to do is to read in the names of all the files in that
> directory into an array, but I have no idea how to do this. 

readdir and friends should help you. Good luck!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 13 Aug 1998 11:12:00 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Read directory and not files
Message-Id: <g83vq6.th2.ln@localhost>

Chua Boon Yiang (chuaby@hotmail.com) wrote:
: Hi
: I am using perl on NT. Just wondering if there is anyway just to read
: the directories name and not filenames using readdir() function ?


   @dirs = grep -d, readdir(DIR);


   see '-X' in the perlfunc man page for a description of 
   available file test operators.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Thu, 13 Aug 1998 15:41:09 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: retrieving hash name
Message-Id: <Pine.GSO.4.02.9808130837310.10161-100000@user2.teleport.com>

On 13 Aug 1998, Mark C. Wilhelm wrote:

> Suppose one "dynamically" names a hash during the course of a script,

Do you mean with a symbolic reference?

> and then creates a reference to the hash.  Is is it possible, using
> the reference, to retrieve the _name_ of the hash as well as the
> key/value pairs?

In general, no, since it may not have a name at all. (Or it may have more
than one!) But if the name is in a symbol table somewhere, you could dig
into that symbol table and search for it. *shudder*

But why should you need its name again? If you know you're going to need
some information later, store _that_ away, possibly in a hash. You could
use the (hard) reference as a key, and the "name" you need to remember as
a value.

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 13 Aug 1998 15:58:18 GMT
From: syarbrou@ais.net (Steve .)
Subject: searching a group of files with a specific last character
Message-Id: <35d30c9a.7153309@news.ais.net>

I have a directory with text files.  I am doing a report on them which
isn't a problem.  What I need to know, is instead of reading one file,
or all the files, or a list of files, how do I read all the files in
the directory that have a capital T before the .LOG?  In otherwords, I
would like to tabulate totals for a report combining the data from
*T.LOG.  Any ideas?  Thanks.

STeve


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

Date: Thu, 13 Aug 1998 08:15:47 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Setting DOS environment variables in a perl script
Message-Id: <MPG.103ca2ffc68b5fab9897c6@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <6quoip$lfa$1@nnrp1.dejanews.com> on Thu, 13 Aug 1998 13:09:45 
GMT, vdielman@debis.com <vdielman@debis.com> says...
> could anybody tell me how to set DOS environment variables in PERL? I want to
> define an env-variable e.g. "SET LOCATION = jdvn" in a DOS batch-file and
> want a PERL script to assign new values to these vars so i can use them as
> command line parameters of the NT-command "net user...".

Look in perlvar for the hash %ENV.  Keep in mind that you can change the 
environment for yourself or for your children, but not for your parent.

-- 
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 13 Aug 1998 15:36:49 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Setting DOS environment variables in a perl script
Message-Id: <Pine.GSO.4.02.9808130836280.10161-100000@user2.teleport.com>

On Thu, 13 Aug 1998 vdielman@debis.com wrote:

> could anybody tell me how to set DOS environment variables in PERL?

The perlvar manpage can. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 13 Aug 1998 15:34:23 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: using ssi-like in perl script
Message-Id: <Pine.GSO.4.02.9808130833110.10161-100000@user2.teleport.com>

On Thu, 13 Aug 1998, Wouter Hermans wrote:

> the site uses on each page some ssi for showing buttons and text.  on
> my iis server it doesn't seem possible to make a print "<!--#include
> file="blah.html"-->"; in the script.  it just shows <!--#include
> file="blah.html"--> when you look at the source of the page the search
> cgi has generated.

It sounds as if you want your server to do something that it's not doing.
Maybe the docs, FAQs, and newsgroups about servers could be of assistance
to you. Good luck!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 13 Aug 1998 11:58:40 +0930
From: Martin Gregory <mgregory@asc.sps.mot.com>
Subject: What is an lvalue (in perl)?
Message-Id: <r8g1f1boo7.fsf@asc.sps.mot.com>


In comp.lang.perl.misc, Michael Rubenstein explains:

> On 11 Aug 1998 13:50:20 +0930, Martin Gregory wrote:
> [...]
> >I read this and thought "Bah hah - that's funny, but now I get it!"
> >
> >Then I did this:
> >
> >  perl -e 'for ($a=1, $a < 7, $a++){print;}'
> >
> >Then I was confused again.  
> >
> >Can you predict what this prints?
> >
> >If you didn't predict it correctly, can you now explain why it does
> >what it does?
> 
> I must confess that I didn't predict it, but this behavior is
> documented.
> 
> From perlop, the result of $a=1 is an lvalue.  It assigns 1 to a, but
> its value is $a, not 1.  In most contexts this doesn't matter, but
> here it does.  Since $a has value 1, $a < 7 and $a++ both have value 1
> and the latter also sets $a to 2.
> 
> From perlsyn, this form of for iterates through the list.  It doesn't
> successively evaluate the expressions, but first constructs the list.
> From the above, the list is ($a, 1, 1).  Since $a now has the value 2,
> the loop prints 211.

This is an excellent explanation - I feel like I understand this now.

All except for one thing.  Just what, formally, is an lvalue?  And how
does it behave?

I've always thought of it as 'something that can go on the LHS of an
assignment', but clearly this is too fuzzy to help me solve problems
like the one above.

Is this a correct & complete statement:  

 "An lvalue (in perl) is a reference that automatically dereferences
 itself when used" ?

That statement helps me understand how this works:

  perl -e '($a = 1) = 2; print $a';

Is it a safe thing to think?

Thanks,

Martin.


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

Date: Thu, 13 Aug 1998 12:10:17 -0400
From: John Porter <jdporter@min.net>
Subject: Re: What is the purpose of Perl
Message-Id: <35D30FE9.1530@min.net>

Craig Berry wrote:
> 
>   foreach (grep { ! /sin/ } @crowd) {
>     throw($_, $stone[0]);
>   }

for $him ( @crowd ) {
  unless ( defined $him->{'sin'} ) { # yes, you better quote it!
    $him->throw( $stone[0] );
    last;
  }
}

-- 
John Porter


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

Date: Thu, 13 Aug 1998 12:30:37 -0400
From: John Porter <jdporter@min.net>
Subject: Re: What is the purpose of Perl
Message-Id: <35D314AD.4951@min.net>

# Behold:
for ( @all_things ) {
  $_->DESTROY;
  $_ = new ref($_);
}

$heaven = new Heaven;
$earth = new Earth;
$Jerusalem = $heaven->new_city();

sub Heaven::new_city {
  bless {
    brilliance => PreciousJewel->brilliance,
    gates => [ map {
       new Gate
          angel => $angel[$_],
          tribe => $tribe[$_],
          composition => 'pearl'    # !!!
       } ( 0..11 ) ],
    foundations => [ map {
       new Foundation
          apostle => $apostle[$_],
          composition => $foundation_stone[$_]
       } ( 0..11 ) ],
    size => 12_000, # stadia on each side
    wall_thickness => 144, # cubits
    wall_composition => 'jasper',
    composition => 'gold',
  }, 'City';
}

sub Gate::shut {
   carp "Illegal operation";
}


-- 
John Porter


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

Date: Thu, 13 Aug 1998 16:49:00 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: What is the purpose of Perl
Message-Id: <8c4svgesk0.fsf@gadget.cscaper.com>

>>>>> "Bob" == Bob Trieger <sowmaster@juicepigs.com> writes:

Bob> map { push @ark,("$_ " x 2) } @animals;

slight bug there:

	push @ark, map { ($_) x 2 } @animals;

Gets rid of the map-in-a-void-context too.

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: 13 Aug 1998 16:33:12 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: What is the purpose of Perl
Message-Id: <6qv4g8$ijo$1@marina.cinenet.net>

John Porter (jdporter@min.net) wrote:
: Craig Berry wrote:
: > 
: >   foreach (grep { ! /sin/ } @crowd) {
: >     throw($_, $stone[0]);
: >   }
: 
: for $him ( @crowd ) {
:   unless ( defined $him->{'sin'} ) { # yes, you better quote it!
:     $him->throw( $stone[0] );
:     last;
:   }
: }

Great, now we'll have to go back to the Client and ask Him for a spec
clarification, what his intent was if *two* members of the crowd were
without sin.  (Would the Nth one throw the Nth stone?)  Iterative
specification, you gotta love it... 

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Thu, 13 Aug 1998 13:21:34 -0700
From: CRC <comeng@erols.com>
Subject: Re: Win NT Formmail and opening temporary files
Message-Id: <35D34ACE.675B@erols.com>

Ethan H. Poole wrote:
> 
> In article <peaceml-1208981858390001@207-172-119-146.s146.tnt2.brd.erols.com>,
> peaceml@erols.nospam.com says...
> >
> >I'm kind of new at this so forgive me if I'm asking for something that
> >has been rehashed to death.  I'm using Matt Wright's formmail.pl file with
> >some modifications to make it work with softmail instead of Windmail.  I
> >can run this once with success.  However if I do not unlink the temporary
> >file nor manually delete the temporary file, I can not run again.  It just
> >hangs.  I have eliminated execution of softmail.exe so all the send_mail
> >portion of formmail.pl file does is create $tempfile and it still fails.
> >I have limited the problem to the following line:
> >
> >Open(MAIL,">$tempfile") || die ("Cannot open $tempfile - Check Directory
> >Permissions : $!");
> >
> >If the file already exists, the open appears to hang.  If I test for
> >existance of $tempfile and attempt to unlink it before the open, that also
> >hangs. The NT system I am using is using NTFS.  I've tried chmod, and
> >SetAttributes to no avail.  Do I have to set the file permissions in the
> >formmail.pl file using Win32::FileSecurity?  Any
> >answers/help/explainations/directions/etc. would be appreciated.
> 
> I'm assuming you are using IIS as your web server, though the suggestion would
> remain the same for any other web server:
> 
> Ask your system administrator to set "CHANGE" file permissions for the
> Anonymous Web User (e.g. IUSR_xxx) for your cgi-bin directory and all
> subdirectories.  Most likely you have only read permissions which denies you
> the write to create new or modify existing files.
> 
peaceml here (no matter what the mail header says)
I am using IIS 2.0.  The directory containing the tempfile and tempfile
itself were all set to Everyone Full Control (not a secure idea, I know,
but it is a localized test).   I tried just specifying IUSR_name with
CHANGE only for the temporary file and its directory to no avail.  The
mailform.pl file is operating out of the c:\scripts directory on the
server.  Does this make a difference since the temporary file is in a
complete different directory?  Do I have to reboot after making
changes?  Can I even do this with IIS 2.0?  Thanks.

John


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

Date: Wed, 12 Aug 1998 23:23:08 -0600
From: dgris@rand.dimensional.com
Subject: Re: X-file (?=...), case postponed.
Message-Id: <199808130523.XAA28655@rand.dimensional.com>

[posted to comp.lang.perl.moderated and mailed to the cited author]

In article <1ddo5ve.bugjws54wh1oN@bay2-150.quincy.ziplink.net> you write:
>Patrick Timmins <ptimmins@netserv.unmc.edu> wrote:
>
>[discussion of split(/(?=(.*)/)]
>

>Suppose the string being split is 'a|b|c'.  So, you want to put the
>delimiter *before* the first element??  split(/(\|)/, 'a|b|c') would
>return ('|', 'a', '|', 'b', 'c') or something like that.  That's hardly
>logical...

Well, no, that doesn't make much sense at all.  But that isn't the
point here.  The point is that split is behving in ways other than
normal, and that it is underdocumented that it is doing so.

#!perl

$_ = '|a|b|c';

print join "--", (split /\|/);
# produces --a--b--c

print join "--", (split /(?=\|)/);
# produces |a--|b--|c
__END__

The first example matches the | at the
beginning of the string and returns
the null string that is in $`.

I'd expect the second example to split on the
null before |, but it doesn't because split
won't match leading nulls if they are
the result of matching the null pattern.  But 
it will match leading nulls if the pattern is 
non-null.  I understand why this is confusing 
to people.

For reasons pointed out elsewhere in this thread
this is reasonable behavior, but it should be
documented better (and yes, a patch is forthcoming :-).

dgris
-- 
Daniel Grisinger           dgris@perrin.dimensional.com
"No kings, no presidents, just a rough consensus and
running code."
                           Dave Clark


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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed 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 V8 Issue 3439
**************************************

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