[12319] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5919 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 8 10:07:21 1999

Date: Tue, 8 Jun 99 07:00:23 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 8 Jun 1999     Volume: 8 Number: 5919

Today's topics:
        __DATA__ <arpin@adan.kingston.net>
    Re: __DATA__ (Randal L. Schwartz)
        Arrays - remove multiple entries <David.Hiskiyahu@alcatel.be>
    Re: Arrays - remove multiple entries <cschmitz@stud.informatik.uni-trier.de>
    Re: Arrays - remove multiple entries (Sam Holden)
    Re: Arrays - remove multiple entries <jpeterson@office.colt.net>
    Re: Brackets and comparisons <xpalo03@vse.cz>
    Re: Brackets and comparisons (Sam Holden)
    Re: Brackets and comparisons (M.J.T. Guy)
    Re: Brackets and comparisons <aqumsieh@matrox.com>
    Re: CGI and SSI in perl <vincent_vanbiervliet@be.ibm.com>
        Creating an external config file. How ? <greg@paradox.net.au>
    Re: DBD::ODBC <gellyfish@gellyfish.com>
    Re: Get Date in Perl <gellyfish@gellyfish.com>
    Re: how can i do this? <jdf@pobox.com>
    Re: how can i do this? (Tad McClellan)
    Re: How to use <!--exec to pass arguments in cgi ? <thomas.distler@icn.siemens.de>
        How write a perl program that connects to a remote Orac <chongsun@krdl.org.sg>
    Re: How write a perl program that connects to a remote  <gellyfish@gellyfish.com>
        install test failed ipc <joe@laffeycomputer.com>
    Re: Interpreter. <garethr@cre.canon.co.uk>
    Re: Looking for a Command Line E-Mailer for NT <dominikl@pyramid.de>
        Nomination for clueless utterance of the month   was: R <bradw@newbridge.com>
    Re: Perl "constructors" armchair@my-deja.com
    Re: perl > NTMail <gellyfish@gellyfish.com>
        perl cgi and apache (fezzzza)
    Re: Perl cgi problem: use cgi qw()param; unrecognized s <gellyfish@gellyfish.com>
        reading socket problem <axc@iname.com>
    Re: REDIRECT in the BODY of a HTML page... (Randal L. Schwartz)
        Return value of -die- <xpalo03@vse.cz>
    Re: Return value of -die- (Tad McClellan)
    Re: Using hash keys <cschmitz@stud.informatik.uni-trier.de>
    Re: Using string variable as name of subroutine to call (Randal L. Schwartz)
    Re: Using string variable as name of subroutine to call <gellyfish@gellyfish.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Tue, 8 Jun 1999 09:34:39 -0400
From: "Andre Arpin" <arpin@adan.kingston.net>
Subject: __DATA__
Message-Id: <375d1b6e.0@news.cgocable.net>

When I run this program I get the following error message

Read on closed filehandle <DATA> at D:\XX.PL line 6.

Is it possible to read data within a package

Thanks in advance
Andre


package a_package;

BEGIN
{
 while (<DATA>)
 {
  print $_;
 }
}

__DATA__
this is a test







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

Date: 08 Jun 1999 06:55:42 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: __DATA__
Message-Id: <m14skig5k1.fsf@halfdome.holdit.com>

>>>>> "Andre" == Andre Arpin <arpin@adan.kingston.net> writes:

Andre> Is it possible to read data within a package

Yes, but not in a BEGIN block (as you had), which executes before Perl
has even seen the __DATA__ marker!

You'll have to do something like a lazy initialization in the first
function you call in the package:

    package bar;
    my @data;

    sub foo {
	    @data = <DATA> unless @data;
	    ...
    }

    __DATA__
    your data
    here

print <DATA>; __END__
Just another Perl hacker,

-- 
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@teleport.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: Tue, 08 Jun 1999 12:31:02 +0200
From: David Hiskiyahu <David.Hiskiyahu@alcatel.be>
Subject: Arrays - remove multiple entries
Message-Id: <375CF0E5.8067E7B5@alcatel.be>


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

I saw once a nice piece of Perl code that would efficiently
eliminate multiple occurences of a element from a sorted array.

Example:    (Albert, Alex, Alex, Bill, Charlie, Charlie, Charlie, David, Eugene,
Eugene)
will become:  (Albert, Alex, Bill, Charlie, David, Eugene).

Does anyone have the right piece of Perl script?

I hope that this can be done better than below:

foreach $name (@list) { push @newlist, $name unless (grep /$name/, @newlist) }

In fact, this is about using arrays as sets.

Thanks,

