[10572] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4164 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 6 08:07:48 1998

Date: Fri, 6 Nov 98 05:00:44 -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           Fri, 6 Nov 1998     Volume: 8 Number: 4164

Today's topics:
        #!/usr/local/bin/perl   USE in Win95??? <wmodem@ix.netcom.com>
        And Or Comparisons <bill@sterzenbach.com>
    Re: Array problems for newbie (Collin Rogowski)
    Re: Array problems for newbie <Allan@due.net>
    Re: Backward <perlguy@technologist.com>
        Beginner needs to know how to set up perl <vivian@velocity.clara.net>
        cgi.pm http socket example <sysop@scbbs.com>
    Re: cgi.pm http socket example <Tony.Curtis+usenet@vcpc.univie.ac.at>
    Re: cgi.pm http socket example <e.christensen@netjob.dk>
    Re: Comparing ASCII dates (Steffen Beyer)
        Configuration PERL <s.gontier@dl.ac.uk>
        customizable users mail in perl <mosheb@duridium.com>
        Help! - Problem with "variable" variable.... (Jim Lynn)
    Re: IIS4, Perl, Object Moved <sysop@scbbs.com>
    Re: Need a two way hash <prauz@sprynet.com>
    Re: ODBC Resource? <perlguy@technologist.com>
    Re: Odd number of elements? <jdf@pobox.com>
    Re: pass a file directly to stdout? (Joergen W. Lang)
    Re: pass a file directly to stdout? <jdf@pobox.com>
        perl cgi tutorial <infotec@mail.otenet.gr>
    Re: perl cgi tutorial (Tore Aursand)
    Re: Perl5 win32 directory structure and Config.PM (Randy Kobes)
    Re: perlcc and shared libraries <sehughes@mistral.co.uk>
    Re: Please help on finding difference between dates. (Steffen Beyer)
    Re: PLEASE HELP! <perlguy@technologist.com>
        Processing Arrays / Hashes <neiled@enteract.com>
    Re: Processing form (Tore Aursand)
    Re: Processing form <perlguy@technologist.com>
    Re: Processing form <perlguy@technologist.com>
    Re: Raw socket programming in Perl <carvdawg@patriot.net>
        really complicated reg. exp. question <eedalf@eed.ericsson.se>
    Re: Sending a file to a printer (Collin Rogowski)
    Re: Using recv in Socket programming <carvdawg@patriot.net>
    Re: WEB/CGI NT4.0/IIS problem executing an executable <perlguy@technologist.com>
    Re: why use do BLOCK? <zenin@bawdycaste.org>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Fri, 6 Nov 1998 02:50:09 -0800
From: "DDC" <wmodem@ix.netcom.com>
Subject: #!/usr/local/bin/perl   USE in Win95???
Message-Id: <71uk87$j66@dfw-ixnews8.ix.netcom.com>

How do you translate this line for proper CGI use in Windows 95 or windows
NT?  Or on my ISPs host?


#!/usr/local/bin/perl

I don't understand UNIX,  and my Perl interpreter or PERL.EXE
is at at C:\PERL\BIN
Please advise?

thanks, DD





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

Date: Fri, 6 Nov 1998 00:30:21 -0500
From: "Billsterz" <bill@sterzenbach.com>
Subject: And Or Comparisons
Message-Id: <71tubc$dpk$1@nntp.erinet.com>

Hi All,

What would the syntax be to evaluate

if (!($FORM{'value1'})) {
  &one_or_other;
}

AND

if (!($FORM{'value2'})) {
  &one_or_other;
}

I would like to evaluate both variables, and if both were empty, run
&one_or_other telling them one or the other fields are required.

I read that you use && but I can't seem to put it in the right place.







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

Date: Fri, 06 Nov 1998 11:14:52 GMT
From: collin@rogowski.de (Collin Rogowski)
Subject: Re: Array problems for newbie
Message-Id: <3642d9c1.174505745@news.uni-X.net>

>#!/usr/bin/perl -w
>print "Enter your word list followed by 'control' Z\n";
>while (<>) {
>push (@array, $_);
>}
>@arrayr = reverse (@array);
>print @arrayr;


You're thinking to much! :-)
A stack (which is produced when you use push), is in reverse order!
So all you have to is, to pop it again:

while (<>){
  push(@stack, $_);
}
while (@stack) {
  print pop(@stack);
}

Collin Rogowski


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

Date: Fri, 6 Nov 1998 08:00:08 -0500
From: "AmD" <Allan@due.net>
Subject: Re: Array problems for newbie
Message-Id: <71urk7$9tj$1@camel18.mindspring.com>


Collin Rogowski wrote in message <3642d9c1.174505745@news.uni-X.net>...
>>#!/usr/bin/perl -w
>>print "Enter your word list followed by 'control' Z\n";
>>while (<>) {
>>push (@array, $_);
>>}
>>@arrayr = reverse (@array);
>>print @arrayr;
>
>
>You're thinking to much! :-)
>A stack (which is produced when you use push), is in reverse order!


Hmm, I am not sure what you mean by reverse order here.  The values in the
array
are certainly in the same order they were entered.

foreach (@stack) {
    print "$_\n";
}


>So all you have to is, to pop it again:
>

Well popping removes the last element of the array each time it is called so
your suggestion does produce the desired result.  However, it does not solve
the problem that was originally described.  In Windoze the last element
(which should be displayed first) will still not be printed.  You still need
a leading

