[6595] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 220 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 2 12:16:49 1997

Date: Wed, 2 Apr 97 09:00:23 -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           Wed, 2 Apr 1997     Volume: 8 Number: 220

Today's topics:
     Re: "Bad free()" warning, splitting on variable delimit (covington maiko)
     Re: base conversion (for unix rgb/hex converter) (David Staschover)
     Re: Can't get 2 way communication using sockets (Mike Stok)
     Re: Compilation problem on sco box (Engineered Plastics Corp)
     Re: Could some one please help <flg@vhojd.skovde.se>
     Re: Data struc. or algor. for multi-type lists <seay@absyss.fr>
     Re: Deleting a line from a file <seay@absyss.fr>
     Re: Filter: Latex to SGML problem (regular expressions) (Eric Bohlman)
     Re: Filter: Latex to SGML problem (regular expressions) (David Alan Black)
     Re: Form post to Sendmail fails (brian d foy)
     HELP: Unable to create sub "%s" error in code (CTR)
     Re: How to concat many digits to be one string? <stacey@mcs.kent.edu>
     In-line GIF extraction (Kent Brye)
     J.A.F.O. <james_whetstone@hp-roseville-om2-om.hp.com>
     lock file necessary? carelf@demon.nl
     Re: Multiplication9s <tchrist@mox.perl.com>
     Re: New Microsoft Perl Product (fwd) (Paddy Spencer)
     Re: New Microsoft Perl Product (fwd) (Eric Bohlman)
     Re: Perl Mail Parser Question ()
     Re: Perl mishandles some multidimensional array referen <merlyn@stonehenge.com>
     Re: SIGCHLD bug in 5.004Beta? (Bryan Miller)
     Re: Starting, Suspending, and Restarting a Child <tchrist@mox.perl.com>
     Re: String substitution problem (Tad McClellan)
     Re: Unix and ease of use (WAS: Who makes more ...) <mike@roan.co.uk>
     Re: Using Perl with MS-Access <gardh@norway.eu.net>
     Re: When is perl program too large? (Bennett Todd)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 2 Apr 1997 14:46:40 GMT
From: mcovingt@coewl.cen.uiuc.edu (covington maiko)
Subject: Re: "Bad free()" warning, splitting on variable delimiters
Message-Id: <5htrgg$qpe@vixen.cso.uiuc.edu>

Hello again.

	Reading over code with fresh eyes does wonders! Specifically,
I found that I had used a variable name twice, and fixing that got rid of
the error.

	However, I'm still curious as to why the error only appeared in the
case where I split on the variable delimiters. I'd expect to get an error
ALL the time!

	Maiko Covington (maiko@yertle.csl.uiuc.edu)



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

Date: 2 Apr 1997 11:13:45 -0500
From: das@panix.com (David Staschover)
Subject: Re: base conversion (for unix rgb/hex converter)
Message-Id: <5hu0jp$pp9@panix.com>

thanks! That one liner did it! The Windows-based rgb-hex converters are
too awkward with the sliders..

David

Eric Bohlman (ebohlman@netcom.com) wrote:
: David Staschover (das@panix.com) wrote:
: : I want to write a unix shell command to convert from rgb to hex. Is there
: : a function
: : in perl to convert bases?

: Not for converting arbitrary bases, but for this application take a look 
: at printf, sprintf, pack and unpack.

: If all you want to do is take 3 decimal numbers typed on the command line 
: and convert them into a 6-character hex code, the following will do it:

: printf "%02X%02X%02X\n", @ARGV[0..2];

:  


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

Date: 2 Apr 1997 13:32:05 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Can't get 2 way communication using sockets
Message-Id: <5htn4l$9li@news-central.tiac.net>

In article <3339ABCC.3331@csu.edu.au>, Tim Archer  <tarcher@csu.edu.au> wrote:
>I am trying to a get a conversation going between a client and
>server using sockets. I can get the server to write to the client or
>the client to the server but when I try and do something like this:
>
>[Server]
>print CLIENT "How are you";
>$in = <CLIENT>;
>
>[Client]
>$in = <SERVER>;
>print SERVER "I'm Good thankyou!";