--
***   David Hiskiyahu, Alcatel SSD, 1 Fr.Wellesplein,  Antwerp  ***
***    Phone/Fax: +32 3 240 7965/9820, private +32 3 225 2712   ***



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

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
I&nbsp;saw once a nice piece of Perl code that would efficiently
<br>eliminate multiple occurences of a element from a sorted array.
<p>Example:&nbsp;&nbsp;&nbsp;&nbsp;(Albert, Alex, Alex, Bill, Charlie,
Charlie, Charlie, David, Eugene, Eugene)
<br>will become:&nbsp; (Albert, Alex, Bill, Charlie, David, Eugene).
<p>Does anyone have the right piece of Perl script?
<p>I&nbsp;hope that this can be done better than below:
<p>foreach $name (@list)&nbsp;{&nbsp;push @newlist, $name unless (grep
/$name/, @newlist) }
<p>In fact, this is about using arrays as sets.
<p>Thanks,
<pre>--&nbsp;
***&nbsp;&nbsp; David Hiskiyahu, Alcatel SSD, 1 Fr.Wellesplein,&nbsp; Antwerp&nbsp; ***
***&nbsp;&nbsp;&nbsp; Phone/Fax: +32 3 240 7965/9820, private +32 3 225 2712&nbsp;&nbsp; ***</pre>
&nbsp;</html>

--------------FBCE4B3293477E0C5CCCE4DB--



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

Date: 8 Jun 1999 11:27:48 GMT
From: Christoph Schmitz <cschmitz@stud.informatik.uni-trier.de>
Subject: Re: Arrays - remove multiple entries
Message-Id: <7jiunk$n33$2@fu-berlin.de>

David Hiskiyahu <David.Hiskiyahu@alcatel.be> wrote:
: I saw once a nice piece of Perl code that would efficiently
: eliminate multiple occurences of a element from a sorted array.

: Example:    (Albert, Alex, Alex, Bill, Charlie, Charlie, Charlie, David, Eugene,
: Eugene)
: will become:  (Albert, Alex, Bill, Charlie, David, Eugene).

: Does anyone have the right piece of Perl script?

You can do it like this:

@newarr = grep { $res = $_ ne $last; $last = $_; $res } @arr;

assuming @arr contains your sorted list. This runs in linear
time, whereas the solution you mentioned would need n^2 steps.

HTH,

Christoph 

-- 
-- Christoph Schmitz <cschmitz(at)stud.informatik.uni-trier.de> --
The price one pays for pursuing any profession, or calling, is an intimate
knowledge of its ugly side.  -- James Baldwin


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

Date: 8 Jun 1999 11:43:14 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Arrays - remove multiple entries
Message-Id: <slrn7lq0ei.cn4.sholden@pgrad.cs.usyd.edu.au>

On 8 Jun 1999 11:27:48 GMT,
    Christoph Schmitz <cschmitz@stud.informatik.uni-trier.de> wrote:
>David Hiskiyahu <David.Hiskiyahu@alcatel.be> wrote:
>: I saw once a nice piece of Perl code that would efficiently
>: eliminate multiple occurences of a element from a sorted array.
>
>: Example:    (Albert, Alex, Alex, Bill, Charlie, Charlie, Charlie, David, Eugene,
>: Eugene)
>: will become:  (Albert, Alex, Bill, Charlie, David, Eugene).
>
>: Does anyone have the right piece of Perl script?
>
>You can do it like this:
>
>@newarr = grep { $res = $_ ne $last; $last = $_; $res } @arr;

You could also read the documentation that comes with perl. Particular
attention should be payed to the FAQ as you will find the following :

    How can I extract just the unique elements of an array?

There are several possible ways, depending on whether the array is
ordered and whether you wish to preserve the ordering.

 ...a bunch of ways follows...


One of which is like the grep solution above but more elegant.

-- 
Sam

If your language is flexible and forgiving enough, you can prototype
your belief system without too many core dumps.
	--Larry Wall


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

Date: Tue, 08 Jun 1999 12:24:30 GMT
From: <jpeterson@office.colt.net>
Subject: Re: Arrays - remove multiple entries
Message-Id: <2Y773.223$TM6.1195@news.colt.net>

David Hiskiyahu <David.Hiskiyahu@alcatel.be> wrote:
> I saw once a nice piece of Perl code that would efficiently
> eliminate multiple occurences of a element from a sorted array.

> I hope that this can be done better than below:

> foreach $name (@list) { push @newlist, $name unless (grep /$name/, @newlist) }

The line above would be useful if for some reason you had unsorted data. Once
it is sorted, de-duplicating is easier:

while (@oldarray){
	if ($newarray[-1] ne $oldarray[0])
	{
		push @newarray, shift @oldarray;
	}
	else
	{
		shift @oldarray;
	}
}

I daresay there are more efficient forms than this, too.



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

Date: Tue, 08 Jun 1999 12:06:48 +0200
From: Ondrej Palkovsky <xpalo03@vse.cz>
To: outlaw_torn <outlaw_torn@mailexcite.com>
Subject: Re: Brackets and comparisons
Message-Id: <375CEB38.A0357F6E@vse.cz>

outlaw_torn wrote:

> if ($line1 =~ /$line2/) {
>         ...
>         }
> 
> Now the problem is that $line2 occasionally has a string with brackets
> ().  When it happens, the perl says mismatched ()'s or something to that
> effect.
> 
This works for me:
$line1=~s/\(/\\\(/g;$line1=~s/\)/\\\)/g;
$line2=~s/\(/\\\(/g;$line2=~s/\)/\\\)/g;
if (eval "\$line1=~/$line2/") {
        ...
}

