[11622] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5222 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 25 04:01:39 1999

Date: Thu, 25 Mar 99 01:00:20 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 25 Mar 1999     Volume: 8 Number: 5222

Today's topics:
        @INC Problem (Jens Engelbrecht)
    Re: [AJM] CGI.pm Cookie question (Ronald J Kimball)
    Re: [AJM] Need assistance with sockets and Perl (Ronald J Kimball)
    Re: ANNOUNCE: Boston.pm Social Meeting, Thurs Mar 25 (Ronald J Kimball)
        Appending one DBM file to another india_invest@my-dejanews.com
        cgi directory listing <edwardv@jps.net>
    Re: cgi directory listing <jbc@shell2.la.best.com>
        CGI scripts on IIS4 <drumnjim@ericbr.globalnet.co.uk>
    Re: CGI scripts on IIS4 (Larry Rosler)
    Re: File Read Error: Step at / chunk error message (Ronald J Kimball)
    Re: How to create a new directory (Ronald J Kimball)
    Re: never mind... <uri@home.sysarch.com>
    Re: Not possible in Perl?? <rick.delaney@home.com>
    Re: Not possible in Perl?? <uri@home.sysarch.com>
        passing variables to script through SSI? <breap@counsel.net>
    Re: Perl Books (was Re: << string definer) (Ronald J Kimball)
        Premature end of script headers solidice@my-dejanews.com
        Problem importing multiple values using "strict" melLA@west.net
    Re: regular expression (Ronald J Kimball)
    Re: Standard Deviation (Andrew Johnson)
        Tk extensions for PERL on WinNT <partha@mihy.mot.com>
    Re: Using a Web Proxy in Perl <Tony.Curtis@vcpc.univie.ac.at>
    Re: Values of 'true' and 'false'? (Ronald J Kimball)
    Re: Values of 'true' and 'false'? (Larry Rosler)
    Re: why my sub returns nothing? (Ronald J Kimball)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Thu, 25 Mar 1999 09:37:10 +0100
From: engelbrecht@t-online.de (Jens Engelbrecht)
Subject: @INC Problem
Message-Id: <36F9F5B5.FC68B99@dachs.de>

Hello,

I wrote a cgi script using the modul LWP::Simple.
By running the script on the server I get the following error:

"Can't locate LWP/simple.pm in @INC (@INC contains:
/usr/lib/perl5/i586-linux/5.00404 /usr/lib/perl5
/usr/lib/perl5/site_perl/i586-linux /usr/lib/perl5/site_perl .) at
crawler.pl line 9.
BEGIN failed--compilation aborted at crawler.pl line 9."

The correct path to LWP::Simple is " /usr/lib/perl5/site_perl/LWP " .
How do I get the script to look in this directory ?
Thanks for helping.

Jens Engelbrecht




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

Date: Thu, 25 Mar 1999 00:04:28 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: [AJM] CGI.pm Cookie question
Message-Id: <1dp711v.j3gh43swe8cgN@p74.block2.tc1.state.ma.tiac.com>

Ron Savage <Savage.Ron.RS@bhp.com.au> wrote:

> Note that -cookie is ignored according to the documentation:
> Official Guide to Programming with CGI.pm
> Lincoln Stein
> Wiley
> 0-471-24744-8
> page 225 (at the end of redirect() ).


I find that rather intriguing...


#!/usr/local/bin/perl

use CGI qw(:cgi);

$cookie1=cookie(-name=>'name',-value=>'NAME VALUE');
$cookie2=cookie(-name=>'nic',-value=>'NIC VALUE');


print redirect(-uri=>'http://main/mainmenu.html',
                 -cookie=>[$cookie1,$cookie2]);
__END__

(offline mode: enter name=value pairs on standard input)
Status: 302 Found
Set-cookie: name=NAME%20VALUE
Set-cookie: nic=NIC%20VALUE
Date: Thu, 25 Mar 1999 03:54:29 GMT
Uri: http://main/mainmenu.html
Location: http://main/mainmenu.html
Content-type: text/html


It certainly looks to me like -cookie was not ignored.  I don't have
Lincoln Stein's CGI.pm guide, so I can't verify your citation...
Perhaps the behavior changed between versions?


[CGI.pm version 2.36]