print  "\n";

AmD




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

Date: Fri, 6 Nov 1998 12:00:31 GMT
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: Backward
Message-Id: <3642E4DF.4E891B07@technologist.com>

japanesque@my-dejanews.com wrote:
> 
> I am wondering if someone can help me to use backward command.  If someone
> fill in a blank as "ABC", then print as "CBA" as result.  Please help.  Thank
> you.

$var = "ABC";
@ar_var = split(//,$var);
print reverse @ar_var,"\n";

Worked for me, but it may not be the most efficient...

HTH,
Brent

-- 
Java? I've heard of it, it is what I drink when I am hacking Perl. -me
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$            Brent Michalski             $
$         -- Perl Evangelist --          $
$    E-Mail: perlguy@technologist.com    $
$ Resume: http://www.inlink.com/~perlguy $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


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

Date: Fri, 6 Nov 1998 08:51:15 -0000
From: "Vivian" <vivian@velocity.clara.net>
Subject: Beginner needs to know how to set up perl
Message-Id: <71udht$amg$2@eros.clara.net>

Beginner needs to know how to set up perl
e.g how to:
set world-writable ("chmod a+w <dirname>").
what does this mean?

Or
set world-executable ("chmod a+x <scriptname>")


Please suggest URL Or
give me a step by step guide if possible


thanks to all




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

Date: Fri, 06 Nov 1998 11:04:28 GMT
From: Ron Parker <sysop@scbbs.com>
Subject: cgi.pm http socket example
Message-Id: <3642D7BE.E142E2F8@scbbs.com>

I have downloaded the CGI.PM Perl 5 Library, the CPAN Perl CGI
Programming FAQ and Perl Reference Page, and searched www.dejanews.com,
but still cannot find an example of how to use the cgi.pm package to
write a script to connect to a www server, send a POST or GET request,
and print the resulting page.

Can someone point me to a location where I can find this particular
script, or past it into a reply?  I'd really appreciate it.  Currently,
I am using a script which utilizes cgi-lib.pl, http-lib.pl, and the
Socket.pm package, but it is causing an "Object Moved" error when used
to call a IIS4 server.  I want to try using a cgi.pm script to see if
there is a difference.

Thanks.


--

 Ron Parker
 TradePoint LA / Tradewinds / SCBBS

 www.intl-trade.com
 www.tradepointla.org
 www.scbbs.com




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

Date: 06 Nov 1998 12:11:02 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: cgi.pm http socket example
Message-Id: <83d871nkjd.fsf@vcpc.univie.ac.at>

Re: cgi.pm http socket example, Ron <sysop@scbbs.com> said:

Ron> I have downloaded the CGI.PM Perl 5 Library, the CPAN
Ron> Perl CGI Programming FAQ and Perl Reference Page, and
Ron> searched www.dejanews.com, but still cannot find an
Ron> example of how to use the cgi.pm package to write a
Ron> script to connect to a www server, send a POST or GET
Ron> request, and print the resulting page.

That's because this has nothing to do with CGI.pm

Ron> Can someone point me to a location where I can find
Ron> this particular script, or past it into a reply?  I'd
Ron> really appreciate it.  Currently, I am using a script
Ron> which utilizes cgi-lib.pl, http-lib.pl, and the
Ron> Socket.pm package, but it is causing an "Object Moved"
Ron> error when used to call a IIS4 server.  I want to try
Ron> using a cgi.pm script to see if there is a difference.

You want the LWP modules.

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: Fri, 06 Nov 1998 13:41:13 +0100
From: Ernst <e.christensen@netjob.dk>
To: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: cgi.pm http socket example
Message-Id: <3642EE69.29F4@netjob.dk>

Tony Curtis wrote:
> 
> Re: cgi.pm http socket example, Ron <sysop@scbbs.com> said:
> 
> Ron> I have downloaded the CGI.PM Perl 5 Library, the CPAN
> Ron> Perl CGI Programming FAQ and Perl Reference Page, and
> Ron> searched www.dejanews.com, but still cannot find an
> Ron> example of how to use the cgi.pm package to write a
> Ron> script to connect to a www server, send a POST or GET
> Ron> request, and print the resulting page.
> 
> That's because this has nothing to do with CGI.pm
> 
> Ron> Can someone point me to a location where I can find
> Ron> this particular script, or past it into a reply?  I'd
> Ron> really appreciate it.  Currently, I am using a script
> Ron> which utilizes cgi-lib.pl, http-lib.pl, and the
> Ron> Socket.pm package, but it is causing an "Object Moved"
> Ron> error when used to call a IIS4 server.  I want to try
> Ron> using a cgi.pm script to see if there is a difference.
> 
> You want the LWP modules.
> 
> 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>
Ore simpler
Use http-lib.pl
Ernst


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

Date: 6 Nov 1998 10:04:29 GMT
From: sb@engelschall.com (Steffen Beyer)
Subject: Re: Comparing ASCII dates
Message-Id: <71uhjd$b85$1@en1.engelschall.com>

Robert Lowe <Robert.H.Lowe@X-no.spam-X.lawrence.edu> wrote:

> Before I re-invent something in a messy way, does anyone have
> any tips on how to get the difference between two ASCII dates
> in days?  The dates are in DD-MMM-YYYY format.  I suppose it
> would trivial if an ASCII date could somehow be converted to
> an internal system time, but I don't know if there is such a
> mechanism.

use Date::Calc qw(:all);

if (Date_to_Days(Decode_Date($date1)) < Date_to_Days(Decode_Date($date2)))
{
    # $date1 comes before $date2
}

Available from CPAN http://www.perl.com/CPAN/authors/id/STBEY/ or my
web site at http://www.engelschall.com/u/sb/download/.

HTH.

Yours,
-- 
    Steffen Beyer <sb@engelschall.com>
    Free Perl and C Software for Download: www.engelschall.com/u/sb/download/


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

Date: Fri, 06 Nov 1998 09:57:47 +0000
From: Sebastien Gontier <s.gontier@dl.ac.uk>
Subject: Configuration PERL
Message-Id: <3642C81B.BB4C88@dl.ac.uk>

Hi,

Does anyone had this problem configuring Perl??

"Use of uninitialized value at configpm line 403, <GLOS> chunk 530.
configpm: tmp not valid at configpm line 403
*** Error code 2 (bu21)!

What can I do? Thank you for your help.
Seb.





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

Date: Fri, 06 Nov 1998 13:04:06 +0200
From: Moshe Bar-Nachoom <mosheb@duridium.com>
Subject: customizable users mail in perl
Message-Id: <3642D7A6.205FAEF5@duridium.com>

I have a program that loops through users' database and sending them
customiaed e-mails.
The program runs on an ISP machine as a cgi operated from an
administration html. I don't have shell access.
The problem is that the ISP has somehow configured sendmail to do a
strange loop - sending a simple message can put you on hold (host
contacted, waiting for reply) for minute!!!
The cgi flow is:
1. go to directory and search for users' files.
2. open first/next user file and build mail message
3. send mail messgae (and take your time, maybe it's coffe time)
4. if there is more users' files go to step 2
5. print summary of mail sent and exit
I cann't afford the wait so I tried "exec"ing smaller programs, without
shell, I cann not do it.
I tried to spawn subroutine that sends mail so the main program will
finish quick, and let the server worry about the rest, but fork ran my
program endlessly, ever spawning new mail messages.
PLEASE ?!?!?!? how can I do it with spawn.
(hints of telling the ISP how to configure sendmail and special flags
that will make it run faster are more than welcomed)
Thak you..

--
Moshe Bar-Nachoom
[mailto:mosheb@duridium.com] [http://www.duridium.com]
"Power corrupts. Absolute power is kind of neat."
John Lehman, Secretary of the Navy, 1981-1987




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

Date: Fri, 06 Nov 1998 02:15:07 GMT
From: jimlynn@pmpix.com (Jim Lynn)
Subject: Help! - Problem with "variable" variable....
Message-Id: <36445b7c.6546242@news.supernews.com>

I know this should be easy, but I seem to be suffering from a major
brain fart.  I have a script that is passed a series of keypairs such
as:
desc1=some
desc2=list
desc3=of
desc4=words
desc5=etc

it is also passed ICNT which contains the number of these keypairs.
Now the following code should work and print out a list of the values,
but doesn't.  what am i doing wrong?


 for ($y=1;$y<=$ICNT;$y++) {           
         if ($y>=$ICNT+1) {last;}      
         $xstr=$in{'desc'.$y};           
         $xstr =~ tr/\"/ /;            
         print "$xstr<br>";    
         $itm++;                       
         print "$desc$y<br>";          
 }                               


Thanks, 
Jim      


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

Date: Fri, 06 Nov 1998 08:36:14 GMT
From: Ron Parker <sysop@scbbs.com>
Subject: Re: IIS4, Perl, Object Moved
Message-Id: <3642B4FE.C3A040B7@scbbs.com>



Steve Kilbane wrote:

> In article <3641716D.53FA3B71@scbbs.com>, Ron Parker <sysop@scbbs.com> writes:
> I think you need to clarify what you're doing, and what the problem is.
>
> > I wrote a Perl script running on a Unix server which does http socket
> > calls (using cgi-lib.pl, http-lib.pl, and Socket.pm) to pages running on
> > an IIS 4.0 server.
>
> So the browser talks to the Unix web server, the Unix server invokes
> your script, and the script does an HTTP request to the NT server, right?
>

Right.

> > Whether on Netscape or IE browser, the server
> > returns "Object Moved" error message, "This document may be found
> > here".  And, one must click on the link to the url (the same one which
> > was sent in the original socket call).
>
> Which server? Is your script just passing the IIS response back to the Unix
> server verbatim, or processing it? On first read-through, I thought you
> meant that your script was supposed to produce redirection responses.
> So, is IIS returning redirections, or the Unix server?
>

IIS is returning the "Object Moved" message as a reponse to the "POST" request
sent by the script.

> I presume that you're asking for proper files, not missing off the
> trailing "/" on requests to directories, etc. :-)
>

The URL in the POST request is correct.  A similar program works on another Unix
machine running an older NCSA www server and Perl 4.x.  The only difference
between the two is that Perl 5.x requires that I print the header "Content Type:
text/html" before processing the POST request and Perl 4.x does not.  If I don't
print this header first under Perl 5.x, the cgi-bin script fails.  If I do print
it, the IIS response to the POST request is "Object Moved".  Any ideas?

 local ($current_host, $host, $service, $file, $first_line);

 chop ($current_host = `/bin/hostname`);
 $host = $temp_host;
 $service = 80;
 $file = "$root\?$query";

 &open_connection (HTTP, $host, $service);
 print HTTP "GET $file HTTP/1.0\n\n";
 while (<HTTP>) {
  $outputline = $_;
  print "$outputline";
 }
 close (HTTP);




> steve
> --
> <Steve_Kilbane@cegelecproj.co.uk> - All opinions are mine alone.
> IIS4+Perl5 FAQ: http://www.whitecrow.demon.co.uk/steve/iis4.html



--

 Ron Parker
 TradePoint LA / Tradewinds / SCBBS

 www.intl-trade.com
 www.tradepointla.org
 www.scbbs.com




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

Date: Fri, 06 Nov 1998 10:36:19 +0000
From: Balazs Rauznitz <prauz@sprynet.com>
Subject: Re: Need a two way hash
Message-Id: <3642D123.1DAAFDE@sprynet.com>

Awrobinson wrote:
> 
> I'm building an application where I have two quantities matched up. In some
> cases, I need to use one set as the key to the other. In other cases, I need to
> use the second set as the key to the first. Can anyone suggest a convenient way
> to do this? Is there a way to use the values in a hash to get to the keys?
> 
> TIA...
> 
> Andrew Robinson
> ---
> Disclaimer: The opinions expressed are mine alone and do not represent the
> views of America Online

%other_way = reverse (%one_way);

one_way is put into list context so it will only be a list of (key1,
val1, key2, val2 .....keyN, valN). Now if you reverse it then it will be
(valN, keyN .....,val1, key1) which is what you wanted to do.

Balazs


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

Date: Fri, 6 Nov 1998 12:02:13 GMT
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: ODBC Resource?
Message-Id: <3642E545.4E8A5A07@technologist.com>

Geoff Caylor wrote:
> 
> Hello,  I'm looking for any sort of resource for ODBC programming for the
> Win32 environment, and so far haven't found anything of value...
> 
> Any leads are greatly appreciated!
> 
> Geoff Caylor

Try:
http://www.roth.net/odbc/
or
http://www.perl.com

Good luck,
Brent
-- 
Java? I've heard of it, it is what I drink when I am hacking Perl. -me
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$            Brent Michalski             $
$         -- Perl Evangelist --          $
$    E-Mail: perlguy@technologist.com    $
$ Resume: http://www.inlink.com/~perlguy $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


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

Date: 06 Nov 1998 14:46:15 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: Alex Vandiver <vandiver@tiac.net>
Subject: Re: Odd number of elements?
Message-Id: <m3lnlprl20.fsf@joshua.panix.com>

Alex Vandiver <vandiver@tiac.net> writes:

> I'm confoogled.  Why does perl choke about "Odd number of elements in
> hash list" on the follwong lines of code?

> %h = {@a};                            # Dies

You have just assigned a reference (which is a scalar) to a hash.
There is only one scalar on the rhs of that assignment, and one is
odd.  Perhaps you meant

   %h = @a;

> P.S.  I have yet to find anyplace what perl means by "chunk" in the
> error message above.

I don't see that word in the error message above.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Fri, 6 Nov 1998 12:43:01 +0100
From: jwl@_munged_worldmusic.de (Joergen W. Lang)
Subject: Re: pass a file directly to stdout?
Message-Id: <1di2msv.683d2x8h8cvuN@host039-210.seicom.net>

Brad Fenwick <bfenwick@mts.net> wrote:

> I am writing a web database. I am trying to find a way to simply pass
> a file, unparsed, directly to STDOUT. Basically I want to serve up
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> some html pages that are outside the web root to STDOUT and hense back
> to the browser. The cgi "Locate: /bla/bla.html" command is of no use
> because it only works with files off of your web root. My attempts to
> open the file with perl open, and then parse through the filehandle...
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Huh ?

> which normally works... seems to get caught. My assumption is that is
> because perl is trying to parse the file as I read it in line by line,
> and obviously running into trouble with anything that it thinks is a
> perl var or escaped something.
> 
> My guess is there is a very elegantly simple way to pass a file to
> stdout (without using a system command) without having to parse it
> through first and print it out that way... I just can't find any clear
> examples that show me that elegant way.

How about...

#!/usr/bin/perl -w

$file = "blah/foop/grumple/file.html";

print "Content-type: text/html\n\n";
# send a minimal header before the file.

open FILE, "$file" or die "Can't open $file: $!";

print $line while defined ($line = <FILE>);
# print file to STDOUT

close FILE;

__END__

?

Joergen
-- 
  To reply by email please remove _munged_ from address Thanks !
-------------------------------------------------------------------
   "Everything is possible - even sometimes the impossible"
             HOELDERLIN EXPRESS - "Touch the void"


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

Date: 06 Nov 1998 14:50:16 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: bfenwick@mts.net (Brad Fenwick)
Subject: Re: pass a file directly to stdout?
Message-Id: <m3iugtrkvb.fsf@joshua.panix.com>

bfenwick@mts.net (Brad Fenwick) writes:

> I am trying to find a way to simply pass a file, unparsed, directly
> to STDOUT.

   open(F, '<file') || die "file: $!\n";
   print <F>;
   close F;

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Fri, 6 Nov 1998 09:47:31 +0200
From: "John Spyrou" <infotec@mail.otenet.gr>
Subject: perl cgi tutorial
Message-Id: <71u9mk$39d$1@ns1.otenet.gr>

I have downloaded perl for windows and I am a linux user too. I have found
some cgi scripts writen in perl but I really dont know the language.
So I would be pleased if someone could tell me a good
perl tutorial and if it is about cgi programming too it will be great.
Can I find tutorials for both sublects somewhere ?

thanx in advance
George Statis





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

Date: Fri, 06 Nov 1998 10:04:35 GMT
From: tore@forumnett.no (Tore Aursand)
Subject: Re: perl cgi tutorial
Message-Id: <3643c89d.149428566@news.online.no>

On Fri, 6 Nov 1998 09:47:31 +0200, "John Spyrou"
<infotec@mail.otenet.gr> wrote:
> I have found some cgi scripts writen in perl but I really don't
> know the language.

First of all:  Learn Perl.  Perl is not CGI.  CGI is not Perl, but
both *can* be, if you understand what I mean? :-)

