[6928] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 553 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jun 1 12:24:06 1997

Date: Sun, 1 Jun 97 09:00:24 -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           Sun, 1 Jun 1997     Volume: 8 Number: 553

Today's topics:
     Re: 2-way communication with unix command <merlyn@stonehenge.com>
     C -> Perl with a lot of functions (Egghat)
     Compatibility Issues between Perl and Oracle (Michael Swertfager)
     DBM Bug in Perl5.003_02 for BSDi 3.0? <bkyan@mindcast.com>
     Re: FrontPage97 & PERL, Help! <ulsass@berlin.snafu.de>
     Re: Help, PERL under Windows 95 testing <ulsass@berlin.snafu.de>
     Re: How to extract text enclosed by... (Tina Marie Holmboe)
     Re: Internal data structure of lists <rootbeer@teleport.com>
     Re: New FAQ question? Decimal -> Binary conversion <rootbeer@teleport.com>
     Own to chek if two or more words are in a string ? (Ccadic)
     Re: Own to chek if two or more words are in a string ? <chaimf@cris.com>
     Re: perl compiler ? <merlyn@stonehenge.com>
     Re: Perl error handling for s/ and associative arrays <ajohnson@gpu.srv.ualberta.ca>
     Re: Perl error handling for s/ and associative arrays (Tad McClellan)
     perl.nlm; 4.1 Netware; None Intranetware <bruce@tasconline.com>
     Printing Arrays to a file (Bugsy)
     Re: Printing Arrays to a file (Tung-chiang Yang)
     Re: Printing Arrays to a file (Honza Pazdziora)
     Re: Printing Arrays to a file (Tad McClellan)
     Re: Regex lookahead help (Chipmunk)
     Re: Second perl book (Brian Lavender)
     Re: Standalone web database for Perl? <burchd@erols.com>
     Re: while(<>) and perl -e: B.. or feature? <rootbeer@teleport.com>
     Re: Why is ("a" == 0) true? (Honza Pazdziora)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 01 Jun 1997 08:42:43 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: Jonathan.Hudson@jrhudson.demon.co.uk (Jonathan Hudson)
Subject: Re: 2-way communication with unix command
Message-Id: <8cpvu6tjm3.fsf@gadget.cscaper.com>

>>>>> "Jonathan" == Jonathan Hudson <Jonathan.Hudson@jrhudson.demon.co.uk> writes:

Jonathan> Having recently accepted delivery of two new Unix boxes from
Jonathan> "industry leaders" and typed 'perl -v', the leading version
Jonathan> digit was *NOT* 5.  If your management forbids you to
Jonathan> install upgrades that don't come from the vendor, then
Jonathan> unfortunately perl 4 is a fact of life.

Well, I could argue that in this case "the vendor" is the Perl
development team (guided by Larry), or even "The Perl Institute".  Any
"ready to release" version is an approved ehancement... just stay away
from the development releases.

But it'd be really funny if this same "management" *requires* you to
respond to any CERT security notice by installing the required
patches: there have been at least a few CERT-ifiable notices against
4.036, 5.001, 5.002 and 5.003.  The safest version of Perl is *now*
5.004.

Pointy-haired managers.  <sigh>

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 457 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Sun, 25 May 1997 22:21:40 GMT
From: egghat@vocalweb.de (Egghat)
Subject: C -> Perl with a lot of functions
Message-Id: <3388b9c7.497511@personalnews.germany.eu.net>

Hi,

I habe got a large set of c functions, which I plan to use inside
Perl. I have read through the man pages perlxs and it's tutorial. 

AFAIK I have to create a lot of .xs files, which include the C source.
But my c files have to remain "C compilable" and it would by quite a
disaster to maintain two trees of the same files. 

Is there any possibilty to automagically create perl headers from the
C sources? And, do I have to create all those .xs files manually and
do I have to include the C-source into the .xs files?

Any other ways to get my c functions into perl?

TIA

Egghat
---------------------------------------------------------------------------
                          http://www.boersenspiel.de
              	         Das Boersenspiel im Internet
             *Realitaetsnah*  *Kostenlos*  *Ueber 5000 Wertpapiere*
---------------------------------------------------------------------------


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

Date: Fri, 30 May 1997 16:43:31 GMT
From: mswertfa@cisco.com (Michael Swertfager)
Subject: Compatibility Issues between Perl and Oracle
Message-Id: <5mmvs7$q25$1@news-sj-2.cisco.com>