If you're going to use <> rather than sysread to read from a socket then
you should make sure that the producer auto-flushes after every write (set
$| to 1 with the appropriate file handle selected or if you're using one
of the new fangled OO wrappers around file handles then use the autoflush
method) and remember that <> tries to read to the next end of record
(usually a line as end of record is usually \n) or to the end of file.  So
you might find terminating the strings with \n or closing the socket helps
out.

Hope this helps,

Mike


-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: 2 Apr 1997 10:16:30 -0600
From: epc@earth.execpc.com (Engineered Plastics Corp)
Subject: Re: Compilation problem on sco box
Message-Id: <5hu0ou$jf5$1@earth.execpc.com>

In article <5hsake$q0l@hendrix.postino.com>,
>Jim Femister (jfemister@acm.org) wrote:
>: I am getting the following output when trying to make perl5.003 for SCO:
>:         cc  -L/usr/local/lib -o miniperl miniperlmain.o libperl.a -ldbm.nfs
>: -lin
>: tl -lsocket -lnsl_s -lndbm -lld -lm -lc -lPW -lx
>: undefined                       first referenced
>:  symbol                             in file
>: Perl_chsize                         libperl.a
>: ld fatal: Symbol referencing errors. No output written to miniperl
>: *** Error code 13           
>: Things seem to run smoothly until this attempt to compile "miniperl".
>: Any suggestions?
>

And, In article <5hsake$q0l@hendrix.postino.com>,
Danny Aldham <danny@hendrix.postino.com> wrote:
>Either use gcc to make perl, or download the perl distribution from
>ftp.sco.com and use the hints file included with it. For some reason
>this has not been fed back into the regular perl distribution hints.
>--
>Danny Aldham    SCO Ace, MCSE    www.postino.com

While the above was not the precise error message I was receiving when
I attempted to build perl for the free version of SCO Open Server 5, I
was ultimately successful in building perl5_003 with the development
system on Open Server 5 as is.  

I ran Configure with the -d switch (accept all defaults), shelled out
at the end and removed the -O compiler optimization flag from the config.sh
file.  Everything ran smoothly after that.

Hope this helps...

-mm
-- 
Martin A. Miller, Systems Administrator, Bon Vivant At-Large & Stunt Borg.
Engineered Plastics Corp. Menomonee Falls, WI. |  Email: epc@execpc.com
Idiot Filter: "Ya, we run the C++ operating system on a QNX platform
over FDDI twisted pair at 600 MIPS." If they swallow that, hang up.


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

Date: 2 Apr 97 10:39:56 GMT
From: "Fredrik Lindberg" <flg@vhojd.skovde.se>
Subject: Re: Could some one please help
Message-Id: <01bc3f52$38106d00$e20f10c2@odens.di.vhojd.skovde.se>

>>> alastair brown wrote
> Please could some one shed some light onto this problem. I'm trying to
> return some of the enviroment variables to my script using the following
> code

[code removed]

Its very difficult analysing your problem since you dont supply more code.
Do you use the CGI module? The problem seems to be caused by your 
program not issuing the right http headers.

Here is a simple test cgi script that returns the values you wanted. The
script uses the CGI module (but perhaps the CGILite module would have
been enough for this script), so you have to get it if you dont already 
have it.

#!/usr/bin/perl
#
use CGI;

# Create a new CGI object
#
$CGIObject =  new CGI;

# Print out http headers and HTML header
print $CGIObject->header;
print $CGIObject->start_html("CGI Result");


print "<H1>This is what I came up with ... </H1><BR>";

$rem_host = $ENV{REMOTE_HOST} . "!";
$rem_add = $ENV{REMOTE_ADDR} . "!";
$browser = $ENV{HTTP_USER_AGENT} . "!";

print "<H4>";
print "$rem_host <P>";
print "$rem_add <P>";
print "$browser  <P>";
print "</H4>";

# End the page ..

print $CGIObject->end_html;

__END__

Hope this helps

/Fredrik




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

Date: Wed, 02 Apr 1997 15:18:48 +0100
From: Douglas Seay <seay@absyss.fr>
To: Christopher Lott <cml@cs.umd.edu>
Subject: Re: Data struc. or algor. for multi-type lists
Message-Id: <334278D8.3BED@absyss.fr>