Ideal books for learning Perl the easy way:
- "Learning Perl, 2nd Edition", O'Reilly (ISBN: 1-56592-284-0)
- "Programming Perl, 2nd Edition", O'Reilly (ISBN: 1-56592-149-6)

Secondly:  A nice book - in my opinion - for learning CGI using
Perl, is "CGI Programming on the World Wide Web", also from
O'Reilly.  (ISBN: 1-56592-168-2)

Good luck!


-- 
Tore Aursand
ForumNett Online AS
http://www.forumnett.no/


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

Date: 6 Nov 1998 05:55:59 GMT
From: randy@theory.uwinnipeg.ca (Randy Kobes)
Subject: Re: Perl5 win32 directory structure and Config.PM
Message-Id: <slrn7454bn.q87.randy@theory.uwinnipeg.ca>

On Thu, 05 Nov 1998 13:44:32 -0600, 
	Brian P. Barnes <bbarnes@dev.tivoli.com> wrote:
>I have tried numerous times to compile the new source for Win32
>Perl5.005 according to the README. It always gives me a
>/perl/perl5.005/lib directory, no bin directory at all and Perl located
>at /perl/perl5.005/perl.exe. I seem to have DBI compiled (miraculously)
>and it even seems to pass the initial tests. DBD complains that it can't
>find /perl/lib directory, probably because it is buried behind the
>perl5.005 directory.
>
>I want to try to organize the essential files by hand and it would be
>great to have a normal, working model to look at. Could somebody who has
>compiled a WIN32, 5.005, (VC++ ?) possibly do a "ls -R" from the Perl
>root directory and post it here. It would also be most helpful if you
>could throw in the /perl/lib/Config.PM file.
>
>Is this a common problem and can anyone shed any light on how it
>happened?
>

