[8821] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2438 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 28 06:07:37 1998

Date: Tue, 28 Apr 98 03:00:30 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 28 Apr 1998     Volume: 8 Number: 2438

Today's topics:
    Re: 'each' and recursion, do they mix? <jll@skynet.be>
    Re: 'each' and recursion, do they mix? <jll@skynet.be>
    Re: ActiveStates vs. Standard Distribution (Philip)
        ANNOUNCE: Perl Builder IDE Now Available <perl@solutionsoft.com>
        Calling Win32-function CallNamedPipe <Andreas.Kuckartz@materna.de>
    Re: Changing @INC greene@gucc.org
        error opening Database file <a_klein@ix.netcom.com>
        Getting the filehandle from a typeglob <fecund@fatnet.net>
    Re: Help! Internal Server Error???? <robban@it-konsult.com>
    Re: image size for jpg and/or gif <admin@hatsoft.com>
        JavaScript to Perl var passing <kuesko@earthlink.net>
        message board question <idk@idkconsulting.com>
    Re: Need to find web-based e-mail client in Perl! Tim@netshift.com
        New boy on the perl block (Richard Cooper)
    Re: Perl experts!! help me!! greene@gucc.org
        Perl Scripts Newsgroup <mikey@in.net>
        Perl/Wall lingo question (RHS Linux User)
    Re: Perl/Wall lingo question <rra@stanford.edu>
        Permutations in hashes make Perl hurt (Tom Rokicki)
        Problem with Perl script (Probaply very simple) stevenf@pcdynamics.nl
    Re: QRe: == vs. eq <danboo@negia.net>
    Re: QUESTION: How do I print file contents to screen? greene@gucc.org
        Redefined subroutines using mod_perl Chris_Schoenfeld@sonic.net
    Re: Splitting a variable ??? <sowmaster@juicepigs.com>
    Re: Splitting a variable ??? <jdf@pobox.com>
    Re: Splitting a variable ??? <igor.k@usa.net>
    Re: Splitting a variable ??? (Martien Verbruggen)
    Re: Statistics for comp.lang.perl.misc <cnwetzel@linguistik.uni-erlangen.de>
    Re: XML to HTML conversion (Andy Wardley)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 28 Apr 1998 11:26:54 +0200
From: Jean-Louis Leroy <jll@skynet.be>
Subject: Re: 'each' and recursion, do they mix?
Message-Id: <VA.000000a5.148e6132@jll>

>  local each %hash;

Yes, that's the syntax I had in mind. But I like 'local pos %hash' better.

> Back *where*?  There is no problem to answer this if the hash did not
> change.  But if it did?

We could prevent the hash from changing when its iterator localized. Any 
attempt to modify the hash would die() unless the iterator is exhausted. 
An alternative would be to die() only if running under -w and restore the 
iterator to pair of undefs otherwise. Localizing the whole hash would 
re-enable modifications.

Anyway I think that programs that iterate over a hash and modify it at the 
same time are rare. Indeed, the sanity of this is questionable.

I'll try to put what I mean in pseudocode. Assuming that the data 
structure behind a hash looks looks like:

    struct hash
    {
        hash_content content;
        hash_iterator iter;
        
        localize()
        {
            push content, iter;
        }
    }
    
 .where 'content' contains the buckets, keys, values, whatever, and 
'iterator' contains the iterator's state. Localize() implements 
localization for the whole hash, what you get when you say 'local (%h)'.

We could modify 'hash' in the following manner:

    struct hash
    {
        hash_content content;
       
        struct hash_iterator
        {
            // other states
            int localized_depth; // initially 0
            
            localize()
            {
                push *this;
                ++localize_depth;
            }
        };
        
        hash_iterator iter;
        
        localize()
        {
            push *this;
            iter.localized_depth = 0;
        }
        
        sub put_at(key, val)
        {
            die if iter.localized_depth;
            // like before
        }
    }

The cost would be very small for apps that don't use the new feature: test 
iter.localized_depth + do a branch + copy an extra integer when localizing 
the whole hash. Using the feature would cost very little as well.

That being said, I don't think it's worth the effort *unless* the 
efficiency of 'each' is improved enough to beat iterating over keys. I 
must say that I have a very hard time believing this is unfeasible...

Jean-Louis Leroy
http://ourworld.compuserve.com/homepages/jl_leroy



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

Date: Tue, 28 Apr 1998 11:26:58 +0200
From: Jean-Louis Leroy <jll@skynet.be>
Subject: Re: 'each' and recursion, do they mix?
Message-Id: <VA.000000a6.148e6f29@jll>

> That is not very Perlish!

Indeed. But if is helps detect a bug earlier...

