[11201] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4801 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 1 22:07:21 1999

Date: Mon, 1 Feb 99 19:00:21 -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, 1 Feb 1999     Volume: 8 Number: 4801

Today's topics:
        Counting characters in binary code horng@earthlink.net
    Re: debug this script please <palincss@his.com>
        E-mail piped to PERL script besides using .forward file <nospam@aol.com>
    Re: E-mail piped to PERL script besides using .forward  (Martien Verbruggen)
        getting MODEM responses in unix (Chris Bergeron)
    Re: Help with "Malformed header" error <palincss@his.com>
    Re: HELP with string parsing and scoring (Gary E. Ansok)
    Re: Help! Problem searching for data in a large text fi <staffan@ngb.se>
        HELP!! How to delete files created by perl from telnet! <support@mekagames.com>
    Re: how to code a between() with regex? <palincss@his.com>
    Re: how to code a between() with regex? (Duane Lunday)
    Re: How to get Perl for Red Hat Linux 5.2? <palincss@his.com>
    Re: How to use Sockets in Perl? <carvdawg@patriot.net>
        i may be stupid <jon@jonstuff.force9.co.uk>
    Re: i may be stupid <allan@due.net>
    Re: i may be stupid <palincss@his.com>
    Re: i may be stupid (Martien Verbruggen)
        maths-tutor in perl-cgi <mm00ivr00@mcmail.com>
    Re: Need Tutorial (Duane Lunday)
    Re: Newbie question <gasmiley@nospam.mediaone.net>
        Perl - socket error on bind <ericmail@ozemail-nospam-.com.au>
    Re: Perl - socket error on bind (Martien Verbruggen)
        Perl 5.001 File Locking? <mkshanx@ust.hk>
    Re: Perl syntax ( URGENT ) (Jim Michael)
    Re: Perl syntax ( URGENT ) <staffan@ngb.se>
    Re: Visual Perl? <design@raincloud-studios.com>
    Re: Visual Perl? <uri@ibnets.com>
    Re: Visual Perl? (Alastair)
    Re: Visual Perl? (Martien Verbruggen)
        win32 perflib and processor statistics <cheetah@epix.net>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Mon, 01 Feb 1999 23:50:59 GMT
From: horng@earthlink.net
Subject: Counting characters in binary code
Message-Id: <795el1$pge$1@nnrp1.dejanews.com>

I am trying to format articles written in binary code (i.e. Chinese
language).  The format of the articles should have a fixed width or number of
characters per row before the articles can be included in the html
(obviously, the web browsers do not know how to wrap the binary text in an
appropriate way).  It seems that Text::Wrap didn't work for me.  Can anyone
tell me how to do it?  Thanks in advance.

Tim

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


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

Date: Mon, 01 Feb 1999 19:37:20 -0500
From: Steve Palincsar <palincss@his.com>
Subject: Re: debug this script please
Message-Id: <36B648C0.26A885AC@his.com>

myname@mydomain.com wrote:
> 
> Can anyone tell me what is wrong with this script ?
> I really don't get it, I always get an internal server error.
> I chmod te files read/write/execute
> 
> Please help,
> 
> Peter
> 
> netket@dma.be
> 
> #!/usr/bin/perl -w
> use strict;
> srand;
> my $whichImg = rand(4);
> my $img;
> if ($whichImg < 1) <==================  guess what is missing here
> 
> $img = '1.gif';
> } <===================================  close brace.  Where is the open brace?
> elsif ($whichImg < 2) <===============  and you've done it again
> 
> $img = '2.gif';
> } <===================================  there's that close again; where is the open?
> elsif ($whichImg < 4) <===============  ditto
> 
> $img = '3.gif';
> } <===================================  ditto once again
> print "<img src=\"$img\">\n";


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

Date: Mon, 1 Feb 1999 19:47:56 -0500
From: "news1.coastalnet.com" <nospam@aol.com>
Subject: E-mail piped to PERL script besides using .forward file, would like to use .domains file?
Message-Id: <oWrt2.170$Of6.783@news13.ispnews.com>

How can I pipe incoming E-mail to a PERL program using the .domains file?
Or some other process for obtain:
questions@foo.com IS piped to say questions.cgi
answers@foo.com IS piped to say answers.cgi

Any suggestions?

Domains files look like:
info@bar.com #
list-request@bar.com #
foo@bar.com foo
root@bar.com root@shaver.com
questions@bar.com joe@somewhereelse.com
other@bar.com jim@other.net
bar.com jim@other.net

I know how to pipe e-mail using the ".forward" file.  Using something like:
"|/homedir/email_a.cgi"

However this only works for the ONE user account.

Thanks for help!!!

Arthur :)
E-mail: gibbs(at)cheerful.com




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

Date: Tue, 02 Feb 1999 02:18:38 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: E-mail piped to PERL script besides using .forward file, would like to use .domains file?
Message-Id: <2gtt2.76$wk3.6694@nsw.nnrp.telstra.net>

