[12000] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5599 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 7 18:07:32 1999

Date: Fri, 7 May 99 15:00:23 -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           Fri, 7 May 1999     Volume: 8 Number: 5599

Today's topics:
    Re: Can't Find Benchmark on CPAN (Larry Rosler)
        CGI timeout in web-based listserv (Robert Watkins)
    Re: CGI timeout in web-based listserv <design@raincloud-studios.com>
    Re: Find all files regardless of extension <laurens@bsqaure.com>
    Re: Find all files regardless of extension <laurens@bsqaure.com>
    Re: Find all files regardless of extension (Bart Lateur)
    Re: Find all files regardless of extension (Larry Rosler)
    Re: Find all files regardless of extension (Larry Rosler)
    Re: Function vs Object oriented (Randal L. Schwartz)
    Re: HASH references... <keighvin@urjet.net>
    Re: HASH references... (Andrew Johnson)
    Re: HASH references... (I R A Aggie)
    Re: HASH references... (I R A Aggie)
    Re: How to get current working directory? (Bart Lateur)
    Re: how to grep -v ?? <ludlow@us.ibm.com>
    Re: How to keep travelled path in hash ? (Michel Dalle)
    Re: How to match a variable in pattern - Help a newbie  (Larry Rosler)
    Re: Is evaluation of printf operands left-to-right? (Larry Rosler)
        perl strange file problems heinrich7486@my-dejanews.com
        PGP package doesn't install...need help (Pete Holsberg)
    Re: procedure to convert sec to HH:MM:SS format (Andrew Allen)
    Re: procedure to convert sec to HH:MM:SS format (Larry Rosler)
    Re: running a file from unix shell (Bob Trieger)
    Re: Scripting language with LFN support? (Sylvan Butler)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Fri, 7 May 1999 13:17:16 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Can't Find Benchmark on CPAN
Message-Id: <MPG.119cea238a0ad4839899fc@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <xTFY2.89$vP2.100@news.rdc1.tn.home.com> on Fri, 07 May 1999 
18:01:01 GMT, Charles R. Thompson <design@raincloud-studios.com> says...
> I've never had this much trouble 'drilling-down' to a module. I'm trying to
> find the benchmark module so I can test a few things. I went to CPAN and
> modules by name... when I click on Benchmark I end up in ILYAZ. Benchmark is
> nowhere to be found in this directory... not even in the modules/
> subdirectory. Is the actual .gz named something else?

Benchmark.pm is part of the standard perl distribution.  Look in 
 .../lib/ .

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 07 May 1999 21:33:07 GMT
From: r-watkins@worldnet.att.net (Robert Watkins)
Subject: CGI timeout in web-based listserv
Message-Id: <7gvm74$7d8$1@bgtnsc02.worldnet.att.net>

I have written a browser interface to a number of mailing lists for our 
company. The interface allows subscribers to subscribe/unsubscribe to as many 
or as few of the lists as they want on one page; it remembers an individual's 
configuration, etc. On the administration side, the marketing people can send 
out their lists, get a count of the subscribers and such without having to ask 
me.

To send out a bulletin, the sender selects the appropriate list, uses a 
browser-based upload to chose a text file from their hard drive and clicks on 
"Send". This triggers a Perl script that pipes the message to each subscriber 
to a shell script that writes the message into a spool directory, where a 
shell daemon picks them up to send out via sendmail. When all the messages 
have been written to the spool directory, the sender gets a "done" page in 
their browser stating that the file <bulletin.txt> has been sent to the 
<number> subscribers of <chosen list>.

As far as I can discern, the problem is as follows:

When a message is sent to a list of 800 subscribers, it takes so long to write 
out all the messages into the spool directory that there is a timeout before 
the "done" page can be written to the sender's waiting browser. All hte 
messages to get sent out, however, it is just the sender that gets an error 
message. I tested it with a list of 250 e-mail addresses and it didn't give me 
a hiccup, although it did take a minute or so to return the "done" page to the 
browser.