> >Also, what do you think of making *the* iterator amenable to local()?
> >That would solve the problem you mentioned, wouldn't it?
>  
> I'm not sure I understand what you want to do here.

For a detailed explanation see my reply to Ilya elsewhere in the thread.

> I don't know why; I had expected it to be slower, but not as slow as
> it is.  (`each' is not for speed; it is a space optimization, not a
> time optimization.  You should expect it to be slower.)

Iterating over a hash efficiently is easy. Perhaps there's more to it 
than just iteration though.

I find your comment on 'each' being a space optimization intriguing. The 
only space it saves compared to iterating over 'keys %h' is on a stack, 
isn't it? I suppose the opt. Is for *huge* hashes...

> If yu really want to know, the place to look is in the Perl source.

I'll try to find the time.

Jean-Louis Leroy
http://ourworld.compuserve.com/homepages/jl_leroy



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

Date: Tue, 28 Apr 1998 07:42:59 GMT
From: gwynp_nospam@artware.qc.ca (Philip)
Subject: Re: ActiveStates vs. Standard Distribution
Message-Id: <35458833.14578360@nntphost.login.net>

On Wed, 22 Apr 1998 11:41:52 -0400, "Michael Wil. Swiercz"
<mike@borg.com> wrote:

>Many moons ago, I battled with getting Perl installed and usuable on an
>NT Server. Thus, I figured to ask now, before I find myself ripping the
>remaining hair out of my head. Any feedback would be appreciated.

My guess is that PerlIS will cause you to rip the remaining hair out
of your head... it might be faster and all, but isn't pretty and
crashes far to often.

-Philip


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

Date: Mon, 27 Apr 1998 23:04:20 -0700
From: Marty Ford <perl@solutionsoft.com>
Subject: ANNOUNCE: Perl Builder IDE Now Available
Message-Id: <35457164.C17@solutionsoft.com>

We would like to invite everyone here to try a pre-release 
copy of Perl Builder--the first complete, integrated 
development environment for Perl. Perl Builder offers
a high quality IDE which is reminiscent of the top 
visual tools from companies like Microsoft and Borland. 

Perl Builder is now available for download at 
<http://www.solutionsoft.com/perl.htm>.

Key features include:

* Integrated Editor/Debugger with color syntax 
  highlighting, breakpoints, single step, watches, 
  and "tool tip" variable inspection.

* Perl Builder's CGI Wizard is a code generator which 
  automates development and lets you create sophisticated 
  CGI scripts visually. 

* CGI Simulation lets you test and debug CGI scripts 
  right on the Windows 95/NT desktop. Script output, such 
  as dynamic HTML and email messages, can be examined visually. 
  No webserver is required.

* Supports both CGI and general purpose (non-CGI) Perl 
  development.

* Fully windowed (GUI) environment; you never need to 
  work with the command line.

* Editor scripting lets you extend the Perl Builder IDE using
  Perl.  

Perl Builder runs on Windows 95 or NT; however, the scripts 
created may be used on any system which supports Perl.

Please let us know what you think of Perl Builder. Your 
feedback and suggestions are very important to us. We will make 
every effort to incorporate as many suggestions and 
improvements as possible before the final release of the product.

The Perl Builder Team
perl@solutionsoft.com
http://www.solutionsoft.com/perl.htm


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

Date: Tue, 28 Apr 1998 10:57:44 +0200
From: Andreas Kuckartz <Andreas.Kuckartz@materna.de>
Subject: Calling Win32-function CallNamedPipe
Message-Id: <35459A08.194@materna.de>

How can I call the Win32-function CallNamedPipe?

It is not (yet) made available in the Win32::Pipe module
and an Altavista search for "CallNamedPipe AND Perl" resulted in
a single hit which did not help.

Andreas

-----
German translation:

Wie kann ich die Win32 Funktion CallNamedPipe aufrufen?

Sie ist (noch) nicht im Win32::Pipe Modul enthalten
und eine Altavista-Suche nach "CallNamedPipe AND Perl"
hat nur einen Treffer ergeben, der aber nicht geholfen hat.


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

Date: Tue, 28 Apr 1998 02:02:36 -0600
From: greene@gucc.org
Subject: Re: Changing @INC
Message-Id: <6i3uuc$pb9$1@nnrp1.dejanews.com>

In article <6huob9$t13$1@nntp2.ba.best.com>#1/1,
  "Grimes" <grimes@msn.com> wrote:
>
> How do I change the default @INC list of paths?
>

Use a BEGIN block to add/modify the INC list, for example

#!/usr/bin/perl -Tw

BEGIN {
    # Add my cgi-bin directory to the @INC variable
    push @INC, "/home/www/~myroot/cgi-bin" ;
    require "mymodule.pl" ;
}

 ...

HTH,
JAG
--
# James Greene - Informatics Consulting - D-79539 Loerrach, Germany
# Internet: www.gucc.org/greene/consult - greene@gucc.org
# PGP Fingerprint: 8930 41E7 351B 56D8 801C  D4D9 4C76 AF0F E24E F307
perl -we "$_=join'<',qw{d2by' f5e;f4z($iu w0@86yo=&ae b!097)l(&aa8vme
b$*};$_=unpack'u*',uc;print"

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Tue, 28 Apr 1998 02:07:22 -0700
From: "Adam Klein" <a_klein@ix.netcom.com>
Subject: error opening Database file
Message-Id: <6i469s$gn6@sjx-ixn6.ix.netcom.com>

I am trying to open an ascii database using perl and I keep getting this
error.  The code that I am using is:

open(DATABASE, "$database") || die "Content-type: text/html\n\nCannot open
database! " . $database;
  @database = <DATABASE>;
  close(DATABASE);

but I get an error returned in the browser that says that it can't open the
database file.  Why is this happening?  Do I need to create the file first?
How do I fix this problem?

Please help :)

Thank you,

Adam




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

Date: Tue, 28 Apr 1998 01:13:02 -0700
From: "yary h." <fecund@fatnet.net>
Subject: Getting the filehandle from a typeglob
Message-Id: <35458F8E.1330@fatnet.net>

I am delighted to discover that one can extract a filehandle
reference from a lexicly scoped variable.  The entry on page 282
of the blue camel book made me think that it could only be done
with package variables.

This means I can have a module with:

my counter="CONN00";

sub new_connection {
    # Makes a connection & returns a filehandle.
    my $self = shift;
    my $sock = ++$counter;

    # Get the servers inet address
    my $addr = inet_aton($self->{HOST})
	or croak "Can't find address for host '$self->{HOST}': $!";

    # Use the glob *sock to create a filehandle from the name in $sock
    socket(*sock, PF_INET, SOCK_STREAM, getprotobyname('tcp'))
        or die "Can't create socket: $!";
    # And now replace the scalar $sock with that filehandle
    $sock = *sock{FILEHANDLE};
    # connect
    connect($sock, sockaddr_in($self->{PORT}, $addr))
	or croak "Can't connect to host '$self->{HOST}', port $self->{PORT}:
$!";

    autoflush $sock;
    
    $self->{SOCK} = $sock;
}


which (with the appropriate glue to set $self->{HOST} etc. beforehand)
lets the caller easily get handles to a server while hiding all the
uglies, and it works with all strictness!

I was a little dissapointed that I couldn't do

++$counter;
my $sock = *counter{FILEHANDLE};

socket($sock, .... )

which dies with
Can't use an undefined value as a symbol reference

On the one hand it makes sense, because the filehandle reference 
doesn't exist until socket creates it.  On the other hand, when
I'm calling socket with a glob, the filehandle part is undefined,
and socket defines it, so shouldn't it work with undefined input?

Maybe what I really want is for
$foo = *bar{FILEHANDLE};
to create that filehandle reference if it doesn't exist.

or am I being too anal about not using "no strict refs"? and too anal
about not using typeglobs when all I want is the filhandle?

Note that with "use Symbol" and gensym I can get an anonymous
filehandle.  Or I could say "++counter; my $sock = *counter"
and get good behavior, but I'm obsessive about using filehandle
references instead of globs. It's not a completely pointless obsession,
I like being able to say
    autoflush $sock;
which works when $sock is a filehandle ref, but not when it's
a glob ref.

-y


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

Date: 28 Apr 1998 08:08:15 GMT
From: "Robert Friberg" <robban@it-konsult.com>
Subject: Re: Help! Internal Server Error????
Message-Id: <01bd727c$b8cd10c0$c82da8c0@robban.ittek.org>

I'm trying to write what should be a simple perl script to open an html
document and extract email address and then write them to a text file for a
mailing list script.  I've tried everything I can think of and I keep
getting
that damned Internal Server Error.

	Hope you survived the attack following this post ;?)

	You need to download perl so you can work with your script
	locally before trying it on the server. Go to http://www.activestate.com 
	and get the latest distribution (for win95/NT)
	which is about 1.5 MB to download. Documentation in html 
	and a bunch of modules are included. The installation is
	a no-brainer. Check out www.perl.com too, where you'll find
	tons of information, including the faq's.

	Type perl -w name_of_your_script at the dos command prompt
	to run your script.

	Good luck!
	Robban


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

Date: Mon, 27 Apr 1998 23:54:52 -0700
From: "Henry Wolff" <admin@hatsoft.com>
Subject: Re: image size for jpg and/or gif
Message-Id: <35457ceb.0@news.greatbasin.net>

As per the instruction in the tar.gz, I did the following

>perl Makefile.PL
worked fine
>make && make test
worked fine

> make install
result:
You do not have permissions to install into
/usr/libdata/perl5/site_perl/i386-bsdos at -e line 1
*** Error code 2


Henry Wolff
Send Some Virtual Postcards - FREE
http://www.hatsoft.com/webcard/index.html





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

Date: Tue, 28 Apr 1998 00:32:17 -0700
From: Tito Ciuro <kuesko@earthlink.net>
Subject: JavaScript to Perl var passing
Message-Id: <35458601.BE9620E4@earthlink.net>

Hi!

I wrote a little program using JavaScript which uses an array of people.
Each node holds the name and phone number. My question is:

1) How can I pass this array to Perl so that I can save the info to a
file? I thought of using ACTION=open, append and close and pass the info
to the query string.

2) Does anyone know how to call a Perl script from JavaScript without
using the Submit button?

3) I have various arrays with info, and I'd like to save them at once.
Any suggestions?

If anyone wants to share some stuff, please reply to tito@cemax.com.
Thanks so much for the help. Regards,


Tito Ciuro



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

Date: Tue, 28 Apr 1998 08:04:27 +0100
From: Matthew Wheeler <idk@idkconsulting.com>
Subject: message board question
Message-Id: <35457F7B.5ADEE0C2@idkconsulting.com>

I have no clue of how to use newsgroups, so if this messes up, I
apologize.  I'm just pretty desperate for help here.  Please respond to
bjk@glasscity.net if you can answer the posed question.

To an expert, this will probably seem like a stupid question, but here
we go anyhows. It's regarding using perl for a message board.

We have uploaded the wwwboard.pl and associated files from Matt's
Scripts and they work pretty well, however, when we go to read the new
messages, it says that access to read the file is forbidden.  If we go
into the directory, and "chmod" the file to 777, it then becomes
readable.

However, that would mean chmoding each individual file to 777 every time
a new one is created.  We know that there is a way to avoid that, but we
don't know how.  Is there a way we can make it so that each new file is
given the permissions which would make the file accessible?

The message board is at: http://www.idkconsulting.com/wwwboard.html

The messages are being stored in www.idkconsulting.com/messages/

If you wish for me to send you the wwwboard.pl file, I will.  Nobody has
yet replied to our plea.  I hope you can.  Thanks.



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

Date: Tue, 28 Apr 1998 02:59:14 -0600
From: Tim@netshift.com
Subject: Re: Need to find web-based e-mail client in Perl!
Message-Id: <6i428h$2rd$1@nnrp1.dejanews.com>



Overkill? yes probably but we thought web kiosks were very simple two and a
half years ago, NetShift distills down every thing we have learnt about them
since, especially security etc. Also the email client is a specific web kiosk
one, so I thought it might be useful.

Regards Tim


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Tue, 28 Apr 1998 09:28:25 GMT
From: RCooper@rnib.org.uk (Richard Cooper)
Subject: New boy on the perl block
Message-Id: <6i4413$f2c$1@flex.news.pipex.net>

I am using a combination of perl, IDC/HTX and Active Server Pages to
query a database.  The database if basically a product catalogue and
ordering system.  I only want at the moment verified past customers to
place orders, so I need to verify the customers identification at the
beginning before they are allowed to place an order. 

Has anyone got any good suggestions as to what techniques  are best to
use to verify the customer is valid, stop anyone else from ordering,
keep a record of the customer identification throughout there
ordering, quering of stock and ordering session.

Any helpfull hints would be most appreciated.

Thank you in advance

Richard 



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

Date: Tue, 28 Apr 1998 02:48:22 -0600
From: greene@gucc.org
Subject: Re: Perl experts!! help me!!
Message-Id: <6i41k5$10k$1@nnrp1.dejanews.com>

In article <35435742.8608410@usenet.kornet.nm.kr>#1/1,
  thee@pcrc.hongik.ac.kr (Tau Kim) wrote:
>
>  Hi, I'm a student studying computer science. And I've got in trouble
> with this!
>
>  I'm writing a program which mesures the performance of the compiler.

Perl is an interpreter, not a compiler. The Perl compiler is, AFAIK, still
betaware.

Once you've installed the latest-and-greatest Perl distribution, type
perldoc Benchmark
at the command prompt.

--
# James Greene - Informatics Consulting - D-79539 Loerrach, Germany
# Internet: www.gucc.org/greene/consult - greene@gucc.org
# PGP Fingerprint: 8930 41E7 351B 56D8 801C  D4D9 4C76 AF0F E24E F307
perl -we "$_=join'<',qw{d2by' f5e;f4z($iu w0@86yo=&ae b!097)l(&aa8vme
b$*};$_=unpack'u*',uc;print"


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Tue, 28 Apr 1998 01:05:53 -0500
From: Mikey Vaughan <mikey@in.net>
Subject: Perl Scripts Newsgroup
Message-Id: <35457FD1.684F@in.net>

Hello again,

Is there a specific newsgroup that can offer assistance for writing cgi
scripts??

Thanks.. mv



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

Date: 28 Apr 1998 06:00:15 GMT
From: humbubba@raptor.cqi.com (RHS Linux User)
Subject: Perl/Wall lingo question
Message-Id: <slrn6kapck.m45.humbubba@raptor.cqi.com>


Hi.
What is the source of Larry Wall's terminology, or the
terminology of whoever wrote  man perl...  ?

I've been programming for years, and I don't recognize
a lot of the terms, in the sense they're used there.
e.g. "scalar". I ask because it seems to have a distinct
style from something else. I do Forth, C, machine code,
BASIC, and I don't recognize it. PASCAL? Some 
lexical algebra thing?

If you care to comment, please email me.
Rick Hohensee
humbubba@cqi.com


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

Date: 28 Apr 1998 00:43:40 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Perl/Wall lingo question
Message-Id: <m3ogxmie6q.fsf@windlord.Stanford.EDU>

RHS Linux User <humbubba@raptor.cqi.com> writes:

> I've been programming for years, and I don't recognize a lot of the
> terms, in the sense they're used there.  e.g. "scalar".

Well, I don't know what else you're wondering about, but a scalar is from
mathematics and physics and simply refers to a real number (as opposed to
a vector).  More specifically, a scalar is a magnitude with no associated
direction.

That's a bit at odds with how the word is used in Perl, though, where it
refers to a "simple" variable (a number or string), but I suppose the
analogy is that a scalar isn't an array or hash.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 27 Apr 1998 22:52:02 -0700
From: rokicki@cello.hpl.hp.com (Tom Rokicki)
Subject: Permutations in hashes make Perl hurt
Message-Id: <6i3qq2$k58@cello.hpl.hp.com>

If the keys of a hash are permutations of a string (or, if the length
of the string plus the sum of the characters in the string is a
constant across the keys of a hash) then Perl essentially uses a
single linked list (only one bucket is filled) as the attached code
shows; run it and watch Perl go quadratic!

One minor fix to this is to grow the hash bucket vector whenever the
number of elements grows larger than the size of the vector (rather
than just when this is true at the time a new bucket is started).
This doesn't completely solve the problem, however, as permutations
will still tend to use a small subset of the buckets.

I'm currently looking into a better hash function to solve this problem,
hopefully without introducing any other problems.  Any thoughts or
suggestions?

-tom

This is perl, version 5.004_04 built for PA-RISC1.1

Copyright 1987-1997, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5.0 source kit.

#/usr/local/bin/perl -w
use strict ;
#   Generate permutations and call a function or closure for each.
sub permaux {
   my($prefix, $s, $f) = @_ ;
   if ($s eq "") {
      &{$f}($prefix) ;
   } else {
      my $i ;
      for ($i=0; $i<length($s); $i++) {
       permaux($prefix.substr($s,$i,1), substr($s,0,$i).substr($s,$i+1), $f);
      }
   }
}
sub perm { permaux("", @_) }
#   Example bad case for hashes:  permutations
my %a = () ;
@a{1..$ARGV[0]} = 1 x $ARGV[0] if (@ARGV) ;
my $s = "Perl is_fun." ;
my $inserted = 0 ;
sub watch_add {
   my $str = $_[0] ;
   if (!$a{$str}++) {
      $inserted++ ;
      if ($inserted % 1000 == 1) {
         my $hash_as_scalar = %a ;
         my @time = times() ;
         print "$inserted $hash_as_scalar $time[0]\n" ;
      }
   }
}
perm($s, \&watch_add) ;


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

Date: Tue, 28 Apr 1998 04:42:43 -0600
From: stevenf@pcdynamics.nl
Subject: Problem with Perl script (Probaply very simple)
Message-Id: <6i48aj$ds6$1@nnrp1.dejanews.com>

I everyone!

Check out this HTMLcode.

<html>
<form action=/cgi-bin/print.cgi method=get>
Text1 <input type=text name=text1 size=40><br>
Text2 <input type=text name=text2 size=40><br>
Text3 <input type=text name=text3 size=40><br>
<input type=submit value="Make Document">
</form>
</html>

Now I use this Perl script to make a new document with the text just entered.

#!/usr/local/bin/perl
&parse_form_data (*form);
print "Content-type: text/html\n\n";
print <<End_of_document;

<html>
Text1: $form{'text1'}<br>
Text2: $form{'text2'}<br>
Text3: $form{'text3'}<br>
</html>

End_of_document
exit ();

sub parse_form_data
{
    local (*FORM_DATA) = @_;
    local ( $request_method, $query_string, @key_value_pairs,
           $key_value, $key, $value);
    $request_method = $ENV{'REQUEST_METHOD'};
    if ($request_method eq "GET") {
        $query_string = $ENV{'QUERY_STRING'};
    } elsif ($request_method eq "POST") {
        read (STDIN, $query_string, $ENV{'CONTENT_LENGTH'});
    } else {
        &return_error (500, "Server Error",
                       "Server uses unsupported method");
    }
    @key_value_pairs = split (/&/, $query_string);
    foreach $key_value (@key_value_pairs) {
        ($key, $value) = split (/=/, $key_value);
        $value =~ tr/+/ /;
        $value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg;
        if (defined($FORM_DATA{$key})) {
            $FORM_DATA{$key} = join ("\0", $FORM_DATA{$key}, $value);
        } else {
            $FORM_DATA{$key} = $value;
        }
    }
}

The problem is that I'm getting an : Internal Server Error 500
This line : #!/usr/local/bin/perl is correct!
The personal that made this says it works and I believe him because when I run
it on my workstation it runs correct. But when I upload it onto the server
where the script should run it doesn't work! :(
The Perl version they are using is : Perl 5.003
Can somebody please please help me because I really really need this script to
work.

If possible could you please send your answer to my emailaddress, because I
can't get the newsgroup here at my work! My emailaddress :

stevenf@pcdynamics.nl

Thank you very very much!



-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Tue, 28 Apr 1998 02:50:24 -0400
From: Dan Boorstein <danboo@negia.net>
Subject: Re: QRe: == vs. eq
Message-Id: <35457C30.4089EAE8@negia.net>

Greg Bacon wrote:
> 
> In article <35453A24.FC967A05@coos.dartmouth.edu>,
>         Ronald J Kimball <rjk@coos.dartmouth.edu> writes:
> : Yes, a lot of unintelligent posts are made from web browsers.  Perhaps that is
> : because so many posts are made from web browsers in general.  Until I see a
> : conclusive set of statistics, I refuse to accept this foolish stereotype.
> 
> The problem is that your denying the claim doesn't do anything.  The
> heuristic is already widely accepted among most of clpmisc's regular
> answerers.  (Has anyone yet resorted to killing based on the
> son-of-1036 forsaken X-Newsreader: header?)  The claim is yours to
> debunk.  We're reasonable people.
> 

let's pretend for a moment that quarrels should be settled based on
gut feeling, and that proof is determined by concensus of opinion.

an assertion was made suggesting that the users of a certain class of
NNTP clients were more likely to ask FAQs, since most FAQs originate
from said clients.

a counterpoint was made, attempting to invalidate the first assertion,
based on the belief that most posters use NNTP clients in the suspect
class.

so, as i see it, it's your turn to make an assertion to counter this.
simply reiterating the original assertion gets us nowhere since it
can always be countered. it's like a draw in chess when the same
position is repeated again and again.

now, let's step back into a realm where we attempt to prove our
assertions with data.

umm, none has been proffered. what is there to "debunk"?

$my_sig =~ s/ANSWER/REBUTTAL/;

skeptically yours,

-- 
Dan Boorstein   home: danboo@negia.net  work: danboo@y-dna.com

 "THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER."
                         - Cosmic AC


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

Date: Tue, 28 Apr 1998 02:13:55 -0600
From: greene@gucc.org
Subject: Re: QUESTION: How do I print file contents to screen?
Message-Id: <6i3vji$qhm$1@nnrp1.dejanews.com>

In article <6huvoq$an4$1@news.netunlimited.net>#1/1,
  "David Joyce" <djoyce@netunlimited.net> wrote:
>
> How do I print the contents of a file to screen?  For instance, I have  a
> log-file .txt file that I want to print out
> to screen, along with any entries I have just appended.  Do I use <STDOUT>?
>

Nope. You go to your local bookstore, and ask them for a list of books with
the word "Perl" in the title. Or you can try this code...

#!/perl/bin/perl

$|++;
foreach (@ARGV) {
    print "$_\n" ;
    print "-" x length, "\n" ;

    if (not open TEXT, "<$_") {
        warn "Can't read $_: $!\n" ;
        next ;
    }
    print while <TEXT> ;
    close TEXT ;
}
__END__

--
# James Greene - Informatics Consulting - D-79539 Loerrach, Germany
# Internet: www.gucc.org/greene/consult - greene@gucc.org
# PGP Fingerprint: 8930 41E7 351B 56D8 801C  D4D9 4C76 AF0F E24E F307
perl -we "$_=join'<',qw{d2by' f5e;f4z($iu w0@86yo=&ae b!097)l(&aa8vme
b$*};$_=unpack'u*',uc;print"

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Tue, 28 Apr 1998 03:35:06 -0600
From: Chris_Schoenfeld@sonic.net
Subject: Redefined subroutines using mod_perl
Message-Id: <6i44bq$745$1@nnrp1.dejanews.com>

I thought I was doing everthing right with mod_perl ala scoping etc...but I
keep getting redefined sub warnings on all the subs in my script - what is up
with that?

Thanks
Chris

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Tue, 28 Apr 1998 02:15:31 -0400
From: Bob Trieger <sowmaster@juicepigs.com>
To: Matthew Wagley <rudedog@gcnet.com>
Subject: Re: Splitting a variable ???
Message-Id: <35457403.521E@juicepigs.com>

Matthew Wagley wrote:
> 
> I am wanting to split an input of a string say
> 
> 042498a
> 
> I want to split that out to 04  24  98  a   into separate variable or an
> array.  Can this be done?? I have tried finding it in Learning perl book and
> all over the net.  Last resource was here.  I appreciate your help or even a
> point in the right direction where this is documented on the net.


perldoc -f substr

$string = "042498a";
$foo = substr($string,0,2); # first 2 characters of $string
$bar = substr($string,2,2); # 2 chars starting at 3rd position of
$string
$baz = substr($string,4,2); # 2 chars starting at 5th position of
$string
$bob = substr($string,6,1); # 7th char of $string


HTH
-- 
Bob Trieger               |  Titanic: big boat, bigger
sowmaster@juicepigs.com   |           iceberg, big deal


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

Date: 28 Apr 1998 02:24:01 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Splitting a variable ???
Message-Id: <vhrujtny.fsf@mailhost.panix.com>

"Matthew Wagley" <rudedog@gcnet.com> writes:

> I am wanting to split an input of a string say
> 
> 042498a
> 
> I want to split that out to 04  24  98  a

  @foo = ('042498a' =~ /..?/g);

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY


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

Date: Mon, 27 Apr 1998 23:42:02 -0700
From: "Igor Krivokon" <igor.k@usa.net>
Subject: Re: Splitting a variable ???
Message-Id: <6i3thu$b9e$1@news.ncal.verio.com>

Bob Trieger wrote in message <35457403.521E@juicepigs.com>...
>Matthew Wagley wrote:
>> 
>> I am wanting to split an input of a string say
>> 
>> 042498a
>> 
>> I want to split that out to 04  24  98  a   into separate variable or an
>> array.  Can this be done?? I have tried finding it in Learning perl book and
>> all over the net.  Last resource was here.  I appreciate your help or even a
>> point in the right direction where this is documented on the net.
>
>
>perldoc -f substr
>
>$string = "042498a";
>$foo = substr($string,0,2); # first 2 characters of $string
>$bar = substr($string,2,2); # 2 chars starting at 3rd position of
>$string
>$baz = substr($string,4,2); # 2 chars starting at 5th position of
>$string
>$bob = substr($string,6,1); # 7th char of $string
>
>


$string = "042498a";
($a, $b, $c, $d ) = $string =~ /(\d\d)(\d\d)(\d\d)(\w)/;

perldoc perlre


Regards,

Igor Krivokon
<igor.k@usa.net>






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

Date: 28 Apr 1998 06:51:03 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Splitting a variable ???
Message-Id: <6i3u8n$gm5$1@comdyn.comdyn.com.au>

In article <35457403.521E@juicepigs.com>,
	Bob Trieger <sowmaster@juicepigs.com> writes:
> Matthew Wagley wrote:
>> 
>> I am wanting to split an input of a string say
>> 
>> 042498a
>> 
>> I want to split that out to 04  24  98  a   into separate variable or an
>> array.  Can this be done?? I have tried finding it in Learning perl book and
>> all over the net.  Last resource was here.  I appreciate your help or even a
>> point in the right direction where this is documented on the net.
> 
> 
> perldoc -f substr
> 
> $string = "042498a";
> $foo = substr($string,0,2); # first 2 characters of $string
> $bar = substr($string,2,2); # 2 chars starting at 3rd position of
> $string
> $baz = substr($string,4,2); # 2 chars starting at 5th position of
> $string
> $bob = substr($string,6,1); # 7th char of $string

Or, alternatively

# perldoc perlre

my $s = '042498a';
my @array = ($s =~ /(\d\d)(\d\d)(\d\d)(\w)/);

TIMTOWTDI

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


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

Date: Tue, 28 Apr 1998 10:15:19 +0200
From: Christian Wetzel <cnwetzel@linguistik.uni-erlangen.de>
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <35459017.72CC@linguistik.uni-erlangen.de>

Greg Bacon:

> Top 10 Posters by OCR (minimum of five posts)

I always wonder what "OCR" means in this context?

Christian


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

Date: Tue, 28 Apr 1998 09:08:49 GMT
From: abw@cre.canon.co.uk (Andy Wardley)
Subject: Re: XML to HTML conversion
Message-Id: <Es49Ep.Kvy@cre.canon.co.uk>

Brent A Ellingson <bellings@badlands.NoDak.edu> wrote:
>Are there "standard" ways to take XML data, do some simple
>data transforms, and inject the data into HTML?  

What you're describing is a typical application of XML and XSL (Extensible
Style Language).  You mark up your data in XML and use a style sheet to
describe how that markup should be rendered in HTML.

Larry Wall has a prototype XML parser and Ken MacLeod has XML::Grove which
will parse the XML document.  There is an XSL module on the way (my 
apologies, I forget from who).  

The XSL working committee is expected to release the proposed recommendation
for XSL version 1.0 on May 1st.  Until then, and given that it will be some
undetermined time after that until an off-shelf-solution is available, 
there isn't an easy way to do this.

The solution to this kind of problem that I developed and use is a perl
module called Text::MetaText.  At the simplest level, it's a template 
processor, but it is designed with HTML page construction and web site 
interface generation in mind and has a number of features that specifically
aid in this task.

><!-- orinal XML record -->
><person>
>   <name>Kilroy Jones</name>
>   <url>www.math.ndsu.nodak.edu/faculty/kjones/</url>
>   <university>Sand Hill University</university>
>   <year>1982</year>
>   <title>Assoc Prof</title>
>   <email>kjones@ndsu.nodak.edu</email>
></person>

As an example, using MetaText, I might create a record like this...

%% INCLUDE person 
   name       = "Kilroy Jones"
   url        = "www.math.ndsu.nodak.ude/faculty/kjones/"
   university = "Sand Hill University"
   year       = 1982
   title      = "Assoc Prof"
   email      = "kjones@ndsu.nodak.edu"
%%

><!-- resulting HTML record -->
><tr>
>   <td><a href="www.math.ndsu.nodak.edu/faculty/kjones/">Kilroy Jones</a>,
>       Sand Hill University, 1982</td>
>   <td>Associate Professor</td>                   <!-- note expansion -->
>   <td><a href="mailto:kjones@ndsu.nodak.edu">
>       <address>kjones@ndsu.nodak.edu</address></a></td>
></tr>

 ...and create a "person" file which acts as the style sheet:

<tr>
   <td><a href="%% url %%">%% name %%</a>, 
        %% university %%, %% year %%</td>
   <td>%% title %%</td>
   <td><a href="%% email %%">
       <address>%% email %%</address></a></td>
<tr>

When the processor finds the "%% INCLUDE person .... %%" directive it
processes the 'person' file, substituting the variables for those values
defined.

You can program perl hooks into specific directive types to get the 
processor to call your own code.  A custom "person" directive like this:

  %% person id="kjones" %%

might call a perl function or object method which loads a database 
record, sets the name, url, university, etc., fields accordingly and
then processes the "person" template.  This kind of thing makes 
expansions like "Assoc Proc" => "Associate Professor" easy.

>Are "custom" perl scripts the easiest way to do this, or is there
>something better?  I'd like to find something GPL'd (or close to
>GPL'd) if at all possible.  I'd also like to find a system that's
>relatively simple to use.

Text::MetaText is free to use and extend according to the Perl 
Artistic License.  It's fairly simple to use and well documented.

The crux matter here is how important XML is to you.  It is definately
the way to go for the future, and it is my intention to modify 
MetaText to grok XML as well as it's own format, just as soon as the
standards are better defined.

In the mean time, Text::MetaText should do what you want and hopefully 
provide an easy upgrade path to a more XML-centric solution in the 
future.  Converting documents between XML and the existing MetaText format
shouldn't be too difficult as they are similar in semantics, if not 
in syntax.

Text::MetaText is available from CPAN:

    http://www.perl.com/CPAN/authors/id/ABW

Larry's XML parser and Ken's XML::Grove are not yet available from CPAN
as they're still in hot development.  As far as I know, they're not on
"general release" so I'll keep those under my hat for the moment.  You 
can get more info by subscribing to the XML perl development list.  Send
email to ListManager@ActiveState.com with the message:

    SUBSCRIBE Perl-XML

Info on XSL is available from:

    http://www.w3.org/Style/XSL/


Hope this helps.

A


--
Andy Wardley <abw@kfs.org>   Signature regenerating.  Please remain seated.
     <abw@cre.canon.co.uk>   For a good time: http://www.kfs.org/~abw/


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

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


Administrivia:

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

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