[10690] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4282 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 23 19:07:21 1998

Date: Mon, 23 Nov 98 16:00:23 -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           Mon, 23 Nov 1998     Volume: 8 Number: 4282

Today's topics:
    Re: "ELSE" command in Perl?? (Larry Rosler)
    Re: "ELSE" command in Perl?? (I R A Aggie)
    Re: "ELSE" command in Perl?? (Sam Holden)
    Re: "ELSE" command in Perl?? <due@murray.fordham.edu>
    Re: "ELSE" command in Perl?? <due@murray.fordham.edu>
    Re: "ELSE" command in Perl?? <due@murray.fordham.edu>
    Re: "ELSE" command in Perl?? <r28629@email.sps.mot.com>
    Re: 1st Edition of Learning Perl (Bbirthisel)
        A little problem with Perl code nguyen.van@imvi.bls.com
    Re: appending <J.D.Gilbey@qmw.ac.uk>
    Re: Changing the env variables? (I R A Aggie)
    Re: Changing the env variables? (I R A Aggie)
        help me, perl community!! <maconsultants@thelyp.com>
    Re: HELP!  Newbie needs major help... (Martien Verbruggen)
        How do you distribute Perl programs? <larkas@eden.rutgers.edu>
    Re: How to tell if a file is being written to? (Martien Verbruggen)
    Re: htpasswd source code (+ crypt) <br@ndon.com>
    Re: HTTP_REFERER and Browser History (Martien Verbruggen)
        in need of some help <jiyeung@pacbell.net>
        Launching two subroutines at the same time <jim.mamay@uchsc.edu>
    Re: Launching two subroutines at the same time <zenin@bawdycaste.org>
        mkDir Question <airman@inreach.com>
    Re: mkDir Question (Martien Verbruggen)
        Net::Ping--any resolution to its use? <gtc@gches.goodnet.com>
    Re: novice question re CGI.pm/cgi-lib.pl <tutton@nortelnetworks.com>
        Plotting graphics with Perl for Win32 ? <guide@rokura.roknet.ro>
    Re: Q: Parents and childs <jhi@alpha.hut.fi>
    Re: Quickie (Martien Verbruggen)
        Receiving and Responding to Cookies from a Server perl  <torrid@mindspring.com>
    Re: Sum by group (Claes Bjorklund)
    Re: supressing output from external program in perl (Martien Verbruggen)
        sysread ... need help w/ single byte I/O, urgent!  plea (Ralph Forsythe)
    Re: Trouble installing Date::Manip module (Martien Verbruggen)
        using Expect.pm in cgi <fergal@clubi.ie>
        Xforms4Perl and 'choice' (Tom Harrington)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Mon, 23 Nov 1998 13:57:23 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: "ELSE" command in Perl??
Message-Id: <MPG.10c37a1c450deedb989889@nntp.hpl.hp.com>

In article <73cht7$oib$1@news2.xs4all.nl> on Mon, 23 Nov 1998 21:53:17 
+0100, Jeroen Roeper <lookitsme@cyberspam.com> says...
> Hi perl wizards,
> 
> a question, I have a Perl script that displays a flat text database. Now I
> want to know if there is such thing as the If-Then-Else command such as in
> VB

Of course there is.  You are just missing some punctuation.

> This is the chunk of code I use now, but it doesn't seem to work, any
> ideas??
> 
>    if( $web = "" )

This assigns the null string to $web and then tests to see if it is TRUE 
(it isn't!).

     if( $web eq "" )

>    {
>    print "<b>$com</b><br>";
>    else

     } else {

>    print "<a href=\"$web\">$com</a>";
>    }

You might want to look into alternative quoting methods to avoid those 
nasty backslashes.

You should also start out right by using the '-w' flag, which would warn 
you about such things as testing on a constant (as you did above):

    Found = in conditional, should be == at try.txt line 6.

Of course, as you are comparing strings, it should be 'eq', not '=='...

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


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

Date: Mon, 23 Nov 1998 18:00:55 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: "ELSE" command in Perl??
Message-Id: <fl_aggie-2311981800550001@aggie.coaps.fsu.edu>

In article <1diygs7.1hv3vy7g15km4N@roxboro0-028.dyn.interpath.net>,
phenix@interpath.com (John Moreno) wrote:


+    if( $web = "" )

+ Of course I'd style it a bit differently and you are using a numeric
+ instead of character comparison

Ummm...no. You're being thrown by the if () block, but that's an assignment!
So, essentially, what he's got is:

if ( I can assign a value to $web )

That's the way *I* parse it...but nothing parses perl like perl... :)

James


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

Date: 23 Nov 1998 23:08:18 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: "ELSE" command in Perl??
Message-Id: <slrn75jqn2.g2n.sholden@pgrad.cs.usyd.edu.au>

On Mon, 23 Nov 1998 18:00:55 -0500, I R A Aggie <fl_aggie@thepentagon.com>
	wrote:
>In article <1diygs7.1hv3vy7g15km4N@roxboro0-028.dyn.interpath.net>,
>phenix@interpath.com (John Moreno) wrote:
>
>
>+    if( $web = "" )
>
>+ Of course I'd style it a bit differently and you are using a numeric
>+ instead of character comparison
>
>Ummm...no. You're being thrown by the if () block, but that's an assignment!
>So, essentially, what he's got is:
>
>if ( I can assign a value to $web )
>
>That's the way *I* parse it...but nothing parses perl like perl... :)

Ummm...no. $web = "" evaluates to "" which is false thus the test is always
false as opposed to always true ;)