Hi,
   Are you using Windows NT or Windows 95/98? On NT the compilation
is relatively straightforward, but needs tweaking on 95/98. Also,
since you're building it, you may as well use the latest - 5.00502.
   It seems strange you have no bin directory - on mine it's under
	\perl\5.00502\bin
which is also where
	\perl\5.00502\lib
is. But then I just accepted the default install locations - did you
change these? Since DBI installed OK, it sounds like everything's
there, but in perhaps some non-standard locations. And since DBD::*
can't find it, it also sounds like perhaps it's getting confused at
times about where things are.
   It might be an idea to start afresh with 5.005_02, use the
default locations, and install again. This is probably a lot
simpler than to start moving things around by hand.
   Hope this helps ... 

-- 
		Best regards,
		Randy Kobes

Physics Department		Phone: 	   (204) 786-9399
University of Winnipeg		Fax: 	   (204) 774-4134
Winnipeg, Manitoba R3B 2E9	e-mail:	   randy@theory.uwinnipeg.ca
Canada				http://theory.uwinnipeg.ca/


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

Date: Fri, 06 Nov 1998 10:39:37 +0000
From: Stuart Hughes <sehughes@mistral.co.uk>
Subject: Re: perlcc and shared libraries
Message-Id: <3642D1E9.EA9E6AE1@mistral.co.uk>