I have heard rumors about compatiblity issues between Perl and Oracle.

What I heard was that certain Perl calls do not work properly with
some versions of Oracle. 

Does anyone have anymore information about this? Or, know where I can
dig it up.

-Michael



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

Date: Sun, 01 Jun 1997 01:30:48 -0700
From: Benjamin Kyan <bkyan@mindcast.com>
Subject: DBM Bug in Perl5.003_02 for BSDi 3.0?
Message-Id: <33913338.1E3481F5@mindcast.com>

I think I found a possibly serious bug, in the Perl5.003_02
interpreter, which came pre-compiled with BSDi 3.0.  As far
as I know, Perl5.003 is the latest stable build...  If
anyone knows of a patch for this or another build I should
be using, please let me (and other BSDi3/Perl5 users) know!  
Thanks in advance!

The following code would normally be expected to generate 
the following output, which I have verified on several other 
platforms (Linux and Solaris), as well as Perl4 on the same 
system (BSDi 3.0):

	900, 901, 902, 903
	900, 901, 902, 903

With the pre-compiled Perl5.003_02 on BSDi 3.0, 
the first "901" gets clobbered and replaced by a 
"1", as follows:

	900; 1; 902; 903
	900; 901; 902; 903

Here's my code:

	#!/usr/bin/perl

	# The following two lines *should* print the same thing.
	# ======================================================
	&printjoin ("900", "901", &getbad);
	&printjoin ("900", "901", &getnormal);
	
	sub getbad
	{
		# Just opening and closing a dbm 
		# *shouldn't* affect the return values.
		# =====================================
		dbmopen(%dbm, "test_target", 0666);
		dbmclose(%dbm);

		return ("902", "903");
	}	

	sub getnormal
	{
		return ("902", "903");
	}

	sub printjoin
	{
		print join("; ", @_), "\n";
	}

Similarly, this bug also appears if I use the following:

	# The following two lines *should* print the same thing.
	# ======================================================
	print join("; ", ("900", "901", &getbad)), "\n";
	print join("; ", ("900", "901", &getnormal)), "\n";
	
-- 

Best Regards,
Benjamin Kyan
bkyan@mindcast.com

==========================  ========================  ==============
Clickstream Communications  9101 W. Sahara, #105-183  T 404.685.0852
(website) www.mindcast.com  Las Vegas, Nevada  89117  F 404.685.0853
==========================  ========================  ==============


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

Date: Sun, 01 Jun 1997 17:42:49 +0200
From: "Markus Ulsa_" <ulsass@berlin.snafu.de>
To: dkranste@vpsiinc.com
Subject: Re: FrontPage97 & PERL, Help!
Message-Id: <33919879.2CDE80EB@berlin.snafu.de>


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

Hi Don !

> Please Help!
>
> I am a beginner Perl "programmer" and just bought FrontPage97
> and I have no idea how to go about previewing a CGI script
> with FP97 before uploading to my ISP's webserver.  I am taking
> a intro to CGI class online and I am unable to receive
> adequate help in answering this question.  Here's my setup:
>
> pc with win95
> MS FrontPage97 (using the MS Personal Web Server)
> I have downloaded Perl5 and saved to my C drive.  (did install it)
> My ISP is using a UNIX webserver.
>
> Please let me know if I can do anything to help you help me
> better!  Thanks! Don

First I recommend getting "Winperl" from Maxwell Nairn Andrews
(Perl32b3.zip, sorry for no available download-destination). You can
test your scripts under your Windows-"Home-Shell". This helped me a lot
as an origin win/dos-user.
Next, install the latest perl for win32. It'll install everything in the
right place, as eg in the registry. Then get PWS (Personal Web Server)
for Win 95 Microsoft . Put your script in "/scripts" an test with a
simple "helloworld.pl" in netscape. Enter
"http://yourserver/scripts/helloworld.pl?" in Netscape/ Explorer....
Dont forget the questionmark.It should work. Then you can work with html
and perl as cgi without problems and w/o always connecting to your ISP.

have fun,

Markus

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

<HTML>
Hi Don !
<BLOCKQUOTE TYPE=CITE>Please Help!

<P>I am a beginner Perl "programmer" and just bought FrontPage97
<BR>and I have no idea how to go about previewing a CGI script
<BR>with FP97 before uploading to my ISP's webserver.&nbsp; I am taking
<BR>a intro to CGI class online and I am unable to receive
<BR>adequate help in answering this question.&nbsp; Here's my setup:

