[18393] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 561 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Mar 25 00:05:44 2001

Date: Sat, 24 Mar 2001 21:05:17 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <985496716-v10-i561@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 24 Mar 2001     Volume: 10 Number: 561

Today's topics:
    Re: 3D objects for download msouth@fulcrum.org
    Re: A very simple question.... (Martin Vorlaender)
        Array question? (n by n) <milliwave@rfengineering.freeserve.co.uk>
    Re: Array question? (n by n) <joe+usenet@sunstarsys.com>
    Re: Array question? (n by n) (Logan Shaw)
    Re: array vs. array question <wuerz@yahoo.com>
    Re: C++ call <gus@black.hole-in-the.net>
    Re: C++ call <cliff@rayman.com>
        Can Someone Explain This, Please? (Tom Hoffmann)
    Re: Can Someone Explain This, Please? <info@fruiture.de>
    Re: Can Someone Explain This, Please? (Tom Hoffmann)
    Re: Can Someone Explain This, Please? (Gwyn Judd)
    Re: CGI style - CGI vs "here is" vs ?? <mnemotronic@mind\no-spam/spring.com>
        converting cgi-lib to cgi.pm <todd@mrnoitall.com>
    Re: Does a Perl code generator for web databases exist  <ron@savage.net.au>
    Re: Does a Perl code generator for web databases exist  <ron@savage.net.au>
    Re: Eazel and DB_File <s1sims@home.com>
        Help with syntax error <newuser@nospam.slip.net>
        Help with syntax error <newuser@nospam.slip.net>
    Re: Help with syntax error (Gwyn Judd)
    Re: Help with syntax error <newuser@nospam.slip.net>
    Re: How adding Hours & Days to current date? <"al<NoSpam>sorrell"@yahoo.com>
    Re: QUE: Serial port interrupt handling from perl (Bbirthisel)
    Re: require'ing OO modules on the fly - any danger? <goldbb2@earthlink.net>
    Re: Routine to Color-Code Java/C/C++ Code <goldbb2@earthlink.net>
    Re: Running another perl script from a script? <gtoomey@usa.net>
    Re: Script mysteriously erases file it's supposed to ap <goldbb2@earthlink.net>
    Re: Still can't die with Tar <goldbb2@earthlink.net>
        the space (cljlk)
    Re: the space <info@fruiture.de>
    Re: the space (cljlk)
    Re: the space (Martien Verbruggen)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 25 Mar 2001 00:44:45 GMT
From: msouth@fulcrum.org
Subject: Re: 3D objects for download
Message-Id: <99jf1t$9mb$1@inxs.ncren.net>

nina.ahlberg <nina.ahlberg@ntlworld.com> wrote:
> please help me! where can I download 3 objects , such as chairs tables,
> sofas and so on, i have tried already 3D cafe, anu other useful websites??
> Thank you!!
> Nina

you mean like on that commercial where they get scuba fins out of their
printer?  that was just a special effect.  So far, we can only transfer
information through the net.  

However, your optimism is appreciated.

-- 
Michael South                   |   http://fulcrum.org
Head Mathophile,                |   101 Canyon Run
fulcrum.org                     |   Cary NC  27513 USA
(msouth@fulcrum.org)            |   (919) 465-9074


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

Date: Sat, 24 Mar 2001 12:53:39 +0100
From: martin@radiogaga.harz.de (Martin Vorlaender)
Subject: Re: A very simple question....
Message-Id: <3abc8ac3.524144494f47414741@radiogaga.harz.de>

Laurie Muench (lamuench@home.com) wrote:
> > trying to write to the file:
> >  /photo/family/album.htm
> > from:
> > /photo/cgi-bin/family/submit.cgi
> > and I do not know the correct way to reference it.
>
> Nevermind.  I figured it out.  I am too used to Windows.
> "../../family/album.htm" is what I wanted.

The default directory the script starts in isn't covered by the CGI
standard. So your relative path could fail with some configurations
(webserver software, and locations of the script; most notably IIS when
the script is in a subdirectory of the CGI directory). It's better to
let perl determine the path to the script, and work from there: Insert

  use FindBin ();

at the top of your script, and address the file like

  "$FindBin::Bin/../../family/album.htm"

cu,
  Martin
-- 
One OS to rule them all       | Martin Vorlaender  |  VMS & WNT programmer
One OS to find them           | work: mv@pdv-systeme.de
One OS to bring them all      |   http://www.pdv-systeme.de/users/martinv/
And in the Darkness bind them.| home: martin@radiogaga.harz.de


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

Date: Sat, 24 Mar 2001 23:36:26 -0000
From: "Milliwave" <milliwave@rfengineering.freeserve.co.uk>
Subject: Array question? (n by n)
Message-Id: <99jauk$i03$1@news6.svr.pol.co.uk>

I have written the following code in perl, why does this code not work? It
compiles ok!, but does not
print the table[0][1] or any other combination ex: table[1][1]

 In the code below the variables hold information like
 1 two hello 3 4 56 70

     The Code
     -------------

        my @array;
        @array = "$table_call_no $table_cell_type $table_cell_name
$table_xmin $table_ymin $table_xmax $table_ymax");
        push @table, [ @array ];
        print $table[0][1];


""I would like to see""
  print $table[0][1],
  to print     two




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

Date: 24 Mar 2001 18:48:15 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Array question? (n by n)
Message-Id: <m3wv9ebuf4.fsf@mumonkan.sunstarsys.com>

"Milliwave" <milliwave@rfengineering.freeserve.co.uk> writes:

>  In the code below the variables hold information like
>  1 two hello 3 4 56 70
> 
>      The Code
>      -------------
> 
>         my @array;
>         @array = "$table_call_no $table_cell_type $table_cell_name
> $table_xmin $table_ymin $table_xmax $table_ymax");
                                                 ^^