tstmartin@granite.com wrote:
> 
> I have a very similar (I think) problem - I have a Shared library in C, and a
> wrapper in C I've built following the perlxstut, but cannot figure out how to
> get perl to load the shared library at run time. The wrapper seems to be
> loading but perl cant resolve references to the shared libarary routines.


Similar problem, but in my case, nothing started life as C source, I am
trying to use a shared library generated from perl source code, using
the perl compiler.

Anybody got any ideas ?????????????????????



> Solaris 2.5; perl 5.004, gcc 2.7.2.2
> 
> I believe part or all of my answer may lie in ExtUtils::Liblist, but have not
> been able to decipher it. Perhaps that is where your answer lies also?
> 
> Any help appreciated. The future of perl at this company is on the line !
> 

Normally, all this is taken care of for you, when you start a module
project using h2xs (a util that comes with perl, see the perl docs, and
cookbook).  The important part is to have a line that says bootstrap
Module (this pulls in the shared library).

If however, you have written and a package in C and compiled it into a
shared library, the following example explains what you need to do.

Lets say the library is called libstuff.so and it contains a function
called myopen() and myread() that you want to call from the perl world. 
After running h2xs to generate the template for the module called
Stuff.pm, edit the Makefile.PL, add the C library name into the LIBS
section:

WriteMakefile(
    'NAME'      => 'Stuff',
    'VERSION_FROM' => 'Stuff.pm', # finds $VERSION
    'LIBS'      => ['-stuff'],   # e.g., '-lm'
);

In 

the file Stuff.xs, add the bindings to your C library functions, imagine
myopen() and myread() work something like the regular open() and read(),
note the complicated stuff for read is ripped off from the POSIX.pm
module (a great source of examples)



#ifdef __cplusplus
extern "C" {
#endif
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#ifdef __cplusplus
}
#endif


MODULE = Stuff            PACKAGE = Stuff


void *
myopen(filename, mode)
        char * filename
        int    mode


int
myread(ptr, buf, size)
    PREINIT:
        SV *sv_buffer = SvROK(ST(1)) ? SvRV(ST(1)) : ST(1);
    INPUT:
        void          * ptr
        int             size
        char          * buf = sv_grow( sv_buffer, size+1 );
    CLEANUP:
        if (RETVAL >= 0)
        {
            SvCUR(sv_buffer) = RETVAL;
            SvPOK_only(sv_buffer);
            *SvEND(sv_buffer) = '\0';
            if (tainting)
                sv_magic(sv_buffer, 0, 't', 0, 0);
        }



in file Stuff.pm, add all the stuff you need:


package Stuff;
require Exporter;
require DynaLoader;

@ISA = qw(Exporter DynaLoader);
@EXPORT = qw(myopen myread );


bootstrap Stuff;		# this is what pulls in the shared library



Now, you do the usual perl Makefile.PL, make, make install. (tests are
nice too).

Someone using your module can now say:

use Stuff;

$fp             = myopen("fred", 0666) or die "oops $!";
$rsize          = 1024;
while( $nread   = myread($fp,$buf,$rsize) ) { 
    $rbuf      .= $buf 
}
$nread          = myread($fs,$buf,$rsize); # get the remainder

print "total read: $nread\n"


Hope this helps.


Stuart Hughes


> Thanks,
> Tom St.Martin
> 
> In article <3640BCFE.62CB82D8@mistral.co.uk>,
>   sehughes@mistral.co.uk wrote:
> > Hi all,
> >
> > In the perldoc for perlcc, I see:
> >
> > %prompt  perlcc A.pm       # compile into 'A.so'
> >
> > and sure enough, I can generate .so's from .pm's.  My question is, how
> > can I later make use of these shared libraries ???
> >
> > TIA
> >
> > Stuart Hughes
> >
> > using 5.005_51 built for i586-linux
> >
> 
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own



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

Date: 6 Nov 1998 10:08:18 GMT
From: sb@engelschall.com (Steffen Beyer)
Subject: Re: Please help on finding difference between dates.
Message-Id: <71uhqi$b85$2@en1.engelschall.com>

hovi <hovi@mtco.com> wrote:

> I am very new at Perl so you will have to excuse me.  I have the binary
> version of Perl 5004_02 and running it on Windows 95 and I do not have a
> C Compiler.  I am trying to find a way to calculate the difference
> between two dates.  Every example I see uses the CALC module which I
> cannot use because I do not have a compiler.  Could somebody give me
> some suggestions on what to do.  Please email me at hovi@mtco.com or
> c_hovious@hotmail.com.

If you get Gurusamy Sarathy's Perl 5.004_04 for Win32, this module is
already included in pre-compiled form.