None of the following has anything at all to do with perl. Nothing.
It doesn't matter that your program is written in perl. It might as
well have been written in any other language. Please, for future
posts, try to post to an appropriate group.

In this case, you would almost certainly want to ask on a group that
talks about mail, like comp.mail.sendmail or comp.mail.misc.

In article <oWrt2.170$Of6.783@news13.ispnews.com>,
	"news1.coastalnet.com" <nospam@aol.com> writes:
> How can I pipe incoming E-mail to a PERL program using the .domains file?

 .domains?

I'd use .forward. Check your system's man page for the functionality.

> Or some other process for obtain:
> questions@foo.com IS piped to say questions.cgi
> answers@foo.com IS piped to say answers.cgi

Huh? Why would you want to execute a CGI script with email as input?
CGI scripts are CGI scripts. They're meant to run on a web server.

> Domains files look like:
> info@bar.com #
> list-request@bar.com #
> foo@bar.com foo
> root@bar.com root@shaver.com
> questions@bar.com joe@somewhereelse.com
> other@bar.com jim@other.net
> bar.com jim@other.net
> 
> I know how to pipe e-mail using the ".forward" file.  Using something like:
> "|/homedir/email_a.cgi"
> 
> However this only works for the ONE user account.

What exactly do you want? some system wide file to capture certain
emails for certain people and do soemthing with those? You could set
up aliases or adapt sendmail.cf. I don't know about .domains files.
Never heard of them. But then, I'm not a mail or sendmail expert.

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: 2 Feb 1999 01:26:30 GMT
From: !@#@!#@#!@garnet.acns.fsu.edu (Chris Bergeron)
Subject: getting MODEM responses in unix
Message-Id: <795k86$ksd$1@news.fsu.edu>

I've tried different things, but none work... I'm trying to read the "RING" 
from my modem when a call comes in...

i use the sysread function in a loop, but it only works until the first call 
comes in...
has anyone done this successfully before?




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

Date: Mon, 01 Feb 1999 20:01:19 -0500
From: Steve Palincsar <palincss@his.com>
To: Jeff <jeff909@hotmail.com>
Subject: Re: Help with "Malformed header" error
Message-Id: <36B64E5F.C5F4FA3F@his.com>

Jeff wrote:
> 
> Hi, I am very new to perl and have been tryint to write a script that will
> open a passwords file and check a name and password a user woudl eneter
> against the names and pwords in the file.   I THINK I have written the
> script correctly but I keep getting an error message "Malformed header" but
> it doesn't tell me which eader is malformed.  Here is an example of the
> script can someone tell me what the issue is?  Thanks for any help.
> 