looks like a syntax error there. Try this instead

  @array = (
            $table_call_no,     # 1
            $table_cell_type,   # two
            $table_cell_name,   # hello
            $table_xmin,        # 3
            $table_ymin,        # 4
            $table_xmax,        # 56
            $table_ymax,        # 70
           );

>         push @table, [ @array ];
>         print $table[0][1];
> 
> 
> ""I would like to see""
>   print $table[0][1],
>   to print     two

Be sure that $table_cell_type eq 'two' then.

-- 
Joe Schaefer             "Life is just one damn thing after another."
                                               --Mark Twain


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

Date: 24 Mar 2001 18:35:03 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Array question? (n by n)
Message-Id: <99jefn$9tf$1@boomer.cs.utexas.edu>

In article <99jauk$i03$1@news6.svr.pol.co.uk>,
Milliwave <milliwave@rfengineering.freeserve.co.uk> wrote:
>I have written the following code in perl, why does this code not work? It
>compiles ok!, but does not
>print the table[0][1] or any other combination ex: table[1][1]
>
> In the code below the variables hold information like
> 1 two hello 3 4 56 70
>
>     The Code
>     -------------
>
>        my @array;
>        @array = "$table_call_no $table_cell_type $table_cell_name
>$table_xmin $table_ymin $table_xmax $table_ymax");
>        push @table, [ @array ];
>        print $table[0][1];
>
>
>""I would like to see""
>  print $table[0][1],
>  to print     two

A string with spaces in it is NOT the same thing as an array.

If I do this:

	@a = "x y z";

I will end up with an array with one element.  That element will
be the string "x y z".

If you want that to be an array with three elements, you need to do this:

	@a = ("x", "y", "z");

Your code is creating the Perl version of a two-dimensional array,
one of the dimensions is always size one.  You should do something like
this intead:

	my @array;
	@array = ($table_call_no, $table_cell_type, $table_cell_name,
		$table_xmin, $table_ymin, $table_xmax, $table_ymax);
	push @table, [ @array ];
	print $table[0][1];

Or, to make it simpler, do this:

	push @table, [ $table_call_no, $table_cell_type, $table_cell_name,
		$table_xmin, $table_ymin, $table_xmax, $table_ymax ];
	print $table[0][1];

Hope that helps.

  - Logan
-- 
whose?  my  your   his  her   our   their   _its_
who's?  I'm you're he's she's we're they're _it's_


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

Date: Sun, 25 Mar 2001 03:25:06 +0100
From: Mona Wuerz <wuerz@yahoo.com>
Subject: Re: array vs. array question
Message-Id: <250320010325062329%wuerz@yahoo.com>

In article <slrn9bq39s.l7k.abigail@tsathoggua.rlyeh.net>,
abigail@foad.org (Abigail) wrote:

> Mona Wuerz (wuerz@yahoo.com) wrote on MMDCCLXII September MCMXCIII in
> <URL:news:240320011758504182%wuerz@yahoo.com>:
>
> $$ But while I can do that by hand, I'm not aware of a perl function that
> $$ performs binary searches. Is there something like that?
> 
> 
> If you mean, is there a Perl primitive, then no. But it's easy to
> write it yourself:

Yeah, that's what I meant when I said 'do it by hand' :) My attempt
looked mostly the same, even though I had an embarrassing 
(-1)**($word lt $list[$index]) in there instead of cmp. (argh) Practice
makes perfect.

-mona


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

Date: Sat, 24 Mar 2001 18:29:38 GMT
From: Gus <gus@black.hole-in-the.net>
Subject: Re: C++ call
Message-Id: <985458578.26270.0.nnrp-08.c29f015a@news.demon.co.uk>

In comp.lang.perl.moderated Eduard Grinvald <eg344@nyu.edu> wrote:
> is there any way to execute calls to a c++ method and store the return value
> from inside a perl script?
> The method is located in a precompiled library.