[posted and mailed]

Christopher Lott wrote:
> 
> Hi,
> 
> I'm working on processing input that is a list of elements,
> where an element can be either a simple token or another list
> (and lists have names).  So the best model of the data seems
> to be a list in which the elements can be of different types.
> 
> It sounds like a very natural thing for lisp, actually, but I
> think Perl is my best bet.  I know that I can process lists in
> Perl, but my reading of the Camel book says that the elements
> of a list must be all of the same type, either scalar, lists,
> hashes, etc.

All elements in a list or hash have to be scalars, but a reference
is a scalar, so it is possible to have a list of elements where
each element points to something different.  To stick a reference
to a list at the end of a list try "push(@list_one, \@list_two);"
and now the last element of @list_one is a reference to
@list_two.


> If I were coding c/C++ I guess I would have a linked list of
> structs, and each struct would have a pointer that would point
> to a list in the case of a list (duh) and to nil in the case of
> a simple token.

Perl doesn't have structs, usually a hash will be used
instead ($record{'field'} for C's record.field).
False values ('' and 0) are not valid references, so
they are often used as NULL pointers.

But that is not useful for you.  Use ref() to know if
the element is a reference to a list or not.  If not, it
has to be a token (by elimination).


> One relatively inelegant way to solve the problem - in any lang -
> is to have two arrays and rely on the indices; array1[index] holds
> the simple token or name of a list, and array2[index] holds some
> indication of whether the thing in array1 is really a simple token
> or a list.  Recursion plus an iterator will process the whole mess.

Don't say things like this in public.


> I suspect there's some elegant way to do this in Perl, either in
> the data structure, algorithm, or some wonderful Perl-thing.  There
> always has been in the past, why should this be any different?  If
> someone has time to share their ideas and insights, that would really
> be great.
> 
> Please send replies to me in addition to posting.  That will help me
> see replies very quickly (lousy news service from my regular server).
> Thanks in advance.

I've done something like this in the past when processing
header files with includes.  Process your list by shift()ing
the first element off the list.   If it is a token, do whatever
needs to be done.  If it is a marker for another list, just
unshift() that list to the front of your main list and keep
going.  Basically this just builds a stack and lets you go
through the stack.  You might prefer push() and pop(), but
I don't like the interesting things to be at the "back" end
of the list.

Note that if you need to keep several lists with unique
markers, a hash is the trick.

The sytnax for derefferencing elements is kinda ugly,
but since you know lisp, all the {} pairs won't be too
much of a problem.  You'll need to glance the Camel to
get the details for syntax or read the man pages closely.

Hope this helps.

- doug


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

Date: Wed, 02 Apr 1997 14:38:22 +0100
From: Douglas Seay <seay@absyss.fr>
To: THIAM YEO <n1835173@sparrow.qut.edu.au>
Subject: Re: Deleting a line from a file
Message-Id: <33426F5E.6980@absyss.fr>

THIAM YEO wrote:
> 
> Hi there!
> 
>   Can anybody tell me how do I seach for a particular word in a text files
> and delete that whole line?

[posted and mailed]

In a Perl script, usually you just go to the next line

	while ( $line=<INPUTFILE> )
		{
		next if ( $line =~ /string_to_be_avoided/ );
		# real stuff goes here
		}

but if you just want to do it from the command line, there
are lots of ways.  The easiest way would be

	grep -v string_to_be_avoided < input > output

If your goal is to delete the line without recopying
the entire file, then you are out of luck.  In Unix
that can't be done (unless you've hacked your local
filesystem and added records, but that isn't portable).
Just use Perl with the -i option to edit in place
(Perl will do the recopying for you).

- doug


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

Date: Wed, 2 Apr 1997 11:52:42 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Filter: Latex to SGML problem (regular expressions)
Message-Id: <ebohlmanE80EBv.LpK@netcom.com>

Andreas Olsson (cie95aol@lustudat.student.lu.se) wrote:
: I'm new to Perl and have some questions.
: My goal is to make a filter for a specific Latex document my company has,
: to SGML (according to the given DTD). I've read about regular expressions
: and I'm sure Perl can solve my problem. Please help me.

[snip]

: $patt =~ s|\\section(.*)\\section|<chapter>$1</chapter>|gs;

: The code above only matches the first and last "\\section" and if I use the
: ? inside the paranthesis I only get a match for the two first "//section".
: How should I write my expression so that it goes through the whole $patt?

The reason for your problem is that after you've done your first 
substitution, you've zapped the second "\\section" which means that the 
next attempt to match won't see anything beginning with "\\section" and 
therefore will be skipped, so you'll only convert every other section.

The solution is to use a lookahead assertion:

s|\\section(.*?)(?=\\section)...

This won't eat up the terminating "\\section" so that the next match will 
start on it, rather than what came after it.

BTW, neither your original pattern nor this modification will properly 
convert the last section in your text.



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

Date: 2 Apr 1997 12:04:15 GMT
From: dblack@icarus.shu.edu (David Alan Black)
Subject: Re: Filter: Latex to SGML problem (regular expressions)
Message-Id: <5hthvv$qak@pirate.shu.edu>

Hello -

"Andreas Olsson" <cie95aol@lustudat.student.lu.se> writes:

>Hello!

>I'm new to Perl and have some questions.
>My goal is to make a filter for a specific Latex document my company has,
>to SGML (according to the given DTD). I've read about regular expressions
>and I'm sure Perl can solve my problem. Please help me.

>One of my problems is that Latex only have a start-tag but in SGML I want
>both start- and end-tag. An example:

>$patt = "text before first\n".
>        "\\section{Chapter1}\n".
>        "text between first\n".
>        "\\section{Chapter2}\n".
>        "text between second\n".
>        "\\section{Chapter3}\n".
>        "text after last"; 

>$patt =~ s|\\section(.*)\\section|<chapter>$1</chapter>|gs;

>I want $patt to look like below afterwards but it doesn't:

>"text before first
><chapter>{Chapter1}.
>text between first
></chapter><chapter>{Chapter2}.
>text between second
></chapter><chapter>{Chapter3}
>text after last</chapter>";

>The code above only matches the first and last "\\section" and if I use the
>? inside the paranthesis I only get a match for the two first "//section".
>How should I write my expression so that it goes through the whole $patt?

Your pattern is eating up too many \section's - in the course of relabeling
the first chapter, it matches (and discards) the \section for Chapter2.

On the bend-before-you-break principle, you might use multiple regexes
(regices?).

Taking the liberty of adding \end{document} and assuming that everything
before it is in the last section....

#!/usr/local/bin/perl -w

$patt = << "EOT";
text before first
\\section{Chapter1}
text between first
\\section{Chapter2}
text between second
\\section{Chapter3}
text after last
\\end{document}
EOT

for ($patt) {
# Singular case: the first \section
    s!\\section!<chapter>!;
# Middle cases:
    s!\\section(.*?)!</chapter>\n<chapter>$1!gs;
# Singular case: the end of the last section
    s!(\\end{document})!</chapter>\n!;
}

print $patt;

text before first
<chapter>{Chapter1}
text between first
</chapter>
<chapter>{Chapter2}
text between second
</chapter>
<chapter>{Chapter3}
text after last
</chapter>


David Black
dblack@icarus.shu.edu


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

Date: Wed, 02 Apr 1997 10:01:41 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Form post to Sendmail fails
Message-Id: <comdog-0204971001410001@nntp.netcruiser>

In article <5htcu8$av4$1@news02.pt.uk.ibm.net>,
Jonathan.J.Forster@lloydsoflondon.co.uk (Jonny Golden Bollocks) wrote:

[redirected to comp.infosystems.www.authoring.cgi]

> I've got a simple form that posts data to a perl script which in turn
> sends the data to a user via Sendmail.
> 
> The problem is: running the script from a command line as root works fine
> but submitting data via a web page fails (the Web server is not running as 
> root). I realise that Sendmail is fussy about it's trusted users.
> 
> Other than running the webserver as root, is there any way of getting around
> this problem?

i've done this sort of thing in several different scripts.  perhaps you 
could post the relevant code?  also, heavy use of error checking and
debugging sorts of things might be enlightening...

if the server UID is the problem -- but i don't think it is-- you might
consider running the script as suid, but not before reading the WWW
security FAQ [1] and adding taint checking (which you should already have
since you are passing data to another program). :)