-- 
Sam

Perl was designed to be a mess (though in the nicest of possible ways). 
	--Larry Wall


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

Date: 23 Nov 1998 23:32:30 GMT
From: "Allan M. Due" <due@murray.fordham.edu>
Subject: Re: "ELSE" command in Perl??
Message-Id: <73crae$o7d$0@206.165.167.210>

Larry Rosler wrote in message ...
>In article <73cht7$oib$1@news2.xs4all.nl> on Mon, 23 Nov 1998 21:53:17
>+0100, Jeroen Roeper <lookitsme@cyberspam.com> says...
>> Hi perl wizards,
>>
>> a question, I have a Perl script that displays a flat text database. Now
I
>> want to know if there is such thing as the If-Then-Else command such as
in
>> VB
>
>Of course there is.  You are just missing some punctuation.
>
>> This is the chunk of code I use now, but it doesn't seem to work, any
>> ideas??
>>
>>    if( $web = "" )
>
>This assigns the null string to $web and then tests to see if it is TRUE
>(it isn't!).
>


This is fascinating to me. When I have seen this in the past I thought the
if  was testing to see if the assignment was made successfully.  When I use:
if ( $web = "foo" ) {print "True"}else{print "False"}
I get True but,
if ( $web = "" ) {print "True"}else{print "False"}
returns False.

    I have always assumed that the if tested whether the assignment was
made, and that this would always be true.  But clearly this is not the case.
Lets check the docs...

Ah, Hall and Schwartz to the rescue.  To paraphrase (or almost quote) any
quantity used in a Boolean context is converted to a string and then, if
that string is null or exactly equal to 0, the test is false.  Otherwise it
is true.   So $web is set to False above and the same result would be seen
for $web = 0, but anything else returns true.  Cool.

So little time, so much to learn.

AmD




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

Date: 23 Nov 1998 23:39:25 GMT
From: "Allan M. Due" <due@murray.fordham.edu>
Subject: Re: "ELSE" command in Perl??
Message-Id: <73crnd$orc$0@206.165.167.210>


I R A Aggie wrote in message ...
>In article <1diygs7.1hv3vy7g15km4N@roxboro0-028.dyn.interpath.net>,
>phenix@interpath.com (John Moreno) wrote:
>
>
>+    if( $web = "" )
>
>+ Of course I'd style it a bit differently and you are using a numeric
>+ instead of character comparison
>
>Ummm...no. You're being thrown by the if () block, but that's an
assignment!
>So, essentially, what he's got is:
>
>if ( I can assign a value to $web )


Now that is what I thought too, but see my response to Larry's excellent
post in this thread.

AmD






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

Date: 23 Nov 1998 23:46:45 GMT
From: "Allan M. Due" <due@murray.fordham.edu>
Subject: Re: "ELSE" command in Perl??
Message-Id: <73cs55$pp7$0@206.165.167.210>


AmD wrote in message <73clid$ama$1@camel21.mindspring.com>...
>Shoot, I forgot to mention your code still won't work.  Better check out eq
>as compared to == when comparing because I am pretty darn sure you don't
>mean = in your if statement, it is always true.  It sets $web to "".
>

Well, I was wrong here.  s/always true/always false/.  See my followup to
Larry R's excellent post where I explain my wrong-headed thinking.

AmD




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

Date: Mon, 23 Nov 1998 17:27:08 -0600
From: Tk Soh <r28629@email.sps.mot.com>
To: AmD <Allan@due.net>
Subject: Re: "ELSE" command in Perl??
Message-Id: <3659EF4C.30C2D007@email.sps.mot.com>

[posted to c.l.p.m and copy emailed]

AmD wrote:
> 
> Shoot, I forgot to mention your code still won't work.  Better check out eq
> as compared to == when comparing because I am pretty darn sure you don't
> mean = in your if statement, it is always true.  It sets $web to "".
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Nope, it should be always false. The assignment operator returns the RHS
value, so you get "", and it means False.


-TK


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

Date: 23 Nov 1998 23:31:10 GMT
From: bbirthisel@aol.com (Bbirthisel)
Subject: Re: 1st Edition of Learning Perl
Message-Id: <19981123183110.22843.00001846@ng108.aol.com>

Hi  Xiaoyan:

>On Mon, 23 Nov 1998 08:30:16 -0800, xma@Haas.Berkeley.EDU (Xiaoyan Ma)
>wrote:
>>I have inherited a 1st edition of Learning Perl. Should I start with it or
>>it's better to spend the money for the 2nd edition?
>>
>>Thanks in advance for any suggestions.
>>
>>Xiaoyan
>
>It's fine.  :-)   It's a good, gentle, introduction to the language, and
>it's not horribly outdated, as far as it goes.
>
>DO spring the money and get the Second Edition of Perl Programming when
>you're ready for it.  The First Edition won't quite cut it now.

Plan to keep the First Edition even if you get the Second. There are
a lot of simple examples that didn't fit in the Second Edition. And learn
to use the on-line documentation as well. Even the Second Edition has
seen "extensions" ;-)