The code that sends the message out is as follows:

    ...
    while (<SUB_LIST>) {
        chomp($_);
        open (MAIL, "| $mailprog") or die "Can't open $mailprog: $!\n";
        print MAIL "To:       $_\n";
        print MAIL "Subject:  ${subject}: $lists{$form{list}}[0]\n";
        print MAIL "Reply to: $lists{$form{list}}[2]\@springer-ny.com\n";
        print MAIL "$bltn_header\n";
        print MAIL "$new_bltn\n";
        print MAIL "$bltn_footer\n";
        close (MAIL);
    }
    close (SUB_LIST);
    # now write "done" message to sender's browser
    ...

where SUB_LIST is the list of e-mail addresses and $mailprog is the shell 
script that writes the full e-mail message to the spool directory.

How can I get this to run such that the sender gets the "done" page rather 
than a server error message?

In case it helps, here are what I believe to be the relevant pages from the 
server's error log (Netscape Enterprise 3.51):

[07/May/1999:08:25:41] failure: for host gate.springer-ny.com trying to POST /cgi-bin/ebultn_admin.pl, cgi-parse-output reports: the CGI program /usr3/usr2/secure-root/etc/httpd/cgi-bin/ebultn_admin.pl did not produce a valid header (read failed, error is Resource temporarily unavailable)
[07/May/1999:08:28:02] failure: HandleResponse(): Error writing to socket (Broken pipe)

Any (relevant) advice would be appreciated.



--------------------------------
Robert Watkins
r-watkinsNO@SPAMworldnet.att.net
--------------------------------



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

Date: Fri, 07 May 1999 21:44:58 GMT
From: "Charles R. Thompson" <design@raincloud-studios.com>
Subject: Re: CGI timeout in web-based listserv
Message-Id: <u9JY2.294$vP2.168@news.rdc1.tn.home.com>

>How can I get this to run such that the sender gets the "done" page rather
>than a server error message?


I'm not sure about that netscape error log. Way over my head. How bout an easy
communication hack? This sounds like the wait you get from some search
engines.

>        print MAIL "$bltn_footer\n";
>        close (MAIL);

---> every 50 mails, print a message the the browser!

>    }
>    close (SUB_LIST);
>    # now write "done" message to sender's browser


I'm not sure what side effect it would cause for the webserver daemon (having
an open connection for too long?), but sending a confirmation for each ...
make that every 25-50 or MORE email message via a print statement might keep
the timeout from occuring. Ya think? Since your browser would be getting input
every x seconds.. there should be no problem then.

Messages 1-50 sent.
Messages 51-100 sent.

I do know if you put the results in a table, it won't display in the browser
until the table tag is closed, but the communication will still be there.

CT




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

Date: Fri, 7 May 1999 12:57:16 -0700
From: "Lauren Smith" <laurens@bsqaure.com>
Subject: Re: Find all files regardless of extension
Message-Id: <7gvgis$ff2$1@brokaw.wa.com>


>Clas <clas.karrlund@nospamemw.ericsson.se> wrote:
>> Hi
>>
>> I want to know if a file called  "filename.*", e.g "filename.txt" or
>> "filename.exe", exists in a directory .
>>
>> I tried to serch for "filename.*" in the directory, but it din4t seem to
>> work.
>>


This isn't a Perl solution, but you can do a system() call to DIR and pipe
the output to a file.  You can use a '/s' flag to search all subdirectories.




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

Date: Fri, 7 May 1999 13:10:20 -0700
From: "Lauren Smith" <laurens@bsqaure.com>
Subject: Re: Find all files regardless of extension
Message-Id: <7gvhbo$gp9$1@brokaw.wa.com>


Lauren Smith wrote in message <7gvgis$ff2$1@brokaw.wa.com>...
>
>>Clas <clas.karrlund@nospamemw.ericsson.se> wrote:
>>> Hi
>>>
>>> I want to know if a file called  "filename.*", e.g "filename.txt" or
>>> "filename.exe", exists in a directory .
>>>
>>> I tried to serch for "filename.*" in the directory, but it din4t seem to
>>> work.
>>>
>
>
>This isn't a Perl solution, but you can do a system() call to DIR and pipe
>the output to a file.  You can use a '/s' flag to search all
subdirectories.
>
>
for example:

$filelist = "C:\SomeDir\list.txt";
system("dir filename /s > $filelist");

Now you have a file that can you can process.

The problem is that the program is not portable anymore.

Lauren




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