[1]
<URL:http://www-genome.wi.mit.edu/WWW/faqs/www-security-faq.html>

-- 
brian d foy                              <URL:http://computerdog.com>                       
unsolicited commercial email is not appreciated


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

Date: Wed, 02 Apr 1997 10:35:57 -0500
From: "David Turkel (CTR)" <dturkel@test-isics.reston.mci.net>
Subject: HELP: Unable to create sub "%s" error in code
Message-Id: <33427CDD.41C67EA6@test-isics.reston.mci.net>

I am having a problem with trying to figure out what my error is here...
Here is the code:

I am using perl5.002.  The error is RUNTIME and it occurs after the
"if(Check_Completion" condition is true.  As soon as it tries to
exectute the next statemant -- WHAM!!!! nothing!


Please email me at dturkel@ndcinc.com if you can help.

Thanks, 

Dave

for( ; $paddr=accept(Client,Server); close Client){
        my($port, $iaddr) = sockaddr_in($paddr);
        my $name = gethostbyaddr($iaddr,AF_INET);

        while($STATUS=<Client>){
        #combine everything into one string
                chop($STATUS);

                $status .= "$STATUS";


        }

        ($collector, $junk)=split(/-/,"$status");

        $aggregation{"$collector"}="1";

        logmsg "Connection from $name [",inet_ntoa($iaddr), "] at port
$port";
        logmsg "Received status : $status";

        if(Check_Completion(\%aggregation)){
                        `/opt/isics/stats/work/sh/form_full_db.sh`;
                        print "Compilation of DB files successful...\n";
                        exit(1);
        }

        $status="";

}


