[6293] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 915 Volume: 7

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Feb 8 15:13:12 1997

Date: Sat, 8 Feb 97 12:00:19 -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           Sat, 8 Feb 1997     Volume: 7 Number: 915

Today's topics:
     DDE calls under NT Perl 5 <groves@goodnet.com>
     Re: Division and Rounding (Patrick Duff)
     Re: DNS lookups in perl <rra@cs.stanford.edu>
     Emulating 'script' with perl (Ng Pek Yong)
     Re: format print produces blank pages (Brian L. Matthews)
     Re: Gregorian to Julain date conversion (Patrick Duff)
     Is this a bug in perl???  (Missing newlines) (....What Is?....)
     Re: Is this a bug in perl???  (Missing newlines) (Mike Heins)
     Re: Matt's Script: SSI Random Banner Generator <devos@knoware.nl>
     Re: Matt's Script: SSI Random Banner Generator (Shishir Gundavaram)
     Re: perl execution in xemacs? <steve@miranova.com>
     Re: Perl vs Korn Shell (Larry W. Virden)
     Re: Perl vs Korn Shell (Larry W. Virden)
     Re: program to recognize and respond to FAQ questions (Nathan V. Patwardhan)
     Re: PSCOPE - an CSCOPE for perl source (Larry W. Virden)
     Serialmio, Perl, and Win95 <user@metricom.com>
     Settle an argument - to die or not to die? <chris@ixlabs.com>
     Re: Settle an argument - to die or not to die? (Brian L. Matthews)
     Re: Settle an argument - to die or not to die? <rootbeer@teleport.com>
     Re: Shell "case" command in perl (Eric Arnold)
     Re: Slightly Nifty, but possibly dangerous perl. <rootbeer@teleport.com>
     Re: Tk: Automatic Multiple Selection in Listboxes <nick@ni-s.u-net.com>
     USING <SELECT MULTIPLE> WITH PERL FORMS (Adam M. Donahue)
     Re: USING <SELECT MULTIPLE> WITH PERL FORMS (Brian L. Matthews)
     Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)

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

Date: Fri, 07 Feb 1997 20:47:45 -0700
From: Jeff Groves <groves@goodnet.com>
Subject: DDE calls under NT Perl 5
Message-Id: <32FBF761.1413@goodnet.com>

Is there a version of perl (or a module) for NT 4.0 that will let me do
DDE calls.  Currently, I'm using Visual Basic to make DDE calls in order
to communicate with another application.

Unfortunately, most of the program does text parsing and Visual Basic
sucks at doing this kind of work.  I've spent days writing routines to
handle text, when I could do the same thing in perl in just a few hours
(or minutes).

If I could figure out how to make perl do DDE calls, my job would be
much easier.

I have a MKS perl 5.0 for NT, but I can't find any mention of DDE calls
anywhere.  Could someone offer any help?

Thanks.

Jeff


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

Date: Sat, 08 Feb 1997 03:58:30 GMT
From: pduff@airmail.net (Patrick Duff)
Subject: Re: Division and Rounding
Message-Id: <3301f816.170853519@news.airmail.net>

On 07 Feb 1997 20:00:27 +0200, Jarkko Hietaniemi <jhi@alpha.hut.fi>
wrote:

>
>> There are some numbers that can't be accurately represented in a
>> typical floating point format, and sometimes
>
>Ahem, I am not quite certain any more on my number theory but isn't it
>that _most_ numbers can't be accurately represented in a typical
>floating point format. Floating point numbers are truncated sums of
>finite series of terms of the form 2^i, that leaves all of the
>irrational and most of the rational numbers out in the cold... 1/3,
>1/5, 1/7, because of the 1/5 also 0.1, 0.01, 0.001, etc cannot be
>accurately represented, ever.  E.g. 1/10 = 1/16 + 1/32 + 1/256 + 1/512 + ...
>            ____
>that is, 0.00011 ,an endlessly repeating fractional number. No number of
>                2
>
>bits in a floating point number is ever gonna be enough to hold them all.
>The floating point numbers are convenient smoke and mirrors which work
>quite well for simple things, but often the seams show...
>
>-- 
>$jhi++;
># Jarkko Hietaniemi <URL:http://www.iki.fi/~jhi/> <URL:mailto:jhi@iki.fi>
># Lost interest?  It's so bad I've lost apathy.
># Not speaking for any past, present, or future employers.

Mathematically,  1.0 = 0.99999999999......