-bill
Making computers work in Manufacturing for over 25 years (inquiries welcome)


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

Date: Mon, 23 Nov 1998 23:28:09 GMT
From: nguyen.van@imvi.bls.com
Subject: A little problem with Perl code
Message-Id: <73cr1n$g95$1@nnrp1.dejanews.com>

I wanted to print out Key & Value by using following code, but it give me a
duplicated copies:

____________________________________________________________________________

 @proc_files = ("aol_out", "msie_out", "netscape_out");
foreach $out_file (<@proc_files>)
{
    $ALL_IN = new IO::File "<$out_file";
    $ALL_OUT = new IO::File ">>all_out";
    hash_sort($ALL_IN);
}

sub hash_sort
{
   while (<$ALL_IN>)
   {
       chomp;
       $count{$_}++;
   }
   foreach (keys %count)
   {
         printf $ALL_OUT ("%s\t%s\n" ,$_, $count{$_});

   }
}
____________________________________________________________________________

following is the result:

AOL_3.0 1440
AOL_4.0 4790
MSIE_4.01       29369
MSIE_3.02       6122
MSIE_3.03       61
AOL_3.0 1440
AOL_4.0 4790
MSIE_3.01       2168
MSIE_3.02       6122
MSIE_4.01       29369
___________________________________________________________________________-

Thanks
Van

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


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

Date: Mon, 23 Nov 1998 23:21:17 +0000
From: Julian Gilbey <J.D.Gilbey@qmw.ac.uk>
Subject: Re: appending
Message-Id: <3659EDED.29B7DECA@qmw.ac.uk>

Richard Hitchell wrote:
> 
> Hi- I this is a very simple question but I am new to all this so I apologise
> in advance! I am writing my first perl program and want to append one file
> to another without creating a totally new file, I also need to make sure
> that no characters are added (ascii).
> 
> This is how I thought it might be done- but of course it just copies one
> file to the other...
> 
> open ( FILE_TO_COPY, $a) || die "cannot open $a for reading: $!";
> open ( MERGEFILE, ">>$b") || die "cannot open $b: $!";
> while (<FILE_TO_COPY>) {
> print MERGEFILE $_;
> }
> print "\nWeekly files merged!";
> close(FILE_TO_COPY);
> close(MERGEFILE);
> 
> Thanks...

Pardon my ignorance, but what's wrong with your solution?  Surely it
solves the problem set?  Is it that you also want to delete the
FILE_TO_COPY when you have finished?  If so, look at the unlink
command.

Incidentally, if all you want to do is to append one file to another,
you might consider the cat command if you are using UNIX: cat $a >> $b
as a shell command should be fine.  And in Perl, you could slurp the
whole file in one go:

open(...)
open(...)
undef $/;
$file_to_copy = <FILE_TO_COPY>;   # Whole file here now
print MErGEFILE $file_to_copy;
close(...)
close(...)

Also, you should have '|| die "blurb"' with your close commands as
well.

   Julian

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

            Julian Gilbey             Email: J.D.Gilbey@qmw.ac.uk
       Dept of Mathematical Sciences, Queen Mary & Westfield College,
                  Mile End Road, London E1 4NS, ENGLAND
      -*- Finger jdg@goedel.maths.qmw.ac.uk for my PGP public key. -*-


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

Date: Mon, 23 Nov 1998 18:10:27 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Changing the env variables?
Message-Id: <fl_aggie-2311981810270001@aggie.coaps.fsu.edu>

In article <3659CC62.3B680977@clockwork.net>, Dan Brian
<dan@clockwork.net> wrote:

+ You sure can alter the environment; why are there two posts saying you
+ can't? 

YOU CAN NOT MODIFY THE PARENT PROCESS' ENVIRONMENT. The parent process in
this case will be the http daemon. The moment the original poster's cgi
script stops, so does any change to the environment.

That's the mechanism he's trying to use to communicate with the customer on
the other end. His methodolog will simply not work. He needs to send the
his modifications back thru the http daemon, either as a new page on STDOUT, 
or perhaps as simple as:

print "Location: http://<whatever>/<somethingelse>\n\n";

if he wants these modifications and shifts to appear transparent to the
customer.

James


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

Date: Mon, 23 Nov 1998 18:19:11 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Changing the env variables?
Message-Id: <fl_aggie-2311981819110001@aggie.coaps.fsu.edu>

In article <3659D853.969A5252@clockwork.net>, Dan Brian
<dan@clockwork.net> wrote:

[posted && cc'd]

+ It would also help if two people didn't post downright mistruths in 
+ response to his question ;).

Allow me to rephrase the orginal question:

I modify the %ENV hash. My program quits. The changes to the %ENV hash
I made disappear. Why?

This is a FAQ, in faqt: perlfaq8

          I {changed directory, modified my environment} in a perl
          script.  How come the change disappeared when I exited the
          script?  How do I get my changes to be visible?

          Unix
              In the strictest sense, it can't be done -- the script
              executes as a different process from the shell it was
              started from.  Changes to a process are not reflected in
              its parent, only in its own children created after the
              change.  There is shell magic that may allow you to fake
              it by eval()ing the script's output in your shell; check
              out the comp.unix.questions FAQ for details.