sub Check_Completion
{

my $aggstatuses = $_[0];
my $box;
my $DONE_FLAG = 1;

#while ( ($box) = each %$aggstatuses){  #This doesn't seem to work
foreach $box (keys %$aggstatuses){
        logmsg "BOX: $box -- $$aggstatuses{$box}\n";
        if($$aggstatuses{"$box"} eq "0"){

                $DONE_FLAG = 0;
                logmsg "Full aggregation not done...\n";
                return 0;
        }

}

logmsg "AGGREGATION DONE... spawning combination processes";
return 1;

}


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

Date: Wed, 02 Apr 1997 10:08:49 -0500
From: Michael Stacey <stacey@mcs.kent.edu>
Subject: Re: How to concat many digits to be one string?
Message-Id: <33427681.4CD3@mcs.kent.edu>

Joruno Jobana wrote:
> 
> Dear,
>         I write program for randomming 8 digits.


Try this:
 #/usr/bin/perl
 srand(time|$$);
 $ST = "";
 for($i=0;$i<8;$i++) {
   $ID[$i]=int(rand(10));
   $ST .= $ID[$i];
 }

  

   
-- 

						Michael


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

Date: 2 Apr 1997 13:36:18 GMT
From: brye@acronet.net (Kent Brye)
Subject: In-line GIF extraction
Message-Id: <5htnci$6pn$1@news2.nap.net>

I've inherited a Perl script that is run by CRON to go out to a web site and 
pull in a GIF.  The page at the server end I believe changed to use an inline 
gif.  What are the steps I should take in order to put this inline gif into a 
file, where we then use it on our site?  This is run on a Sun sparc 20, Solaris 
2.5, Perl 5.002.  The script uses sockets for communicating with the other web 
site.  Any help would be greatly appreciated.

Thanks in advance,
Kent

brye@acronet.net   kbrye@nyx.cs.du.edu



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

Date: Tue, 01 Apr 1997 16:31:39 -0800
From: James Whetstone <james_whetstone@hp-roseville-om2-om.hp.com>
Subject: J.A.F.O.
Message-Id: <3341A8EB.4454@hp-roseville-om2-om.hp.com>

Just Another Forking Obstacle.

Yea.  I'm writin' a script as a cgi and I's needs to fork my script. 
The problem is that I'm on a Windows NT 4.o platform and fork is not a
supported function.  So..any ideas on how I can use the exec function
and still allow the parent program to execute without interuption and
without waiting for the exec'd process to terminate?