(It's not the latest version of that module, but it is reliable)

See http://www.perl.com/CPAN/authors/id/GSAR/perl*bindist*gz

HTH.

Yours,
-- 
    Steffen Beyer <sb@engelschall.com>
    Free Perl and C Software for Download: www.engelschall.com/u/sb/download/


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

Date: Fri, 6 Nov 1998 12:11:22 GMT
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: PLEASE HELP!
Message-Id: <3642E76A.988544A7@technologist.com>

Can you provide us with a code example and let us know what OS you are
running Perl on?

Also, read one of Tom Phoenix's posts about "subjects".  He has some
good pointers. (Hi Tom)

Brent
-- 
Java? I've heard of it, it is what I drink when I am hacking Perl. -me
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$            Brent Michalski             $
$         -- Perl Evangelist --          $
$    E-Mail: perlguy@technologist.com    $
$ Resume: http://www.inlink.com/~perlguy $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


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

Date: Fri, 6 Nov 1998 06:11:12 -0600
From: "Neil Edmondson" <neiled@enteract.com>
Subject: Processing Arrays / Hashes
Message-Id: <71up7q$dee$1@eve.enteract.com>

I expect the below to produce

a
b
c
NewPage
+1m

but what I get is

a
NewPage
+1m

Can some one enlighten me, please?

Thanks, Neil neiled@enteract.com

#!/usr/local/bin/perl

$newpage = {'subroutine' => 'NewPage', 'expiry' => '+1m', 'buttons' => ('a',
'b', 'c')};

@buttons=$newpage->{'buttons'};
foreach $a (@buttons) {
 print "$a\n";
}
print $newpage->{'subroutine'};
print "\n";
print $newpage->{'expiry'};
print "\n";




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

Date: Fri, 06 Nov 1998 09:58:09 GMT
From: tore@forumnett.no (Tore Aursand)
Subject: Re: Processing form
Message-Id: <3642c68c.148899866@news.online.no>

On Thu, 5 Nov 1998 21:28:16 +0300, "Michael Yevdokimov"
<flanker@sonnet.ru> wrote:
> How to extract information from HTML fields into different varables?

It sounds like you should use the CGI.pm module for Perl [1], where
you will find many useful procedures/functions.

Example (straight from my head), assuming you have an HTML page like
this:

[...]
<INPUT TYPE="text" NAME="Name" VALUE="" SIZE="40" MAXLENGTH"80"><BR>
<INPUT TYPE="text" NAME="Email" VALUE="" SIZE="40" MAXLENGTH="80">
[...]

Perl script:

#!/usr/bin/perl
use CGI;

my $name  = $cgi->param('Name');
my $email = $cgi->param('Email');


[1]:
<URL:http://www-genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html


-- 
Tore Aursand
ForumNett Online AS
http://www.forumnett.no/


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

Date: Fri, 6 Nov 1998 11:53:03 GMT
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: Processing form
Message-Id: <3642E31F.C859683A@technologist.com>

Tore Aursand wrote:
> 
> On Thu, 5 Nov 1998 21:28:16 +0300, "Michael Yevdokimov"
> <flanker@sonnet.ru> wrote:
> > How to extract information from HTML fields into different varables?
> 
> It sounds like you should use the CGI.pm module for Perl [1], where
> you will find many useful procedures/functions.
> 
> Example (straight from my head), assuming you have an HTML page like
> this:
> 
> [...]
> <INPUT TYPE="text" NAME="Name" VALUE="" SIZE="40" MAXLENGTH"80"><BR>
> <INPUT TYPE="text" NAME="Email" VALUE="" SIZE="40" MAXLENGTH="80">
> [...]
> 
> Perl script:
> 
> #!/usr/bin/perl
> use CGI;
 ..ADD THE FOLLOWING LINE:
$cgi = new CGI;

> my $name  = $cgi->param('Name');
> my $email = $cgi->param('Email');

> Tore Aursand
> ForumNett Online AS
> http://www.forumnett.no/

Tore said the example was "straight from his head", what version of Perl
does your head run? ;-)

Anyway, the code won't run properly unless you define a "cgi" object.  I
added the line above.

Michael, there is a "Perl" area on http://webreview.com that had some
tutorial articles. They may help...

Good luck Michael!

Brent
-- 
Java? I've heard of it, it is what I drink when I am hacking Perl. -me
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$            Brent Michalski             $
$         -- Perl Evangelist --          $
$    E-Mail: perlguy@technologist.com    $
$ Resume: http://www.inlink.com/~perlguy $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


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

Date: Fri, 6 Nov 1998 12:17:06 GMT
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: Processing form
Message-Id: <3642E8C2.57B8970F@technologist.com>

Michael Yevdokimov wrote:
> 
> Hi
> 
> How to extract information from HTML fields into different varables?
> I have 'email', 'subject', 'message' fields in HTML form and I'd like to
> save info from 'email' into email var, 'message' into msg var, and 'subject'
> into subj.

use CGI qw /:standard/;
$email = param(email);
$msg   = param(message);
$subj  = param(subject);

It is __that__simple Michael!  Good luck with the rest of your program!

Brent
-- 
Java? I've heard of it, it is what I drink when I am hacking Perl. -me
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$            Brent Michalski             $
$         -- Perl Evangelist --          $
$    E-Mail: perlguy@technologist.com    $
$ Resume: http://www.inlink.com/~perlguy $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


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

Date: Fri, 06 Nov 1998 06:46:57 +0000
From: Marquis de Carvdawg <carvdawg@patriot.net>
Subject: Re: Raw socket programming in Perl
Message-Id: <36429B61.C31FA8F4@patriot.net>



ecki@lina.inka.de wrote:

> In comp.security.unix Marquis de Carvdawg <carvdawg@patriot.net> wrote:
> > Thanks for pointing out a spelling error.  However, the same problem persists...
> > the script runs fine, but a NetXRay capture reveals that an IP packet, vice TCP,
> > is sent.  All of the values read from the packet capture have nothing to do with
> > what was included in the script when the packet was constructed...
> Network byte order?
>

That's what I attempted to do.  However, I have no way of verifying atthis point that
all the ones and zeros were in the right place prior to the
packet being sent...I have yet to find a way to print the ones and zeros
that result from a pack()...

Carv




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

Date: Fri, 06 Nov 1998 12:59:08 +0100
From: Alexander Farber <eedalf@eed.ericsson.se>
Subject: really complicated reg. exp. question
Message-Id: <3642E48C.DBDD1193@eed.ericsson.se>

Dear perl hackers,

how do I say "match any character (even \n), but not !#####" ?

I read some file (not perl) with many comments and phase numbers:


!########################################################################
!Check recorded RP events
!########################################################################
@gosub DIRRP_SUB
@label PHASE_90
@set PHASE = 90
@write (PHASE_FILE,"@set MAINPHASE= {PHASE}")