James


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

Date: Mon, 23 Nov 1998 15:21:18 -0800
From: MAConsultants <maconsultants@thelyp.com>
Subject: help me, perl community!!
Message-Id: <3659EDE8.617E7FBC@thelyp.com>

greetings everyone,

i need help.

i'm a new programmer. i've written two whole scripts.  basic stuff for
all of you experts out there. one is an order from for an on-line flower
shop, the other is for a sign-up list. it's not much but it's a great
start. only thing is, i'm having a problem with the order form for the
flower shop. it's a CGI script and it works on my friend's server like a
charm! really sweet (my opinion) and graphically nice to look at.

only, when i transfer the script to the customers ISP's server (an NT
server) it doesn't work. this is no sendmail vs. windmail thing. the
script never even gets that far.  i get the following message:

'D:\inetpub\wwwroot\162117\vjivv4xt\cgi-bin\form.cgi' script produced no
output

first off, i'm a mac expert, not an NT guru.  so maybe i'm twice
screwed...!  anyways, i need help.

is anyone out there?

write me @
handson@loop.com

thanks very much

david



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

Date: Mon, 23 Nov 1998 23:21:14 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: HELP!  Newbie needs major help...
Message-Id: <K5m62.51$Jo2.204@nsw.nnrp.telstra.net>