Here's the proof:

           10x  =  9.9999999999.....
 minus     x  =  0.9999999999.....
----------------------------------------------------
             9x =  9.0000000000.....
 so          x =   1.0000000000.....

But try this on physical hardware and you'll almost always find that
1.0 > 0.9999999999.....

-- 
regards, Patrick Duff (pduff@airmail.net)



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

Date: 07 Feb 1997 19:06:54 -0800
From: Russ Allbery <rra@cs.stanford.edu>
Subject: Re: DNS lookups in perl
Message-Id: <qumafpg6lo1.fsf@cyclone.stanford.edu>

Michael Fuhr <mfuhr@dimensional.com> writes:
> Russ Allbery <rra@cs.stanford.edu> writes:

>> It seems like reimplementing things in Perl is going to result in
>> forking and version skew between your version and BIND.  Of course, you
>> have a very good point about other platforms where libresolv isn't
>> available.

> That last sentence is the kicker.  I'd love to assume everybody has the
> Latest & Greatest BIND but alas, how many sites actually keep up with
> it?  I was hoping that the Perl version could at least provide some
> uniformity, if lacking a little in efficiency or functionality.

Well, if you're interested in more work (heh), what would be really cool
would be to have a nice, stable Perl implementation that doesn't change
all *that* often but that is portable across platforms and uniform *and*
to have a mostly C version that we could link against BIND.

-- 
Russ Allbery (rra@cs.stanford.edu)      <URL:http://www.eyrie.org/~eagle/>


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

Date: 8 Feb 1997 04:52:33 GMT
From: npekyong@mercury.starnet.gov.sg (Ng Pek Yong)
Subject: Emulating 'script' with perl
Message-Id: <5dh0qh$oj6@mercury.starnet.gov.sg>

Hi,

this is probably not a Perl question per se (more like Unix IO internals)
but I still hope someone can help me out in this.

Q1. I am trying to figure out a way to control a arbitrary child process
via perl script by taking control of the child's STDIN.

Specifically, I was thinking of:

<STDIN> --> my_perl_script --> arbitrary child process 

i.e. my_perl_script will take over all inputs from <STDIN>, process
appropriately b4 passing to the child process. 

Note: the child should be getting its input via STDIN as well.



Q2. A more complicated scenario: Bi-directional communication

<STDIN> --> my_perl_script --> arbitrary child process -->---- 
                   ^                                          |
                   |                                          |
                   ^---------<------- feedback -------<-------|
 
I am thinking of using named-pipes to do that, i.e.
 the child process will write to the named-pipes while my_perl_scripts
 will read from it. Will this cause problems?



Please ask me if anything is unclear.

Thanks in advance.


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

Date: 8 Feb 1997 07:41:04 GMT
From: blm@chinook.halcyon.com (Brian L. Matthews)
Subject: Re: format print produces blank pages
Message-Id: <5dhamg$1q0$1@brokaw.wa.com>

In article <32F79FF8.362E@atlml1.attmail.com>,
Charlie Wu  <charliew@atlml1.attmail.com> wrote:
|however, there's a ^L at the end of every page
|thanks. email reply greatly appreciated ... since it's hard to go thru
|hundreds of posts every day here - i use netscape news reader which has
|NO search capability :(

You don't bother to spend 2 minutes reading the documentation, and then
you can't be bothered to use a real newsreader or work with the one you've
got, although you obviously expect everyone else to do so. Do you want
someone to come to your house and chew your food for you too?

Brian
--
Brian L. Matthews				Illustration Works, Inc.
	For top quality, stock commercial illustration, visit:
		  http://www.halcyon.com/artstock


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

Date: Sat, 08 Feb 1997 05:55:01 GMT
From: pduff@airmail.net (Patrick Duff)
Subject: Re: Gregorian to Julain date conversion
Message-Id: <330313b9.177929135@news.airmail.net>

Here's the background & extra documentation for the &Week_Day()
function:

#All functions in this library assume that every year begins on 1
January,
#although this is historically naive.

#Dates such as 010101 need to be passed as "010101" because otherwise
the
#leading zero makes PERL think the number is octal.

#Functions in this library should properly handle all Common Era (CE
or AD)
#dates except where noted below.  BCE (or BC) dates have not been
#extensively tested, so if you use them you may want to do some manual
#checks before trusting the results.  In particular, &YYMMDD will drop
the
#leading "-" sign from negative years.  Note that there was no year 0
in
#either the BCE or the CE calendar.