Regards
  Ondrej 
-- 
Have a taco.
		-- P.S. Beagle


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

Date: 8 Jun 1999 11:39:30 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Brackets and comparisons
Message-Id: <slrn7lq07i.cn4.sholden@pgrad.cs.usyd.edu.au>

On Tue, 08 Jun 1999 12:06:48 +0200, Ondrej Palkovsky <xpalo03@vse.cz> wrote:
>outlaw_torn wrote:
>
>> if ($line1 =~ /$line2/) {
>>         ...
>>         }
>> 
>> Now the problem is that $line2 occasionally has a string with brackets
>> ().  When it happens, the perl says mismatched ()'s or something to that
>> effect.
>> 
>This works for me:
>$line1=~s/\(/\\\(/g;$line1=~s/\)/\\\)/g;
>$line2=~s/\(/\\\(/g;$line2=~s/\)/\\\)/g;
>if (eval "\$line1=~/$line2/") {
>        ...
>}

Why are you using eval when the poster wasn't... since your not using it to
trap exceptions???

What about when $line2 contains "/)" already say for example the string :

$line2 = '\)';

A simple perusal of the perlre documentation would have found :

    \Q          quote (disable) pattern metacharacters till \E

If $line2 is not meant to contain meta characters then you can use
\Q to automatically quote them like the poster did with just the ()s. \Q
will actually get all of them.

However, if you really do want to search for literal strings and not
use regular expressions then you should use index. It is documented in 
the perlfunc documentation.

-- 
Sam

compiling kernels is what I do most, so they do tend to stick to the
cache ;)	--Linus Torvalds


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

Date: 8 Jun 1999 12:58:51 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Brackets and comparisons
Message-Id: <7jj42b$nkv$1@pegasus.csx.cam.ac.uk>

In article <7jic2e$cap$1@nnrp1.deja.com>,
outlaw_torn  <outlaw_torn@mailexcite.com> wrote:
>Hey all
>
>My comparison code goes something like:
>
>if ($line1 =~ /$line2/) {
>	...
>	}
>
>Now the problem is that $line2 occasionally has a string with brackets
>().  When it happens, the perl says mismatched ()'s or something to that
>effect.

You don't say what you mean by "comparison".   (And I can't deduce
your intent from the supplied code because it doesn't work.   :-)