-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Thu, 25 Mar 1999 00:04:30 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: [AJM] Need assistance with sockets and Perl
Message-Id: <1dp71c8.qkus8bhdx5s6N@p74.block2.tc1.state.ma.tiac.com>

Murphy <jt45@tir.com> wrote:

> The following works well if I launch the server on
> MachineA and the client on MachineA.  But if I try to use the client
> on MachineB and the server on MachineA, I get an error.

And that error is...?

-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Thu, 25 Mar 1999 00:04:31 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: ANNOUNCE: Boston.pm Social Meeting, Thurs Mar 25
Message-Id: <1dp71i5.1o8im6g93pc1hN@p74.block2.tc1.state.ma.tiac.com>

Elaine Ashton <elaine@cts.wustl.edu> wrote:

> You know, I also had this wacky idea today to turn my rusting 16yo volvo
> wagon into the "Perl Mobile" in time for YAPC...so..if you were a perl
> mobile what would you look like? This could be a fun group thing to
> paint it....:)

Like a camel, of course.


-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Thu, 25 Mar 1999 06:01:09 GMT
From: india_invest@my-dejanews.com
Subject: Appending one DBM file to another
Message-Id: <7dcjf1$lqm$1@nnrp1.dejanews.com>

I want to append an existing DBM file to another. Can any one help explain in
simple terms how to do it. I have limited knowledge of perl. Also, can I
append part of the data file.

anil

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


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

Date: Wed, 24 Mar 1999 22:14:44 -0800
From: "Edward Villalovoz" <edwardv@jps.net>
Subject: cgi directory listing
Message-Id: <36fa48f5.0@news1.jps.net>

Hi,
    I have an html page that has links to my perl cgi script that will
return a listing of a directory in html format so my users can select the
file and view it.  I now need to pass variables to this cgi because I want
to use one cgi for all directory queries.  So I need to pass the directory I
want the cgi to use and the file mask of what type of files I want returned.
My problems is I don't know how to pass arguments to my perl cgi via my html
page.  I tried just adding it to the end of the link but that didn't work.
ie <A HREF="../cgi-bin/index.pl ../../data/reports">
Can anyone tell me how to pass a variable to my perl script from my html
page?  Thanks  in advance...




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

Date: 25 Mar 1999 08:03:15 GMT
From: John Callender <jbc@shell2.la.best.com>
Subject: Re: cgi directory listing
Message-Id: <36f9edc3$0$201@nntp1.ba.best.com>

In comp.lang.perl.modules Edward Villalovoz <edwardv@jps.net> wrote:
> Can anyone tell me how to pass a variable to my perl script from my html
> page?  Thanks  in advance...

In this case, I can predict not only the approximate number of people
who will tell you you should have posted this in
comp.infosystems.www.authoring.cgi (3 people, plus or minus 2), but
even the precise words that at least one of them will use:

"What does this have to do with Perl?"

At a certain point the snide comebacks start to become (almost) as
sadly repetitive as the questions. And so, of course, with my own
meta-chatter...

Anyway, asking in c.i.w.a.cgi for stuff like this will increase your
chances of getting helpful answers and decrease your chances of getting
abused for asking it.

Oh, on your question, something like:

<A HREF="/cgi/my_script.pl?walnuts=rutabegas">Run my script with the
'walnuts' param set to a value of 'rutabegas'</A>

is one of several approaches that may do what you're looking for.

-- 
John Callender
jbc@west.net
http://www.west.net/~jbc/


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

Date: Thu, 25 Mar 1999 06:44:57 -0000
From: "Drummond Richardson" <drumnjim@ericbr.globalnet.co.uk>
Subject: CGI scripts on IIS4
Message-Id: <7dcm4k$3ko$1@newnews.global.net.uk>

I am running IIS4 and SP4. I am trying to set up my server to run perl cgi
scripts. I have installed perl for win 32, I have adjusted registery
settings and associated .pl files with the perl interpreter using IIS4
server manager. If I run my script using the command prompt it works fine,
so I input:'c:\perl\bin> perl hellowww.pl'
and get this as the output:

'Content-type: text/html
<html>
<head>
<title>Perl meets the www</title>
</head>
<body>
</body>
</html>'

This is correct since this is the perl script:

#!C:\Perl\bin\Perl.exe
# hellowww.pl
# perl program that draws a web page.
#
print "Content-type: text/html", "\n\n";
print "<html>", "\n";
print "<head>", "\n";
print "<title>Perl meets the www</title>", "\n";
print "</head>", "\n";
print "<body>", "\n";
print "</body>", "\n";
print "</html>", "\n";
#                              end hellowww.pl

However, when I run the script in my browser this is what appears in the
screen:

>CGI Error
>The specified CGI application misbehaved by not returning a complete set of
HTTP >headers. The headers it did return are:
>Can't open perl script "???????????l??????????f": Invalid argument


So,what does this mean?
I would be very grateful for any help.

Drummond Richardson







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

Date: Wed, 24 Mar 1999 23:43:20 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: CGI scripts on IIS4
Message-Id: <MPG.116388f6b748c3159897c4@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <7dcm4k$3ko$1@newnews.global.net.uk> on Thu, 25 Mar 1999 
06:44:57 -0000, Drummond Richardson <drumnjim@ericbr.globalnet.co.uk 
>says...
> ... If I run my script using the command prompt it works fine,
> so I input:'c:\perl\bin> perl hellowww.pl'
> and get this as the output:
> 
> 'Content-type: text/html

There needs to be a blank line here, to end the headers.

> <html>
 ...

> This is correct since this is the perl script:
> 
> #!C:\Perl\bin\Perl.exe
> # hellowww.pl
> # perl program that draws a web page.
> #
> print "Content-type: text/html", "\n\n";

This specifies that a blank line be printed, but it is not in the output 
(above).  What gives???

> print "<html>", "\n";
 ...

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


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

Date: Thu, 25 Mar 1999 00:04:32 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: File Read Error: Step at / chunk error message
Message-Id: <1dp728m.1btyhw6szcqnsN@p74.block2.tc1.state.ma.tiac.com>

Steve Guidos <sguidos@nr.infi.net> wrote:

> My perl script aborts and generates the following error message on a
> seemingly random basis:
> 
> PRODFILE Step at /u/web/artfo4/cgi-local/cron-RandHome.pl line 35,
> <PRODFILE> chunk 454.
> 
> 
> Line 35 of that perl script reads:
> 
> $TempLine = <PRODFILE> or die($!, "PRODFILE Header");  # header line !
> 
> 
> The previous code opens, reads through, closes, and then re-opens the text
> file PRODFILE, and line 35 reads in the first line of that file.  I cannot
> find a description of the 'Step at' error in any of the the perl docs.  Can
> anyone tell me what the error message means, or what is happening?  And why
> doesn't my text "PRODFILE Header" get output as part of the error message to
> stderr?


I don't believe that is line 35 of your program.

The line which is outputting that message should look more like:

do { something } or die "PRODFILE Step";
                         ^^^^^^^^^^^^^

because that's the text that is appearing in the output.


'at' has no special meaning; it is simply a preposition starting the
prepositional phrase "at /u/web/artfo4/cgi-local/cron-RandHome.pl line
35", which tells you the file and line where the error occured.

'<PRODFILE> chunk 454' means that this message was output after reading
from the PRODFILE filehandle 454 times.


Post more of your code for some actual debugging help...

-- 
#!/usr/bin/sh -- chipmunk (aka Ronald J Kimball)
      perl -e'for(sort keys%main::){print if $$_ eq 1}
            ' -s  -- -' Just' -' another ' -'Perl ' -'hacker 
' http://www.tiac.net/users/chipmunk/ [rjk@linguist.dartmouth.edu]


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

Date: Thu, 25 Mar 1999 00:04:33 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: How to create a new directory
Message-Id: <1dp72k1.1m6b4jn1tap1d7N@p74.block2.tc1.state.ma.tiac.com>

Dale Sutcliffe <dales@enhanced-performance.com> wrote:

> What is the command for creating a new directory from within a perl/cgi
> script?
> 
> What is the command for deleting a directory?
> 
> What is the command for deleting a file?

You missed one...

What is the command for reading the documentation?

perldoc


The perlfunc page starts with a list of functions by category, you
should be able to find what you need there.


(If you're on a PC, you can read the documentation in HTML format with
your web browser.  If you're on a Mac, use the Shuck utility, provided
with the MacPerl distribution.)