Yes, there is. Get a copy of SWIG from www.swig.org and write an interface
library (it's very straightforward) and link with the library you mention.




-- 
gus@black.hole-in-the.net
0x58E18C6D
82 AA 4D 7F D8 45 58 05  6D 1B 1A 72 1E DB 31 B5
http://black.hole-in-the.net/gus/


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

Date: Sat, 24 Mar 2001 22:00:48 GMT
From: ___cliff rayman___ <cliff@rayman.com>
Subject: Re: C++ call
Message-Id: <3ABD17A2.AD8E4E86@rayman.com>

check out Inline::CPP
http://search.cpan.org/search?dist=Inline-CPP

this is a solid module.  good chance it will eventually
be included in the perl core.

Eduard Grinvald wrote:

> is there any way to execute calls to a c++ method and store the return value
> From inside a perl script?
> The method is located in a precompiled library.


-- 
_____cliff_rayman_____cliff_@_rayman_._com_____


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

Date: Sun, 25 Mar 2001 00:27:04 GMT
From: tom.hoffmann@worldnet.att.net (Tom Hoffmann)
Subject: Can Someone Explain This, Please?
Message-Id: <slrn9bqeks.ls.tom.hoffmann@localhost.localdomain>

Quite often I want to do a substitution in a string while preserving
the original value, so I do:

$string = 'This is a 4321 string';
$digits = $string;
$digits =~ s/.+?(\d+).+/$1/;
print "STRING=$string\n";
print 'DIGITS=$digits\n";

to get:
STRING=This is a 4321 string
DIGITS=4321


I found in the Cookbook that I can combine this as:

($digits = $string) =~ s/.+?(\d+).+/$1/;
print "STRING=$string\n";
print 'DIGITS=$digits\n";

to get:
STRING=This is a 4321 string
DIGITS=4321

Okay, great. However, if I eliminate the parenthesis:

$digits = $string =~ s/.+?(\d+).+/$1/;
print "STRING=$string\n";
print 'DIGITS=$digits\n";

I get:
STRING=4321
DIGITS=1

I understand why $string gets reset to '4321', but why does $digits get
set to '1', and not '4321'?


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

Date: Sun, 25 Mar 2001 01:32:43 +0100
From: "fruiture" <info@fruiture.de>
Subject: Re: Can Someone Explain This, Please?
Message-Id: <99jem7$t25$1@Merlin.et.bocholt.fh-gelsenkirchen.de>

Tom Hoffmann <tom.hoffmann@worldnet.att.net> wrote:
>...
> Okay, great. However, if I eliminate the parenthesis:
>
> $digits = $string =~ s/.+?(\d+).+/$1/;
> print "STRING=$string\n";
> print 'DIGITS=$digits\n";
>
> I get:
> STRING=4321
> DIGITS=1
>
> I understand why $string gets reset to '4321', but why does $digits get
> set to '1', and not '4321'?

beforehand: i hope my english is not too bad
second: noew $digits gets the number of matches.
first ``$string =~ s/.+?(\d+).+/$1/;'' is evaluated, there was 1 match and
 that is the value to be returned to $digits afterwards...

i hope you understand...i'm from .de

--
do something for your health
______fruiture.de___yeah!_





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

Date: Sun, 25 Mar 2001 01:48:48 GMT
From: tom.hoffmann@worldnet.att.net (Tom Hoffmann)
Subject: Re: Can Someone Explain This, Please?
Message-Id: <slrn9bqje6.ra.tom.hoffmann@localhost.localdomain>

On Sun, 25 Mar 2001 01:32:43 +0100, fruiture <info@fruiture.de> wrote:
>
>beforehand: i hope my english is not too bad
>second: noew $digits gets the number of matches.
>first ``$string =~ s/.+?(\d+).+/$1/;'' is evaluated, there was 1 match and
> that is the value to be returned to $digits afterwards...
>
>i hope you understand...i'm from .de

Yes I do understand ... thanks, And BTW, your english is much better
than my danish :)
>
>--
>do something for your health
>______fruiture.de___yeah!_
>
>
>


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

Date: Sun, 25 Mar 2001 02:30:36 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Can Someone Explain This, Please?
Message-Id: <slrn9bqm2a.j82.tjla@thislove.dyndns.org>

I was shocked! How could Tom Hoffmann <tom.hoffmann@worldnet.att.net>
say such a terrible thing:
>On Sun, 25 Mar 2001 01:32:43 +0100, fruiture <info@fruiture.de> wrote:
>>
>>beforehand: i hope my english is not too bad
>>second: noew $digits gets the number of matches.
>>first ``$string =~ s/.+?(\d+).+/$1/;'' is evaluated, there was 1 match and
>> that is the value to be returned to $digits afterwards...
>>
>>i hope you understand...i'm from .de
>
>Yes I do understand ... thanks, And BTW, your english is much better
>than my danish :)

You do know .de is Germany right? Also I should point out that his
answer was correct but left out some subtle nuances. You might also like
to try:

($digits) = $string =~ m/(\d+)/;

The match operator in list context will return each thing that was
matched inside brackets. This is probably more efficient than the
version using s///.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
The temperature of the aqueous content of an unremittingly ogled
culinary vessel will not achieve 100 degrees on the Celsius scale.


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

Date: Sat, 24 Mar 2001 18:06:20 -0700
From: pt <mnemotronic@mind\no-spam/spring.com>
Subject: Re: CGI style - CGI vs "here is" vs ??
Message-Id: <3ABD448C.69789709@mindspring.com>



"Alan J. Flavell" wrote:

> On Sat, 24 Mar 2001, pt wrote:
>
> >    A basic CGI style question : are there any Widely Accepted Practices
> > for creating the "static" sections of a web page which don't require the
> > services of a CGI?
>
> Do you have a Perl question?
>

    CGI.  As in "use CGI;".  As in "CGI.pm", which is (I think) a Perl module.



>
> My Perl answer would be "a here-document".
>
> > It seems that lots of calls to CGI would be less
> > efficient than a "here is" document with the HTML,
>
> I don't quite get your point.  There is only one call to a CGI per
> generated document.
>

    The Perl scripts I've seen in books appear to contain many calls to
functions (or invocation of methods) in CGI.pm. These functions (or methods)
emit HTML, or so I understand.  For example, a script with calls to CGI::p(),
CGI::ol(), CGI::ul(), CGI::li(), would appear to be calls to CGI.pm.  Maybe
I'm confused and these are actually calling the Vatican.  Maybe "call" is the
wrong term.  I don't understand how a Perl script with many references to
CGI::p() would only be calling CGI::pm once per generated document.


>
> Or are you confusing this with an SSI document which invokes several
> CGI calls?  That's surely suboptimal.  Plus, SSI is non-standard (you
> have to check the documentation for the particular server that you're
> using, and maybe make changes if you have to change servers), whereas
> CGI is a published specification, which is adhered to by quite a range
> of servers, meaning that your implementations will be quite portable.
> Using CGI.pm (which hides some adjustments for certain server
> differences) can make your code even more portable.
>
> In brief, SSI has its uses for simple needs, but is best avoided for
> things of any complexity.
>
> > or slurping an external file,
>
> Do you suppose that opening and reading an external file is going to
> be significantly more efficient than a here-document?  There are
> benchmark tests if you want to stage a demonstration, but I'd reckon
> that in practice any differences are chicken-feed compared with the
> convenience of having the data right there in the same file as the
> program code (script).
>

    There's efficiency.  And then there's style.  Efficiency is merely one