[Removed from Newsgroups: alt.perl doesn't exist on my server, and I
doubt its usefulness.  comp.lang.perl is long dead. Please inform your
news admin. news.groups.comp.lang.perl.misc doesn't exist]

In article <8Ke62.1631$5n1.12807917@news.magma.ca>,
	"J.Oliver" <sabs45@hotmail.com> writes:
> Hi,
> 
> I'm just at the very beginning stages of learning PERL.

It's Perl for the language, perl for the program.

> Problem:  I need to run a script against a set of files.  Each file has a
> different file name.  Each one contains a clear text record of all the mail
> our company has sent or recieved. (in different directories.)  There is no
> way to distinguish who it belongs to by the file name.
> 
> What I would like to do is first GREP the from: header for each file and
> then move the file into a specific directory depending on who it belongs to.
> The script would then move to the next file and repeat.

The above looks to me like you have these records in standard mailbox
format? If so, you may definitely want to have a look at the
Mail::Util and Mail::Header modules. I use those regularly to run
through a bunch of mailboxes here, some of which are very large.
They're good.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Hi, Dave here, what's the root
Commercial Dynamics Pty. Ltd.       | password?
NSW, Australia                      | 


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

Date: Mon, 23 Nov 1998 18:45:11 -0500
From: Larry Kasoff <larkas@eden.rutgers.edu>
Subject: How do you distribute Perl programs?
Message-Id: <3659F387.FAE15F0@eden.rutgers.edu>

I know this may be a stupid question, but how do I give my program to
other people who may or may not have perl? Can I legally distribute Perl
with my program?



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

Date: Mon, 23 Nov 1998 23:08:04 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: How to tell if a file is being written to?
Message-Id: <oVl62.47$Jo2.204@nsw.nnrp.telstra.net>

In article <3658BB7B.27D3ABE5@noway.nz>,
	Scott Searle <scott.searle@noway.nz> writes:
> Gidday folks,
> 
>     Just a quick question here, but how might I go about seeing if a
> process is idle, or if it is active.  I am trying to restart a database
> server, but it is critical that no records are being
> added/deleted/modified etc, while the database accessed.  My first
> attempt was to run the truss command on the pid of the database (truss
> -p pid), which worked -- it showed me that my file was not being written
> to, however there has to be a much easier way to do this.

[snipped rest]

All this sounds extremely dangerous to me. Even if the database
process is 'idle' when you check, there is no guarantee that it will
still be idle when you kill it. I wont even try to come up with a
method to find that out if it is idle. This is the same sort of
problem you have when two processes access the same file or memory
location.

Apart from that, it may have many things in memory that it still needs
to flush to disk. It may have open files that need to be flushed
correctly. 

If I were you, I would use the method that the database vendor
suggests. Only shut down a database the way the vendor specifies it.
If the database server is correctly implemented, it will make sure
that all transactions in progress will either be finished, or rolled
back, and that all open files and memory caches will be flushed
correctly.

Of course, if your db vendor tells you it's safe to kill the process,
then you can be fairly certain that it will do the Right Thing(tm).

Ask in a newsgroup about your database type what the best method is.

I can however guarantee you that there is no decent method to first
check that the process is idle, and then kill it.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Little girls, like butterflies, need no
Commercial Dynamics Pty. Ltd.       | excuse - Lazarus Long
NSW, Australia                      | 


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

Date: Mon, 23 Nov 1998 18:57:03 -0500
From: "Brandon L. Golm" <br@ndon.com>
Subject: Re: htpasswd source code (+ crypt)
Message-Id: <3659F64F.ED1A2FA9@ndon.com>


Here's a diff that corrects a fatal error in your code.  I don't think anyone
could find anything without this fix!


4c4
< use HTML::Parse
---
> use HTML::Parse;


AmD wrote:

> Andrew Chapas wrote in message <73c4pd$3pr3@Talisker.taide.net>...
> >Hi!
> >Need source code for Java of Unix htpasswd utility (together with crypt.c)
> >Together with "crypt()" source code.
> >Thanks!
> >Andrew
>
> Well, since this question has nothing to do with Perl, why don't we use Perl
> to show you one way to answer it.
>
> #!/usr/local/bin/perl -w
> use strict;
> use LWP::Simple;
> use HTML::Parse
> require HTML::FormatText;
> my $htmlinfo =
> get("http://ink.yahoo.com/bin/query?p=JAVA+crypt+htpasswd+crypt.c&hc=0&hs=4"
> );
> my $info = parse_html($htmlinfo);
> my $formatter = new HTML::FormatText;
> print $formatter->format($info);
>
> AmD
>
> I think I will just keep posting this script all day.  Just in that kind of
> mood.
>
> [removed all those nasty crossposts]



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

Date: Mon, 23 Nov 1998 22:52:24 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: HTTP_REFERER and Browser History
Message-Id: <IGl62.43$Jo2.204@nsw.nnrp.telstra.net>

[Warning: Followups set. This is NOT an issue for clp.misc]

In article <3658E3ED.F22484D1@clockwork.net>,
	Dan Brian <dan@clockwork.net> writes:
> Whether specified in the RFC or not, it's still a web server dependent
> variable, as in, the web server sets the variable? If you had read the

If you take that viewpoint, then all CGI environment variables are web
server dependent. CGI is specified by the documents mentioned. If a
web server does not follow the specifications, it has implemented CGI
wrongly. The CGI specification states that all headers passed by the
client shall be made available as environment variables prefixed with
HTTP_

There is nothing server specific about that.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | If at first you don't succeed, try
Commercial Dynamics Pty. Ltd.       | again. Then quit; there's no use being
NSW, Australia                      | a damn fool about it.


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

Date: Mon, 23 Nov 1998 14:34:33 -0800
From: Jimmy Yeung <jiyeung@pacbell.net>
Subject: in need of some help
Message-Id: <3659E2F9.EE6AC0A4@pacbell.net>

I wrote this script in order to print out the contents in a directory,
and have it posted on a website, therefore allowing the website to be
automated . . . it would update itself each time someone adds a file to
the directory . . .

#!/usr/local/bin/perl

print "Content-type:text/html\n\n";

chdir("/directory/directory/directory/directoryineedtopost") || die
"Cannot open directory";
opendir(engops,".") || die "Cannot open directory";

foreach (readdir(engops)) {
      print "<br><A HREF=http://www.cisco.com/$_>$_</A>";
      print "<p>";
} 
closedir(engops);

The script works fine now; however it is also reading out the "." and
the ".."  , i tried adding a if (/^[^.]/) but it didnt seem to work . .
how would i go about printing only the files that do not begin with a
dot?  I have tried globbing it ( <*> )  but it didnt work . . . it kept
getting bugs when it brought up csh .. . so can anyone help?  thank you!


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

Date: Mon, 23 Nov 1998 14:55:37 -0700
From: Jim Mamay <jim.mamay@uchsc.edu>
Subject: Launching two subroutines at the same time
Message-Id: <3659D9D9.722B174F@uchsc.edu>


--------------36E68C84FB56DC65CF18AC5B
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Good day,
Is there a way to launch multiple subroutines at the same time?

Example
    &do_stuff1();
    &do_stuff2();

Both happen at the same time.

Thanks for thehelp.
Sincerely
Jim

--
----------------------------------------------
Jim Mamay
Director of Scientific Computing
        Biomolecular Structure Program
University of Colorado Health Sciences Center
4200 E. 9th Ave., Campus Box A060
Denver, CO 80262

Phone : 303-315-0060
Fax   : 303-315-0207
EMail : jim.mamay@uchsc.edu
URL   : http://biomol.uchsc.edu



--------------36E68C84FB56DC65CF18AC5B
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Good day,
<br>Is there a way to launch multiple subroutines at the same time?
<p>Example
<br>&nbsp;&nbsp;&nbsp; &amp;do_stuff1();
<br>&nbsp;&nbsp;&nbsp; &amp;do_stuff2();
<p>Both happen at the same time.
<p>Thanks for thehelp.
<br>Sincerely
<br>Jim
<pre>--&nbsp;
----------------------------------------------
Jim Mamay
Director of Scientific Computing
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Biomolecular Structure Program
University of Colorado Health Sciences Center
4200 E. 9th Ave., Campus Box A060
Denver, CO 80262

Phone : 303-315-0060
Fax&nbsp;&nbsp; : 303-315-0207
EMail : jim.mamay@uchsc.edu
URL&nbsp;&nbsp; : <A HREF="http://biomol.uchsc.edu">http://biomol.uchsc.edu</A></pre>
&nbsp;</html>

--------------36E68C84FB56DC65CF18AC5B--



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

Date: 23 Nov 1998 23:35:27 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Launching two subroutines at the same time
Message-Id: <911863842.219707@thrush.omix.com>

[posted & mailed]

Jim Mamay <jim.mamay@uchsc.edu> wrote:
: Is there a way to launch multiple subroutines at the same time?

	perldoc -f fork

: Example
:     &do_stuff1();
:     &do_stuff2();
: Both happen at the same time.

	fork()
	    ? do_stuff1()
	    : do_stuff2();

	Error checking and synchronization is left as an exercise for
	the reader.

: --------------36E68C84FB56DC65CF18AC5B
: Content-Type: text/html; charset=us-ascii
: Content-Transfer-Encoding: 7bit


	Please don't post in HTML, *ever*.  Thanks.

-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: Mon, 23 Nov 1998 22:59:17 GMT
From: "L. Birdwell" <airman@inreach.com>
Subject: mkDir Question
Message-Id: <3659E95F.EA7C9C7D@inreach.com>

mkdir("$path/$dir", 0777)

Shouldn't this make a directory with 777 permissions? If not, I would
appreciate input on how you would do it. It seems to be creating the
directories in 755 mode. My ISP is one of those who will not allow 777
in the cgi-bin directory so maybe this has something to do with it.

Thanks for any input
mailto:airman@inreach.com





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

Date: Mon, 23 Nov 1998 23:51:53 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: mkDir Question
Message-Id: <tym62.55$Jo2.204@nsw.nnrp.telstra.net>

In article <3659E95F.EA7C9C7D@inreach.com>,
	"L. Birdwell" <airman@inreach.com> writes:
> mkdir("$path/$dir", 0777)
> 
> Shouldn't this make a directory with 777 permissions? 

# perldoc -f mkdir
=item mkdir FILENAME,MODE

Creates the directory specified by FILENAME, with permissions specified
by MODE (as modified by umask).
                        ^^^^^
# perldoc -f umask

Now, the umask is a reasonably complex thing. Basically, the bits set
in the umask will be cleared with the permissions you hand to mkdir.

umask 002;
mkdir ("blabla", 0777);

This will result in a directory with permissions 0775.

Martien
-- 
Martien Verbruggen                  | My friend has a baby. I'm writing down
Webmaster www.tradingpost.com.au    | all the noises the baby makes so later
Commercial Dynamics Pty. Ltd.       | I can ask him what he meant - Steven
NSW, Australia                      | Wright


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

Date: Mon, 23 Nov 1998 15:35:47 -0700
From: "Geoffrey T. Cheshire" <gtc@gches.goodnet.com>
Subject: Net::Ping--any resolution to its use?
Message-Id: <3659E342.7A8D79F4@gches.goodnet.com>

Hi all,

Apropos the thread a while back on Net::Ping, I never did see a solution
posted.  I'm trying to use the package as documented, but get the
following error:

Use of uninitialized value at
/usr/lib/perl5/5.00502/i586-linux/Socket.pm line 275.
Bad arg length for Socket::unpack_sockaddr_in, length is 0, should be 16
at
/usr/lib/perl5/5.00502/i586-linux/Socket.pm line 275.

The relevant code is:

    my $p = Net::Ping->new();
    print "$host is alive.\n" if ($p->ping($host, $timeout));
    $p->close();

Any ideas?

Thanks,

Geoff

--
Geoffrey T. Cheshire





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

Date: Mon, 23 Nov 1998 17:28:44 -0600
From: John Tutton <tutton@nortelnetworks.com>
Subject: Re: novice question re CGI.pm/cgi-lib.pl
Message-Id: <3659EFAC.9713474F@nortelnetworks.com>

richard@stirlingbrig.com wrote:

> Hello folks,
> Ok Im a newbie at this but but Im having a problem I can fix, and it
> doesnt make sense
>
> Im trying to create a CGIscript in Perl to handle formdata, so wanted
> to use either CGI.pm, or cgi-lib.pl
>
> Whichever one I use I get an error
> with cgi-lib.pl error = Can't find string terminator "END_MULTIPART"
> anywhere before EOF at cgi-lib.pl l
> ine 119.
>
> with CGI.pm I get a similar one for line 686 message about cant find
> SMTHG_SMTHNG_OvERLOAD
>
> please - what the heck am I doing wrong !!!
>
> Slowly going bald !
> Richard

I encountered the same error, and in my case it was caused by not having

a carriage return after the "END_MULTIPART" part.

Hope that helps in your case.

-JT




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

Date: Mon, 23 Nov 1998 18:17:53 +0200
From: adi sorescu <guide@rokura.roknet.ro>
Subject: Plotting graphics with Perl for Win32 ?
Message-Id: <36598AB1.DEAFE42B@rokura.roknet.ro>

Hello !
I'm new to perl...I'm trying to find a Perl extension for plotting some
graphics , using perl scripts.

I've found  Lincoln Stein's  GD module , and Roth's binaries to install
GD package on Win32(becouse I don't know where I can find a gcc compiler
to bulid myself the binaries ) .
Unlike the Roth's ODBC.pm  , GD.pm doesn't work despite the fact I
followed the instrucions to add it to perl extensions(I copied the GD.pm
\perl\lib and GD.pll to \perl\lib\auto\gd\).Perl keeps saying Can't
locate loadable object for module GD in @INC

Any help ? 
where can I find a gcc port to WIn32 ?

thanks in advance !

Adrian Sorescu


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

Date: 24 Nov 1998 00:21:37 +0200
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: Q: Parents and childs
Message-Id: <oeevhk62gpa.fsf@alpha.hut.fi>


Bernd Nies <bnies@hsr.ch> writes:

> Hi,
> 
> How can I check (without blocking with wait) from 
> the parent process whether the forked child is still 
> running or not?

Either the less-known kill signal 0 or POSIX::waitpid and WNOHANG.

-- 
$jhi++; # http://www.iki.fi/~jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen


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

Date: Mon, 23 Nov 1998 23:14:45 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Quickie
Message-Id: <F%l62.48$Jo2.204@nsw.nnrp.telstra.net>

In article <73b65r$3ns@bmdhh222.europe.nortel.com>,
	"Antony" <amcnulty@nortel.co.uk> writes:

> My script needs to be run a subroutine every time the timestamp of a certain
> file is altered.

You don't give us enough specifics here.

Do you need to run something immediately when the time stamp changes?
Do you need to run something now and again, which checks whether the
time stamp changed and then does something?
What's the resolution of the check?
How often do you expect the time stamp to change?
Which timestamp are you talking about? modification? access? inode?
What's the OS (different OS's change timestamps at different times and
have different tools available to you)?