-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
        perl -le 'print "Just another \u$^X hacker"'


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

Date: 25 Mar 1999 00:29:34 -0500
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: never mind...
Message-Id: <x77ls69lxd.fsf@home.sysarch.com>

>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:

  LR> All right.  I don't use it.  But I do use the following, quite often:

  LR>   $condition and do_something();

  LR> rather than

  LR>   do_something() if $condition;

  LR> when I want to emphasize the condition, not the consequent.  I might 

i think and vs. if is more pure style. i have used both but i lean to
if. i agree with the concept of emphasizing the condition but if both
expressions are short then they are equally readable IMO.

like:

	next if $line =~ /^\s*$/ ;
vs.
	$line =~ /^\s*$/ && next ;

i like the if version here since i emphasize that this is a skip line
kind of thing. why we skip is not as important to me. since it is a next
statement i know this line of code is not in the main flow of the loop
or it is an way of skipping the rest of the loop body.

  LR>   $condition and do_something() or do_something_else();

  LR> Isn't that very close to the

  LR>   $condition ? do_something() : do_something_else();

  LR> that we don't seem to like.

i don't like either. IMO a full if/else statement is called for in both
cases.

  LR> And we all do this, don't we:

  LR>   open FOO, 'bar' or die "Like a dog, because $!\n";

but this is such a common idiom that it has meaning greater than its
basic semantics.

try this for size:

	die "Like a dog, because $!\n" unless open FOO, 'bar' ;

that is ugly!!!

  LR> Now substitute '&&' for 'and' and '||' for 'or' in any of the
  LR> above (fixing the priorities of the last one, of course), and see
  LR> if that changes your feelings about anything.  Mine do.  I begin
  LR> to feel as bad about them as about the ?:.

i disagree since the use of || and its brethren is very accepted and
idiomatic while using ?: for a similar effect is not common nor
intuitively obvious (hey that's a phrase i haven't used since my days in
tech school).

and if you don't like the short circuit idioms, just revert back to full
if/unless statements

	unless( open FOO, 'bar' ) {
		die "Like a dog, because $!\n"
	}

speaking of which i like || over or since it visually separates the
expressions. i always use parens in open (and for many other builtins)
so i don't have precedence issues.

  LR> It may be that the short-circuit lowest-precedence logicals 'and'
  LR> and 'or' imply evaluation for flow control, while the conditional
  LR> expression and the short-circuit higher-precedence logicals imply
  LR> evaluation for a value, as you say -- because an assignment on the
  LR> left means what it looks like.

well, look at this:

$foo = shift || 'default' ;

$foo = shift or 'default' ; # BROKEN

so your point about || being better for its value is a good one. i doubt
i will ever use or for its value. hell, i rarely use it anyway as i like
|| better as i said.

  LR> Or is it just a question of TIMTOWTDI?

could be!

uri


-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Thu, 25 Mar 1999 05:16:52 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Not possible in Perl??
Message-Id: <36F9C8B8.85EAE8E0@home.com>

Joe wrote:
> 
> I wish to read in a file, add 10 to each byte in the file and write it 
> back out to another file. I checked PERL FAQ, asked PERL programmers, 
> checked the FAQ and I cannot find a simple answer on how to do such an 
> elementary task. Is it possible??

Sure it's possible, but what does each byte represent?  An ascii value,
a signed char, something else?  Do you care about rollover into two
bytes in the output?  

If you post what you've tried it might make it more obvious what you're
trying to do.  Here's something that is almost surely not what you want,
but it does what you asked.

    open(FH, 'input')    or die "Can't open input:  $!\n";
    open(OUT, '>output') or die "Can't open output:  $!\n";
    while (read(FH, $byte, 1)) {
        print OUT $byte + 10;
    }

-- 
Rick Delaney
rick.delaney@home.com


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

Date: 25 Mar 1999 00:45:38 -0500
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: Not possible in Perl??
Message-Id: <x74sna9l6l.fsf@home.sysarch.com>

>>>>> "J" == Joe  <painter2000@Cybernex.Net> writes:

  J> I wish to read in a file, add 10 to each byte in the file and write
  J> it back out to another file. I checked PERL FAQ, asked PERL
  J> programmers, checked the FAQ and I cannot find a simple answer on
  J> how to do such an elementary task. Is it possible??