style, and not my ultimate guide.  Flow, readability, maintainability,
chutzpah, and feel are other styles.



>
> >  Nothing in perlstyle, and
> > the style section in CGI only discusses OO vs. function calls.
>
> That's a new question, though.
>
> One of the keys to doing a good programming job is learning to
> partition the problem into its essential parts, and seeking advice
> about those parts in appropriate places.  When you have questions
> about the Perl language, they're on-topic here.

    I sincerely apologize for wasting your time.  My ISP is a cheesy one, and
doesn't carry the comp.languages.perl.style.CGI.pm.questions.saturday
newsgroup.  I shall give them a piece of my mind, though it be my last.



> If you have questions
> about the best way to implement some task involving CGI, which just
> happens to be in Perl, then this is a suboptimal place to raise it:
> you'd be more at home on comp.infosystems.www.authoring.cgi.  In this
> case I'd say your questions were a bit of both - what say the regular
> japhs?
>
> --
>
>          This .sig only acknowledges that the message was displayed on
>          the recipient's machine. There is no guarantee that the
>          content has been read or understood.


Remove the obvious anti-spam to reply.


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

Date: Sat, 24 Mar 2001 17:07:37 -0700
From: Todd Anderson <todd@mrnoitall.com>
Subject: converting cgi-lib to cgi.pm
Message-Id: <3ABD3390.4CDFCB80@mrnoitall.com>


--------------F871B32AFAA7A560A1403285
Content-Type: text/plain; charset=us-ascii; x-mac-type="54455854"; x-mac-creator="4D4F5353"
Content-Transfer-Encoding: 7bit

Dear Hackers,
I am trying to modify a script originally built with cgi-lib.pl and am
now converting it to use cgi.pm.
I can't figure out how to modify the code below...
    local ($main_script, *in) = @_;

I'm guessing it should be like this...
local ($query->($main_script, *in) = @_;

   Any ideas are appreciated. Thanks in advance for your help.



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

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<font size=+1>Dear Hackers,</font>
<br><font size=+1>I am trying to modify a script originally built with
cgi-lib.pl and am</font>
<br><font size=+1>now converting it to use cgi.pm.</font>
<br><font size=+1>I can't figure out how to modify the code below...</font>
<br><font size=+1>&nbsp;&nbsp;&nbsp; local ($main_script, *in) = @_;</font><font size=+1></font>
<p><font size=+1>I'm guessing it should be like this...</font>
<br><font size=+1>local ($query->($main_script, *in) = @_;</font><font size=+1></font>
<p><font size=+1>&nbsp;&nbsp; Any ideas are appreciated. Thanks in advance
for your help.</font>
<br>&nbsp;
<br>&nbsp;</html>

--------------F871B32AFAA7A560A1403285--



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

Date: Sun, 25 Mar 2001 13:42:37 +1000
From: "Ron Savage" <ron@savage.net.au>
Subject: Re: Does a Perl code generator for web databases exist ?
Message-Id: <EYcv6.1781$R.68513@ozemail.com.au>

[snip]

> There are many applications in which a simple flat file database would useful.  For simple databases,
> it should be possible to build a code generator that would process a table to produce a set of HTML and CGI
> pages that implement a standard set of database operations based on DBI.  Need a new database, write a new table
> and run the code generator.
>
> I think I can see how to do it, but suspect that someone has already done it.  Can anyone provide a pointer ?

[snip]

Close, but no cigar. There is no need to generate code per db or per table, when 2 fixed scripts will do it.

I use MySQL.

My bootstrap.pl is 222 lines. It goes thru all dbs and all tables and generates 2 tables:
1) Is a given table to be visible? By default, Yes. But the 2nd script allows this to be edited.
2) If it is, prepare enough info so a form can be generated for this table, so add/change/delete can be done on any field in any
record.

My manage.pl is 929 lines long. It offers a menu for tables, and then an Add button and an Edit/Delete button. For the latter, you
must choose a record to work on, of course.

They'll be published shortly as tut # 36, at http://savage.net.au/Perl-tutorials.html

35 is now available, so perhaps today, perhaps not.

I recently changed my column-naming convention, as I write a tut on DBIx::Recordset, which broke manage.pl. I'm fixing it right now.
Hold your breath. If you turn blue and (execute) die('Perl lives!'), continued holding of breath is contra-indicated :-).

--
Cheers
Ron  Savage
ron@savage.net.au
http://savage.net.au/index.html





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

Date: Sun, 25 Mar 2001 14:44:53 +1000
From: "Ron Savage" <ron@savage.net.au>
Subject: Re: Does a Perl code generator for web databases exist ?
Message-Id: <0Tdv6.1799$R.69709@ozemail.com.au>

I've just posted tut # 36 in comp.lang.perl.modules.

Hit: http://savage.net.au/Perl-tutorials.html#tut-36

--
Cheers
Ron  Savage
ron@savage.net.au
http://savage.net.au/index.html





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

Date: Sun, 25 Mar 2001 00:29:11 GMT
From: Tuxman <s1sims@home.com>
Subject: Re: Eazel and DB_File
Message-Id: <3ABD3C1F.2060907@home.com>

Was wondering if anyone had installed Eazel on a RH7.0, or other flavor, 
system and experienced problems with using DB_File.pm. Have a database 
application that I've been working on and went to run it this morning 
and get the following error:

  DB_File needs compatible versions of libdb & db.h
	you have db.h version 3.1.14 and libdb version 3.1.17
Compilation failed in require at addr.pl line 37.
BEGIN failed--compilation aborted at addr.pl line 37


I used the Eazel installer and not the rpm's, I think it changed glib or 
something to an older version because when I use up2date Orbit, glib and 
a bunch of other packages are showing newer versions. That wasn't 
happening last week before I installed Eazel,


Thanks for any help,

Tuxman



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