Date: Fri, 07 May 1999 20:27:15 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Find all files regardless of extension
Message-Id: <37344c3a.6508282@news.skynet.be>

Jonathan Stowe wrote:

>> I want to know if a file called  "filename.*", e.g "filename.txt" or
>> "filename.exe", exists in a directory .

>I have heard some people saying that glob() doesnt work properly on NT
>if that is the case you might need to examine the functions:
>
>  opendir()
>  readdir()
>  closedir()

Don't forget about grep().

	opendir DIR,$dirpath;
	@matches  = grep { /^filename\./ } readdir(DIR);
	closedir(DIR);

	Bart.


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

Date: Fri, 7 May 1999 14:13:44 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Find all files regardless of extension
Message-Id: <MPG.119cf76036e9b5489899ff@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <7gvhbo$gp9$1@brokaw.wa.com> on Fri, 7 May 1999 13:10:20 -
0700, Lauren Smith <laurens@bsqaure.com> says...
> Lauren Smith wrote in message <7gvgis$ff2$1@brokaw.wa.com>...
> >>Clas <clas.karrlund@nospamemw.ericsson.se> wrote:
> >>> I want to know if a file called  "filename.*", e.g "filename.txt" or
> >>> "filename.exe", exists in a directory .
> >>>
> >>> I tried to serch for "filename.*" in the directory, but it din4t seem to
> >>> work.
> >
> >This isn't a Perl solution, but you can do a system() call to DIR and pipe
> >the output to a file.  You can use a '/s' flag to search all
> subdirectories.
>
> for example:
> 
> $filelist = "C:\SomeDir\list.txt";
> system("dir filename /s > $filelist");
> 
> Now you have a file that can you can process.
> 
> The problem is that the program is not portable anymore.

It is also slow, because it spawns another process.  I wouldn't even use 
glob().  The preferred way is to use opendir() and readdir(), or -- for 
recursion -- use File::Find.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 7 May 1999 14:52:02 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Find all files regardless of extension
Message-Id: <MPG.119d005986dd285d989a02@nntp.hpl.hp.com>

In article <37344c3a.6508282@news.skynet.be> on Fri, 07 May 1999 
20:27:15 GMT, Bart Lateur <bart.lateur@skynet.be> says...
> >> I want to know if a file called  "filename.*", e.g "filename.txt" or
> >> "filename.exe", exists in a directory .
 ...
> Don't forget about grep().
> 
> 	opendir DIR,$dirpath;
> 	@matches  = grep { /^filename\./ } readdir(DIR);
> 	closedir(DIR);

      my $PoB = $dirpath =~ /^[a-z]:/i && '(?i)'; # or something :-)
	@matches  = grep { /$PoB^filename\./o } readdir(DIR);

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 07 May 1999 14:57:22 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Function vs Object oriented
Message-Id: <m16764wnjx.fsf@halfdome.holdit.com>

>>>>> "Gabe" == Gabe  <grichard@uci.edu> writes:

Gabe> It seems (at least with CGI.pm) that function oriented
Gabe> programming reduces keystrokes. Other than that it isn't obvious
Gabe> to me what the significant differences are and/or benefits of
Gabe> either. The docs for this module seem to prefer the object
Gabe> oriented style, but why?

I prefer the function-oriented form, and now advocate that in my
columns.  The OO-style is in the docs probably due mostly to
historical accident, as that was the original interface.  The biggest
advantage of the OO-format is that I don't have to worry if I'm
writing a subroutine that happens to be similar to an HTML tag. :)

Gabe> On a different note, using CGI.pm to generate dynamic documents
Gabe> seems kinda cumbersome. I mean, isn't it easier and faster just
Gabe> to use a here document?  What am I not thinking about?

Sticky fields, for one.  The ability to regenerate the same form with
most of the same fields filled out because a user made an error is
very nice for the user.  Unless you're in to punishing the user for an
error.

print "Just another Perl hacker,"

-- 
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: Fri, 7 May 1999 15:13:34 -0600
From: "Paul L Tomlinson" <keighvin@urjet.net>
Subject: Re: HASH references...
Message-Id: <926111356.369.29@news.remarQ.com>