never say anything is impossible in perl. as a turing compatible
language it can compute anything that is computable. also one of perl's
mottos is: perl make easy things easy and hard things possible.


try this one liner (tested):

perl -0777pe 's/(.)/chr( ord($1) + 10 )/egs'

that wasn't too hard was it?


uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Thu, 25 Mar 1999 00:31:12 -0800
From: "COUNSEL.NET" <breap@counsel.net>
Subject: passing variables to script through SSI?
Message-Id: <36F9F450.7BE5D0C7@counsel.net>

Hi folks,

I have a banner script which runs through a server side include, and
based on a match in the documents URI it will randomly pull a banner
from the corresponding control file.  For example if the webpage is in a
directory called /test/ and that matches one of the control files it
will pull the banner from the pool in control file "test".

What I'd like to do is format an SSI call to the banner program and pass
a variable to the script so that it defaults to a control file specified
in the variable passed to the script through the SSI.  I've tried a few
variations but all generate errors.  I was thinking something like
this...

	<!--#exec cgi="/cgi-bin/bannerscript.cgi?controlfileabc"-->

 ...to pass a variable to the script which would tell the script to pull
the banner from the control file "controlfileabc".  Alas this syntax
crashes my program.

Can anyone point this wayward guy towards my solution?

Thanks! - ps - Cc: me too, this newsgroup moves fast!

Bob Reap
Counsel.Net
==


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

Date: Thu, 25 Mar 1999 00:04:27 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Perl Books (was Re: << string definer)
Message-Id: <1dp70np.112up779ur5hyN@p74.block2.tc1.state.ma.tiac.com>

Dale Henderson <dhenders@cpsgroup.com> wrote:

>     Scratchie> Here is a critical review of the book in question:
>     Scratchie> http://xenu.phys.uit.no/~tom/TYP21D.html
> 
>      It seems like I saw a list of reviews by Tom Christiansen on
>      www.perl.org; however, I can't find them now. It also seems that
>      Tom didn't like this book either. (Not sure).

http://reference.perl.com/query.cgi?section=books

 ...with a link to Tom C's Camel Critiques.


He gave _Teach Yourself Perl5 in 21 Days_ three camels out of 5,
although specific aspects of the book received two and even one camels.

-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
        perl -le 'print "Just another \u$^X hacker"'


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

Date: Thu, 25 Mar 1999 08:31:01 GMT
From: solidice@my-dejanews.com
Subject: Premature end of script headers
Message-Id: <7dcs85$tm7$1@nnrp1.dejanews.com>

I'm trying to get this guestbook CGI script to work. I've put the script in
it's own directory called guestbook along with the .htm files and images.
I've chmod 755 guest.cgi the script. Then went to the add.htm so I could see
if it would work. I get a 500 Internal Server Error saying this

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to
complete your request.

Please contact the server administrator, electron@electronicparty.com and
inform them of the time the error occurred, and anything you might have done
that may have caused the error.

Premature end of script headers:
/home/electron/public_html/guestbook/guest.cgi

Additionally, a 404 Not Found error was encountered while trying to use an
ErrorDocument to handle the request.

Apache/1.3.3 Server at www.electronicparty.com Port 80

I telnet to my server and do perl -c guest.cgi and get guest.cgi syntax ok
Also print "Content-type: text/html\n\n"; is already in the guest.cgi script


So if anyone can give me some ideas. I'd appreciate it. I have no clue what
I'm really doing.

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


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

Date: Thu, 25 Mar 1999 06:17:15 GMT
From: melLA@west.net
Subject: Problem importing multiple values using "strict"
Message-Id: <36f9d456.10978513@news.west.net>

Problem: Need to find en efficient way to accommodate "use strict"
pragma with my initialization file.

Setup: Init file contains combination of 42 non-changing strings and
arrays that I'm trying to import into $main using a require statement
that points to the init file (and most of those constants will be used
in subroutines of $main, so I see additional scoping problems ahead).

Previous posts I read on this issue involved a single value, and the
recommendation was for the poster to use either "my", or "use vars
(...)", or to append the constant with $main:: or $::. That's fine for
just one value, but I'd like to avoid appending all 42 of mine
manually. What other options do I have?