> Also, anyone ever come up with many problems in porting UNIX perl scripts
> over to WinNT ?

Depends on the script. If it calls external stuff, many problems. If
it forks, problem. If it uses unix specific stuff, problem. If none of
the above, none to few problems.

Sorry I can't be more specific.

> Got any hints for doing it quicker?

You might check the perl for win32 FAQ at www.activestate.com to see
if they mention things you need to be aware of.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | That's funny, that plane's dustin'
Commercial Dynamics Pty. Ltd.       | crops where there ain't no crops.
NSW, Australia                      | 


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

Date: Mon, 23 Nov 1998 17:49:03 -0500
From: Tim Turner <torrid@mindspring.com>
Subject: Receiving and Responding to Cookies from a Server perl script
Message-Id: <3659E65F.AD176DB9@mindspring.com>


Many web sites use cookies to store authentication information upon
login which is then rechecked every time you hit a page in the secure
area.  Is it possible to have a perl program that is accessing a web
site "on the backend" from inside the script receive that cookie info
and store it in a way that it can offer it up to the other server so it
can automagically move around through the forms on th eother server
without losing the authentication.?  Confusing huh?

Say website acme.com is running a server cgi that on the backend is
gogin to send username and password information to a login on say
Yahoo.com.  Once logged in, yahoo will send back some
authentication/session cookies.  I need the perl script to receive and
store these, so that the running perl program can then post classifieds
for example, without being boinged (i.e. it can somehow present the
stored cookies/session info back to yahoo.com as it moves through other
pages and forms).