--Jim Whetstone

james_whetstone@hp-roseville-om2-om.hp.com


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

Date: Wed, 2 Apr 97 15:55:02 +0100
From: carelf@demon.nl
Subject: lock file necessary?
Message-Id: <9704021555.aa07471@kantoor.demon.nl>

Hi everyone,

Several people are using a simple script of mine simultaneously on
SunOS 4.1.4 

The script writes to a backup file.
Something like this:

open(BACKUPF,">>$backup_file")||die "Could not open backup file: $!.\n";
$time=scalar localtime;
print BACKUPF "Firstvalue: $value0\nSecondvalue: $value1\nDate: $time\n\n"
close(BACKUPF);

Will I need a lockfile for this?

Cheers,

Carel.



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

Date: 2 Apr 1997 14:47:40 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Multiplication9s
Message-Id: <5htrid$fku$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, steve@golf.com (Steven Sajous) writes:
:Is there a way to keep this freom happening?
:
:$value =19.95;
:$number = 1;
:
:$total = $value * $number
:I get $total = 19.950000000000000698

Yes, you have to learn about floating point numbers.
Go read a good book on numerical analysis. :-(

This question comes up daily, and it's very disconcerting.
It scares me that people are using computers with so little
background.  It's the same fear that I experience when I 
see someone locking files with the wrong algorithm.

I do notice this:

    %  perl4 -le 'print 19.95 * 1'
    19.949999999999999
    %  perl5 -le 'print 19.95 * 1'
    19.95

This is merely because we reduced the number of digits of precision in
the default output format to squelch confusion such as yours.  It's not
as though it's a different number of anything.

Bottom line:  numbers are not represented exactly.  If you want a certain
kind of format, use a formatted print, as in printf "%.2f".

This question will be more directly addressed than it currently is in
the next version of the FAQ.

--tom
-- 
	Tom Christiansen	tchrist@alumni.cs.colorado.edu

if (shm == (char *)-1)  /* I hate System V IPC, I really do */
    --Larry Wall, from doio.c in the v5.0 perl distribution


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

Date: Wed, 02 Apr 1997 14:50:59 GMT
From: paddy.spencer@parallax.co.uk (Paddy Spencer)
Subject: Re: New Microsoft Perl Product (fwd)
Message-Id: <859989020.901493@red.parallax.co.uk>

abostick@netcom.com (Alan Bostick) kirjoittanut::

: > MICROSOFT VISUAL PERL++ ADDS ENORMOUS POWER AND EASE OF USE TO A
: > PROGRAMMING FAVORITE.
: > 
: > 
: > April 1, 1997

I'm _hoping_ this is an April Fool, given the date, but it sounds too
damned much like the kind of thing that M$ would do. It's scary. Kind
of like reading the "diary" of Jim Hacker (as in "Yes, [Prime]
Minister") which is eerily believable without the laughter track you
get on TV...


Obj(Newbie)Perl:

I know you can do this:

	$arg eq "-n" || die "Use -n you moron!!\n";

and if you try doing 

	$arg eq "-n" || $arg = "-n";

it complains about modifying logical or operator. Any way around this
or does one have to use the incredibly passe if(...){} construct?

-- 
Paddy Spencer        Parallax Solutions Ltd (http://www.parallax.co.uk/)
No-one ever said to van Gogh, "Paint 'A Starry Night' again, man!" 
                                                        -- Joni Mitchell



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

Date: Wed, 2 Apr 1997 14:09:57 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: New Microsoft Perl Product (fwd)
Message-Id: <ebohlmanE80KoL.3rz@netcom.com>

Paddy Spencer (paddy.spencer@parallax.co.uk) wrote:

: Obj(Newbie)Perl:

: I know you can do this:

: 	$arg eq "-n" || die "Use -n you moron!!\n";

: and if you try doing 

: 	$arg eq "-n" || $arg = "-n";

: it complains about modifying logical or operator. Any way around this
: or does one have to use the incredibly passe if(...){} construct?

That's because "||" has a higher precedence than "=" so the statement is 
parsed as

(($arg eq "-n") || $arg) = "-n";

which is semantically meaningless (how can you assign something to the 
result of a comparison?).  The best way to deal with this is to use "or" 
instead of "||"; "or" has an extremely low precedence, so it's more 
likely to work the way you expect it to.



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

Date: 2 Apr 1997 13:51:22 GMT
From: mhm@dax.austin.ibm.com ()
Subject: Re: Perl Mail Parser Question
Message-Id: <5hto8q$138i$1@ausnews.austin.ibm.com>

Luigi Mattera (mattera@ssga.ssb.com) wrote:
:   I've been trying write a mail parser for Perl on a unix system.  It
: simply has to filter out the subject and body of the message.  I can
: get the subject using a simple /Subject: / search.  I can possibly
: catch the body for a single message, but how to do it over multiple
: messages has me stumped beyond belief.

:   Programming Perl only uses a while(<>) to loop through a
: filehandle.  I can feed through it manually with $var = <NAME>, but I
: can not differentiate the end of the message.

:   Anyone know how to do this easily?  I've read through the modules,
: and I can't find anything simple enough for what I need.

Have you tried the "mailagent" package?

--
----------------------------------------------------------------------
Michael H. Moran                  | Standard Disclaimer:  The content 
mhm@austin.ibm.com                | of this posting is independent of 
IBM Corporation, Austin, Texas    | official IBM position.


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

Date: 02 Apr 1997 09:18:45 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: hansm@icgned.nl
Subject: Re: Perl mishandles some multidimensional array references???
Message-Id: <8cwwqlz9cq.fsf@gadget.cscaper.com>

>>>>> "Hans" == Hans Mulder <Hans> writes:

Hans> In that case, what happened to the $H{list} notation for
Hans> quasi-multidimensional hashes?  Is it deprecated?  Obsolete?
Hans> Should I use HoHs instead?

It's entirely equivalent to $H{join($;, list)} = scalar, and therefore
reduces to one of the above forms.

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 516 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: 27 Mar 1997 16:03:35 GMT
From: millerb@pt9549.ped.pto.ford.com (Bryan Miller)
Subject: Re: SIGCHLD bug in 5.004Beta?
Message-Id: <5he5on$p3q3@eccws1.dearborn.ford.com>

Aaron, Penny, Jaymee Minner (badsmrfs@stratos.net) appears to have written:
>When my SIGCHLD handler executes in 5.00393, I get the following
>warning:

>  Argument "CHLD" isn't numeric in entersub at
>  /usr/local/lib/perl5/sun4-solaris/5.00393/POSIX.pm line 206.

>Any ideas what this is?

I'm getting this error too under Digital Unix.  I walked through
this with the debugger and it appears to be attempting to assign
a null string instead of a number.  I will run it again a capture
the results...

Bryan


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

Date: 2 Apr 1997 15:02:59 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Starting, Suspending, and Restarting a Child
Message-Id: <5htsf3$g85$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    armin.faltl@siemens.at writes:
:	kill $SIGSTOP $pid if $chldActive;

You mean 

    kill 'STOP', $pid if $child_active;

Note especially the comma.

--tom
-- 
	Tom Christiansen	tchrist@alumni.cs.colorado.edu
"We are starting a movement in the state legislatures...to forbid the
 installation of clinics that dispense contraceptives."
    --Phyllis Schlafly, President, Eagle Forum


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

Date: Wed, 2 Apr 1997 05:53:54 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: String substitution problem
Message-Id: <ichth5.9j.ln@localhost>

Ted Yee (ted@qp.com) wrote:
: Here's my problem:

: I have a string substitution where sometimes, some extra text in the
: replacement term will conflict with the matching term.

: ie.

: $string = "this is a test";
: $term = "is";

: $string =~ s/$term/replace with this/gi;

: The problem is that with the above example, the resulting output is:
                                                  ^^^^^^^^^^^^^^^^

There is no output resulting from the above code ;-)

If you added:

print "$string\n";

there would be some output...


: threplace with this replace with threplace with threplace with this a
: test


I do not get that when I run it...


: Now, I do have a work around but I'd like to know if there is a
: cleaner way than doing it like this:

[ snip different way ]

: This will give the desired result of:

: threplace with this replace with this a test


I get this 'desired result' from the first code.

Something else is wrong...



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


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

Date: Wed, 2 Apr 1997 11:18:21 GMT
From: Mike Jagdis <mike@roan.co.uk>
Subject: Re: Unix and ease of use (WAS: Who makes more ...)
Message-Id: <E80CqL.nr4@roan.co.uk>

Tom Wheeley said

>Bollocks.  Imagine if there were no patent laws, and Pharmacy, Ltd. discover
>paracetamol.  They would still be charging a hundred pounds per pill today;
>were it not for the _openness_ afforded by the patent system which allows
>smaller medical companies to sell boxes of 100 paracetamol tablets for 1 pound.

The "openness" usually comes when the patents expire and others are
able to produce generics without the overhead of paying license fees
to the patent holder. Patents exist to encourage invovation and
invention by granting the inventor a reasonable period to recoup
their R&D costs. This "reasonable period" is somewhat less than
reasonable in the software industry though!

>You are thinking of the software industry, where there is mis-use of copyright
>laws.  There is no glasnost after x years in this industry.

Sure there is. Copyright expires eventually. Unfortunately the
period is again far too great for the software industry :-(.

>Believe me, the patent system was designed to encourage invention and
>openness by protecting the little guy.

Patents protect *inventors*. Whether big, little, individual, corporation,
white, black, pink wih yellow spots (blobby, blobby, blobby)...

>Copyright was designed to protect authors of printed works.

I think you need to reread the Copyrights, Designs and Patents Act
(and maybe the Berne convention as well). Non-printed works are
*explicitly* covered (such as electronic storage). Computer programs
are *explicily* covered. Databases are *explicitly* covered (as an
arrangement). Computer *generated* works are *explicitly* covered
(where the legal author is the person who caused the work to be
generated).

  In fact get a good book on computer law as well. They generally
include pretty good commentaries on such aspects.

>The choice is whether you define software as
>Science (where knowledge is shared) or as literature.  The fact is that due
>to the malleability of software, it is science.

This is opinion not fact. The _fact_ is that your opinon is at odds
with existing laws. Legally software is no more science than a cheap
paperback novel - it's just an expression of some ideas in a given
language. However, some of the underlying algorithms (the ideas
being expressed) may be classed as inventions and be patentable in
one or more countries.

  My personal opinon is that professionals should know far more about
the laws under which they work than they appear to! :-)

				Mike

-- 
 .----------------------------------------------------------------------.
|  Mike Jagdis                  |  Internet:  mailto:mike@roan.co.uk   |
|  Roan Technology Ltd.         |                                      |
|  54A Peach Street, Wokingham  |  Telephone:  +44 118 989 0403        |



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

Date: Wed, 02 Apr 1997 14:54:48 +0200
From: Gard Arneson Haugen <gardh@norway.eu.net>
Subject: Re: Using Perl with MS-Access
Message-Id: <33425718.D6C@norway.eu.net>

If your scripts are runing on a nt sever you can use Win32::ODBC.

you can find info at www.roth.net/odbc

Gard

Kevin Posen wrote:
> 
> Hi.
> 
> I've been requested to use a Perl CGI script to receive data from an HTML form
> and to add this to a database maintained in MS-Access.
> 
> I have no idea where to start as I haven't used Access (or any other database
> maintenance system) much at all.
> 
> Any ideas?
> 
> Thanks,
> Kevin Posen


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

Date: 2 Apr 1997 14:10:43 GMT
From: bet@waltz.rahul.net (Bennett Todd)
Subject: Re: When is perl program too large?
Message-Id: <slrn5k4q6g.nt.bet@waltz.rahul.net>

Zenin <good.luck@getting.spam.to.zenin.at.best.com> wrote:
>	If you've got 800 lines in one file you're doing something wrong.

	; wc /usr/local/bin/mailagent
	  15913   76547  524322 /usr/local/bin/mailagent
	; file /usr/local/bin/mailagent
	/usr/local/bin/mailagent: perl commands text
	;

Now for my own coding, I'm enclined to agree with you --- I haven't written a
single file as long as 800 lines in a long, long time, and I may never do so
again. But I'm not sure I'd try to call that an absolute rule. I do like
mailagent.

-Bennett


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

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

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