#The Gregorian calendar was adopted at different times in different
#countries.  The Catholic countries of Europe accepted it in 1582, as
#decreed by Pope Gregory XIII, or shortly thereafter.  Many Protestant
#European countries switched in 1699 or 1700.  Great Britain and its
#colonies (including what later became the United States) made the
change in
#1752.  Other countries switched at various times, some as late as the
#1920s.  China started using the Gregorian calendar in 1912, but used
#different year numbers until 1949.  Prior to the Gregorian calendar,
#different countries used various dates other than January 1 as the
#beginning of the year.  There were other variations on the Julian
calendar,
#and some completely different calendars, like the French
Revolutionary
#Calendar.  The year that the calendar was changed in any country can
be
#particularly confusing, especially if the date for the beginning of
the
#year was also changed.

#If $Gregorian_Year is set to 1582, the Julian calendar is used on or
#before Thursday, 4 October 1582;  the Gregorian calendar is used on
or
#after Friday, 15 October 1582 (10 days skipped).  If $Gregorian_Year
is set
#to 1752, the Julian calendar is used on or before Wednesday, 2
September
#1752;  the Gregorian calendar is used on or after Thursday 14
September
#1752 (11 days skipped).  These are the only values for
$Gregorian_Year
#understood by the current version of this library.  The intervening
dates
#are considered illegal, since those dates were skipped over when the
#Gregorian calendar was adopted.

###########################################################################

#Global variables:

#$Gregorian_Year = 1582;   #Not a leap year, 355 days long
$Gregorian_Year = 1752;   #Not a leap year, 355 days long

if ($Gregorian_Year == 1582) {
   $Gregorian_Month = 10;
   $Julian_Day = 4;             #The last date in the Julian Calendar
   $Gregorian_Day = 15;         #The first date in the Gregorian
Calendar
};
if ($Gregorian_Year == 1752) {
   $Gregorian_Month = 9;
   $Julian_Day = 2;             #The last date in the Julian Calendar
   $Gregorian_Day = 14;         #The first date in the Gregorian
Calendar
};

#The $Base_Century and $Century_Threshold values are used by several
routines
#in this file.  They assume $Base_Century if YY > $Century_Threshold,
else
#$Base_Century + 1:
$Base_Century = 19;  #Change this to 20 in 2050!
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
$Century_Threshold = substr(($year+50),-2);  #Sliding 100-year window

#Verify assumptions:
if ($year > 99) {  #"localtime" may change to four-digit years someday
   die "Warning: localtime() now returns four-digit years!\n";
};
if ($year == 50) {  #Change 50 to 49 to disable warning in XX50
   print "Change \$Base_Century from \"",$Base_Century,"\" to \"",
         ($Base_Century+1),"\" in week_day.pl!\n";
};

#              0  1  2  3  4  5  6  7  8  9 10 11 12
@Month_Days = (0,31,28,31,30,31,30,31,31,30,31,30,31);
#Note:  The count for February does not include a leap day, if any.

@Day_Names = ('Sunday',  #'Sunday' is at index 0 AND index 7 for
convenience

'Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday');

@Month_Names = ('MONTH INDEX SHOULD NEVER BE 0',
   'January', 'February', 'March', 'April', 'May', 'June',
   'July', 'August', 'September', 'October', 'November', 'December');



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

Date: 8 Feb 1997 06:35:48 GMT
From: whatis@nic.cerf.net (....What Is?....)
Subject: Is this a bug in perl???  (Missing newlines)
Message-Id: <5dh6s4$dnl@news.cerf.net>

Here's the program:

------------------------------------------------------------------------
#!/usr/local/bin/perl5

@words = (
	'One',
	'Two',
	'Three',
	'Four',
	'Five',
	'Six',
	'Seven',
);

print (join "\n", (sort @words)), "\n\n";
print STDOUT (join "\n", (sort @words)), "\n\n";
------------------------------------------------------------------------

And here's the output:

------------------------------------------------------------------------
Five
Four
One
Seven
Six
Three
TwoFive
Four
One
Seven
Six
Three
Two

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

Why are those two newlines being ignored when I use "print" but they
show up just fine when I use "print STDOUT"?

I tested this under perl5.002 under SunOS 4.1.4 and perl5.003 under
SunOS 5.5.1 and Linux 1.2.3, and it behaves the same.

Steven Boswell
whatis@yyz.com
<http://www.cerfnet.com/~whatis/>


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