>+ How can I refer to elements in a hash using a pointer, reference, or
>+ variable?
>
>If I'm groking your question, you want to know how to access an element
>within a hash using a variable. This may provide enlightenment:
>
>%hash=qw/a 1 b 2 c 3 d 4 e 5/;
>foreach $key (sort keys %hash) {
>  print "$key $hash{$key}\n";
>}


    Nope, you're not groking my question.  Check the source code on the
original message - I want to address the hash based on a value contained
within a scalar:

    $whatever = "name";
    $FORM{'$whatever'};

    As I said, this doesn't work.  I'm looking for another way to say
"$FORM{'name'}" so I can create that by which to address the hash, it'll
help me keep my code organized and smaller.  Check the source.

    Paul




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

Date: Fri, 07 May 1999 21:20:18 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: HASH references...
Message-Id: <mOIY2.32$FC1.5308@news2.rdc1.on.home.com>

In article <926111356.369.29@news.remarQ.com>,
 Paul L Tomlinson <keighvin@urjet.net> wrote:

!      Nope, you're not groking my question.  Check the source code on
!  the original message - I want to address the hash based on a value
!  contained within a scalar:
!  
!      $whatever = "name";
!      $FORM{'$whatever'};
!  
!      As I said, this doesn't work.  I'm looking for another way to
!  say "$FORM{'name'}" so I can create that by which to address the
!  hash, it'll help me keep my code organized and smaller.  Check the
!  source.
 
don't use single quotes around the hash key variable ...
this works fine:

#!/usr/bin/perl -w
use strict;
my %form;
$form{name} = 'blah';
my $whatever = 'name';
print $form{$whatever};
 
regards
andrew

-- 
Andrew L. Johnson   http://members.home.com/andrew-johnson/
      "Where the hell are my fries, kid?"
          -Tom Christiansen, on comp.lang.perl.misc
      


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

Date: 7 May 1999 21:29:15 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: HASH references...
Message-Id: <slrn7j6mu9.1ll.fl_aggie@stat.fsu.edu>

On Fri, 7 May 1999 15:13:34 -0600, Paul L Tomlinson <keighvin@urjet.net>, in
<926111356.369.29@news.remarQ.com> wrote:

[me:]
+ >If I'm groking your question, you want to know how to access an element
+ >within a hash using a variable. This may provide enlightenment:
+ >
+ >%hash=qw/a 1 b 2 c 3 d 4 e 5/;
+ >foreach $key (sort keys %hash) {
+ >  print "$key $hash{$key}\n";
+ >}

+     Nope, you're not groking my question.  Check the source code on the
+ original message - I want to address the hash based on a value contained
+ within a scalar:
+ 
+     $whatever = "name";
+     $FORM{'$whatever'};

Umm, yes, actually I *am* groking your question...

Try this:

$whatever='name';
$FORM{$whatever}='value';
print "$FORM{$whatever}\n";

Use '' around barewords, and not variables.

James


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

Date: 7 May 1999 21:32:24 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: HASH references...
Message-Id: <slrn7j6n46.1ll.fl_aggie@stat.fsu.edu>

On Fri, 07 May 1999 19:11:55 GMT, Charles R. Thompson
<design@raincloud-studios.com>, in
<%VGY2.215$vP2.173@news.rdc1.tn.home.com> wrote:

+ >%hash=qw/a 1 b 2 c 3 d 4 e 5/;

+ I've never seen that before. Interesting.
+ (going to open a book)

This is probably one of the most useful things about Usenet: you get
exposed to things you never otherwise would have seen. I probably picked
that construct up from Randal.

James


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

Date: Fri, 07 May 1999 20:45:08 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: How to get current working directory?
Message-Id: <37394f49.7290799@news.skynet.be>

Kevin A. Collins wrote:

>I was just wondering if there is a standard way to get the path of the
>current working directory.

Abbreviate that... Cwd. :-)

It's a module on most Perl ports.

>I'm using Perl for
>Win32 right now and there is a Win32::GetCwd() function, but I just
>thought there might be a more portable solution.

If plain
 
	use Cwd;
	print cwd;

works on your system, then that's the portable solution.

The reason why it's so complicated, is because reliably getting the
current directory on Unix and related systems is unbelievably
complicated. Apparently, it's "top secret". ;-)

	Bart.


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