Thanks
Milt
(remove all CAPS from my e-addr)

x-no-archive: yes




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

Date: Thu, 25 Mar 1999 00:04:35 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: regular expression
Message-Id: <1dp73di.1u7xrcad7o0vdN@p74.block2.tc1.state.ma.tiac.com>

<rheinman@my-dejanews.com> wrote:

> #! /opt/perl5/bin/perl -w
> use diagnostics;

> $value = "initialize";

Don't need that...

> open(FH, "< input.file") || die "cannot open input file: $!";
> open(HH, "> output.file") || die "cannot open output file: $!";
> $inline = <FH>;
> while (defined($inline = <FH>)){
>    $value = s/brown/red/g;

$inline =~ s/brown/red/g;

You need to specify $inline as the variable to perform the substitution
on.

>    select HH; # and write record
>    print "$value \n";

print HH "$inline\n";

Much simpler just to print to the filehandle explicitly.

> }


HTH!

-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
perl -e '$_="\012534`!./4(%2`\cp%2,`(!#+%2j";s/./"\"\\c$&\""/gees;print'


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

Date: Thu, 25 Mar 1999 07:36:32 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: Standard Deviation
Message-Id: <slrn7fjpui.9q2.andrew-johnson@24.66.40.189.mb.wave.home.com>

In article <36F998A5.A7889D7A@home.com>,
 Kenneth Rose <kenrose@home.com> wrote:
! Hi all,
! 
! I was recently in a programming competition (today actually...we placed
! first too...yay!).  Anyways, one of the problems was, given a list of
! numbers in a file, to print out the standard deviation of the numbers
! (they told us how to do this).  Off the top of my head, you had to find
! the mean of the numbers, then find the sum of the squares of the
! difference between the mean and each number in the list.  After all
! that, divide the sum by the mean, and then take the square root of that
! result! Oy! It took about 30 minutes to code.  But, I was thinking about
! it afterwards, and I remembered the Perl libraries.  Sure enough, I
! found stat.pl, which had standard deviation.  The only problem is, for
! the life of me, I can't figure out how to use it.
! 
! Here's what I have:
! 
! require 'stat.pl';
! @ary = stat(foo);
! $st_dev = @ary[$ST_DEV];
! 
! OK, WTF is foo? I see this everywhere!
! Anyways, let's say that I have the following.
! 
! @nums = (3, 2, 4, 1);
! 
! 
! Actually, I don't care how long the list is.  How do I find the standard
! deviation of @nums (using the stat.pl file)?

stat.pl doesn't do statistics, it is a wrapper for the stat() function
to get info on entries in the filesystem. $ST_DEV doesn't refer to
standard deviation but the device number of the filesystem.

There is, however, a 'Statistics::Descriptive' module on CPAN which
provides methods to get the stats you want.

Or, you can code your own function using a much simpler formula
than you describe above:

#!/usr/bin/perl -w
use strict;

my @data = (12,13,12,11,16,10,13,11,12,14);
my ($mean, $variance, $st_dev) = simple_stats(@data);
print <<STATS;
mean:     $mean
variance: $variance
st_dev:   $st_dev
STATS

sub simple_stats {
    my @data = @_;
    my $size = @data;
    return unless $size;
    my ($sum_x, $sum_x2) = (0, 0);
    for (@data) {
        $sum_x  += $_;
        $sum_x2 += $_ ** 2;
    }
    my $mean  = $sum_x / $size;
    my $var   = ($sum_x2 - ($sum_x ** 2 / $size)) / ($size - 1);
    my $stdev = sqrt($var);
    return ($mean, $var, $stdev);
}
__END__

hope that helps
regards
andrew




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

Date: Thu, 25 Mar 1999 11:24:32 +0530
From: Ramanujam Parthasarathi <partha@mihy.mot.com>
Subject: Tk extensions for PERL on WinNT
Message-Id: <36F9CF98.2AA1FA54@mihy.mot.com>

Hi,

Where can I get the binary for TK extension to PERL for WinNT platform?
Right now I'm developing a PERL-TK application on UNIX(Solaris). I would
like to see if its portable on to NT.

Thanks,
Partha



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