<P>pc with win95
<BR>MS FrontPage97 (using the MS Personal Web Server)
<BR>I have downloaded Perl5 and saved to my C drive.&nbsp; (did install
it)
<BR>My ISP is using a UNIX webserver.

<P>Please let me know if I can do anything to help you help me
<BR>better!&nbsp; Thanks! Don</BLOCKQUOTE>
First I recommend getting "Winperl" from Maxwell Nairn Andrews (Perl32b3.zip,
sorry for no available download-destination). You can test your scripts
under your Windows-"Home-Shell". This helped me a lot as an origin win/dos-user.
<BR>Next, install the latest perl for win32. It'll install everything in
the right place, as eg in the registry. Then get PWS (Personal Web Server)
for Win 95 <A HREF="http://www.microsoft.com">Microsoft</A> . Put your
script in "/scripts" an test with a simple "helloworld.pl" in netscape.
Enter "<A HREF="http://yourserver/scripts/helloworld.pl">http://yourserver/scripts/helloworld.pl</A>?" in Netscape/ Explorer....
Dont forget the questionmark.It should work. Then you can work with html
and perl as cgi without problems and w/o always connecting to your ISP.

<P>have fun,

<P>Markus
<BR>
<BR></HTML>

--------------7754440FDAC44C5216612F1F--




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

Date: Sun, 01 Jun 1997 17:38:16 +0200
From: "Markus Ulsa_" <ulsass@berlin.snafu.de>
To: Chuck <chuckr@ptw.com>
Subject: Re: Help, PERL under Windows 95 testing
Message-Id: <33919768.DDC2600@berlin.snafu.de>


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

Hi Chuck,

Chuck wrote:

> Hello,
>
> I'm messing around trying to get PERL for Win32's
> (http://www.perl.hip.com/) to work in my Windows 95 OS. I'm just
> another
> newbie to the internet who wants to learn a little more about it. I
> can
> post all my files to my ISP for testing, but being connected to teh
> internet is a pain in the butt. And my scripts have to be FTP'ed every
>
> time just to test a small change. What I want is to have the ability
> to
> test my programs before I post them to my ISP's Linux Server. In DOS,
> I
> can run PERL by typing "perl myfile.cgi" and it writes the html code
> that I would normally see in Netscape. That works fine... But I wan't
> to
> be able to test out everything that I would see in Netscape.
>
> Is there a way to get my PERL scripts to run under Windows 95 in
> Netscape?

Yes.

> I tried to create a link to the file like I would if it was on the
> Linux
> server. But Netscape starts it up with
> "file:///D|/Perl/bin/myfile.cgi"
> This shows me the script in whole. I want to see the output of my
> scripts.

Won't work.

> Also, if my scripts do work under DOS, then I shouldn't I be able to
> redirect the output to a file instead of to the screen with a pipe
> command? such as
> "perl myfile.cgi > testfile.htm"
>
> Any suggestions would be beneficial, especially with Windows.
>
> Chuck
> chuckr@ptw.com
>
> P.S., I did read the FAQ first. Although it's huge, and has helped out
>
> tremendously with the installation, it does little for help with
> Windows
> 95 tips for testing PERL Scripts and such.

  First I recommend getting "Winperl" from Maxwell Nairn Andrews
(Perl32b3.zip, sorry for no available download-destination). You can
test your scripts under your Windows-"Home-Shell". This helped me a lot
as an origin win/dos-user.
Next, install the latest perl for win32. It'll install everything in the
right place, as e.g. in the registry. Then get PWS (Personal Web Server)
for Win 95 Microsoft . Put your script in "/scripts" an test with a
simple "helloworld.pl" in netscape. Enter
"http://yourserver/scripts/helloworld.pl?" in Netscape. Don't forget the
question mark. It should work. Then you can work with html and perl as
cgi without problems and w/o always connecting to your ISP.

have fun,

Markus

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

<HTML>
Hi Chuck,

<P>Chuck wrote:
<BLOCKQUOTE TYPE=CITE>Hello,

<P>I'm messing around trying to get PERL for Win32's
<BR>(<A HREF="http://www.perl.hip.com/">http://www.perl.hip.com/</A>) to
work in my Windows 95 OS. I'm just another
<BR>newbie to the internet who wants to learn a little more about it. I
can
<BR>post all my files to my ISP for testing, but being connected to teh
<BR>internet is a pain in the butt. And my scripts have to be FTP'ed every
<BR>time just to test a small change. What I want is to have the ability
to
<BR>test my programs before I post them to my ISP's Linux Server. In DOS,
I
<BR>can run PERL by typing "perl myfile.cgi" and it writes the html code
<BR>that I would normally see in Netscape. That works fine... But I wan't
to
<BR>be able to test out everything that I would see in Netscape.

<P>Is there a way to get my PERL scripts to run under Windows 95 in
<BR>Netscape?</BLOCKQUOTE>
Yes.
<BLOCKQUOTE TYPE=CITE>I tried to create a link to the file like I would
if it was on the Linux
<BR>server. But Netscape starts it up with "<A HREF="file:///D|/Perl/bin/myfile.cgi">file:///D|/Perl/bin/myfile.cgi</A>"
<BR>This shows me the script in whole. I want to see the output of my
<BR>scripts.</BLOCKQUOTE>
Won't work.
<BLOCKQUOTE TYPE=CITE>Also, if my scripts do work under DOS, then I shouldn't
I be able to
<BR>redirect the output to a file instead of to the screen with a pipe
<BR>command? such as
<BR>"perl myfile.cgi > testfile.htm"

<P>Any suggestions would be beneficial, especially with Windows.

<P>Chuck
<BR>chuckr@ptw.com

<P>P.S., I did read the FAQ first. Although it's huge, and has helped out
<BR>tremendously with the installation, it does little for help with Windows
<BR>95 tips for testing PERL Scripts and such.</BLOCKQUOTE>
&nbsp; First I recommend getting "Winperl" from Maxwell Nairn Andrews (Perl32b3.zip,
sorry for no available download-destination). You can test your scripts
under your Windows-"Home-Shell". This helped me a lot as an origin win/dos-user.
<BR>Next, install the latest perl for win32. It'll install everything in
the right place, as e.g. in the registry. Then get PWS (Personal Web Server)
for Win 95 <A HREF="http://www.microsoft.com">Microsoft</A> . Put your
script in "/scripts" an test with a simple "helloworld.pl" in netscape.
Enter "<A HREF="http://yourserver/scripts/helloworld.pl">http://yourserver/scripts/helloworld.pl</A>?" in Netscape. Don't forget
the question mark. It should work. Then you can work with html and perl
as cgi without problems and w/o always connecting to your ISP.

<P>have fun,

<P>Markus
<BR></HTML>

--------------DBA2075887645EBCC52B0486--





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

Date: 1 Jun 1997 17:31:55 +0200
From: tina@htmlhelp.com (Tina Marie Holmboe)
Subject: Re: How to extract text enclosed by...
Message-Id: <5ms4lb$m17@hrotti.ifi.uio.no>

 = Eileen Wharmby =

> In the same vein, how would I retrieve the first 60 characters? I want
> to work through the string inserting a linefeed after every 60
> characters.

  If I understand the problem correctly, you could try something like
this:

  foreach $piece ( ( $buffer =~ /.{60}/isg ) ) {
    print "$piece\n" ;
  }

--
 Tina Marie Holmboe
 [ tina@htmlhelp.com    ]      WDG     [ http://www.htmlhelp.com/%7Etina/    ]
 [ tina@ifi.uio.no      ]  University  [ http://www.ifi.uio.no/%7Etina/      ]
 [ tina@elfi.adbkons.se ]    Private   [ http://www.elfi.adbkons.se/%7Etina/ ]


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

Date: Sun, 1 Jun 1997 06:58:40 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "robert c. combs" <xrcc0494@dcaca037.ca.boeing.com>
Subject: Re: Internal data structure of lists
Message-Id: <Pine.GSO.3.96.970601065630.7444D-100000@kelly.teleport.com>

On Fri, 30 May 1997, robert c. combs wrote:

> So the basic question is...
> if you did a raw dump of a list that looked like:
> ['mine', 'yours', 'his'] what would/should it look like?

That question is less meaningful than it sounds, because Perl won't
necessarily store an entire variable into one chunk of memory.

If you're wanting to interface your C code to Perl, check out perlxs and
related manpages, which should give you the whole (albeit complex) story.

Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Sun, 1 Jun 1997 06:55:56 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Tom Oelke <tpo9617@rit.edu>
Subject: Re: New FAQ question? Decimal -> Binary conversion
Message-Id: <Pine.GSO.3.96.970601065501.7444C-100000@kelly.teleport.com>

On Sat, 31 May 1997, Tom Oelke wrote:

> I've seen 3 separate threads (including my own) about doing decimal /
> number conversion from decimal or hex string etc. to output in binary
> form. 
> 
> I'd suggest having this as a new FAQ question, as I couldn't find it in
> the FAQ when I was looking. 

Sounds good. Write it up and send it to the FAQ maintenance address. 
Thanks! 

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: 1 Jun 1997 10:02:22 GMT
From: ccadic@aol.com (Ccadic)
Subject: Own to chek if two or more words are in a string ?
Message-Id: <19970601100201.GAA26305@ladder02.news.aol.com>

I would like to find a function that is able to check if two or more words
appear in a string an dreturn true o r False

Exemple:


sub check {bla bla...}

$string_a = 'Hi this is my pentium talking";
$true = 1;


if &chek (('Hi','pentium') = $true) {Print (" 2 Words found")}
if &chek (('Hi','pentium,talking') = $true) {Print (" 3 Words found")}



Can anyone help me....



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

Date: 01 Jun 1997 08:58:40 -0400
From: Chaim Frenkel <chaimf@cris.com>
To: Ccadic  <ccadic@aol.com>
Subject: Re: Own to chek if two or more words are in a string ?
Message-Id: <m37mgetr7j.fsf@nlk.nlk.com>

>>>>> "Ccadic" == Ccadic  <ccadic@aol.com> writes:

Ccadic> sub check {bla bla...}
Ccadic> $string_a = 'Hi this is my pentium talking";
Ccadic> $true = 1;
Ccadic> if &chek (('Hi','pentium') = $true) {Print (" 2 Words found")}
Ccadic> if &chek (('Hi','pentium,talking') = $true) {Print (" 3 Words found")}
Ccadic> Can anyone help me....

Well what's wrong with reading the manual and FAQ.

But being in a generous mood, heres a simple version to get you started.

#!/usr/local/bin/perl -w
sub check
{
	my($haystack) = shift;

	for $needle (@_) {
		return "True" unless 0 > index($needle, $haystack)
	}
	"False";
}

print "needle in haystack ", &check("needle", "haystack"),"\n";
print "hay in haystack ", &check("hay", "haystack"),"\n";
print "stack in haystack ", &check("stack", "haystack"),"\n";

__END__

Results in:

needle in haystack False
hay in haystack True
stack in haystack True

Generalization to regular expressions (eg \b to ensure word boundary. Be
careful of what is a word boundary.) and checking for exact count of
matched words, is left as an excersize for the poster.

<chaim>
-- 
Chaim Frenkel					Nonlinear Knowledge, Inc.
chaimf@cris.com						 +1-718-236-0183


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

Date: 01 Jun 1997 08:47:25 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: frederic.cote@fundp.ac.be (Frederic COTE)
Subject: Re: perl compiler ?
Message-Id: <8cn2patjea.fsf@gadget.cscaper.com>

>>>>> "Frederic" == Frederic COTE <frederic.cote@fundp.ac.be> writes:

Frederic> Do you know if it is possible to compile a perl script ?

Yes.  Every version of Perl since 1988 has been a compiler,
translating the entire Perl program to an internal parse tree for
agressively optimized efficiency, then executing that "bytecode-like"
parse tree for the duration of your program.  Thus "1 + 2" in your
source file gets compiled to "3" in ultimate executable "image", and
so on.

So it's not only possible -- it's the only way Perl has ever executed!

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 457 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Sun, 01 Jun 1997 02:50:54 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Perl error handling for s/ and associative arrays
Message-Id: <339129DE.3FCF62E3@gpu.srv.ualberta.ca>

Tad McClellan wrote:
> 
> Joakim Larsson (joakim@korridor.se) wrote:
> 
[snip]
 
> $err =~ s/<!MGFFORM ([^>]*?)>/$FORM{$1}/g;
> 
> Because that is what you really want to match anyway.
> 
> You don't need s///e either. The replacement part is "double quotish"
> (ie. it acts like it was in a double quoted string), which will
> interpolate the variable for you...
> 
> : How can I tune the expression to return an empty string for
> : non valid keys?
> 
> I dunno. ;-(
> 

everythin Tad said :-)
 plus one way to assign a null string if your variable
is not defined: *note, you'll have to use /e again so
you can evaluate the trinary conditional ? :

$FORM{'a'} = 'Hi ';$FORM{'B'} = 'there ';$FORM{'c'} = 'guru! ';
$err = '<!MGFFORM a><!MGFFORM b><!MGFFORM c>';
$err =~ s/<!MGFFORM ([^>]*?)>/$FORM{$1}?$FORM{$1}:""/ge;
print $err;

regards
andrew


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

Date: Sun, 1 Jun 1997 08:34:26 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Perl error handling for s/ and associative arrays
Message-Id: <2ptrm5.kh.ln@localhost>

Andrew Johnson (ajohnson@gpu.srv.ualberta.ca) wrote:
: Tad McClellan wrote:
: > 
: > Joakim Larsson (joakim@korridor.se) wrote:
: > 
: [snip]
:  
: > $err =~ s/<!MGFFORM ([^>]*?)>/$FORM{$1}/g;
: > 
: > Because that is what you really want to match anyway.
: > 
: > You don't need s///e either. The replacement part is "double quotish"
: > (ie. it acts like it was in a double quoted string), which will
: > interpolate the variable for you...
: > 
: > : How can I tune the expression to return an empty string for
: > : non valid keys?
: > 
: > I dunno. ;-(
: > 

: everythin Tad said :-)
:  plus one way to assign a null string if your variable
: is not defined: *note, you'll have to use /e again so
: you can evaluate the trinary conditional ? :

: $FORM{'a'} = 'Hi ';$FORM{'B'} = 'there ';$FORM{'c'} = 'guru! ';
: $err = '<!MGFFORM a><!MGFFORM b><!MGFFORM c>';
: $err =~ s/<!MGFFORM ([^>]*?)>/$FORM{$1}?$FORM{$1}:""/ge;
: print $err;


Cool! Now I do know ;-)


But...

if $FORM{'a'} = '0' (or any other "false" value), it won't do the Right Thing.

So, you need:

$err =~ s/<!MGFFORM ([^>]*?)>/defined($FORM{$1})?$FORM{$1}:""/ge;
                              ^^^^^^^

--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 1 Jun 1997 13:21:25 GMT
From: "Bruce Rashke" <bruce@tasconline.com>
Subject: perl.nlm; 4.1 Netware; None Intranetware
Message-Id: <01bc6e8d$9d4dd8a0$35b2adcd@tascinet.com>

Looking for information re: using perl.nlm in none intranetware
environment. Anyone have good resource from install, to setup, to using. 
WWW server is Glaci on Netware 4.1 Server.



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

Date: 1 Jun 1997 09:21:15 GMT
From: rlall1@mugca.cc.monash.edu.au (Bugsy)
Subject: Printing Arrays to a file
Message-Id: <5mreub$tiu$1@towncrier.cc.monash.edu.au>

I'll apologise now to all of you who have been asked this type of question
before, but I'm new to perl, (and to programing to for that matter), and I'm
having trouble printing the contents of an array to a file.  I've read the
camel book, and the perl manpages and faq, but have been unable to solve this
problem.

Erm I guess I'd better tell you what it is...okie when I print my array to a
file, it's printing it all on one line, (and then wrapping the text), rather
than one entry per line. 

At present I'm using the following code for this task, anyone have any
suggestions?

=======BEGIN CODE

@altsorted = sort { $a cmp $b } @AltGroups;
open (AG, ">$altgroups") || die "$0: Can't open $altgroups - $!\n";
while ($line = <$altgroups>) {
    push(@OldList,$1);
}
close (AG);
if (@altsorted ne @OldList) {
   system ("rm", "$altgroups");
   system ("touch", "$altgroups");
   open (AG, ">$altgroups");
     print AG "@altsorted \n";
   close (AG);
}

=======END CODE

Thanks in Advance

Bugsy

-- 
                   Bugsy <rlall1@mugc.cc.monash.edu.au>
             Home Page http://www-mugc.cc.monash.edu.au/~rlall1
            Finger rlall1@mugca.cc.monash.edu.au for PGP key.


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

Date: Sun, 1 Jun 1997 10:29:52 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: Printing Arrays to a file
Message-Id: <199706011029.DAA29399@netcom18.netcom.com>

Bugsy (rlall1@mugca.cc.monash.edu.au) wrote:

: @altsorted = sort { $a cmp $b } @AltGroups;
: open (AG, ">$altgroups") || die "$0: Can't open $altgroups - $!\n";
: while ($line = <$altgroups>) {
:     push(@OldList,$1);
: }
: close (AG);

This is strange here.  You opened a file handle AG for writing, but
you do not write anything before closing it.  I suppose you incorrectely
opened AG for writing though you meant to open it for reading.

If you really mean opening AG for $altgroups, you can use

   while ($line = <AG>){

besides, if you do not use any pattern matching, I wonder what you are
doing to push $1 into @OldList.

: if (@altsorted ne @OldList) {
:    system ("rm", "$altgroups");
:    system ("touch", "$altgroups");
:    open (AG, ">$altgroups");
:      print AG "@altsorted \n";
:    close (AG);
: }

@altsorted and @OldList are two arrays.  I wonder what you get when you
use "ne" to compare them.

If you do want to print the entries of @altsorted as one entry per line,
use

   while (@altsorted){
      print AG "$altsorted[0]\n";
      shift(@altsorted);
   }

Gurus might write above codes into two lines or even one line.
All suggestions here are run with Perl 1.001 in my brains and untested
by Perl [45].xxxx, though.

--
Tung-chiang Yang                       tcyang@netcom.com

soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
   http://www.iglou.com/tcyang/Taiwan_faq.shtml, China_faq.shtml



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

Date: Sun, 1 Jun 1997 12:59:08 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Printing Arrays to a file
Message-Id: <adelton.865169948@aisa.fi.muni.cz>

rlall1@mugca.cc.monash.edu.au (Bugsy) writes:

[...]

> Erm I guess I'd better tell you what it is...okie when I print my array to a
> file, it's printing it all on one line, (and then wrapping the text), rather
> than one entry per line. 

You probably will want to check the meaning of the $" variable.

Hope this helps.

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
     Have you done your DES today? --> http:/www.des.sollentuna.se/


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

Date: Sun, 1 Jun 1997 08:51:41 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Printing Arrays to a file
Message-Id: <dpurm5.vn.ln@localhost>

Tung-chiang Yang (tcyang@netcom.com) wrote:
: Bugsy (rlall1@mugca.cc.monash.edu.au) wrote:

[ snip good comments about other strangeness in the posted code ]


: If you do want to print the entries of @altsorted as one entry per line,
: use

:    while (@altsorted){
:       print AG "$altsorted[0]\n";
:       shift(@altsorted);
:    }

: Gurus might write above codes into two lines or even one line.


Even a simple "Intermediate Perler" such as myself might write
it in two lines:

$" = "\n";
print "@altsorted\n";

OR (better)

$, = "\n";
print @r, '';  # null string just to get a newline after the last real element

-----

OR, three lines:

while (@altsorted){
   print STDOUT shift(@altsorted), "\n";
}

OR (better)

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


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 1 Jun 1997 14:50:38 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: Regex lookahead help
Message-Id: <5ms27u$n4p$1@dartvax.dartmouth.edu>

In article <5mn20g$mcq$1@neocad.com>
stampes@xilinx.com (Jeff Stampes) writes:

> I have a hash set up that defines a certain regular expression for
> each entry.  This is a filter mechanism that is supposed to work 
> along the lines of "If you're looking in the foo directory on the
> bar CD, find me the files that match /$regex/".  When I go into the
> actual comparison loop, I am plugging the regex into a positive
> match.
> 
> so here's the problem.  I have some strings that are in the form
> 'data/foo/bar/not.this'  I want to NOT match these strings.  
> However, the regex needs to be plugged into a positive assertion
> match.  There could be anywhere from 3-6 levels before the 
> 'not.this'.    
> 
> I was hoping to use a negative lookahead, but can't seem to find
> something that works.  For example:
> 
> m{(.+/)+(?!not.this)}
> 
> this may work, but it also results in a non-match for
> 'data/foo/bar/this'.  
> 
> I hope I've gotten the problem across here, it's hard to describe.
> If you have any clues, please share.

I'm afraid I'm still not quite clear on what you want to match and what
you don't want to match.

Here's the results with your regexp (in the debugger):

  DB<1> p 'data/foo/bar/this' =~ m{(.+/)+(?!not.this)}
data/foo/bar/
  DB<2> p 'data/foo/bar/not.this' =~ m{(.+/)+(?!not.this)}
data/foo/

Your regexp matches part of each string.  I think what you were saying
is that you want to match the whole string or not match at all.  Is
that correct?

If so, this should work:
m{^(/?(.+/)+)(?!not.this)([^/]+)$}

  DB<6> p 'data/foo/bar/this' =~ m{^(/?(.+/)+)(?!not.this)([^/]+)$}
data/foo/bar/data/foo/bar/this
  DB<7> p 'data/foo/bar/not.this' =~ m{^(/?(.+/)+)(?!not.this)([^/]+)$}


Notes:
This regexp will match an optional / at the beginning of the string.
If the match succeeds, the path will be in $1, the filename will be in
$2.

Chipmunk


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

Date: Sun, 01 Jun 1997 08:06:12 GMT
From: brian@brie.com (Brian Lavender)
Subject: Re: Second perl book
Message-Id: <33912b87.2716746@nntp.netcruiser>

On Sat, 31 May 1997 18:12:21 +0200, uzs90z@uni-bonn.de (Michael
Schuerig) wrote:

>Has
>anyone of them written a book or is there some place on the web where I
>ought to look?

I would definitely visit Randal Schwartz's home page, he wrote
Learning Perl, and check out his Unix Review and Web Techniques
columns. He provides valuable insight and after you have read his
columns you will be far ahead. They are easy to understand unlike some
of the man pages (IMHO). All of his columns are available, so print
them out, sit by the AC (summertime), and enjoy. Start with Unix
Review first unless you are an advanced Perl Hacker.

Brian

Randal's Valuable Web Pages

Home Page
http://www.stonehenge.com/merlyn

Unix Review
http://www.stonehenge.com/merlyn/UnixReview/

Web Techniques
http://www.stonehenge.com/merlyn/WebTechniques/
----------------
Brian Lavender
Napa, CA
Brie Business Directory - Napa Valley     http://www.brie.com/bbd 
(707) 226-8891

"Have you heard of the new improbability drive?"


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

Date: 1 Jun 1997 15:06:08 GMT
From: "David" <burchd@erols.com>
Subject: Re: Standalone web database for Perl?
Message-Id: <01bc6e9c$966842a0$4160accf@ethereal>

Sprite.pm is a delimited text database using a SQL subset that is good for
small uses.  MSQL is available for $50 a server ( I think) if you need a
larger solution (you
would have to use the Perl (DBI).
David
burchd@erols.com

Gary Weinfurther <gary@mich.com> wrote in article
<MPG.df65c741202955a989680@news.mich.com>...
> A client wants a "simple" database application developed in Perl for a 
> corporate intranet.  According to the client, the web server does not 
> currently have a DBMS.  He wants a small, low-budget database for this 
> application and it does not need to interact with any other application 
> on the intranet.  Is there a Perl library that manages database records, 
> similarly to a data management library for C or other languages?  Or do 
> we have to purchase a large C/S RDBMS and install it on the server?
> 
> Thanks in advance!
> -- 
> 
>    ...Gary (gary@mich.com)
> 


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

Date: Sun, 1 Jun 1997 06:52:01 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Michael Schilli <mschilli@blacksun.com>
Subject: Re: while(<>) and perl -e: B.. or feature?
Message-Id: <Pine.GSO.3.96.970601064907.7444B-100000@kelly.teleport.com>

On Sat, 31 May 1997, Michael Schilli wrote:

> I wonder why 
> 
>    perl -e 'while(<>) {...}'
> 
> doesn't process file names from the command line 

I wonder why yours doesn't but mine does. :-)  Maybe you have found a bug
in your copy of Perl. Does this do the right thing? Hope this helps!

    perl -e 'while (<>) { tr/:/~/; print }' /etc/passwd

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Sun, 1 Jun 1997 12:47:48 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Why is ("a" == 0) true?
Message-Id: <adelton.865169268@aisa.fi.muni.cz>

dchen@interport.net writes:

> Thanks for all the responses.
> 
> Clive Newall <crn@bby.com.au> put it best:
> 	"... read p 528 of the blue camel"
> where it says "any non-numeric string is numerically equal to zero."
> 
> I was getting confused staring at page 21 in the blue camel (sept 96),
> where it says:  Any number is true except for 0 and
>                 Any string is true except for "" and "0".
> So I assumed, erroneously, that "a" is true and 0 is false,
> thus ("a" != 0).  

I think that there is one more thing: You do not compare 'boolean'
value of "a" and 0. You compare their natural values and how you
compare them is said by the != operator. So in this case it's not the
true/false that matters, but rather the numeric value of "a", as you
have already found out.

> Next time I use 'eq'.

Yes, at least when you compare strings.

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
     Have you done your DES today? --> http:/www.des.sollentuna.se/


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

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

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