If you want to check if the strings are equal, don't use a regex at all:

  if ($line1 eq $line2) {

If you want to check if $line2 is a substring of $line1, either use \Q
in a regexp

  if ($line1 =~ /\Q$line2/) {

or use the index function:

  if (index($line1, $line2) >= 0) {


   perldoc perlre
   perldoc -f index


Mike Guy


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

Date: Tue, 8 Jun 1999 08:57:46 -0400 
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Brackets and comparisons
Message-Id: <x3yso82g88l.fsf@tigre.matrox.com>


outlaw_torn <outlaw_torn@mailexcite.com> writes:

> My comparison code goes something like:
> 
> if ($line1 =~ /$line2/) {
> 	...
> 	}
> 
> Now the problem is that $line2 occasionally has a string with brackets
> ().  When it happens, the perl says mismatched ()'s or something to that
> effect.

No .. in regexps, brackets are special. They are used to capture the
results of the matches. You need to tell Perl to consider them
literally:

	if ($line1 =~ /\Q$line2/) {
		...
	}

Checkout perlre for more info.
Alternatively, you can look at the quotemeta() function in perlfunc.

> So I did the obvious:
> 
> $line2 =~ s/\(//g;
> $line2 =~ s/\)//g;

That is not so obvious to me! You are trying to delete all brackets,
but won't that cause your regexp to fail anyway? You are probably
trying to do something like:

	$line2 =~ s/\(/\\\(/g;
	$line2 =~ s/\)/\\\()/g;

but this is unncessary since quotemeta() or the \Q..\E constructs do
that for you.

> But, it didn't make a difference...the braces remain.

You sure??

> So, I need to either get the substitution to work, or stuff with
> comparison some how....any suggestions?

HTH,
Ala



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

Date: Tue, 8 Jun 1999 14:08:24 +0200
From: "Vincent Vanbiervliet" <vincent_vanbiervliet@be.ibm.com>
Subject: Re: CGI and SSI in perl
Message-Id: <375cf8e2@news.uk.ibm.net>

Hasanuddin Tamir <hasant@trabas.co.id> wrote in message
news:slrn7lnde7.vph.hasant@borg.intern.trabas.co.id...
> On Mon, 7 Jun 1999 12:40:45 +0200,
> Vincent Vanbiervliet <vincent_vanbiervliet@be.ibm.com> wrote:
>
> > Your server probably only looks for SSi for shtml files. This is for a
> > faster response time, if every file (html, cgi, pl) would have to be
parsed
> > to look for SSI, this could slow down the server.
>
> It's not what Apache says (well, don't know about
> other servers). I could put the FAQ concerning this
> matter but this is really not an appropriate place.
>
That is why I say: _could_ slow down the server, because I use a Netscape
server, and the Netscape documentation
suggests that this _will_ slow down the server...

Vincent




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

Date: 8 Jun 1999 20:46:06 -0800
From: "Greg Savage" <greg@paradox.net.au>
Subject: Creating an external config file. How ?
Message-Id: <01beb1ac$7eda9ca0$f34f39cb@stingray>

I have compilled my perl script and now need to store my configuration
options in an external text file for ease of modification. I am looking for
an efficient routine to read in the following pairs, ignoring # comments
and assign them to variables.

# This is a comment
logdir /var/log
logfile local0
warning 2
limit 5
admin admin@domain.com

I guess a hash would be a good start but am unsure to the structure.


Advice would be appreciated.



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

Date: 8 Jun 1999 14:03:53 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: DBD::ODBC
Message-Id: <375d14b9@newsread3.dircon.co.uk>

Ysteric's <eyounes@aol.com> wrote:
> Even with a Foxpro table ?
> 

You can always try $dbh->commit and see what happens (it will tell if it
is inappropriate).  Are we talking Foxpro as in DBF (XBase) files here ?
cause that used to never actually delete the entries just marked them as
deleted - you might see if you get the same results with DBD::XBase.

/j\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: 8 Jun 1999 10:50:33 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Get Date in Perl
Message-Id: <375ce769@newsread3.dircon.co.uk>

outlaw_torn <outlaw_torn@mailexcite.com> wrote:
> In article <x7ogir73vh.fsf@home.sysarch.com>,
>   Uri Guttman <uri@sysarch.com> wrote:
> 
>>   ot> Doco...whats that?
>>
>> it is obvious you really don't have a clue about perl or usenet.
>>
> Sarcasm is wasted on you.
> 

What sarcasm when you are told you are wrong you get out of your pram
and start throwing your toys around.

>> telling them to
>> figure it out from empirical (look it up. you probably don't know how
> to
>> use a dictionary either) results.
> 
> WTFs wrong with give the guy a little credit, assuming he has some
> intelligence and giving a place to start for his own conclusion.  Maybe
> you don't understand sarcasm but you understand how to be patronising.
> 

You gave incorrect information - specifically that the year value as
returned by localtime is a two-digit value, you were corrected and now
you have a tantrum - oh BTW you had better look up 'sarcasm' and
'patronising' while you are following Uri's advice.

>>   ot> Share what you know. Learn what you don't.
>>
>> what a crock. when's the last time we have seen a good answer from a
>> deja posting. (stowe in london being excepted. why are you using
> deja?)
>>
> 
> Why not use deja? Does it make a difference.
> 

It shouldnt but the observation remains valid.  There is a poverty of good
answers flowing from that direction - there are of course exceptions and
those people know who they are and wont get offended by the assertion.

> Look buddy...I dont care if your a fucking regular (flips the bird).  If
> your so high and fuckin mighty, why didn't you reply.  

Unfortunately your ill-informed and misleading post had already arrived.
If people were just to ignore incorrect postings what would happen ?

>                                                         Guys like you
> shit me to no end.  "I've been posting here for a long time so I must be
> respected"...yeah right.  Go home.
> 

Oh, nearly forgot :

*plonk*

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: 08 Jun 1999 09:34:57 -0400
From: Jonathan Feinberg <jdf@pobox.com>
To: smnayeem@my-deja.com
Subject: Re: how can i do this?
Message-Id: <m3r9nmhl32.fsf@joshua.panix.com>

smnayeem@my-deja.com writes:

> I cant work out how to access each element of an array of array using
> two for loops.

  my $lol = [[1,2,3],[4,5,6],[7,8,9]];

  foreach my $list (@$lol) {
    foreach my $item (@$list) {
       print "$item\n";
    }
  }

  for (my $i = 0; $i < @$lol; $i++) {
    for (my $j = 0; $j < @{$lol->[$i]}; $j++) {
       print "$lol->[$i]->[$j]\n";
    }
  }

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


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

Date: Tue, 8 Jun 1999 04:15:09 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: how can i do this?
Message-Id: <dejij7.a0p.ln@magna.metronet.com>

smnayeem@my-deja.com wrote:
: I cant work out how to access each element of an array of array using
: two for loops.
: heres my code :


: 3      	  for ($j = 0;$j <= $#[$header->[$i]];$j++) {
                                      ^             ^
                                      ^             ^

  Use {curly braces} not [square brackets]


   [ you have a whole bunch of bare words there too. You should
     enable warnings on *all* of your Perl programs!
   ]


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Tue, 08 Jun 1999 14:07:32 +0200
From: distler <thomas.distler@icn.siemens.de>
Subject: Re: How to use <!--exec to pass arguments in cgi ?
Message-Id: <375D0784.74429CB6@icn.siemens.de>


Try somthing like this.
It should work

my @args = ("path to command",
            "par1",
            "par2",
            "par3");
$exit=system ("@args 1>$tmpfile");


smgpage@hotmail.com wrote:

> Dear Expert !
>     I head is broken into two now after testing the whole nite and I
> need your help now !How to pass arguments in the TAG
>    <!-- exec cgi="/cgi-bin/action.pl --> ???
>
>     I can run http://www.mysite.com/cgi-bin/action.pl?45665 by typing in
> the location of netscape but when I embeded the TAG  (<!...>)in HTML it
> says eror eror and nothing more but eror ! Please Tell me how to pass
> arguments with the above tag !
>
> *45665 is my argument which is a filename. I want to opne that file for
> some data and display it in my HTML page. It is just like counter. But
> because I need to use lots of data files in one page I need to tell th
> cgi which file to use.
>
> Kindly email you help to me at smgpage@hotmail.com !
>
> THANKS IN ADVANCE !
>
> James Yap
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.



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

Date: Tue, 8 Jun 1999 18:15:16 +0800
From: "Lim Chong Sun" <chongsun@krdl.org.sg>
Subject: How write a perl program that connects to a remote Oracle database server without configuring any connections? NT
Message-Id: <7jiqkl$914$1@godzilla.krdl.org.sg>

No text!




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

Date: 8 Jun 1999 14:10:18 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: How write a perl program that connects to a remote Oracle database server without configuring any connections? NT
Message-Id: <375d163a@newsread3.dircon.co.uk>

Lim Chong Sun <chongsun@krdl.org.sg> wrote:
> No text!

No answer then! ( Seriously it is counter-productive putting your whole
post in a long subject line because some newsreaders will show only the
first ten or twenty characters perhaps.)

Oh never mind - you will probably want to use DBD::Oracle available from
CPAN - If you are using the Activestate distribution for Win32 then the
module is also available to be installed via PPM.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: Tue, 8 Jun 1999 08:30:48 -0500
From: Joe Laffey <joe@laffeycomputer.com>
Subject: install test failed ipc
Message-Id: <Pine.LNX.4.10.9906080828510.5109-100000@tripe.laffeycomputer.com>

Hi,

I am installing PERL 5.005_3 on NetBSD 1.4 Mac68k.

I ran into this error when running the tests:
lib/ipc_sysv........msgget failed: No space left on device
dubious
        Test returned status 28 (wstat 7168, 0x1c00)
DIED. FAILED tests 1-16
        Failed 16/16 tests, 0.00% okay

None of my filesystems are full. Anyone have a clue? Does NetBSD just not
support ipc_sysv?

Thanks,


Joe Laffey
LAFFEY Computer Imaging
St. Louis, MO
http://www.laffeycomputer.com/
 ------------------------------
Your mouse has moved.   Windows NT must be restarted for the change to
take effect.   Reboot now?  [ OK ]



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

Date: Tue, 8 Jun 1999 11:47:42 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
To: Fabrice Ceugniet <fabrice@centropolisfx.com>
Subject: Re: Interpreter.
Message-Id: <si909ux6ap.fsf@cre.canon.co.uk>

Fabrice Ceugniet <fabrice@centropolisfx.com> wrote:
> The Perl application I am writing would need an interpreter.  Does
> anyone have an idea of what already exist in Perl. Is there any
> lex/yacc equivalent in Perl?  Is it possible to give Perl a grammar?

The simplest solution is to use Perl itself as the scripting language
for your application, for you already have an interpreter -- `eval'.  If
security is an issue, use the `Safe' module to control evaluation.

If you need to write your own language, then the following CPAN modules
may be of use:

   Parse::Lex.pm (Philippe Verdret)
   Object-oriented generator of lexical analyzers
   http://www.cpan.org/modules/by-module/Parse/ParseLex-2.10.tar.gz

   Parse::Yapp (Francois Desarmenien)
   Compiles yacc-like LALR grammars to generate Perl OO parser modules.
   http://www.cpan.org/modules/by-module/Parse/Parse-Yapp-0.31.tar.gz

   Parse::RecDescent (Damian Conway)
   Generate recursive-descent parsers
   http://www.cpan.org/modules/by-module/Parse/Parse-RecDescent-1.65.tar.gz

-- 
Gareth Rees


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

Date: Tue, 08 Jun 1999 14:39:29 +0200
From: Dominik Leinfelder <dominikl@pyramid.de>
Subject: Re: Looking for a Command Line E-Mailer for NT
Message-Id: <375D0F01.3E70D129@pyramid.de>

Jason Sova schrieb:

> Does anybody here know where I could find a nice comand line based
> E-Mailer that I could use with perl to send the results of a online
> form? My OS is NT.
>
> Thanks
> Jason
> sova0001@algonquinc.on.ca

Maybe blat.exe is helpful for you.
just have a look @ http://gepasi.dbs.aber.ac.uk/softw/Blat.html

greetinx
Dominik Leinfelder



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

Date: 08 Jun 1999 09:07:12 -0400
From: bj <bradw@newbridge.com>
Subject: Nomination for clueless utterance of the month   was: Re: Help needed and much appreciated
Message-Id: <op17lpealj3.fsf_-_@newbridge.com>

stuw@dial.pipex.com.remove.everything.after.com (Stuart Wright) writes:

> But I
> don't really care.  I just want the scripts to work.  I imagine most of the
> people asking questions here don't want to learn how to use Perl rather
> than get a particular script to work.

So you would prefer to be spoonfed an solution without any
explaination or knowledge transfer that could make you more proficient
in a commonly used language, that you are obviously doing support or
development in... and you claim to be a "software developer".... I
take it you don't want to become more productive or marketable.

baffled,
bj


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

Date: Tue, 08 Jun 1999 09:10:19 GMT
From: armchair@my-deja.com
Subject: Re: Perl "constructors"
Message-Id: <7jimlo$g69$1@nnrp1.deja.com>

In article <7jgi09$noj$1@nnrp1.deja.com>,
  John Porter <jdporter@min.net> wrote:
> In article <7il85o$t0u$1@nnrp1.deja.com>,
>   armchair@my-deja.com wrote:
> > Would you agree that you and I disagree on whether the forced type
> > declaration in C++ adds to the readability and
> > understandability of the
> > code in languages such as Perl?
>
> I probably agree with you on that -- but I think you said that wrong.
> Nothing in C++ (forced type declarations or anything else) has any
> impact on code in Perl or any other language.

I am saying: "we disagree on whether the forced type specification in
C++, makes C++ more readable than code in languages such as Perl which
has no or ambiguous type declarations".

>
> > Scalar variables in Perl (numbers, strings, references to
> > (numbers,strings,hashes,arrays,objects)) are all identified
> > the same.
> >   my $variable.
> > This is not the same as C++ syntax.
> > Nor is is that same as what takes place under the hood.
>
> Obviously.  I never said it was.

Well, with your creative editing, you deleted what you said as well, so
presumably you agree you were wrong as well.

>
> > > (Btw, p could indeed point to any type, including built-ins.
> > > Maybe not in an ideal system, but it's still possible,
> > > and common.)
> >
> > No it can't. Try and get this to compile
> >
> > int *a;
> > short b = 2;
> > a = &b;
> >
> > Only pointers declared as void can point to any variable, and
> > then you
> > can't dereference them unless you cast them to the
> > appropriate pointer
> -
> > you must ultimately know they type of what they point to.
>
> If that's true, then the language has changed since the last time I
> used it.  It used to be, a pointer could point to any memory location,
> regardless of what you or the computer thought was stored there.
> All it took was a cast.  You could dereference it, too.  The only
> case that was guaranteed to cause a problem was dereferencing a
> NULL pointer.
>
> But you're telling me that
>
> 	Foo x;
> 	int* p = (int*) &x;
> 	int i = *p;
>
> is an error.  That's news to me.

That is an error, absolutely. Int pointers should not point to Foo
classes or structs, and that pointer should not later be dereferenced.
By the way, how did you come out on getting my code to compile. I will
repeat it again here:

int *a;
short b = 2;
a = &b;

>
> > Overloading of operators in Perl? I guess I missed that in perlobj.
>
> It's not in the core.  Read perldoc overload if you're interested.

Oops, I seem to remember an argument for comments like this. "I could
add stuff to Assembly for operator overloading - it's a Turing
derivative aint' it? Did you fall asleep in class that day?" Tell me
about what is in the Perl core my good man, not what someone has coaxed
it into doing with unknown success.

>
> > > The philosophy of OO says that types should be abstracted.
> > > Different
> > > systems abstract them to different levels, and perhaps the best we
> > > can say is that this is proper.  In Perl, it was decided
> > > that -- most
> > > of the time -- numbers and strings should be dealt with
> > > via a common
> > > abstraction, i.e. a common superclass.
> >
> > If I have a date/time object, the "philosophy of OO" may say that I
> > don't need to know how it is represented, but they have
> > nothing against
> > me knowing that it represents dates and times. But with my $a =
> > somefunction(); I don't know whether $a represents date/times
> > or is a
> > count of the number of times some functionality
> > in Perl is represented
> > as having arose from long and deep thought.
>
> It's simply a higher degree of abstraction.
> Some programmers see this as a feature.

It's simply a higher degree of uncertainty. Some programmers are happy
to live with it.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 8 Jun 1999 11:02:38 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: perl > NTMail
Message-Id: <375cea3e@newsread3.dircon.co.uk>

Rob Taylerson <rob@rtanet.com> wrote:
> can anyone recommend a perl script that reliably handles the conversation
> from a webserver to an NT based mailserver (NT Mail ver 4).
> Its just the HELO... RCPT TO  etc etc bit that we can't make work.
> 

The module Net::SMTP part of the libnet bundle available from CPAN
will do that for you.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: Tue, 08 Jun 1999 13:35:49 GMT
From: fezzzza@yahoo.com (fezzzza)
Subject: perl cgi and apache
Message-Id: <375d19a9.1968613@news.easynet.co.uk>



Please help I cant seem to get my perl script running on apache on red
hat 6.0 I get a server error 

on looking at the error logs I get a [error[ (2) no such file or
directory :exec of /home/httpd/cgi-bin/hello.cgi failed

I have set all the directorys and and to chmod 777 and inable the suid
bit flag on perl.

in the script the firslt line is !#/usr/bin/perl I have tried moving
the perl file to the cgi-bin and chaing it to !#perl

still the same error message I have swtiched on indexes and includes
and FollowSysmlinks and ExecCGI in the access.conf and set up both 
a  AddHandler cgi-script .cgi and Addtype application/x-httpd-cgi .cgi

or set them up as one or the other.

I am a complete loss of what the probmlem might be

Oh if I run on the command line 

perl /home/httpd/cgi-bin/hello.cgi it works fine

As anyone got any ideas ???

Thanks in advance 


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

Date: 8 Jun 1999 14:25:39 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Perl cgi problem: use cgi qw()param; unrecognized switch use CGI qw(param);
Message-Id: <375d19d3@newsread3.dircon.co.uk>

aaron@preation.com wrote:
> 
> 
> My Web Server Tells me "Unrecognized switch:" in the error log when I run
> a script. It says the error is caused by the following line:
> 
> use CGI qw(param);
> 
>
> I only know to use this line to get the info from a form that was
> submitted. When I take it out, everything else works fine, just the
> values I am trying to pass don't come through. How else can I get the
> values through, what should I call to make this work?
> 

you probably want to use :

  use CGI qw(:standard);

You also probably want to read the documentation for the CGI manual -

  perldoc CGI

The documentation is also available online at:

  <http://stein.cshl.org/WWW/CGI/>

if for some reason you arent able to see it locally.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: Tue, 8 Jun 1999 16:14:09 -0700
From: "Alex" <axc@iname.com>
Subject: reading socket problem
Message-Id: <7jj51r$o4a$1@news.kolumbus.fi>

Hi

I have next problem.

This (example) script below should record browser requests.
It's working fine with browsers what are sending

Headers\r\n
\r\n
Body \r\n
(eq Netscape)

but not with browsers what are sending

Headers\r\n
\r\n
Body
(without last \r\n)

Problem is that the Body line will not be received untill rePosted

=====================================
#!/usr/bin/perl

use Socket;

socket (SOCKET, PF_INET, SOCK_STREAM, 0);
bind (SOCKET, sockaddr_in(2010, INADDR_ANY));
listen SOCKET, 5;

while(1) {

$osoite = accept ASIAKAS, SOCKET;
select ASIAKAS;
$| = 1;

while (<ASIAKAS>) {
open (FRE, ">>noktest.txt");
print FRE "$_";
close (FRE);
}

close (ASIAKAS);

}
=====================================

In my log it will look like:

=================================
Request nr 1.
=================================
POST / HTTP/1.0
Host: hel.tietovalta.fi:2010
Accept: text/plain, text/html, image/gif,
image/jpeg,application/x-nokia-9000-communicator-add-on-software,
*/*
User-Agent: Nokia-Communicator-WWW-Browser/3.0 (Geos 3.0 Nokia-9110)
Content-Type: application/x-www-form-urlencoded
Content-Length: 28
Via: 1.1 proxy.hel.tietovalta.fi:8080 (Squid/1.1.21)
X-Forwarded-For: 193.229.121.197
Cache-control: Max-age=259200

==================================
Request nr 2.
==================================
test=aapunen&kala=xx%F6ks%F6POST / HTTP/1.0
Host: hel.tietovalta.fi:2010
Accept: text/plain, text/html, image/gif,
image/jpeg,application/x-nokia-9000-communicator-add-on-software, */*
User-Agent: Nokia-Communicator-WWW-Browser/3.0 (Geos 3.0 Nokia-9110)
Content-Type: application/x-www-form-urlencoded
Content-Length: 28
Via: 1.1 proxy.hel.tietovalta.fi:8080 (Squid/1.1.21)
X-Forwarded-For: 193.229.121.197
Cache-control: Max-age=259200

==================================

As you see the body for previous request will be sent within next request.
What can be the reason and how to fix it?

Regards
Alex,





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

Date: 08 Jun 1999 04:47:19 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: REDIRECT in the BODY of a HTML page...
Message-Id: <m1bteqgbi0.fsf@halfdome.holdit.com>

>>>>> "Claus" == Claus Pruefer <pruefer@idnet.de> writes:

Claus> HTML-Page creates INPUT-fields, if you hit the TRANSMIT button,
Claus> the data is given to a CGI-Script, which creates a HTML-page
Claus> (HEADER & BODY), now in the BODY i create RADIO-BUTTONS with a
Claus> NEW TRANSMIT button...  if you hit the TRANSMIT button there
Claus> should be 2 different possibilities:

Claus> if the user selected "yes" from the radio button the cgi-script
Claus> should CLEAR the BROWSER window or create a NEW HTML-PAGE or a
Claus> NEW HEADER...

Claus> second possibility is if the user selected "NO" the browser
Claus> should do a simple redirect to a specific url...

The action script for the form with the radio-button can respond
either with a new HTML page or a redirect, yes.  You won't get
immediate redirects from selecting a form element unless you use
client side scripting (which won't work on my browser, nor thousands
of others, so beware).

But this now (and then) has NOTHING to do with Perl.  Please go ask
further questions in comp.infosystems.www.authoring.cgi, to which I've
directed followups.

print "Just another Perl hacker,"

-- 
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@teleport.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: Tue, 08 Jun 1999 11:59:43 +0200
From: Ondrej Palkovsky <xpalo03@vse.cz>
Subject: Return value of -die-
Message-Id: <375CE98F.3CA393E2@vse.cz>

Let's have some simple code:

#!/usr/bin/perl
`mt -f /dev/nst0 rewind`;
$? && die;

Now I start this like:
>simple.perl;
>echo $?;
And the output:
mt: /dev/nst0: Pxmstup odmmtnut
Died at - line 4.
0

(I don't have rights to /dev/nst0). The problem is, that the script
shouldn't return the zero value, but something else(probably 1, that's
what mt returns). Could you point me, where is the problem?

Thanks
  Ondrej Palkovsky
  xpalo03@vse.cz
-- 
Seleznick's Theory of Holistic Medicine:
	Ice Cream cures all ills.  Temporarily.


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

Date: Tue, 8 Jun 1999 04:22:10 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Return value of -die-
Message-Id: <irjij7.a0p.ln@magna.metronet.com>

Ondrej Palkovsky (xpalo03@vse.cz) wrote:
: Let's have some simple code:

: #!/usr/bin/perl


   That is _too_ simple. It should be:

      #!/usr/bin/perl -w


: (I don't have rights to /dev/nst0). The problem is, that the script
: shouldn't return the zero value, but something else(probably 1, that's
: what mt returns). Could you point me, where is the problem?


   There was a bug in some perl's die() return values.

   I think it was in one of the 5.004xx versions. Fixed in 5.005.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 8 Jun 1999 10:36:30 GMT
From: Christoph Schmitz <cschmitz@stud.informatik.uni-trier.de>
Subject: Re: Using hash keys
Message-Id: <7jirne$n33$1@fu-berlin.de>

Derek Lavine <derek@realware.com.au> wrote:
: I want to pass a function a hash, thus

: %data = ( field1 => "field1 data",
:                 field2 => "field2 data",
:                 field3 => "field3 data"
:                 etc.
:              )

: then I want to pass this to a function along with a list of required
: field names

: e.g.

: $reqfields = "field1, field3"

: iscomplete ( \%data, $reqfields );

: iscomplete needs to return 'true' if %data does indeed contain non empty
: entries for the keys specified in $reqfields

: I guess in general I am asking things like how do I get individual keys
: or all the keys from a hash.

: What is an easy way to step through a string like "field1, field2,
: field3" etc. so that on each iteration I have "field1", "field2" etc. to
: work with

Something like

sub iscomplete {
	my $hashref = shift;
	my $reqfields = shift;

	# the split is what you asked for
        # -> perldoc -f split
	foreach (split /\,\s+/, $reqfields) {  
		return 0 if (not exists $hashref->{$_});	
	}

	return 1;
}

should do the job.

: Also is it possible to use the value of a string, $str, as an L_Value so
: if $str="myvar1" I would like to be able to set $myvar1 (the real
: variable) via $str, something like

: ${$str} = "this is going to be placed in the var called myvar1";

: NOTE: (I am using the '{' and '}' to indicate what I need, not that I
: think this is the way to do it)

This is exactly the syntax for symbolic references. Read man perlref.

HTH,

Christoph

-- 
-- Christoph Schmitz <cschmitz(at)stud.informatik.uni-trier.de> --
/* Halley */
         (Halley's comment.)


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

Date: 08 Jun 1999 04:42:26 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Using string variable as name of subroutine to call
Message-Id: <m1hfoigbq5.fsf@halfdome.holdit.com>

>>>>> "Uri" == Uri Guttman <uri@sysarch.com> writes:

Uri> unless you really, really know what you are doing. which eliminates about
Uri> %99 of all perl hackers. symrefs have their use but it is usually in
Uri> obscure or dark corners. 

Having not seen the % used as a prefix before, I had to recall where,
and remembered that that's the URI encoding scheme.  Since you're Uri,
I figured you were encoding some secret there.  Let's see what it is:

	$ perl -MURI::Escape -e 'print uri_unescape("%99");'
	

Well, that wasn't very useful.  I don't even know what it is, except
that it's \231. :)

So, what *was* the secret message there?

:)

-- 
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@teleport.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: 8 Jun 1999 14:33:23 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Using string variable as name of subroutine to call
Message-Id: <375d1ba3@newsread3.dircon.co.uk>

Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>>>>>> "Uri" == Uri Guttman <uri@sysarch.com> writes:
> 
> Uri> unless you really, really know what you are doing. which eliminates about
> Uri> %99 of all perl hackers. symrefs have their use but it is usually in
> Uri> obscure or dark corners. 
> 
> Having not seen the % used as a prefix before, I had to recall where,
> and remembered that that's the URI encoding scheme.  Since you're Uri,
> I figured you were encoding some secret there.  Let's see what it is:
> 
> 	$ perl -MURI::Escape -e 'print uri_unescape("%99");'
> 	
> 
> Well, that wasn't very useful.  I don't even know what it is, except
> that it's \231. :)
> 
> So, what *was* the secret message there?
> 

The character it makes looks like a theta to me on my PC ...

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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