and I would like to create a hash with keys = phase numbers (here 90)
and values = comment (between the !###### lines). So I do:


open MAIN, $ARGV[0] or die;
undef $/;			# read the file in one string
my $main = <MAIN>;		
$main =~ s/!#{20,}\n!(.+)\n!#{20,}\n(.|\n)*?\@LABEL\s+PHASE_(\d+)/@{[ $phase{$3} = join ' ', split '
', lc $1 ]}/ig;


And it works almost fine. But the problem is, that there are 
some lonely !####### comment lines lying around, like here:


!########################################################################
!Use local variables
!########################################################################
@gosub DIRRP_SUB
!########################################################################
!Check recorded RP events
!########################################################################
@gosub DIRRP_SUB
@label PHASE_90
@set PHASE = 90
@write (PHASE_FILE,"@set MAINPHASE= {PHASE}")


And it gives me wrong results: $phase{'90'} = 'use local variables'

But I would like to have       $phase{'90'} = 'check recorded rp events'
(the most next comment). So I have tried:

$main =~ s/!#{20,}\n!(.+)\n!#{20,}\n(?!!#{20,})*?\@LABEL\s+PHASE_(\d+)/@{[ $phase{$3} = join ' ',
split ' ', lc $1 ]}/ig;

But it gives the error message:
/!#{20,}\n!(.+)\n!#{20,}\n(?!!#{20,})*?\@LABEL\s+PHASE_(\d+)/: regexp *+ operand could be empty at
 ./fix.pl line 26.


What does it mean? And how do I use this "look ahead"? Thank you!

/Alex


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

Date: Fri, 06 Nov 1998 11:17:55 GMT
From: collin@rogowski.de (Collin Rogowski)
Subject: Re: Sending a file to a printer
Message-Id: <3642dac2.174762935@news.uni-X.net>

you can use the command copy.
e.g copy printer1.pl lpt1

Collin Rogowski
On 4 Nov 1998 22:10:57 GMT, m.adam@libr.canterbury.ac.nz wrote:

>I feel that this is an embarassingly obvious question but I've searched all my
>documentation and read all the FAQs I can find without getting an answer.
>
>I am writing perl scripts on Windows NT.  I need to send a file to a printer: 
>\\NTServer\printer1.  How do I do this?
>
>Margaret



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

Date: Fri, 06 Nov 1998 06:50:10 +0000
From: Marquis de Carvdawg <carvdawg@patriot.net>
Subject: Re: Using recv in Socket programming
Message-Id: <36429C21.A5209F7F@patriot.net>

I am trying to something similar, so if you would, could you post
the information and code that works?

Thanks...

Arvind Krishnaswamy wrote:

> I want to use the recv function multiple times to get data from a socket
> into a buffer. The bytes of data vary with each recv (and this is not
> known). Is there any way I can use recv to do this? What is the
> alternative if I cannot use recv?
>
> If I specify a fixed number like 1000 for example, I may not get all
> data if it exceeds that number. The code basically looks like
>
> for (@querylist) {
> ....
> ....
> printf SOCKET $query;
> recv (SOCKET, $result, ???? , 0);
> }
>
> Thanks,
>
> Arvind





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

Date: Fri, 6 Nov 1998 12:08:14 GMT
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: WEB/CGI NT4.0/IIS problem executing an executable
Message-Id: <3642E6AE.E09A2A2F@technologist.com>

Pete Lucuk wrote:
 ...SNIP... 
> $translate = "c:\\inetpub\\prcweb\\cgi-bin\\test.exe GE 0 *
> c:\\temp\\in159.GE c:\\temp\\out159.eng 0 6 10.0.0.5";

> On a development machine, the one I am having a problem with, I formated
> the machine and installed NT4.0/IIS, Perl, and my Web/CGI App from
> scracth and now I am not able to execute this executable,
> c:\inetpub\prcweb\cgi-bin\test.exe!!!
^^^^ Is this how you are calling the program from Perl?  If so, it will
never work because the \ will escape the character following it.

The first thing I'd do is replace ALL of the \\'s with /'s in your
program.  Then, start using ONLY / in your paths.  There are a couple
reasons for this:
- It is easier to read.
- It works on UNIX and NT.
- If you only use the /, then it eliminates the possibility of you
forgetting to use \\ when you really meant \.

This _may_ not fix the problem, but hopefully this post will help others
running Perl on NT out there too...

Brent
-- 
Java? I've heard of it, it is what I drink when I am hacking Perl. -me
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$            Brent Michalski             $
$         -- Perl Evangelist --          $
$    E-Mail: perlguy@technologist.com    $
$ Resume: http://www.inlink.com/~perlguy $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


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

Date: 06 Nov 1998 06:56:17 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: why use do BLOCK?
Message-Id: <910335318.910054@thrush.omix.com>

Chris Sherman <sherman@unx.sas.com> wrote:
	>snip<
: I do stuff like this alot...  Tom doesn't like it, but oh well...
:    open FIN, $filename or do {
:       print "Blew it:  Could not open file $filename.  $!\n";
:       return $error_code
:    };

	A little obfusted, isn't it?

	unless (open FIN, $filename) {
	    warn "Blew it: Could not open file '$filename': $!";
	    return $error_code;
	}

	Of course, this also goes against standard calling semantics by
	returning true from a function that failed...  I'd throw an
	exception or just set $@ to the error message and return;

	use Carp ();	
	sub foo {
	    unless (open FIN, $filename) {
	    	$@ = Carp::longmess ("Can not open file '$filename': $!");
	    	return;
	    }
	}

	...later in the program...

	foo() or die $@;

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


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

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


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 4164
**************************************

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