Date: 8 Feb 1997 07:35:57 GMT
From: mheins@prairienet.org (Mike Heins)
Subject: Re: Is this a bug in perl???  (Missing newlines)
Message-Id: <5dhact$sac@vixen.cso.uiuc.edu>

 ....What Is?.... (whatis@nic.cerf.net) wrote:
: Here's the program:
: 
: ------------------------------------------------------------------------
: #!/usr/local/bin/perl5

Your problem -- no -w.  Run with that and realize it is a bee in
your bonnet, not a bug in Perl.  Do you think something this basic
could have gotten through all those updates?



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

Date: Sat, 08 Feb 1997 04:25:49 +0100
From: Peter de Vos <devos@knoware.nl>
Subject: Re: Matt's Script: SSI Random Banner Generator
Message-Id: <32FBF23D.18C8@knoware.nl>

Try <!--#exec cgi="ssi_rand_image.cgi" --> in stead of 
<!--#exec cgi="ssi_rand_image.cgi"-->. The space between the final 
" and the - is important.


Thomas J. Forbes wrote:
> 
> I am trying to get Matt's Random Banner Generator with Server Side
> Includes running. This is my first attempt at SSI, I get the message:
> [an error occurred while processing this directive]. The line in my
> shtml file reads <!--#exec cgi="ssi_rand_image.cgi"--> and is located
> at http://www.medstore.com/ads2/forsalead.shtml.
> 
> The banner images are in ads2/banners and the cgi file is in the ads2
> directory. Here is the script, with the modified variables:
> 
> #!/usr/bin/perl
> ##############################################################################
> # SSI Random Image Displayer    Version 1.2
> #
> # Copyright 1996 Matt Wright    mattw@worldwidemart.com
> #
> # Created 7/1/95                Last Modified 11/4/95
> #
> # Scripts Archive at:           http://www.worldwidemart.com/scripts/
> #
> ##############################################################################
> # COPYRIGHT NOTICE
> #
> # Copyright 1996 Matthew M. Wright  All Rights Reserved.
> #
> #
> #
> # SSI Random Image may be used and modified free of charge by anyone
> so      #
> # long as this copyright notice and the comments above remain intact.
> By    #
> # using this this code you agree to indemnify Matthew M. Wright from
> any     #
> # liability that might arise from it's use.
> #
> #
> #
> # Selling the code for this program without prior written consent is
> #
> # expressly forbidden.  In other words, please ask first before you
> try and  #
> # make money off of my program.
> #
> #
> #
> # Obtain permission before redistributing this software over the
> Internet or #
> # in any other medium.  In all cases copyright and header must remain
> intact.#
> ##############################################################################
> # Define Variables
> 
> $basedir = "http://www.medstore.com/ads2/banners/";
> 
> @images =
> ("ama.gif","cai.gif","gms.gif","labquip.gif","meddepot.gif","mee.gif","mis.gif","mmr.gif","open.gif","tfsrehab.gif");
> 
> @urls = ("http://www.medstore.com/assetmgmt/",
>          "http://www.medstore.com/cai/",
>          "http://www.medstore.com/gms/",
>          "http://www.medstore.com/labquip/",
>          "http://www.medstore.com/meddepot/",
>          "http://www.medstore.com/mee/",
>          "http://www.medstore.com/mis/",
>          "http://www.medstore.com/mmr/",
>          "http://www.medstore.com/join.htm",
>          "http://www.medstore.com/tfsrehab/");
> 
> @alt = ("Your MedStore or MedMart Web site includes your company
> banner HERE!",
>         "Your MedStore or MedMart Web site includes your company
> banner HERE!",
>         "Your MedStore or MedMart Web site includes your company
> banner HERE!",
>         "Your MedStore or MedMart Web site includes your company
> banner HERE!",
>         "Your MedStore or MedMart Web site includes your company
> banner HERE!",
>         "Your MedStore or MedMart Web site includes your company
> banner HERE!",
>         "Your MedStore or MedMart Web site includes your company
> banner HERE!",
>         "Your MedStore or MedMart Web site includes your company
> banner HERE!",
>         "Your MedStore or MedMart Web site includes your company
> banner HERE!",
>         "Your MedStore or MedMart Web site includes your company
> banner HERE!");
> 
> ##############################################################################
> # Options
> $uselog = "0";            # 1 = YES; 0 = NO
>    $logfile = "/path/to/log/file";
>    $date = `/usr/bin/date`; chop($date);
> 
> $link_image = "1";        # 1 = YES; 0 = NO
> $align = "middle";
> $border = "2";
> 
> # Done
> ##############################################################################
> 
> srand(time ^ $$);
> $num = rand(@images); # Pick a Random Number
> 
> # Print Out Header With Random Filename and Base Directory
> print "Content-type: text/html\n\n";
> if ($link_image eq '1' && $urls[$num] ne "") {
>    print "<a href=\"$urls[$num]\">";
> }
> 
> print "<img src=\"$basedir$images[$num]\"";
> if ($border ne "") {
>    print " border=$border";
> }
> if ($align ne "") {
>    print " align=$align";
> }
> if ($alt[$num] ne "") {
>    print " alt=\"$alt[$num]\"";
> }
> print ">";
> 
> if ($link_image eq '1' && $urls[$num] ne "") {
>    print "</a>";
> }
> 
> print "\n";
> 
> # If You want a log, we add to it here.
> if ($uselog eq '1') {
>    open(LOG, ">>$logfile");
>    print LOG "$images[$num] - $date - $ENV{'REMOTE_HOST'}\n";
>    close(LOG);
> }
> 
> I'm stuck. I have not modified the script in any way, and I checked
> the syntax with perl -c, all checked OK.
> 
> I set the permissions as follows:
> 
> perl script - chmod 755
> forsalead.shtml - chmod 777
> ads2 and ads2/banners directories - chmod 777
> 
> Anyone have an idea? I can't seem to figure this one out.
> 
> Thanks for looking,
> 
> TOM FORBES


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

Date: 8 Feb 1997 06:41:40 GMT
From: shishir@ruby.ora.com (Shishir Gundavaram)
To: shishir@ora.com
Subject: Re: Matt's Script: SSI Random Banner Generator
Message-Id: <5dh774$m8l@amber.ora.com>

Thomas J. Forbes (tforbes@ix.netcom.com) wrote:
: I am trying to get Matt's Random Banner Generator with Server Side
: Includes running. This is my first attempt at SSI, I get the message:
: [an error occurred while processing this directive]. The line in my
: shtml file reads <!--#exec cgi="ssi_rand_image.cgi"--> and is located
: at http://www.medstore.com/ads2/forsalead.shtml.
: 
: The banner images are in ads2/banners and the cgi file is in the ads2
: directory. Here is the script, with the modified variables:

First, this is not a CGI newsgroup. Please post to: c.i.w.authoring.cgi.

OK, having said that, here are some suggestions. You say that the CGI
program is in the ads2 directory. Is the Web server configured to
recognize this as a CGI directory or configured to recognize
the ".cgi" extension as a CGI application?

_IF_ you do have your server configured properly, then try using
a virtual path to the CGI program, instead of a relative one. In other
words, don't use:

    <!--#exec cgi="ssi_rand_image.cgi"--> 

but, instead, use:

    <!--#exec cgi="/ads2/ssi_rand_image.cgi"--> 

--Shishir


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

Date: 08 Feb 1997 11:07:43 -0800
From: Steven L Baur <steve@miranova.com>
Subject: Re: perl execution in xemacs?
Message-Id: <m2zpxft8u8.fsf@altair.xemacs.org>

Nigel Byrnes writes:

> hi
> I think the subject says it all really. I want to be able to execute
> perl programs from my xemacs window. If poss., how do i do it?

I'm not sure what you mean.  You can execute anything by using the
`M-!' command.  You can run the perl debugger in XEmacs with perldb:

C-h f perldb
perldb: an interactive autoloaded Lisp function.
  -- loads from "gud".
Run perldb on program FILE in buffer *gud-FILE*.
The directory containing FILE becomes the initial working directory
and source-file directory for your debugger.

-- 
steve@miranova.com baur
Unsolicited commercial e-mail will be billed at $250/message.


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

Date: 8 Feb 1997 01:57:49 -0500
From: lwv26@cas.org (Larry W. Virden)
Subject: Re: Perl vs Korn Shell
Message-Id: <5dh85d$o93@csa21s4m.cas.org>


According to Neil S. Briscoe <neilb@zetnet.co.uk>:
:You have asked the same question in comp.lang.korn have you?  What do you
:mean "There isn't such a news group!"?

You mispelled it - its <URL:news:comp.unix.shell>.

-- 
Larry W. Virden                 INET: lvirden@cas.org
<URL:http://www.teraform.com/%7Elvirden/> <*> O- "We are all Kosh."
Unless explicitly stated to the contrary, nothing in this posting should
be construed as representing my employer's opinions.


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

Date: 8 Feb 1997 02:00:51 -0500
From: lwv26@cas.org (Larry W. Virden)
Subject: Re: Perl vs Korn Shell
Message-Id: <5dh8b3$oc6@csa21s4m.cas.org>


According to Ed King <kinge@oklahoma.net>:
:bread.  I want to know if Korn shell scripting or Perl is more
:versatile.  If I just want to invest time learning one which one should
:it be and why.

Two answers:

1. Perl is in most cases considered more versatile.

2. However, "[i]f [you] just want to invest time learning one", I 
recomment Korn shell.

The reason - because once you know korn shell, you can control the
interactive mode you most frequently use to talk to unix.  Korn shell
is what your .profile will be as well as the language that you will use
at the command line.

-- 
Larry W. Virden                 INET: lvirden@cas.org
<URL:http://www.teraform.com/%7Elvirden/> <*> O- "We are all Kosh."
Unless explicitly stated to the contrary, nothing in this posting should
be construed as representing my employer's opinions.


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

Date: 8 Feb 1997 05:46:51 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: program to recognize and respond to FAQ questions
Message-Id: <5dh40b$ar3@fridge-nf0.shore.net>

Tom Fawcett (fawcett@nynexst.com) wrote:

: About six months ago in a fit of idleness I started coding a Perl script to
: respond to FAQ postings.  It would scan comp.lang.perl.misc postings,

I thought Tom C was doing this?

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: 8 Feb 1997 01:51:53 -0500
From: lwv26@cas.org (Larry W. Virden)
Subject: Re: PSCOPE - an CSCOPE for perl source
Message-Id: <5dh7q9$o1j@csa21s4m.cas.org>


Cscope is an interactive C code variable browser.  It provides a
quick way to display all the places variables, symbols, and functions
are used within a series of source files.  It distinguishes between
C code and comments and only shows you string matches in comments
when you specifically request them.

It allows you to go immediately to any occurance of a symbol, change
one or more occurances of a symbol to some new symbol, etc[
-- 
Larry W. Virden                 INET: lvirden@cas.org
<URL:http://www.teraform.com/%7Elvirden/> <*> O- "We are all Kosh."
Unless explicitly stated to the contrary, nothing in this posting should
be construed as representing my employer's opinions.


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

Date: Sat, 08 Feb 1997 00:13:32 -0600
From: user <user@metricom.com>
Subject: Serialmio, Perl, and Win95
Message-Id: <32FC198B.1FCC@metricom.com>

This might be a redundant question...
But here it goes.

Somwehere in the countless e-mails and postings, I remember someone
describing a way of accessing serial ports on a PC using perl.
I've tried the following as a test without conclusive results:

open (PORT, "+<COM1") || die "Cannot open port ";
print "open port 1 \n";
for($i=1; $i<=5; $i++){
  print PORT "=at\n";
  $count= read(PORT, $hello, 2);
  print "output sent\n";
  $count= read(PORT, $hello, 2);
  print "port read\n";
  print $hello;
}


Has anybody had good results attempting to use serial ports via perl?
If so, How?

Thanks
-jose


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

Date: Fri, 07 Feb 1997 20:34:49 -0800
From: Chris Schoenfeld <chris@ixlabs.com>
Subject: Settle an argument - to die or not to die?
Message-Id: <32FC0269.4C33@ixlabs.com>

I write a lot of large-scale CGI tied to databases and the like.

I prefer to print a nice HTML message and die when I trap an bad error,
that is, an error where something has definitely gone wrong, and the
output will suffer at the least.

My boss's error handler does not die - he says that's bad practice. I
think he's nuts. He puts up a message and lets the script run.(In the
event the script dies on it's own, we do trap it and put up a message.)

Who is right? Is it better to let the script run free with unpredictable
results, or to shut down? 

If I'm right, I need some good, well-founded ammunition.

-- 
Chris Schoenfeld
IX Development Laboratories   
Santa Rosa, California
(707)-543-8030 Ext. 12


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

Date: 8 Feb 1997 08:13:07 GMT
From: blm@chinook.halcyon.com (Brian L. Matthews)
Subject: Re: Settle an argument - to die or not to die?
Message-Id: <5dhcij$564$1@brokaw.wa.com>

In article <32FC0269.4C33@ixlabs.com>,
Chris Schoenfeld  <chris@ixlabs.com> wrote:
|My boss's error handler does not die - he says that's bad practice. I
|think he's nuts. He puts up a message and lets the script run.(In the
|event the script dies on it's own, we do trap it and put up a message.)

Although I don't think one can give a general answer that works in
all cases, it does seem fairly dangerous to let a script run when
something has gone wrong. Here's an extreme example:

$dir = '/';

#
# Do something that should set $dir, but if something goes wrong
# leaves it unmodified.
#

system "rm -rf $dir";

Obviously if something does go wrong and $dir remains unchanged,
you don't want it to get to the system.

Again, this is an extreme example, but it's not inconceivable that
if some sort of error occurs, wrong values could be written to a
file or output or something.

Brian
--
Brian L. Matthews				Illustration Works, Inc.
	For top quality, stock commercial illustration, visit:
		  http://www.halcyon.com/artstock


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

Date: Sat, 8 Feb 1997 10:49:35 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Chris Schoenfeld <chris@ixlabs.com>
Subject: Re: Settle an argument - to die or not to die?
Message-Id: <Pine.GSO.3.95.970208103350.9417G-100000@kelly.teleport.com>

On Fri, 7 Feb 1997, Chris Schoenfeld wrote:

> I prefer to print a nice HTML message and die when I trap an bad error,
> that is, an error where something has definitely gone wrong, and the
> output will suffer at the least.
> 
> My boss's error handler does not die - he says that's bad practice. I
> think he's nuts. He puts up a message and lets the script run.(In the
> event the script dies on it's own, we do trap it and put up a message.)
> 
> Who is right? Is it better to let the script run free with unpredictable
> results, or to shut down? 

I sometimes liken this to the experience of driving to the grocery store. 
Some people, like your boss, wait until they get there to clean any dead
pedestrians off of the front bumper, while people like you prefer to stop
at the scene of the accident. 

Of course, I advocate your method. If you drag a pedestrian for very far,
it's likely to cause you more trouble down the road.

But your boss may be worried that users of your script will be left
stranded when your script quits unexpectedly. To handle that, you may want
to use a custom &my_die routine (or __DIE__ handler) which can park in a
safe place, turn on the emergency blinkers, and announce to passers-by
what they can do to help.

Happy travels!

-- 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: 8 Feb 97 06:03:45 GMT
From: eric.arnold@sun.com (Eric Arnold)
Subject: Re: Shell "case" command in perl
Message-Id: <ERIC.97Feb08060345@m-e-ir1.sun.com>

In article <5d4jmk$onc@leech.urbi.com.br>
	perisse@urbi.com.br (Jan-Patrick Perisse Sys. Admin) writes:

>How would a bash "case" look like in perl?
> I've been reading the book and found nothing about it.
>
>
>
>--
>/Jan-Patrick Perisse       /e-mail: perisse@urbi.com.br
>\    Urbi Network         \  Url&PGP key:www.urbi.com.br/perisse
> \Internet Service Provider\  Voice: +55-21-610-4756 | Fax: +55-21-610-4758 
>  \   System Administrator  \  Pager: +55-21-546-1636 #7002196


I posted this a while ago.  I can't decide whether it's a significant 
savings over the usual Perl idiom (see follow up postings).

-Eric


#                             switch/case emulator
#
# Use:
#
#   switch $val, q{
#     case 13 :          {  ...code block...};
#     case "string" :    {  ...code block...};
#     case 'string' :    {  ...code block...};
#     case /regex.*/ :   {  ...code block...};
#     case m{regex.*} :  {  ...code block...};
#
#     # default stuff goes here
#   };
#
# "...code block..." can contain a "last" statement which will break out
# of the switch (a { } block is automatically placed around all the case
# statements).
#
# It relies on the occurrence of ": {" to delimit where the conditional
# ends and the code block begins, so if you have this sequence anywhere
# else, "switch"'s parsing will fail, and a syntax error will result.
#
# Warrenty:  *free code*
#
# - Eric.Arnold@Sun.COM



package Switch;

require Exporter;
@ISA = qw( Exporter );
@EXPORT = qw( switch );

sub switch{
  my( $val, $code_str ) = @_;
  my( $caller_pkg ) = caller;

  $code_str =~ s/^(\s*)case\s+(.*?)\s*:\s*(?=\{)/case_reformat($1,$2)/meg;

  my $s = qq{
    package $caller_pkg;
    \$__switch_arg = '$val';
    {
      $code_str
    }

  };

  #print "evaling: ($s)\n";
  eval $s;
}


sub case_reformat{
  my( $padding, $test ) = @_;

  #print "test=($test)\n";

  if ( $test =~ /^\d+$/ )
  {
    $ret = "\$__switch_arg == $test";
  }
  elsif ( $test =~ /^['"]/ )
  {
    $ret = "\$__switch_arg eq $test";
  }
  elsif ( $test =~ /^[m\/]/ )
  {
    $ret = "\$__switch_arg =~ $test";
  }

  return "$padding$ret and do";
}


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

Date: Fri, 7 Feb 1997 20:44:33 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Graham Bignell <bignell@netcom.ca>
Subject: Re: Slightly Nifty, but possibly dangerous perl.
Message-Id: <Pine.GSO.3.95.970207203606.25553A-100000@linda.teleport.com>

On Fri, 7 Feb 1997, Graham Bignell wrote:

> in conf.cf
> 
> 	sub foo {
> 	"
> 	This is just a bit of text \
> 	that will span lines. $bar \
> 	blahblahblahblah
> 	";
> 	}

What are those backslashes doing in there? 

> in foo.pl
> 
> 	require "conf.cf";
> 
> 	$bar = "BAR";
> 	print &foo;
> 
> Can anyone think of any dangers involved with using functions like this?

If some function makes a local($bar), you may find something surprising
happening. (For that matter, you may be surprised by a my($bar) as well.) 

> Also, I am assuming this works because perl is returning the last
> assignment to $_ instead of a return code or nothing at all, will this
> work in future versions of perl? 

A subroutine's return value is the last expression evaluated. It has
nothing to do with $_, which is unsurprising since your code never
mentioned that variable. 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: Sat, 08 Feb 1997 10:56:43 +0000
From: Nick Ing-Simmons <nick@ni-s.u-net.com>
To: edwardsfv@mindspring.com
Subject: Re: Tk: Automatic Multiple Selection in Listboxes
Message-Id: <32FC5BEB.64B0@ni-s.u-net.com>

Dana & Jennifer Edwards wrote:
> 

> 
> Here is some sample code I've tried.  Tk complains that "-state" is an
> unknown option for a listbox:
> foreach(@array) {
>         if (/some_pattern/) {
>                 $listbox_widget -> insert('end',$_);
>                 # Somehow I'd like to configure the item just inserted as "selected"
>                 # and not the entire listbox as follows (which is illegal anyhow)
>                 $listbox_widget -> configure(-state => 'selected');
>         }
> }
> 
> The selection type is set to 'multiple' during the creation of the
> listbox widget.  If anyone can help me, I would really appreciate it!

RTFM :-)

  $listbox->select(...)


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

Date: 7 Feb 1997 23:50:01 GMT
From: donahue@acf2.nyu.edu (Adam M. Donahue)
Subject: USING <SELECT MULTIPLE> WITH PERL FORMS
Message-Id: <5dgf39$8k0$1@news.nyu.edu>

How do you get ALL the data from a multiple SELECT form?  Using a perl
script with a standard call to $FORM{'favorites'} say, where I want the
user to choose three of fifty options using the CTRL key, how do you
extract this data?  The $FORM{'favorites'} only returns one (the last I
believe) choice selected from the list.

Any help would be appreciated!  Mail me personally if you can.

Thanks!

Adam

-- 
Adam Donahue			 		        400 Broome Street
 Distributed Computing & 				     Suite 410-B
  Information Services			   	     New York, NY 10013 
   New York University		 		 Cyber-Guru Consulting 
    mailto:adam.donahue@nyu.edu	       mailto:headguru@cyber-guru.com 


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

Date: 8 Feb 1997 07:52:31 GMT
From: blm@chinook.halcyon.com (Brian L. Matthews)
Subject: Re: USING <SELECT MULTIPLE> WITH PERL FORMS
Message-Id: <5dhbbv$57u$1@brokaw.wa.com>

In article <5dgf39$8k0$1@news.nyu.edu>,
Adam M. Donahue <donahue@acf2.nyu.edu> wrote:
|The $FORM{'favorites'} only returns one (the last I
|believe) choice selected from the list.

Only if you're using badly broken code to decode the form data.
Check out libwww or CGI.pm, available at your local CPAN.

Brian
--
Brian L. Matthews				Illustration Works, Inc.
	For top quality, stock commercial illustration, visit:
		  http://www.halcyon.com/artstock


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

Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Jan 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.

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 V7 Issue 915
*************************************

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