Regards,
-Tim



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

Date: Tue, 24 Nov 1998 00:06:44 +0100
From: claes_no_spam@canit.se (Claes Bjorklund)
Subject: Re: Sum by group
Message-Id: <claes_no_spam-2411980006450001@p68.one.canit.se>

In article <73ccp0$3so$1@nnrp1.dejanews.com>, ptimmins@netserv.unmc.edu wrote:

>In article <73bvki$okh$1@nnrp1.dejanews.com>,
>  ptimmins@netserv.unmc.edu (Patrick Timmins) wrote:
>
>[snip]
 Hi again!

I am very satisfied with all help I have got about this. Now I want to 
develop this idea to a multidimmensionel tabel with counts and mean
below is an exampel in three levels my question is it possibel
to do a script which are independent of number of levels?
A friend of mine who programming in c++ sayes I should use tree 
structure instead of hash tabels in this problem, is that correct?

Thanks in advanced

\Claes
 
#!perl -w
$row=65;
$cln=7;
$num=2;
for $i (0..$row){  
   for $j (0..$cln){
      $r=rand;
      $LoL[$i][$j]=int($r*3+1);
   }
}

for $i (0..$#LoL){
   @a=@{$LoL[$i]}[0..$num];
   @rem=@{$LoL[$i]}[$num+1..$cln];
   $HoH{$a[0]}{$a[1]}{$a[2]}->{count}++;
   for $k (0..$#rem){
      $HoH{$a[0]}{$a[1]}{$a[2]}->{mean}->[$k] +=
$rem[$k]/$HoH{$a[0]}{$a[1]}{$a[2]}->{count};
   }
}

print "=======\n";
foreach $a0 (sort {$a <=> $b}  (keys %HoH)) {
   foreach $a1  (sort {$a <=> $b}  (keys %{$HoH{$a0}})) {
      foreach $a2  (sort {$a <=> $b}  (keys %{ $HoH{$a0}{$a1} })) {      
         print "$a0 $a1 $a2  $HoH{$a0}{$a1}{$a2}->{count} @{
$HoH{$a0}{$a1}{$a2}->{mean} }\n";
      }
   }
}


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

Date: Mon, 23 Nov 1998 22:56:12 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: supressing output from external program in perl
Message-Id: <gKl62.45$Jo2.204@nsw.nnrp.telstra.net>

In article <MPG.10c289bac073a79298991e@nntp.hpl.hp.com>,
	lr@hpl.hp.com (Larry Rosler) writes:
> I am confused both by the question and by your response.