Date: Sat, 24 Mar 2001 19:55:08 -0800
From: "newuser" <newuser@nospam.slip.net>
Subject: Help with syntax error
Message-Id: <tbqr4trv76kn56@corp.supernews.com>

Hi,
I am trying to add a command to last line of my close mail in my new sub
routine but everytime I run the cgi I get a sytax error. Can someone help me
out and tell me what is wrong and how to correct it.
thank
close(NEWFILE);

   open(EMAIL,"$basedir/$subscribe") || die $!;
   @recipient = <EMAIL>;
   close(EMAIL);
   # Now send mail to $recipient
   foreach $recipient (@recipient) {
     chomp $recipient;
     open (MAIL, "|$mailprog -t $recipient") || die "Can't open
$mailprog!\n";
     print MAIL "From: $host\n";
     print MAIL "Subject: Internet Forum: $subject\n";
     print MAIL "Reply-To: $email\n\n";
     print MAIL "#\n";
     print MAIL "# Entered from $ENV{'REMOTE_HOST'} ($ENV{'REMOTE_ADDR'})
with $ENV{'SERVER_PROTOCOL'}.\n";
     print MAIL "#\n";
     print MAIL "$name posted the following article in the Internet Forum
\n";
     print MAIL " \n";
     print MAIL "Dated : $long_date\n";
     print MAIL "Subject: $subject\n";
     print MAIL " \n";
     print MAIL "$FORM{'body'}\n";
     close (MAIL);
 if ($followup == 1) && ($origemail) && ($FORM{'reply_to') eq 'yes') {
mailerposter($num);
}
  }
}





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

Date: Sat, 24 Mar 2001 19:55:08 -0800
From: "newuser" <newuser@nospam.slip.net>
Subject: Help with syntax error
Message-Id: <tbqrgnsfvr1n5f@corp.supernews.com>

Hi,
I am trying to add a command to last line of my close mail in my new sub
routine but everytime I run the cgi I get a sytax error. Can someone help me
out and tell me what is wrong and how to correct it.
thank
close(NEWFILE);

   open(EMAIL,"$basedir/$subscribe") || die $!;
   @recipient = <EMAIL>;
   close(EMAIL);
   # Now send mail to $recipient
   foreach $recipient (@recipient) {
     chomp $recipient;
     open (MAIL, "|$mailprog -t $recipient") || die "Can't open
$mailprog!\n";
     print MAIL "From: $host\n";
     print MAIL "Subject: Internet Forum: $subject\n";
     print MAIL "Reply-To: $email\n\n";
     print MAIL "#\n";
     print MAIL "# Entered from $ENV{'REMOTE_HOST'} ($ENV{'REMOTE_ADDR'})
with $ENV{'SERVER_PROTOCOL'}.\n";
     print MAIL "#\n";
     print MAIL "$name posted the following article in the Internet Forum
\n";
     print MAIL " \n";
     print MAIL "Dated : $long_date\n";
     print MAIL "Subject: $subject\n";
     print MAIL " \n";
     print MAIL "$FORM{'body'}\n";
     close (MAIL);
 if ($followup == 1) && ($origemail) && ($FORM{'reply_to') eq 'yes') {
mailerposter($num);
}
  }
}





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

Date: Sun, 25 Mar 2001 04:28:26 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Help with syntax error
Message-Id: <slrn9bqsv9.jhv.tjla@thislove.dyndns.org>

I was shocked! How could newuser <newuser@nospam.slip.net>
say such a terrible thing:
> if ($followup == 1) && ($origemail) && ($FORM{'reply_to') eq 'yes') {
>mailerposter($num);
>}

You should indent your programs better. This will make things easier for
you to understand later on. The above line probably should be:

if (($followup == 1) && ($origemail) && ($FORM{'reply_to'} eq 'yes')) 
{
    mailerposter($num);
}

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
I've lost my faith in the stars
And my heart keeps on breaking
		-- Wilson Phillips


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

Date: Sat, 24 Mar 2001 20:27:35 -0800
From: "newuser" <newuser@nospam.slip.net>
Subject: Re: Help with syntax error
Message-Id: <tbqt4vj5t5n741@corp.supernews.com>

Sorry for the double post I think my news server is going a little crazy.
newuser wrote in message ...
>Hi,
>I am trying to add a command to last line of my close mail in my new sub
>routine but everytime I run the cgi I get a sytax error. Can someone help
me
>out and tell me what is wrong and how to correct it.
>thank
>close(NEWFILE);
>
>   open(EMAIL,"$basedir/$subscribe") || die $!;
>   @recipient = <EMAIL>;
>   close(EMAIL);
>   # Now send mail to $recipient
>   foreach $recipient (@recipient) {
>     chomp $recipient;
>     open (MAIL, "|$mailprog -t $recipient") || die "Can't open
>$mailprog!\n";
>     print MAIL "From: $host\n";
>     print MAIL "Subject: Internet Forum: $subject\n";
>     print MAIL "Reply-To: $email\n\n";
>     print MAIL "#\n";
>     print MAIL "# Entered from $ENV{'REMOTE_HOST'} ($ENV{'REMOTE_ADDR'})
>with $ENV{'SERVER_PROTOCOL'}.\n";
>     print MAIL "#\n";
>     print MAIL "$name posted the following article in the Internet Forum
>\n";
>     print MAIL " \n";
>     print MAIL "Dated : $long_date\n";
>     print MAIL "Subject: $subject\n";
>     print MAIL " \n";
>     print MAIL "$FORM{'body'}\n";
>     close (MAIL);
> if ($followup == 1) && ($origemail) && ($FORM{'reply_to') eq 'yes') {
>mailerposter($num);
>}
>  }
>}
>
>
>




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