Date: Fri, 07 May 1999 15:57:25 -0500
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: how to grep -v ??
Message-Id: <373353B5.58717815@us.ibm.com>

pkey@sghms.ac.uk wrote:
> 
> i want to grep an array and return lines that do not contain the
> pattern i.e. grep -v
> 
> @ok = grep -v (/data/, @passwd_array);

perldoc -f grep

-- 
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)


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

Date: Fri, 07 May 1999 20:50:30 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: How to keep travelled path in hash ?
Message-Id: <7gvjl6$sab$1@xenon.inbe.net>

In article <QyGY2.9081$ny.796334@typhoon-sf.snfc21.pbi.net>, snowhare@long-lake.nihongo.org (Benjamin Franz) wrote:
>In article <AmFY2.9066$ny.790708@typhoon-sf.snfc21.pbi.net>,
>Benjamin Franz <snowhare@long-lake.nihongo.org> wrote:
>>In article <7gskak$qpq$1@news.mch.sbs.de>,
>>Michel Dalle <michel.dalle@usa.net> wrote:
>>>Hi,
>>>
>>>here is a little brain teaser. :-)
>>>
>>>I want to keep track of the number of times a certain PATH is travelled 
>>>through a website/city/forrest/..., and I have a file containing the
>>>the different pages/pubs/trees/... by each visitor.
>>>
>>>E.g. : (who when where)
>>>mike 01:52 post1
>>>mike 01:53 post2
>>>john 01:53 post3
>>>mike 01:54 post1
>>>john 01:55 post1
>>>john 01:56 post2
>>>mike 01:57 post3
>>>john 01:58 post2
>>>..
>
>For some reason I just couldn't leave this one alone (probably
>because I've been considering adding path analysis to my
>log analysers).
>
>Mk 2:
[some excellent piece of code snipped]

Before you get to Mk 3 :-) can I just point out that your version does not 
keep track of the FULL path (as I was trying to tackle in the original
message) ?
In the current version of aWebVisit, I already keep track of the individual
links "followed" (although my code is a mess), but I found that the overall 
picture was still missing. So here it is again :

How do I know in the end that :
        578 people followed the path : post1->post2-post3->post1
        1034 people followed the path : post2
        2454 people followed the path : post1->post2->post1
        etc.
and keep this in a structure that doesn't swallow my whole available memory ?

I did a test with :
        - 100 pages/pubs/...,
        - each with between 1..20 predefined links to other pages/pubs,
        - 10000 visits starting at any of the first 10 pages/pubs,
        - each between 1 and 100 steps long.