My booboo. I am not entirely sure anymore what I was thinking, but you
are correct, of course. My answer is nonsensical.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | A Freudian slip is when you say one
Commercial Dynamics Pty. Ltd.       | thing but mean your mother.
NSW, Australia                      | 


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

Date: 23 Nov 1998 23:38:25 GMT
From: ralph_nos@nospam.hemi.com (Ralph Forsythe)
Subject: sysread ... need help w/ single byte I/O, urgent!  please!
Message-Id: <73crlh$i97$1@news-2.csn.net>

Ok, here's the dilemma:  I am trying to read data from an analog to digital 
converter, and am missing something.  The way it works is I send a command 
(which is working fine) to it telling it how many channels I want returned 
(1-11), and it sends back 2 bytes for each channel, MSB and LSB.  I need to 
read the bytes one-at-a-time and do ord() conversions on them - but when I try 
this it just hangs the program.  The only way I can do it so far is to read it 
all at once into a string, which doesn't work very well.

Here is the Basic code sample they sent with it:

Step 1:  Constructing the command string

   channel = 1   (chan #'s start at 0, 0-10 for ch. 1-11 repectively)
   Command$ = "!0RA"+CHR$(channel)

Step 2:  Transmit the command string (which tells it to read the ports)

   Print #1, Command$;

Step 3:  Receive the data

   MSB$ = INPUT$ (1, #1)
   LSB$ = INPUT$ (1, #1)
   reading1 = (ASC(MSB$)*256) + ASC(LSB$)

   MSB$ ...
   LSB$ ...
   reading0 = ...


The idea is to get a value fro 0 to 4095, which will tell me the voltage.  Can 
someone *please* tell me the Perl equivalent to this code fragment?  
Unfortunately I'm a but rusty in this area, but I need to know how to do this 
ASAP.

Thanks a bunch!!
- Ralph Forsythe



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

Date: Mon, 23 Nov 1998 23:01:31 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Trouble installing Date::Manip module
Message-Id: <fPl62.46$Jo2.204@nsw.nnrp.telstra.net>

In article <3658F00F.460CAE99@anu.edu.au>,
	Grant Ozolins <grant.ozolins@anu.edu.au> writes:

>> make install
> Skipping
> /authors/home/username/bin/perlmod/lib/site_perl/./Date/Manip.pm
> (unchanged)

These mean that Date::Manip is already installed, and probably the
same version of it. So, there's no need to install it again.

> /authors/home/username/bin/perlmod/lib/sun4-solaris/5.00404/perllocal.pod:
> cannot create
> make: *** [doc_site_install] Error 1

Perl keeps track of installed modules in that file. Or rather, it logs
installed modules there. 

The problem is most likely that one of the directories in that path
doesn't exist, and the process that creates the file doesn't
recursively build the path to it. I believe this is the last step in
the installation process, so it's very likely not a fatal error.

You could create the directory
authors/home/username/bin/perlmod/lib/sun4-solaris/5.00404/, and see
if that helps.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | The world is complex; sendmail.cf
Commercial Dynamics Pty. Ltd.       | reflects this.
NSW, Australia                      | 


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

Date: Mon, 23 Nov 1998 23:07:02 +0000
From: Fergal Daly <fergal@clubi.ie>
Subject: using Expect.pm in cgi
Message-Id: <3659EA96.D72B1EDE@clubi.ie>

Hi,
	sorry for the cgi nature of this, but I figure there's more chance of
finding the answer here.

I have a cgi script for changing passwords on a remote (linux) machine.
It does this by using ssh to invoke passwd as the user and uses Expect
to carryout the conversation. The problem is that when run as a cgi
script (apache 1.3.3) it has a nasty habbit of printing it's output
twice, what's even more ennoying is that it only does it for some of the
output!

I do a $Expect::Log_Stdout = 0 at the start which gets rid of all the
expect output. If anyone can tell me why this is happening I'd be
delighted as I've been tearing my hair out over this script for days,

Fergal


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

Date: 23 Nov 1998 22:09:00 GMT
From: tph@longhorn.uucp (Tom Harrington)
Subject: Xforms4Perl and 'choice'
Message-Id: <73cmds$m3q3@eccws1.dearborn.ford.com>

Does Xforms4Perl have trouble with the Xforms "choice" type, or is it just
me?  I drew up a form with fdesign, saved to Perl, and ran the resulting
script.  But none of the choice objects get any of their entries.  I get
generated code like this:

  $obj = fl_add_choice(FL_NORMAL_CHOICE2, 110, 80, 90, 30, "Target:");
  $target = $obj;
  fl_set_object_lstyle($obj, FL_BOLD_STYLE);
  fl_set_choice_entries($obj, $fdchoice_target_0);
  fl_set_choice($obj, 1);

 ...which would be fine and dandy if fdchoice_target_0 was defined somewhere.

I can fix it up manually with a second call to fl_set_choice_entries(...),
but it seems like this should be covered.  The generated C code seems OK,
it's just the Perl code that's lacking.

--
Tom Harrington --------- tph@rmii.com -------- http://rainbow.rmii.com/~tph
       "Its 'freedom of speech', as long as you don't say too much"
                           -The Neville Brothers
Cookie's Revenge: ftp://ftp.rmi.net/pub2/tph/cookie/cookies-revenge.sit.hqx


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

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

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