This usually means your script generatred some kind of error
which
was emitted before the proper content-type header.  The most
obvious
choice here is the die statement, although there is no real need
to guess; the answer lurks in your web server error log.  Another
alternative is to put the statement that prints the content-typ[e
header after the shebang line and before the "require".  Then
no matter what, anything generated will show up on screen.

BTW - if you're going to die with an error, why not include
the text of the error message by including $! in your string?
There are, after all, many reasons why a file open might fail,
and wouldn't you like to know which of those reasons caused
the problem?

By the way, doesn't your text belong in the <body> section, not
the <head>?  This HTML page has no body at all.

Not to mention the == comparion operator, which as you know is
for comparing numeric values, not strings.

> #!/usr/bin/perl
> require "cgi-lib.pl";
> &ReadParse;
> &PrintHeader;
> open(FILE,"passcodes.pl") || die "Can't open file\n";
> @indata = <FILE>;
> $name = $in{name};
> $password = $in{password};
> close(FILE);
> print "<HTML>";
> print "<HEAD>";
> print "<TITLE>Checking passwords</TITLE>";
> foreach $i(@indata)
> {
> chop($i);
> ($Pname,$Ppassword)=split(/\|/,$i);
> 
> if($name == $Pname && $password == $Ppassword)
> {
> print "<P>Welcome</P>";
> }
> else
> {
> print "<P> No access </P>";
> }
> 
> }
> print "</HEAD></HTML>";


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

Date: 2 Feb 1999 01:35:03 GMT
From: ansok@alumni.caltech.edu (Gary E. Ansok)
Subject: Re: HELP with string parsing and scoring
Message-Id: <795ko7$gc8@gap.cco.caltech.edu>

In article <36B0AC22.61907DDD@us.ibm.com>,
James Ludlow  <ludlow@us.ibm.com> wrote:
>Jerome O'Neil wrote:
>> timethese(100000,{
>> 
>>         'SP' => sub {my @array1 = split(//,$string);},
>>         'WH' => sub{
>>                 while($char = substr($string,$i++,1)){
>>                         push @array2, $char;
>>                 }
>>             }
>>         }
>
>> Benchmark: timing 100000 iterations of SP, WH...
>>         SP: 118 wallclock secs (70.38 usr +  0.02 sys = 70.40 CPU)
>>         WH:  8 wallclock secs ( 5.22 usr +  0.01 sys =  5.23 CPU)
>
>This should be 'split' vs 'failing a while loop condition 99999 times'

Indeed.  I ran the following benchmark:

#!/usr/tools/bin/perl
use Benchmark;
 
my $string = 'TO SPLIT IS HUMAN, SUBSTR - DEVINE!';
 
timethese(100000,{
 
        'SP' => sub {my @array1 = split(//,$string);},
        'WH' => sub{
                while($char = substr($string,$i++,1)){
                        push @array2, $char;
                }
            },
        'WH+' => sub{
                $i=0; @array2=();
                while($char = substr($string,$i++,1)){
                        push @array2, $char;
                }
            }
        }
);

Benchmark: timing 100000 iterations of SP, WH, WH+...
        SP: 40 wallclock secs (38.94 usr +  0.00 sys = 38.94 CPU)
        WH:  3 wallclock secs ( 2.14 usr +  0.00 sys =  2.14 CPU)
       WH+: 58 wallclock secs (58.92 usr +  0.00 sys = 58.92 CPU)

These results lead me to believe that either a) the WH benchmark is
flawed, as James and Larry have posted, or b) the statement $i=0
is incredibly expensive.  I think a) is more likely :-).

It seems like the rule of thumb should be to initialize any variable 
modified by the benchmarked code at the start of the benchmarked code 
(_not_ outside the timethese contruct).  Or just use my() variables
within the benchmarked subs, as was done in the 'SP' sub.

Hmm... be consistent in your variable treatment, too -- Jerome's
results could have been the result of a high expense of using my()
variables, too.  If you use my() variables in one benchmarked sub,
use them in all (unless that's what you're testing, of course).

-- 
Gary Ansok


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

Date: Tue, 02 Feb 1999 02:57:51 +0100
From: Staffan Liljas <staffan@ngb.se>
Subject: Re: Help! Problem searching for data in a large text file ..
Message-Id: <36B65B9F.56245CFE@ngb.se>

Chris Bowring wrote:
> because of the time it takes for a wildcard/wordsanywhere sequential
> search to be performed on the file by multiple visitors to our site. 
I think you should use a database instead of a file. In this case
(freetext, words anywhere, wildcard), I think Wais is a good idea. There
is a perl module (don't ask me where - CPAN?) called Wais.pm. 

There is also a free wais indexer (and server) (you have to index the
ENTIRE file each time you update), free-Wais.sf (i think). I don't
really know where to find these, but if you are can't find them, contact
me. The waisindexer is a bit hard to install, as is the Wais.pm module.
However, the searches are INCREDIBLY fast. I use it for databases of up
to 15Mb, with advanced queries, and searchtimes are no-where to be seen
(compared to download times: Neglectible) However, indexing of the files
is time and memory consuming, so this is only an option if they are
searched MUCH more than updated.

I have written a cgi-program to parse forms into arbitrarily complex
logical queries for use with Wais indexed databases, and this also has
nifty multilanguage support and layout features. It's not distributed,
but I could send you a copy if you manage to install the waisindexer and
Wais.pm... (you can check it out at http://www.ngb.se/Databases/)

HTH

Staffan


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

Date: 2 Feb 1999 02:43:40 GMT
From: "MekaGames Staff" <support@mekagames.com>
Subject: HELP!! How to delete files created by perl from telnet!!
Message-Id: <01be4e55$80b6c180$ae89accf@default>

Hi!
My perl program created some files in a certain directory. However, I do
not have ftp access to this directory, but I do have telnet directory. What
command do I have to use to delete this files? Thanks for your help!

- Kaveh



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

Date: Mon, 01 Feb 1999 19:53:54 -0500
From: Steve Palincsar <palincss@his.com>
To: Duane Lunday <dlunday@airmail.net>
Subject: Re: how to code a between() with regex?
Message-Id: <36B64CA2.2F700C98@his.com>

Duane Lunday wrote:
> 
> I've been poring over the online faqs as well as "Perl 5 Complete", and can't find an example of what
> i need.
> 
> Basically here's some pseudo code of what i want...
> 
> My $var = "    3] (Kinda_Weird_Filename) With Some Spaces.EXE     :::SIZE 1024k"


Now that everybody's beat the crap out of you,
I think perhaps a stab at a solution might
just be in order:

$var =~ m|\]\s*(\(.+\.EXE)|;
$NewVar = $1;

There are, of course, other ways to do this, some of which do not
use regular expressions.

Since you appear to be new to regular expressions, here's a stab
at explanation:

=~ binds the regexp to $var.  Without this, it looks at $_, the
default.  m| sets | to be the 'boundary' character for the
regexp;
by default this is / but it can be changed as I have done.
To match a ] as a literal character you have to escape it with a
backslash so as to stop it having its special meaning in a
character
class.  \s* means zero or more whitespace characters.  The open
parens begins capturing the matched text into $1.  The \( matches
a literal open parens, again so as to not have a special meaning.
 .+ matches one or more of any char; \. matches a literal dot,
again
escaped so as to not have its special meaning as a metacharacter.
EXE is obvious; the final ) stops capturing to $1, and the the
final
| ends the regexp.

I then assign the contents of $1 to $NewVar.

You could, of course, capture this in-line and not make use of
$1,
but then There's More Than One Way To Do It.


 #this comes
> from a file read..
> #here's what i'd usually do:
> My NewVar$ = Between( $var, '] ', ".EXE")
> 
> In other words, return a substring  of $var that starts with ']' (exclusive) and
> ends with ".EXE" (inclusive)
> or put YET another way, I want to see NewVar$ look like this:
> NewVar$ = "(Kinda_Weird_Filename) With Some Spaces.EXE"
> 
> Also (sorry), if i was going to search thru say 10000 lines for this string, would it be
> easier/better/faster/cooler to save NewVar$ to a hash or array?

As the man said, how you store it depends on how you want to
access it.


> 
> Thanks in advance,
> Duane Lunday
> canter@bigfoot.com


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

Date: Tue, 02 Feb 1999 02:05:50 GMT
From: dlunday@airmail.net (Duane Lunday)
Subject: Re: how to code a between() with regex?
Message-Id: <1103_917921418@c690507-a>


Thanks Steve.  I found a way but yours is cleaner.

Now in defense of my own humble self :)
I DID read the man pages that came with perl.. Personally I find 
them more inscrutible than the language itself.  I read the faqs on 
activestate and miningco incessantly. "Perl 5 Complete" is 
constantly open on my lap.  The examples I found assumed that 
I had either A:  a nicely formatted ascii-delimited file to read or B: 
 I wanted either the left or right chunk of the string. 

And yeah, I come from a background of C, Basic, Foxpro.. 
Depends on the job. I always liked Foxpro's ability to work either 
as a quick and dirty scripting language or a full fledged 
development environment. And there's always another way to 
get things done with it :) sound familiar?
I definitely like the precepts built into Perl, but sometimes I find it 
requires a larger paradigm shift (i HATE that term) than my move 
to OOP did.. In fact, i'd have to say that my headache/output 
ratio is worse with Perl at this point! (no flames about Perl/perl 
please.) And I promise any code I post will compile :P

TO SUM THINGS UP. I'm learning Perl because i think it will be 
a valuable addition to my problem solving toolbox. My experience 
with regex at this point is the occasional GREP thru my source 
code.. Its hard for a person who's thought in terms of left$, right$, 
mid$ for a LONG time to think in terms of *PATTERNS*  of data, 
not just discreet chunks.  

Defender Of the Clueless,
D. Lunday


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

Date: Mon, 01 Feb 1999 19:42:23 -0500
From: Steve Palincsar <palincss@his.com>
Subject: Re: How to get Perl for Red Hat Linux 5.2?
Message-Id: <36B649EF.1060DA53@his.com>

It's gotten installed automatically on every RedHat install I've
done
(and I'm working on machine #5 now).  Or is there more to this
question
than meets the eye?

Franky wrote:
> 
> Hi, I've just installed Linux 5.2 (red hat) and would like to know how I can
> get Perl for Appache installed... I'm new to setting up my own web server so
> I'd appreciate any help I can get... I would like to know where to get it
> how to install and set it up, thanks.
> 
> Franky


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

Date: Mon, 01 Feb 1999 21:43:59 +0000
From: Marquis de Carvdawg <carvdawg@patriot.net>
Subject: Re: How to use Sockets in Perl?
Message-Id: <36B6201F.BAEFC066@patriot.net>



Martin Baur wrote:

> Hi
> Sorry for my newbie question ... but as usual, clients are urging me ..
> :-(
>
> I understand Perl as a language but not its libs yet.
>
> I have to open a socket to a port on a given machine and transmit a
> single line string without CR/LF at the end. After this sending, I have
> to wait synchronously to receive a single line string. Then I can close
> the socket and return. I imagine something like this (sorry for the
> pascal style.  At the moment, I cannot write it properly in Perl.)
>
> function SendSocket (ip, port, string: string): string;
>
> Could please anybody email/post me a code snippet which implements that
> little bit of code? And what libs do I have to have/get?
>
> Thank you VERY much ....

Martin...

I hope this helps...

use IO::Socket;

$host = shift;
$port = shift;

$line = "This is my line";

$remote = IO::Socket::INET -> new (
          Proto => "tcp",
          PeerAddr => $host,
          PeerPort => $port) ||
     die "Could not open socket: $!\n";
  print $remote "$line";
  $return = <$remote>;
  print "$return\n";
close($remote);

Untested for your situation, but should work...



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

Date: Tue, 2 Feb 1999 00:30:37 -0000
From: "jon" <jon@jonstuff.force9.co.uk>
Subject: i may be stupid
Message-Id: <WErt2.19164$w4.2777@stones>

i have three simple .pl files

1.
#!c:/perl/bin/perl.exe

# hellowww.pl
# A Perl program that draws a Web page.

 require "htmlhead.pl";  # Call files
 require "htmlend.pl";
 &HTML_Header ("perl meets the www");
 print "<BODY>", "\n";
 print "<H1>Hello, World!</H1>", "\n";
 &HTML_Footer;

#                    End hellowww.pl

2.
#!c:/perl/bin/perl.exe
# Set up a standard HTML header section with the page title passed
# to it.

sub HTML_Header
{
    print "<META NAME=CONTENT TYPE=text/html>", "\n"; #MIME type
    print "<HTML>", "\n";
    print "<HEAD>", "\n";
    print "<TITLE>", "@_", "</TITLE>", "\n";
    print "</HEAD>", "\n";

}                    # End HTML_Header.pl

3.
#!c:/perl/bin/perl.exe
# Set up a standard HTML footer section.  At this point, it simply
# ends the BODY and HTML sections.

sub HTML_Footer
{
    print "\n", "</BODY>", "\n";
    print "</HTML>", "\n";

}                    # End HTML_Footer

and i am running the sambar server with windows 95 on my machine
when i call first .pl file the next two should spring into life but they
dont
all the files have been placed in the cgi-bin and the path to perl.exe is
fine.  what am i doing wrong here?

thanks in advance for any help
cheers
jon




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

Date: Mon, 1 Feb 1999 19:59:44 -0500
From: "Allan M. Due" <allan@due.net>
Subject: Re: i may be stupid
Message-Id: <j6st2.344$L1.6525@nntp1.nac.net>

jon wrote in message ...
:i have three simple .pl files
:1.
:#!c:/perl/bin/perl.exe
:# hellowww.pl
:# A Perl program that draws a Web page.
: require "htmlhead.pl";  # Call files
: require "htmlend.pl";

When you require files they must have a TRUE value as their last statement
indicating they were required successfully.  How about adding the line

1;

to the end of each of the files you required to indicate that the require was
succesful?

HTH

AmD

[snip the required files not returning 1;]





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

Date: Mon, 01 Feb 1999 20:10:48 -0500
From: Steve Palincsar <palincss@his.com>
Subject: Re: i may be stupid
Message-Id: <36B65098.D4DD22DD@his.com>

This is windows95, right?  Then the #! line does you
no good at all, because that's not how you do it in
the Windows enviroment.  Since somebody already
pointed out to you that files loaded with require
need a 1; at the end to return a true value, let me
ask you -- what happend when you tried to run this,
or test compile it with a -cw ?  Perl is usually quite
good at giving you useful error messages.  Also,
one does not need to include a shebang in a library
file (one you load with a "require" and that contains
subroutine definitions).

jon wrote:
> 
> i have three simple .pl files
> 
> 1.
> #!c:/perl/bin/perl.exe
> 
> # hellowww.pl
> # A Perl program that draws a Web page.
> 
>  require "htmlhead.pl";  # Call files
>  require "htmlend.pl";
>  &HTML_Header ("perl meets the www");

Looks like you are expecting HTML_Header to do something
with this passed parameter, but nowhere in the code
defining that sub do you do anything with a passed
parameter.  I think you have -- ah, I just saw the
@_ buried in the middle of a print statement.  Not the
best way to do this, as you can tell from my reaction.
Why not at the start of that sub do something like
this:

my $text = shift;

and then print $text in your sub.  This is idiomatic
and causes no confusion.  BTW, when you call a sub
and pass it a parameter that way, you can omit
the leading & (which is a holdover from perl4).

>  print "<BODY>", "\n";
>  print "<H1>Hello, World!</H1>", "\n";
>  &HTML_Footer;
> 
> #                    End hellowww.pl
> 
> 2.
> #!c:/perl/bin/perl.exe
> # Set up a standard HTML header section with the page title passed
> # to it.
> 
> sub HTML_Header
> {
>     print "<META NAME=CONTENT TYPE=text/html>", "\n"; #MIME type
>     print "<HTML>", "\n";
>     print "<HEAD>", "\n";
>     print "<TITLE>", "@_", "</TITLE>", "\n";
>     print "</HEAD>", "\n";
> 
> }                    # End HTML_Header.pl
> 
> 3.
> #!c:/perl/bin/perl.exe
> # Set up a standard HTML footer section.  At this point, it simply
> # ends the BODY and HTML sections.
> 
> sub HTML_Footer
> {
>     print "\n", "</BODY>", "\n";
>     print "</HTML>", "\n";
> 
> }                    # End HTML_Footer
> 
> and i am running the sambar server with windows 95 on my machine
> when i call first .pl file the next two should spring into life but they
> dont

"Spring into life"???

> all the files have been placed in the cgi-bin and the path to perl.exe is

Files loaded with "require" have to be on the search path
specified in
the array @INC.  Is your cgi-bin directory on that path?

> fine.  what am i doing wrong here?
> 
> thanks in advance for any help
> cheers
> jon


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

Date: Tue, 02 Feb 1999 02:21:23 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: i may be stupid
Message-Id: <Ditt2.77$wk3.6694@nsw.nnrp.telstra.net>

In article <36B65098.D4DD22DD@his.com>,
	Steve Palincsar <palincss@his.com> writes:
> This is windows95, right?  Then the #! line does you
> no good at all, because that's not how you do it in
> the Windows enviroment.

Yes, it does make a difference. Perl does reparse that line to get at
the possible arguments on it. A -w on that line makes all the
difference.

of course, in this specific case, there was nothing else on that line,
which may be considered an error.

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: Tue, 02 Feb 1999 00:10:51 +0000
From: George Stefanidis <mm00ivr00@mcmail.com>
Subject: maths-tutor in perl-cgi
Message-Id: <36B6428B.72FF@mcmail.com>

i have been assigned a project of creating in a web site a maths-tutor 
using cgi-perl . i need some help about sources and addresses where can
i find examples . THANK you.


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

Date: Tue, 02 Feb 1999 02:27:34 GMT
From: dlunday@airmail.net (Duane Lunday)
Subject: Re: Need Tutorial
Message-Id: <1104_917922722@c690507-a>

two good sites are http://www.perl.miningco.com or
http://www.activestate.com

Good luck!


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

Date: Mon, 01 Feb 1999 20:44:57 -0500
From: Gary Smiley <gasmiley@nospam.mediaone.net>
Subject: Re: Newbie question
Message-Id: <36B65899.1CCDC95B@nospam.mediaone.net>

Here's the latest: My syntax is OK. If I run the pgm via a DOS prompt, it
"sees" the shared drive and writes to it. Over the Web via an HTML form, it
dies trying to open the file for appending.

Gary Smiley wrote:

> Sorry, I have inherited this problem (we run only 1 perl program on our
> site and we have no perl programmers). How do I append records to a file
> on a shared network drive? The program currently writes to a local file
> in the cgi-bin directory,  but I have been told that in order to write
> to a shared network drive, the file name has to be in the form
> \\computername\shareddrivename\directoryname\filename but this doesn't
> work no matter what I try. I have been told by our network guy that the
> permissions have been set to allow me to do this. If anybody could
> either help me or steer me towards a source of info it would be
> appreciated. - Thanks in advance- Gary
>
> --
>
> To reply, please remove the anti-spam portion of the return address.

--

To reply, please remove the anti-spam portion of the return address.




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

Date: Tue, 2 Feb 1999 11:05:43 +1100
From: "Eric Handbury" <ericmail@ozemail-nospam-.com.au>
Subject: Perl - socket error on bind
Message-Id: <795fpa$jju$1@reader1.reader.news.ozemail.net>

Hello,

  I'm wondering if anyone can help me. This is my first attempt at using
sockets in Perl. The code snippet is such:

    #!/opt/bin/perl
    $AF_UNIX = 1;
    $SOCK_STR = 1;
    $PROTO = 0;

    socket(SERVERSOCKET, $AF_UNIX, $SOCK_STR, $PROTO) || die "Socket: $!\n";
    $name = "./sockhand";
    unlink "./sockhand" || warn "$name: $!\n";
    bind(SERVERSOCKET, $name) || die "Bind: $!\n";
    ...

    The program dies at the bind function with the following message:
    Bind: Address family not supported by protocol family

    Any hints? Thanks in advance.

--
Eric.

Sorry, but please remove the -nospam- from my e-mail address before
replying.




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

Date: Tue, 02 Feb 1999 02:11:08 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl - socket error on bind
Message-Id: <09tt2.73$wk3.6694@nsw.nnrp.telstra.net>

In article <795fpa$jju$1@reader1.reader.news.ozemail.net>,
	"Eric Handbury" <ericmail@ozemail-nospam-.com.au> writes:
> Hello,
> 
>   I'm wondering if anyone can help me. This is my first attempt at using
> sockets in Perl. The code snippet is such:
> 
>     #!/opt/bin/perl

no -w flag?
no use strict?

>     $AF_UNIX = 1;

Don't do this. Do 

use Socket;

instead. It will give you those constants a bit more reliably.
This is mentioned in the documentation for socket.

Besides, it'll give you the necessary packing functions.

# perldoc -f socket

>     $SOCK_STR = 1;
>     $PROTO = 0;

> 
>     socket(SERVERSOCKET, $AF_UNIX, $SOCK_STR, $PROTO) || die "Socket: $!\n";

socket(SERVERSOCKET, PF_UNIX, SOCK_STREAM, 0) || die "Socket: $!\n";

on my system AF_UNIX = PF_UNIX = 1, but there's no guarantee that
those will be the same everywhere. Better to be safe than sorry.  I
like PF_UNIX better than AF_UNIX in this case, just a personal
preference.

>     $name = "./sockhand";
>     unlink "./sockhand" || warn "$name: $!\n";
>     bind(SERVERSOCKET, $name) || die "Bind: $!\n";

You need to pack the address of the socket, even for Unix domain sockets:

bind(SERVERSOCKET, sockaddr_un($name)) || die "Cannot bind server: $!";

This is explained in the bind documentation, and in the perlipc
documentation (which is referred to in bind)

# perldoc -f bind
# perldoc perlipc

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: Tue, 2 Feb 1999 10:30:53 +0800
From: "Shanx" <mkshanx@ust.hk>
Subject: Perl 5.001 File Locking?
Message-Id: <795nul$t9a@ustsu10.ust.hk>

HI,

I am trying to lock a text file on my server (flock) but it is giving me the
500 server error. My code is as follows:


_______________CODE___________

#!/usr/local/bin/perl
use CGI qw(:standard);

$EXCLUSIVE = 2;
$UNLOCK    = 8;

$Record = join '|', "hello", "shanx";


open(MYFILE, ">>data.txt");
#flock MYFILE, $EXCLUSIVE;
#       seek MYFILE, 0, 2;
        print MYFILE "$Record \n";
#flock MYFILE, $UNLOCK;
close(MYFILE);

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

print "written";

_____________/CODE___________



As some of you might recognize, I got this from the webreview column. The
FILE locking lines are commented right now, because they do not work. Please
let me know what might be wrong here?

Can the Server setting of my ISP be a problem? They are using some
UNIX...SUN or SOLARIS. They have CGI.pm in their /lib folder. It recognizes
the flock command, when I say "man flock", it gives me :

--------------
NAME
     flock - apply or remove an advisory lock on an open file

SYNOPSIS
     /usr/ucb/cc [ flag ... ] file ...

     #include <sys/file.h>

     int flock( fd, operation)
     int fd, operation;

DESCRIPTION
     flock() applies or removes an  advisory  lock  on  the  file
     associated  with  the file descriptor fd.  A lock is applied
     by specifying an operation parameter LOCK_SH or LOCK_EX  for
     a  shared or exclusive lock.  Additionally, this may be ORed
     with LOCK_NB to make the operation non-blocking.  To  unlock
     an existing lock, the operation should be LOCK_
UN. .......
---------


This looks like C to me. But how about doing the same in Perl?

Also, my ISP is using Sun OS, Perl 5.001 and has the CGI.pm module. Thanks
for your time, please email me a CC too if you reply to this post.

Regards,
Shanx

______________________






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

Date: Tue, 2 Feb 1999 02:28:12 GMT
From: genepool@netcom.com (Jim Michael)
Subject: Re: Perl syntax ( URGENT )
Message-Id: <genepoolF6I9J1.B38@netcom.com>

kamez@my-dejanews.com wrote:
: hi everybody,
Howdy,
: could anyone explain me in detail the meaning of the following lines
: in Perl ( i'm not familiar with ) , so it'll help to better  understand
: to do other stuff

: chop                 ------------> what's the meaning of "chop" ?

perldoc -f chop
perldoc -f chomp

: $line =~ s/\s+/ /g;            ------------------->?

perldoc perlre

:    @arr= split;                ------------------->?
:    @val=split(/:/,arr[2]);   $tt=val[0];  -------->?

perldoc -f split

Hmm, I think I'm starting to see a trend here.

HTH.

Cheers,

Jim
-- 
May the Source be with you.


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

Date: Tue, 02 Feb 1999 03:34:31 +0100
From: Staffan Liljas <staffan@ngb.se>
Subject: Re: Perl syntax ( URGENT )
Message-Id: <36B66437.9F396F7F@ngb.se>

Hi!

> could anyone explain me in detail the meaning of the following lines
> in Perl ( i'm not familiar with ) , so it'll help to better 
> understand  to do other stuff :

> chop                 ------------> what's the meaning of "chop" ?

That's pretty well documented (perldoc perlfunc) chop cuts last char
without looking at it. It's usually used to remove newline characters.
It's performed on $_, this is the default argument to chop. You forgot
the ending ; on this line.

> $line =~ s/\s+/ /g;            ------------------->?

substitution - see perldoc perlop and perlre. This substitutes multiple
space characters with a single space throughout the line (the g makes it
match more than once).

>    @arr= split;                ------------------->?

OK, we split something to an array, see perldoc perlfunc, under split.
Split in this case uses default string to split on (space, one or many,
removing leading) on the default argument, $_, and puts this in the
array @arr. Put it shortly: @arr now has the words of $_.

>    @val=split(/:/,arr[2]);   $tt=val[0];  -------->?

Now we split the third element in @arr (although this looks wrong --
should be $arr[2], no? we split on ':' and put this in @val. $tt gets
the first element. 

To put it shortly: @arr are the words of $_, and $tt is what is before
the : of the third word. If this is all it does, it's rather inelegant.

>    if ( ( index(line,"http-gw") !=-1)
>       && ( index(line,"out=") !=-1) ) {

I suspect you are typing this code rather than copying it, since line
here should be $line, I think (NEVER retype code, ALWAYS copy).

Check perldoc perfunc for index. Also perldoc perlsyn for if's and
perldoc perlop for != and &&... if "http-gw" and "out=" are found in the
line

>       @array=grep(/^in=/,@arr);

we put the elements in @arr that start with "in=" into @array (perldoc
perlfunc for grep, perldoc perlre for /^in=/)

>       @val=split(/=/,array[0]);   in=val[1];

split the first value of @array (this should be $array[0]) on "=" into
@val, and set in to the first element in @val (should be $in=$val[1])
perldoc perlfunc for split. This is a very strange way to do this...

>       @array=grep(/^out=/,@arr);

now we take those that start with out

>       @val=split(/=/,array[0]);  out=val[1];

and set $out to what's after the equal sign in the first of these (more
typos)

>       if (index(line,pcnserver) >= 0 ) {

now we see if the $line contains whatever is in $pcnserver (more typos)

>          t_pcn+=in+out;

and add $in and $out to the value of $t_pcs (perldoc perlop and more
typos)

> Thanks for taking time to read this,

You're welcome: But PLEASE: Copy code, don't retype. The code you posted
doesn't do anything. You would have known this if you had read even a
little documentation on perl. Also learn to use the manuals (I hope my
hints were useful). Ordinarily people try not to reply to posts like
this, but I made a mistake. I'm sorry. But it shows something important:

ALWAYS COPY (don't retype) CODE!
LEARN TO RTFM (see previous posting for my interpretation on this
expression)!

HTH

Staffan


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

Date: 2 Feb 1999 00:02:12 GMT
From: "Charles R. Thompson" <design@raincloud-studios.com>
Subject: Re: Visual Perl?
Message-Id: <795fa4$3vp@bgtnsc01.worldnet.att.net>

>Yeah, this reminds me of a popular program called GirlFriend
1.0. It
>doesn't always know what you want either.  But then again, I
don't think
>it is a Perl Script.


Yeah... error messages like "We need to talk about line 26"
don't help very much.

:)




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

Date: 01 Feb 1999 19:01:17 -0500
From: Uri Guttman <uri@ibnets.com>
To: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Visual Perl?
Message-Id: <39emo9fzci.fsf@ibnets.com>

>>>>> "DG" == Daniel Grisinger <dgris@moiraine.dimensional.com> writes:

  DG> fl_aggie@thepentagon.com (I R A Aggie) writes:
  >> dna, perl, whatever... :)

  DG> <topmind>
  DG> It's all incomprehensible and should be banned, DAMNIT!!!!!!!!
  DG> </topmind>

so dan, you were bottommind all along! you were just trolling for some
badly needed attention! i should have suspected you from the beginning
as your posts under your real name have the same logical consistancy as
the ones under you nom de plume!

uri

:-) if you don't get it.

-- 
Uri Guttman                             Hacking Perl for Ironbridge Networks
uri@sysarch.com				uri@ironbridgenetworks.com	


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

Date: Tue, 02 Feb 1999 00:14:15 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Visual Perl?
Message-Id: <slrn7bcgsk.5l.alastair@calliope.demon.co.uk>

Sven Davies <svend@lubypublishing.com> wrote:
>
>Yeah, this reminds me of a popular program called GirlFriend 1.0. It
>doesn't always know what you want either.  But then again, I don't think
>it is a Perl Script.

My license expired :(

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: Tue, 02 Feb 1999 01:47:19 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Visual Perl?
Message-Id: <HOst2.69$wk3.6331@nsw.nnrp.telstra.net>

In article <36B632CD.2CEF@lubypublishing.com>,
	Sven Davies <svend@lubypublishing.com> writes:

> Yeah, this reminds me of a popular program called GirlFriend 1.0. It
> doesn't always know what you want either.  But then again, I don't think
> it is a Perl Script.

I upgraded mine to Wife 1.0. Works a lot better :)

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: Mon, 1 Feb 1999 21:34:55 -0500
From: "Jeff Beitzel" <cheetah@epix.net>
Subject: win32 perflib and processor statistics
Message-Id: <795o70$nto$1@news1.epix.net>

I'm trying to tie into the performance monitor objects for the win32 version
of perl by using the perflib module.  Among other things, one goal is to
pull CPU % time from the machine.  I modified the sample code that came with
the reskit, but I the numbers I am getting are not %time usage.  The
documentation mentions about different return types and the need for
calculation for the real result, unfortuntantly I can't seem to find the
documentation on what these calculations are.  Any help would be appreciated
(sample code or the location of helpful docs)

Thanks,
Jeff




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

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

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