and ended up with 86000+ nodes in my tree. :-(

I still feel there has to be a more efficient way to keep track of this, but
I haven't figured it out (yet).

Thanks,

Michel.

--
aWebVisit - extracts visitor information from WWW logfiles and shows
the top entry, transit, exit and 'hit&run' pages, the links followed
inside your website, the time spent per page, the visit duration etc.
For more details, see http://gallery.uunet.be/Michel.Dalle/awv.html


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

Date: Fri, 7 May 1999 13:15:14 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How to match a variable in pattern - Help a newbie !
Message-Id: <MPG.119ce9ac376dde759899fb@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <Pine.LNX.4.10.9905080036070.31789-100000@quantum.che.nsk.su> 
on Sat, 8 May 1999 00:40:31 +0700, Anton V. Antich 
<antich@quantum.che.nsk.su> says...
> I've got a following problem. There is a formatted text file, something
> like:
> 
>  O1  1  S    1   ......... 
>  O1  2  S    2   .........
>  O1  3  X    3   .........
>  C1  1  S    4   ........  here go unimportant columns
>  C1  2  S    5    .......
>  C1  3  Y    6    ........
> 
> I have to choose lines which columns 1 and 3 match given values:
> 
> $f1 = 'O1';
> $f3 = 'S';
> 
> Then i want to pass them to a sub and print matching lines. A question -
> is it possible to check variables in the pattern/reg.exp.? I couldn't
> manage to do that, and wrote something like:
> 
> ...
> if (  (/(\w+)\s+\d+\s+(\w+)/) && ($1 eq $f1) && ($2 eq $f3))
>  { print $_;
>  };
> 
> Well, that didn't work either... Please help!

It works just fine.  What makes you think it doesn't?

Here are three Ways To Do It.  The first is Your Way, with a lot less 
punctuation.  The third is probably the fastest, but I'm not going to 
benchmark it.

     print if /(\w+)\s+\d+\s+(\w+)/ && $1 eq $f1 && $2 eq $f3;

     print if / $f1\s+\d+\s+$f3 /; # add /o if constant for the run.

     print if substr($_, 1, 2) eq $f1 && substr($_, 8, 1) eq $f3;

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 7 May 1999 14:14:46 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Is evaluation of printf operands left-to-right?
Message-Id: <MPG.119cf7a263b7563d989a00@nntp.hpl.hp.com>

In article <7gv1ru$h6$1@pegasus.csx.cam.ac.uk> on 7 May 1999 15:46:06 
GMT, M.J.T. Guy <mjtg@cus.cam.ac.uk> says...
+ William Blasius #42722  <Wm.Blasius@ks.sel.alcatel.de> wrote:
+ >I have discovered something strange, and I can't explain it so I hope
+ >someone can shed some insight into this. Consider:
+ >
+ >my @rray = ( 'one', 'two', 'three' );
+ >printf "stacksize %d, the first was: %s\n", $#rray, pop @rray;
+ >
+ >now consider the result:
+ >stacksize 1, the first was: three
+ >stacksize 0, the first was: two
+ >stacksize -1, the first was: one
+ >stacksize -1, the first was: 
+ >
+ >the scalar is apparently evaluated after the pop. Is this the
+ >expected behaviour? It certainly surprised me. The workaround 
+ >is obvious, but my curiosity is aroused.
+ 
+ In general, Perl doesn't define order of evaluation of expressions.
+ Future optimisations may change it.    So don't do that.
+ 
+ And as another example, compare and contrast:
+ 
+         perl -wle 'print $a++, $a++, $a++'
+         perl -wle 'print ++$a, ++$a, ++$a'

The arguments to a function constitute a list, and Perl *does* define 
the order of evaluation of the expressions in the list as left-to-right.  

However, the result of an evaluation may be a reference to the actual 
value, which value may then be changed by a subsequent evaluation!

Here is a snippet from a post of mine on this subject, 1998/06/17:

http://x7.dejanews.com/[ST_rn=ps]/getdoc.xp?AN=363466843

'Wow!  My old C brain is trained never to rely on the order of side 
effects in evaluating the arguments to a function.  My new Perl brain 
knows that the elements of a list are evaluated strictly left-to-right, 
but as we have seen the side effects may *appear* to be evaluated right-
to-left.  Yet "all is right as right can be" (The Mikado).'

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 07 May 1999 20:48:35 GMT
From: heinrich7486@my-dejanews.com
Subject: perl strange file problems
Message-Id: <7gvjj2$upm$1@nnrp1.deja.com>

Hi,

First, a snipet of my code.

unlink </tmp/*.test.runloade.status>; system("($command;echo \$? >
/tmp/${file_name}.test.runloade.status) &"); system ("$binpath/semaphore.pl G
E $file_name >> /var/tmp/semaphore_load.log"); `wait`; $status = `cat
/tmp/${file_name}.test.runloade.status`; print LOG "status = $status\n"; if
($status == 0 or $status == 1)	{  # means edit succeeded  .......... 
 .........  etc.

Now, the problem.  I am returing the return code ($?) from the background
process $command into a unique file.  I then cat the file into $status.  If I
try to remove the unique file anywhere in the script, the $status that prints
to the log appears as null.  However, the $status must be filled because the
if statement executes as if $status = 1.  As soon as I comment out the unlink
command, the $status prints to the log.  I have tried moving the unlink
statement around and also tried `rm filename` and system(filename) and get
the same result.  After the execution, the status in the unique file does
have the correct value, but the log never shows the status, always null when
I try to remove the status file.

Is there anything I can do to ensure one line is completed and out of cache
and on to disk before I continue to the next step?

Any suggestions would be appreciated.  E-mail to heinrich@regents.state.oh.us

Thanks.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 7 May 1999 21:11:05 GMT
From: pjh@mccc.edu (Pete Holsberg)
Subject: PGP package doesn't install...need help
Message-Id: <7gvkt9$4rj$1@lawrenceville.mccc.edu>

I obtained PGP-0.3a from CPAN, gunzipped and untarred it.
(Solaris 2.7) I then did
        perl Makefile.PL
        make
        make install

I added

use PGP::Pipe;

as line 50 of a CGI script and got this error message:

Can't locate PGP/Pipe.pm in @INC (@INC contains:
/usr/local/lib/perl5/sun4m/5.00401 /usr/local/lib/perl5
/usr/local/lib/perl5/site_perl/sun4m
//usr/local/lib/perl5/site_perl .) at
/usr/local/etc/httpd/cgi-bin/afmpgp.cgi line 50.
BEGIN failed--compilation aborted at
/usr/local/etc/httpd/cgi-bin/afmpgp.cgi line 50.
[Fri May  7 12:42:38 1999] [error] Premature end of script
headers: /usr/local/etc/httpd/cgi-bin/afmpgp.cgi

I did a search from /usr/local/lib and the only Pipe.pm is
under IO.

How do I get this to install?

Thanks,
Pete

-- 
Pete Holsberg
MCCC
Trenton, NJ


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

Date: 7 May 1999 20:15:26 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: procedure to convert sec to HH:MM:SS format
Message-Id: <7gvhku$ack$1@fcnews.fc.hp.com>

Bart Lateur (bart.lateur@skynet.be) wrote:
: I've noticed this before: you do seem to have a tendency to rely too (?)
: much on experimentally determined behaviour. You cannot seem to be able
: to accept (and work around) unspecified behaviour. I do. A feature is
: not documented? Don't rely on it. (e.g. execution order for map() ;-)

Except that the documentation is usually rather thin on what is
unspecified ;) To cite an example from elsewhere, can anybody point to
the exact location(s) that specifies (or unspecifies) the behavior of
 
  print ++$a,++$a,++$a; # prints 333
  print $b++,$b++,$b++; # prints 012

I sure can't. Maybe I'm not looking hard enough.

Andrew


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

Date: Fri, 7 May 1999 13:53:59 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: procedure to convert sec to HH:MM:SS format
Message-Id: <MPG.119cf2c02dac5a89899fd@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <373435a7.748243@news.skynet.be> on Fri, 07 May 1999 19:04:54 
GMT, Bart Lateur <bart.lateur@skynet.be> says...
> Larry Rosler wrote:
> >I know of one other situation where a number is implicity truncated:  in 
> >array indexing.  I've looked through perldata, perlop, and perlsyn, but 
> >can't find an explicit statement of this truncation.  All perldata says 
> >is "Normal arrays are indexed by number, starting with 0."  D'oh!.
> 
> I've noticed that too.
> 
> There's even a case whereyou actually need that behaviour: rand(). If
> you give it a (numeric) parameter, it will return a pseudo-random number
> between zero and that number, including the lower but excluding the
> upper limit. It does NOT truncate it to an integer, which is the most
> useful case. So if you want a random element from an array
> 
> 	$ary[rand @ary]
> 
> you explicitely depend on the truncation of the float to integer (you
> need an integer index below scalar(@ary)).

Well, that is implicitly depending on the truncation.  Explicitly 
depending on it would mean

  	$ary[int rand @ary]

C behaves exactly the same way here, by the way -- and (because there is 
a carefully written standard :-) it is documented.  Perl's behavior 
should be documented too.

> >I know of no situation where a number is implicitly rounded.
> 
> And yet, that is what *I* would have expected.

*I* would be astounded!  For one thing, rounding sometimes surprises 
people.  (For example, the IEEE Standard specifies rounding anything.5 
to the nearest *even* integer!),

> >Changing the current implementation of s?printf from truncation to 
> >rounding would be malicious tampering with existing, functioning code.  
> 
> I've noticed this before: you do seem to have a tendency to rely too (?)
> much on experimentally determined behaviour. You cannot seem to be able
> to accept (and work around) unspecified behaviour. I do. A feature is
> not documented? Don't rely on it. (e.g. execution order for map() ;-)

It is a defect in the documentation, then.  Array subscripts truncate.  
The map and grep functions process their lists sequentially.  As with a 
lot in Perl, these things are so 'obvious' that they aren't documented.  
Now if an ANSI/ISO Technical Committee were ever to get their hands on 
it (God forbid) ...

> Anyway, I've heard reports on (s)printf() doing different things on
> different platforms, when given the same data. Nasty but true.

There's no accounting for bugs!  (But there *is* reporting for bugs.  
Let them be reported and fixed or documented, instead of perpetuating 
this FUD.)

> Perl depends on the C compiler used to build the executable with. So
> Perl effectively inherits the behaviour from the C library used. And C
> libraries have a tendency to have differces.
> 
> Since the implementation of (s)printf() is more and more part of Perl's
> own explicit source, you may be in luck. It sure shows that it's
> behaviour is likely to become more and more stable, even across
> different ports, to do one thing when fed a dubious value.

The format specifiers 'd' ('i', in C) 'o' 'u' 'x' all require arguments 
of integral type.

The C programmer must arrange conversion of floats to ints, either 
explicitly (by casting) or implicitly (by assignment).  In each case, 
truncation occurs.

The Perl programmer can arrange conversion of floats to ints, either 
explicitly (by the int() function) or implicitly (by letting the Perl 
implementation of s?printf do the conversion; if it is the C function 
that is called, perl has to do the conversion first).  Any converion 
other than truncation would be a gratuitous surprise -- I called it 
egregious in the previous post.

Now let it be documented!  (Second documentation perlbug of the day 
submitted.)

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 07 May 1999 20:09:17 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: running a file from unix shell
Message-Id: <7gvgh5$k4v$2@holly.prod.itd.earthlink.net>

[ courtesy cc sent by mail if address not munged ]
     
mikej <mikej@1185design.com> wrote:
>Hi,
>
>Im trying to run a file called "Configure" from a unix shell. The file
>has full execute permissions and when I am in the same direcory as the
>file I type:
>
>.../Configure
>
>from the command line. Then it tells me ./Configure: not found
>
>it will say the same thing if I just type:
>
>Configure
>
>About a few months ago we had to reinstall our unix system. Before the
>reinstall i could run anything i wanted from the command line (perl
>scripts and things), but now it keeps saying "not found". Am I missing
>something here?

Sounds like your shebang line is wrong.

The first line of your script should read:
#!/location/of/perl  -w


Good luck



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

Date: 7 May 1999 20:23:36 GMT
From: nospam+_no_Zs__9905@hpb13799z.zboi.hpz.com.invalid (Sylvan Butler)
Subject: Re: Scripting language with LFN support?
Message-Id: <slrn7j6iu8.g3j.nospam+_no_Zs__9905@hpb13799z.zboi.hpz.com.invalid>

On Thu, 06 May 1999 20:44:54 GMT, yong321@yahoo.com <yong321@yahoo.com> wrote:
>Try making a file named qqqqqqqqq (note: 9 Q's). Try "EDIT QQQQQQQQQ." (quotes
>not included) and it won't work at least on NT. If you omit the last dot, EDIT

That is because 'edit.com' on NT doesn't support LFNs.  The CMD.EXE does
just fine.  For example, use VIM (http://www.vim.org) compiled for Win32
and try 'vim QQQQQQQQQ.".  Works great.

>In article <7fhvk6$852$1@q.seanet.com>,
>  "steve hardy" <nospam.shardy@seanet.com> wrote:
>>
>> >> My question is quite simple:
>> >> Is there a scripting language in NT
>> >> (akin to shell, batch, perl etc.) that
>> >> supports long file names?
>> >>
>> >> NT's DOS CLI only supports long file
>> >> names for built in commands (cd, md, rd,
>> >> copy, ren, dir, type...) which makes it worthless.
>>
>> hmm. Where does this assertion comes from?  CMD.exe does support LFN's. If

sdb
-- 
 | Sylvan Butler | Not speaking for Hewlett-Packard | sbutler-boi.hp.com |
 | Watch out for my e-mail address. Thank UCE.   #### change ^ to @ #### |
    They that can give up essential liberty to obtain a little temporary
    safety deserve neither liberty nor safety. --Benjamin Franklin, 1759
 "Don't Tread On Me!"


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

Date: 12 Dec 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 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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 5599
**************************************

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