Date: Sat, 24 Mar 2001 23:14:08 GMT
From: Al <"al<NoSpam>sorrell"@yahoo.com>
Subject: Re: How adding Hours & Days to current date?
Message-Id: <3ABD294D.E7EC6E4@yahoo.com>



MAC wrote:
> 
>  Cano someone help me with this :
> 
> I need a sub routine that adds xx number of days or xx number of hour to a
> already existing valid date like the current time and date.
<snip>

Check CPAN for Date::Manip

Al


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

Date: 25 Mar 2001 01:36:47 GMT
From: bbirthisel@aol.com (Bbirthisel)
Subject: Re: QUE: Serial port interrupt handling from perl
Message-Id: <20010324203647.25034.00000635@ng-cp1.aol.com>

Hi Mihilis,

>I want an example of how to handle serial port interrupts from perl.
>If possible I want to have to possible options:
>- Reading interrupt
>- Writing interrupt

You almost certainly don't want to implement the raw serial driver in
Perl. Even I don't - Win32::CommPort talks to the driver at a rather low API
level, but no where near interrupt services. But most Operating
Systems already have a serial driver to do that (even the $MS ones starting
with W9x - earlier attempts are disparaged even within $MS).

What you probably want is read_characters_if_available, and
write_characters_and_let_me_know_when_done. For those, the functions in
xxx::SerialPort are a possible starting point. Versions for Windows (Win32::)
and POSIX-compliant (Device::). There is also
serial code for the Mac - but not compatible with the ones above.

-bill
Making computers work in Manufacturing for over 25 years (inquiries welcome)


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

Date: Sun, 25 Mar 2001 03:09:28 GMT
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: require'ing OO modules on the fly - any danger?
Message-Id: <3ABD622A.52BBBF69@earthlink.net>

Daniel Berger wrote:
> 
> Hi all,
> 
> I have a server running that takes post's from a web page.  When the user
> click's a link, a command is sent to the server:
> 
> # basic server code
> 
> while($clientSock = $serverSock->accept()){
>    my $command = <$clientSock>;
>    chomp $command;
> }
> 
> What I would like to do instead is set up an OO module for each command, with
> each object having a method called "interact" that it would call when the
> server received the command.
> 
> # Code sample, partially derived from Perl Cookbook, p. 406.
> 
> #!/usr/bin/perl -wT   # Taint checking on
> ...
> while($clientSock = $serverSock->accept){
>    while(my $mod = <$clientSock>){
>       chomp $mod;
>       unless($mod =~ /^(\w+)$/i){ die "Invalid module name\n" } # taint check
>       $mod = $1;

Wouldn't it be preferable to do $mod = "AllowedModules::" . $1; for even
more security?

> 
>       # From here to end of loop - is this bad code?
>       eval "require $mod";

I'm not sure, but is it possible to do either just require $mod (with no
eval), or perhaps eval { require $mod }; (with braces, not quotes?)

>       die if $@;
>       #$mod->import;  # No import needed - we're assuming an OO module
>       $mod->new;        # Create object

It creates an object, but what do you do with it?  ie, shouldn't it be
$moduleinstance = $mod->new;

>       $mod->interact;   # Do stuff

And this would be $moduleinstance->interact;

Of course, you could combine the above two: $mod->new->interact;

Also, shouldn't you pass $clientSock as a parameter to interact or new?
Otherwise, how would it write back to the client?

>    }
> }
> 
> # Sample OO module
> package Hello;
> 
> BEGIN{
>    use Exporter;
>    use vars qw(@ISA $VERSION);
>    @ISA = qw(Exporter);
>    $VERSION = '1.00';
> }
> 
> sub new{
>    my $class = shift;
>    my $self = {};
>    bless($self,$class);
>    return $self;
> }
> 
> sub interact{
>    my($self, %arg) = @_;
>    print "Hooray!  It worked!\n";
> }

sub interact {
	my ($self, $clientSock) = @_;
	print $clientSock "Hooray!  It worked!\n";
}

Unless of course you stuffed $clientSock into $self somewhere.

> 1;
> __END__
> 
> Thus, using the above module as an example, if the server received the
> string "Hello", the server would then "require Hello", create a Hello
> object, and then execute the "interact()" method, printing "Hooray! 
> It worked".
> 
> Before going any further, let me state that I can't use "autouse",
> because it will be the sys-admin writing the modules.  That means I
> have no idea what string he's going to send as a module name - could
> be "booger", could be "jabberwocky".  Point is, it won't be a fixed
> list.  He'll know the rules (must have corresponding ".pm" perl
> module,  module must be OO, module must have a "new" and "interact"
> method) for the modules, but I'll have no idea (nor do I care) what he
> chooses as his module names.  This leaves things very flexible
> and just the way I (and he) want it.

Sounds too flexible.  Suppose someone tries to connect as a client, and
does a request for a module he knows is broken/buggy, or which does
dangerous things in it's new subroutine?

You should restrict it to only those subroutines which are in a
particular subdirectory, and who have a particular prefix.

So for example all modules which clients use must be in the ClientModule
subdirectory, and their names must begin with "ClientModule::"

> After reading the various doom and gloom warnings about doing this on
> the fly from the Cookbook, I'm going to admit that I don't completely
> understand everything that is said there.  What I am humbly asking for
> from this newsgroup is whether or not this code is bad/dangerous, if
> there's a better way to do it, or if this is the standard idiom and I
> should shut up.

Without putting a tighter restriction on what modules are available to
clients, it is dangerously unsafe, and the doom and gloom warnings are
perfectly valid.  If you are very careful, so that only those modules
designed to work with this setup will be used, then it might be safe.

> Thanks much for your time and patience.
> 
> Sincerely,
> 
> Daniel Berger
> 
> --
> "Evil will always triumph because Good is *dumb*"
> 
> - Dark Helmet, Spaceballs