Date: 25 Mar 1999 09:57:34 +0100
From: Tony Curtis <Tony.Curtis@vcpc.univie.ac.at>
Subject: Re: Using a Web Proxy in Perl
Message-Id: <83zp52hrpd.fsf@vcpc.univie.ac.at>

Re: Using a Web Proxy in Perl, Javier
<javierrubio@interlink.es> said:

Javier> Hi all, Im making a perl program to get
Javier> information from some webs, but my problem
Javier> is the conection, is too slow.  I have some
Javier> web proxy that can accelerate the speed, but
Javier> i dont know how to use in Perl(in Netscape
Javier> is easy :) )

Yeah, well netscape is a browser, and perl is a
programming language.

Setting up proxies is trivial with the LWP modules.
See perldoc for LWP::UserAgent which supplies a
method for setting proxies.

hth
tony
-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien.  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


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

Date: Thu, 25 Mar 1999 00:04:37 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Values of 'true' and 'false'?
Message-Id: <1dp73pa.rr27hc1i8f31qN@p74.block2.tc1.state.ma.tiac.com>

Larry Rosler <lr@hpl.hp.com> wrote:

> The Camel says (p. 87): 'These operators return 1 for true, and "" for
> false.'  This is clearly incomplete for numeric context, or there would
> be a run-time warning in the third statement above (try 'print 3 + 
> "";').  And perlop simply says that they return 'true' for the true 
> case; nothing about 'false'.
> 
> Can you point in the docs to a statement of the values of TRUE and FALSE
> as returned by a Boolean operator?  I can't remember where I read it.

Boolean operators return the special values SV_YES for true and SV_NO
for false.  SV_YES comprises a string value of '1' and a numeric value
of 1.  SV_NO comprises a string value of '' and a numeric value of 0.

(This came up on the MacPerl list a while ago.  I figured it out with a
perl compiled for DEBUGGING.)

-- 
#!/usr/bin/sh -- chipmunk (aka Ronald J Kimball)
      perl -s -e'print sort grep { /\s/ } keys %main::
            ' -- -is -' Just' -' another ' -'Perl ' -'hacker 
' http://www.tiac.net/users/chipmunk/ [rjk@linguist.dartmouth.edu]


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

Date: Wed, 24 Mar 1999 23:04:46 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Values of 'true' and 'false'?
Message-Id: <MPG.11637fe7d24ac5b39897c3@nntp.hpl.hp.com>

In article <1dp73pa.rr27hc1i8f31qN@p74.block2.tc1.state.ma.tiac.com> on 
Thu, 25 Mar 1999 00:04:37 -0500, Ronald J Kimball 
<rjk@linguist.dartmouth.edu >says...
> Larry Rosler <lr@hpl.hp.com> wrote:
 ...
> > Can you point in the docs to a statement of the values of TRUE and FALSE
> > as returned by a Boolean operator?  I can't remember where I read it.
> 
> Boolean operators return the special values SV_YES for true and SV_NO
> for false.  SV_YES comprises a string value of '1' and a numeric value
> of 1.  SV_NO comprises a string value of '' and a numeric value of 0.
> 
> (This came up on the MacPerl list a while ago.  I figured it out with a
> perl compiled for DEBUGGING.)

I figured it out by experiment.  But I still don't know if it is in 'the 
docs' for any of the usual values of 'the docs'.

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


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

Date: Thu, 25 Mar 1999 00:04:38 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: why my sub returns nothing?
Message-Id: <1dp740e.kwtr9o9qblx7N@p74.block2.tc1.state.ma.tiac.com>

Ty! Boyack <ty@cnr.colostate.edu> wrote:

> I'm trying to avoid fixing up lots of little scripts that may use
> this method in them --- has anyone heard if this is an official
> bug which will get fixed, or is this one of those cases where
> an old mis-feature has been cleaned up?

This is a known bug.  I believe it has been fixed in perl5.005_03, which
is still under development.

-- 
chipmunk (Ronald J Kimball) <rjk@linguist.dartmouth.edu>
perl -e 'print map chop, sort split shift, reverse shift
' 'j_' 'e._jP;_jr/_je=_jk{_jn*_j &_j :_j @_jr}_ja)_js$_j
~_jh]_jt,_jo+_jJ"_jr>_ju#_jt%_jl?_ja^_jc`_jh-_je|' -rjk-


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

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

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