-- 
The difference between theory and practice is that in theory, theory and
practice are identical, but in practice, they are not.


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

Date: Sun, 25 Mar 2001 02:06:47 GMT
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Routine to Color-Code Java/C/C++ Code
Message-Id: <3ABD537A.72F5BE05@earthlink.net>

np wrote:
> 
> Hi,
> I'm trying to develop a simple little script that color-codes program
> listings in HTML so they look like they would in an editor/IDE. An
> excerpt:
> 
> undef $/;
>  while ($line = <FILE>)
>  {
>  # check for comments
>  $line =~ s#(/\*.*?\*/)#<p class="Codecomment">\n$1</p>\n#gs;
>  $line =~ s#(//.*?)\n#<span class="Codecomment">$1</span>\n#gs;
> $line =~ s#(try)#<span class="Codekeyword">$1</span> #gs;
>  $line =~ s#(catch)#<span class="Codekeyword">$1</span> #gs;
>  $line =~ s#(throws)#<span class="Codekeyword">$1</span> #gs;
> 
> The problem is that I don't want keywords that occur in comments,
> particularly multi-line comments, to be translated. Think of Java:
> almost anything can be in a comment, including html tags and code
> samples.  Can anyone point me in the right direction?
> 
> Nigel Parker

You have to actually fully parse the data similarly to however it is
that perl does it itself.  Since you likely don't want to write a parser
yourself, nor go through the source code for perl, I would suggest you
try bastardizing the perldoc program.  Or maybe you can find a C
colorizer.

Another thing which occurs to me... doesn't the nedit text editor come
with a bunch of colorizing things for various programming languages? 
Perhaps you could steal it's config file for parsing and coloring perl,
or adapt and combine some of the others... Perl is like sed and awk and
sh and lex and c and c++, put into a blender, with a dash of @spices.

-- 
The difference between theory and practice is that in theory, theory and
practice are identical, but in practice, they are not.


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

Date: Sun, 25 Mar 2001 14:50:21 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Re: Running another perl script from a script?
Message-Id: <VBev6.2847$45.13788@newsfeeds.bigpond.com>

There could be a number of problems.
These relate to how your web server is set up.

1. system '/perlscript2.pl' ; do you mean "./perlscript2.pl'
2. What driectory are you in? Try 'system('pwd')
3. What is your path? Is the program in the path. Try print $ENV{PATH}
4. What user are you running as? Some web servers run as user 'nobody',
which hsa limited privileges.
Look at http://www.w3.org/Security/Faq/wwwsf5.html for more info.
5. If you want your script to run in the background, call daemonize()
in the above faq

gtoomey
--------------------
"D.J. Poot" <djpoot@kabelfoon.nl> wrote in message
news:99j5ei$2oar$1@news.kabelfoon.nl...
> Hi there,
>
> I have a perl script from which I need to call another perl script, and
then
> return to the first one. (See below)
>
> ---Example---
>
> perlscript1.pl runs, prints some HTML...
> perlscript2.pl runs, prints some dynamic data...
> perlscript1.pl continues, finishes up the HTML and the scripts are both
> done...
>
> ---Example---
>
> I have been looking at the 'system()' call, but a simple "system
> '/perlscript2.pl';" doesn't seem to do anything, really. Therefore, I am
> asking you people now.. How can I run a perl script from another script?
>
> Thanks a lot in advance!
>
>
> Greetings,
> Dominique
>
>




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

Date: Sun, 25 Mar 2001 02:40:23 GMT
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Script mysteriously erases file it's supposed to append to
Message-Id: <3ABD5B3F.AF54B612@earthlink.net>

nobull@mail.com wrote:
> 
> Bernie Cosell <bernie@fantasyfarm.com> writes:
> 
> > Katia Hayati <hayati@math.uiuc.edu> wrote:
> >
[snip]
> > after you *get* the lock to make sure that you're really about to
> > write at the end of the file.
> 
> It should be noted that what Bernie (and the flock() manapage) is
> presenting here is a work-round for an OS bug.  On the OP's code would
> work properly because O_APPEND is properly implemented.

Not necessarily.

open(LOG, ">>$logfile") occurs, and FH is [correctly] set to the end of
the file.  Next, flock(LOG, LOCK_EX) occurs.  This results in a
[blocking] request for the lock.  While that request is being made,
something else might have the lock.

Suppose that the "something else" truncates the file to length 0.  It
gives up the lock on the now zero length file, and you still have a
filehandle whose current position is the old end of file -- which is now
way past the end.  What happens now?  You write, and maybe it fills out
with zeros up to the position you're writing to... or maybe it produces
an error, or maybe you have a file system which supports sparse files,
and something else happens.

A more likely scenario, is that while you are waiting for the other
process(es) to give up their locks, the file is *lengthened*, so your
filehandle is pointing to some place which is now significantly before
the EOF (when before the other write occured it was *at* EOF).  So you
try and write, and you end up overwriting something else.  This is just
as bad.

So, you should do a seek() to the end immediatlly after flock succeeds,
even if O_APPEND is correctly implemented.  Get it?

> Arguably Perl itself when compiled on a OS with this bug should
> include a work-round.

You could call it a work-around, but it's not for an OS bug, but for a
threading problem.

Here's an pseudocode example which might demonstrate what the seek is
there for.

Here's what leaving the seek out is like:
struct foo {
	mutex x;
	int arraylen;
	int array[100];
};
extern struct foo x;
int last = x.arraylen;
mutex_get_lock(x.lock);
x.array[last] = 5;
x.arraylen = last + 1;
mutex_free_lock(x.lock);

See the problem?  It should be quite clear in this example.

-- 
The difference between theory and practice is that in theory, theory and
practice are identical, but in practice, they are not.


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

Date: Sun, 25 Mar 2001 02:17:53 GMT
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Still can't die with Tar
Message-Id: <3ABD5614.716F9A08@earthlink.net>

BUCK NAKED1 wrote:
> 
> 
> Re: Still can't die with Tar
> 
> > Benjamin Goldberg wrote:
> > > BuckNaked wrote:
> > > system("gunzip success.tar.gz");
> > > print "Gunzip Success returns a Value of $?"; print "<BR>";
> > > system("gunzip failure.tar.gz");
> > > print "Gunzip Failure returns a Value  of $?"; print "<BR><BR>";
> > > [snip]
> > > Gunzip Success returns a Value of 256
> > Exit value 1
> > > Gunzip Failure returns a Value of 512
> > Exit value 3
> 
> Yes, I made a mistake. I meant to type "gunzip" instead of "gzip".
> However, I've changed it to gunzip, and I still get return values of
> 256 and 512. Can you give me the code* that gives you those different
> exit values of 1 and 3... so I can run it and see?

Well, actually I made a typo... gzip dies with exit values 1 and 2, and
tar dies with exit value 3.

system("gunzip success.tar.gz");
print "Gunzip Success returns a Value of ", ($? >> 8), "<BR>";
system("gunzip failure.tar.gz");
print "Gunzip Failure returns a Value  of ", ($? >> 8), "<BR><BR>";

256>>8 is 1, and 512>>8 is 2, and 768>>8 is 3.

Remember, the value with which gunzip/gzip exits with is not precisely
identical to what appears in $? -- there are other things there too:
specifically what signals, if any, the program died due to.

-- 
The difference between theory and practice is that in theory, theory and
practice are identical, but in practice, they are not.


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

Date: 25 Mar 2001 00:40:44 GMT
From: cljlk@hotmail.com (cljlk)
Subject: the space
Message-Id: <99jeqc$1sd$1@bob.news.rcn.net>

Hi,
How to filter out the space by using split.
Between alphabet, thay not alwasy have same white space.
For instance:

$line = "xx   yy a    bb     cc";

($xx,$yy,$a,$bb,$cc) = split(/ /,$line);
                              ^
                              |
                    How to handle this white space?
Thanks





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

Date: Sun, 25 Mar 2001 01:42:21 +0100
From: "fruiture" <info@fruiture.de>
Subject: Re: the space
Message-Id: <99jf89$uqc$1@Merlin.et.bocholt.fh-gelsenkirchen.de>

cljlk <cljlk@hotmail.com> schrieb in im Newsbeitrag:
99jeqc$1sd$1@bob.news.rcn.net...
> Hi,
> How to filter out the space by using split.
> Between alphabet, thay not alwasy have same white space.
> For instance:
>
> $line = "xx   yy a    bb     cc";
>
> ($xx,$yy,$a,$bb,$cc) = split(/ /,$line);
>                               ^
>                               |
>                     How to handle this white space?
> Thanks
> ...

if it is not your aim to count the whitespaces, try this:
($xx,$yy,$a,$bb,$cc)=split(/\s+/,$line);
well, \s in fact  includes \n\f\r\t, but I think that's no problem for
you...

--
do something for your health
______fruiture.de___yeah!_





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

Date: 25 Mar 2001 01:08:10 GMT
From: cljlk@hotmail.com (cljlk)
Subject: Re: the space
Message-Id: <99jgdq$a8r$1@bob.news.rcn.net>

Thanks !!


In article <99jf89$uqc$1@Merlin.et.bocholt.fh-gelsenkirchen.de>, 
info@fruiture.de says...
>
>cljlk <cljlk@hotmail.com> schrieb in im Newsbeitrag:
>99jeqc$1sd$1@bob.news.rcn.net...
>> Hi,
>> How to filter out the space by using split.
>> Between alphabet, thay not alwasy have same white space.
>> For instance:
>>
>> $line = "xx   yy a    bb     cc";
>>
>> ($xx,$yy,$a,$bb,$cc) = split(/ /,$line);
>>                               ^
>>                               |
>>                     How to handle this white space?
>> Thanks
>> ...
>
>if it is not your aim to count the whitespaces, try this:
>($xx,$yy,$a,$bb,$cc)=split(/\s+/,$line);
>well, \s in fact  includes \n\f\r\t, but I think that's no problem for
>you...
>
>--
>do something for your health
>______fruiture.de___yeah!_
>
>
>



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

Date: Sun, 25 Mar 2001 13:04:24 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: the space
Message-Id: <slrn9bqo1o.ugg.mgjv@martien.heliotrope.home>

On 25 Mar 2001 00:40:44 GMT,
	cljlk <cljlk@hotmail.com> wrote:
> 
> $line = "xx   yy a    bb     cc";
> 
> ($xx,$yy,$a,$bb,$cc) = split(/ /,$line);
>                               ^
>                               |
>                     How to handle this white space?

If you want to split on multiple spaces, real spaces, use

split / +/, $line;

The first argument to split is always, yes, always, a regular
expression, except in one special case. That special case is when the
first argument is ' ', in which case it will split on any amount of
whitespace:

split ' ', $line;

and whitespace includes tabs and such. The above is more or less
equivalent to

split /\s+/, $line;

The single space will remove leading and trailing empty fields, while
the /\s+/ will not.

All of this is in the documentation for split() in perlfunc, and the
documentation for regular expressions in perlre. Please, take this
opportunity to read them.

$ perldoc perlfunc
$ perldoc -f split
$ perldoc perlre

$ perldoc perldoc
$ perldoc perl

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Think of the average person. Half of
Commercial Dynamics Pty. Ltd.   | the people out there are dumber.
NSW, Australia                  | 


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

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

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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.

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 V10 Issue 561
**************************************


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