[12134] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5734 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 20 13:07:18 1999

Date: Thu, 20 May 99 10:00:25 -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           Thu, 20 May 1999     Volume: 8 Number: 5734

Today's topics:
        A GLOB????? <joaob@despodata.pt>
    Re: A GLOB????? <gellyfish@gellyfish.com>
        ActiveState and MySQL <craig@mathworks.com>
    Re: ActiveState and MySQL <gellyfish@gellyfish.com>
    Re: Any concept of Constant in Perl <swarren@www.wwwdotorg.org>
    Re: C superior to Perl in DB2 programming? <tzadikv@my-dejanews.com>
        Calling unix programs from a perl script / Internal Ser <eras023@wi.leidenuniv.nl>
        CGI+Apache+SSL <s103391@stud-mail.uni-wuerzburg.de>
    Re: CGI+Apache+SSL <gellyfish@gellyfish.com>
    Re: CGI/ISAPI problem <cassell@mail.cor.epa.gov>
    Re: CGI/ISAPI problem <cassell@mail.cor.epa.gov>
    Re: conditional regexp matching. Please advise. <swarren@www.wwwdotorg.org>
    Re: conditional regexp matching. Please advise. <anand@my-dejanews.com>
    Re: conditional regexp matching. Please advise. (Bart Lateur)
        CSV to DBF Format (Richard Webber)
    Re: CSV to DBF Format <gellyfish@gellyfish.com>
    Re: Is it a file or a link? <swarren@www.wwwdotorg.org>
    Re: Is it a file or a link? (Andrew Allen)
    Re: Looking for Phonetic Program in Perl (Effie Rover)
        MS WORD97 Macro Question <derald_powell@hp.com>
    Re: No classes.zip file found (David Cantrell)
    Re: out of memory! <swarren@www.wwwdotorg.org>
        pattern matching probs... <Matthew@swt.edu>
    Re: pattern matching probs... (Larry Rosler)
    Re: PERLFUNC: scalar - force a scalar context (Bart Lateur)
        Problems with @INC, path gets added but use still not w <Mark.Conlin@bridge.bellsouth.com>
    Re: semi-newbie: pattern matching probs... (Larry Rosler)
    Re: semi-newbie: pattern matching probs... <Matthew@swt.edu>
    Re: su and perl <swarren@www.wwwdotorg.org>
    Re: undef of namespaces (M.J.T. Guy)
    Re: undef of namespaces (Andrew Allen)
    Re: Validating a subnet mask... <swarren@www.wwwdotorg.org>
    Re: Verifying passwd in FreeBSD <anakim@my-dejanews.com>
        wait(), zombies, and solaris: why won't my children die (Charlie Stross)
        We need your help ( doc, link , etc ) !!! <fred@decatomb.com>
        write() not printing TOP format jkane@my-dejanews.com
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Thu, 20 May 1999 16:20:53 +0100
From: =?iso-8859-1?Q?Jo=E3o?= Bonina <joaob@despodata.pt>
Subject: A GLOB?????
Message-Id: <37442854.8EE1B5A9@despodata.pt>


	Hi!
	I'm trying to write a Perl script for e-mail reading using the
Mail::Internet module, but it sayas it needs a GLOB reference.
	So, the question is: what is a GLOB?


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

Date: 20 May 1999 16:46:25 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: A GLOB?????
Message-Id: <37442e51@newsread3.dircon.co.uk>

Joco Bonina <joaob@despodata.pt> wrote:
> 
> 	Hi!
> 	I'm trying to write a Perl script for e-mail reading using the
> Mail::Internet module, but it sayas it needs a GLOB reference.
> 	So, the question is: what is a GLOB?

>From the perdiag manpage (where you should have looked first :)

   Not a GLOB reference 

  (F) Perl was trying to evaluate a reference to a ``typeglob'' (that is,
  a symbol table entry that looks like *foo), but found a reference to
  something else instead. You can use the ref() function to find out what
  kind of ref it really was. See perlref.

Without seeing the offending piece of code it is rather difficult to
tell what the problem is.

I assume your problem is with the print() method where you should be
passing it a reference to a filehandle glob like:

   $mail->print(\*STDOUT);

As it says fairly explicitly in the manpage for the module - if you are
using some other filehandle you will have to treat in the same way.

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



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

Date: Thu, 20 May 1999 11:31:07 -0400
From: Craig Ciquera <craig@mathworks.com>
Subject: ActiveState and MySQL
Message-Id: <37442ABB.F570C52E@mathworks.com>

Hello,

Has anyone gotten DBI and MySQL working with an ActiveState distribution
of PERL???

If so, how so???


Thanks in advance,
Craig



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

Date: 20 May 1999 16:37:03 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: ActiveState and MySQL
Message-Id: <37442c1f@newsread3.dircon.co.uk>

Craig Ciquera <craig@mathworks.com> wrote:
> Hello,
> 
> Has anyone gotten DBI and MySQL working with an ActiveState distribution
> of PERL???
> 

Using DBD::ODBC and the MySQL odbc driver ...

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



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

Date: Thu, 20 May 1999 11:42:59 -0400
From: "Stephen Warren" <swarren@www.wwwdotorg.org>
Subject: Re: Any concept of Constant in Perl
Message-Id: <7i1al1$9d5$1@owl.slip.net>

Jalil Feghhi <jalil@corp.home.net> wrote in message
news:927158122.300751@zeppelin.svr.home.net...
> Is there any way to define constants in Perl?

One would typically just have a variable somewhere and assign the value to
it somewhere:

$varname = 10 ;

Then just use this like any scalar in your program.

There probably are ways of making it read-only if you're paranoid. I'll let
someone else answer that!

--
Stephen Warren, Snr Systems Engineer, Technology House, San Francisco
mailto:swarren@techhouse.com                http://www.techhouse.com/
mailto:swarren@wwwdotorg.org                http://www.wwwdotorg.org/
              MIME, S/MIME and HTML mail are acceptable





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

Date: Thu, 20 May 1999 16:37:30 GMT
From: Tzadik Vanderhoof <tzadikv@my-dejanews.com>
Subject: Re: C superior to Perl in DB2 programming?
Message-Id: <7i1do9$5pm$1@nnrp1.deja.com>

Thanks for answering...  However... did you read my question?
Part of it was:

>I tried doing such a copy recently by simply using "tar" to package
>up the relavant directorys in /usr/local/lib/perl5, but I could
>not run my script on the second machine

You answered:

In article <QSI03.9175$vP2.6358@news.rdc1.tn.home.com>,
  "Bruce (the other) McCrea" <bruce2@home.com> wrote:

> To use the perl code on another machine, you'll need to copy the whole
> /usr/local/lib/perl5 directory tree and /usr/local/bin/perl and
whatever
> gets installed when you install and compile perl or any module.

Ummm... isn't that the same as what I did?  And, as I said, after doing
that, the script did not work.


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


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

Date: Thu, 20 May 1999 18:02:51 +0200
From: Roman Ganhoer <eras023@wi.leidenuniv.nl>
Subject: Calling unix programs from a perl script / Internal Server Error
Message-Id: <3744322B.FEEB3CA7@wi.leidenuniv.nl>

Hi,
We are having a problem when executing a Perl script containing a system
call

For example calling the UNIX copy command 'cp' gives no error but
doesn't execute.
When we call the command 'cat' we get an Internal Server Error

What are we doing wrong?
Can someone help us?

Roel



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

Date: Thu, 20 May 1999 17:54:22 +0200
From: Florian Schmitt <s103391@stud-mail.uni-wuerzburg.de>
Subject: CGI+Apache+SSL
Message-Id: <3744302E.5384BE91@stud-mail.uni-wuerzburg.de>

Is it possible in a cgi to automatically find out if the browser 
supports SSL? 
Any Ideas?

--
Florian Schmitt 
http://www.german-army-shop.com


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

Date: 20 May 1999 16:56:01 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: CGI+Apache+SSL
Message-Id: <37443091@newsread3.dircon.co.uk>

Florian Schmitt <s103391@stud-mail.uni-wuerzburg.de> wrote:
> Is it possible in a cgi to automatically find out if the browser 
> supports SSL? 
> Any Ideas?
> 

Yes - ask in comp.infosystems.www.authoring.cgi 

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



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

Date: Thu, 20 May 1999 09:46:45 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
To: Gunther Schmidl <gschmidl@gmx.at>
Subject: Re: CGI/ISAPI problem
Message-Id: <37443C75.65F1C5D6@mail.cor.epa.gov>

Gunther Schmidl wrote:
> 
> I'm having huge troubles with below script (apart from the obvious bad
> style, probably, but I'm a beginner, so please bear with me :-). In
> interactive mode (that is, on the command line), everything works perfectly
> well - but if I want to run the script on a Microsoft IIS via Perl-ISAPI,
> 'File::Find' stops processing every file recursively and only 'does' the
> directories; this without my changing a single line. The script is running
> as IIS-Administrator, so I'm guessing it's not a security problem. Is there
> a bug in File::Find, am I doing something fundamentally wrong, or what is
> the matter?

Since you don't seem to be getting any help in this ng, you might
want to ask this question in the win32-perl-users listserv,
to which you can subscribe by going to www.activestate.com and
following their links to the list subscription area.

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Thu, 20 May 1999 09:48:23 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
To: Sharad Bansal <sbansal@roartech.com>
Subject: Re: CGI/ISAPI problem
Message-Id: <37443CD7.398AD7E@mail.cor.epa.gov>

Sharad Bansal wrote:
> 
> Sorry, I can't help u with this. But, I have my own perl IIS issue . Did u try
> to redirect STDERR ? ie
> carpout(LOGG) ? IIS just gives an error witht this ...
> 
> It very well might be that Carp and File have bugs under IIS.

Or that IIS has at least one more bug.

But you might want to ask in the win32-centric Perl listservs
that you can subscribe to at the www.activestate.com website.

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Thu, 20 May 1999 11:24:22 -0400
From: "Stephen Warren" <swarren@www.wwwdotorg.org>
Subject: Re: conditional regexp matching. Please advise.
Message-Id: <7i19i3$96f$1@owl.slip.net>

Ravi Kumar <ravik@cyrix.com> wrote in message
news:3740597F.275B92B@cyrix.com...
> All,
>
>     I have to read in hex numbers specifiable either as 0xffffffff or
> fffffffh.
> but not both. I cannot exhaustively try all combinations with several
> regexps. How can I do this with one regexp ?

Well, this way would allow both the above:

    $value =~ s/^0x//i ;
    $value =~ s/h$//i ;
    # value now contains just the hex digits

However, this would allow the user to enter just the hex digits without
either a leading 0x or trailing h, so if you want to force this, you might
have to:

    die "invalid input: $value" if ! ( ( $value =~ /^0x/i ) ||
                                       ( $value =~ /h$/i  )
                                     ) ;

Or something like that...

One can probably do things with saving the results of s/// and or()ing them
to replace the m// and stuff, but this should be a start.

--
Stephen Warren, Snr Systems Engineer, Technology House, San Francisco
mailto:swarren@techhouse.com                http://www.techhouse.com/
mailto:swarren@wwwdotorg.org                http://www.wwwdotorg.org/
              MIME, S/MIME and HTML mail are acceptable





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

Date: Thu, 20 May 1999 15:33:53 GMT
From: Anand <anand@my-dejanews.com>
Subject: Re: conditional regexp matching. Please advise.
Message-Id: <7i1a12$2ou$1@nnrp1.deja.com>

In article <3740597F.275B92B@cyrix.com>,
  Ravi Kumar <ravik@cyrix.com> wrote:
>     I have to read in hex numbers specifiable either as 0xffffffff or
> fffffffh.
> but not both. I cannot exhaustively try all combinations with several
> regexps. How can I do this with one regexp ?

Warning: Beginner is replying.

/0x[0-9a-f]+|[0-9a-f]+h/i

stricter: /^0x[0-9a-f]{1,8}$|^[0-9a-f]{1,8}h$/i

Anand


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


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

Date: Thu, 20 May 1999 16:44:10 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: conditional regexp matching. Please advise.
Message-Id: <37453b0c.21045722@news.skynet.be>

Ravi Kumar wrote:

>    I have to read in hex numbers specifiable either as 0xffffffff or
>fffffffh.
>but not both. I cannot exhaustively try all combinations with several
>regexps. How can I do this with one regexp ?

	/^(?:0x[0-9A-Fa-f]+|[0-9A-Fa-f]+h)$/

but I really can't see what's wrong with

	/^0x[0-9A-Fa-f]+$/ or /^[0-9A-Fa-f]+h$/

	Bart.


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

Date: 20 May 1999 16:03:27 GMT
From: rw@soton.ac.uk (Richard Webber)
Subject: CSV to DBF Format
Message-Id: <7i1bof$dai$1@aspen.sucs.soton.ac.uk>

Hello,

I'm trying to create a perl program which will take csv files up to 500MB in
size, and convert them to DBF format.  I've looked at the DBI:XBase module,
however, I don't have a database server to connect to, and simply want to
output the dbf format files.

Does anyone have any perl code which will do this job, or failing that, does
anyone know the format for dbf files so that I can write perl code myself?

Any help would be greatly appreciated.

Richard.

-- 
Richard Webber			 Tel:    01703 595498
Computing Officer, User Support  Fax:    01703 593939
Computing Services	 	 Email:  R.Webber@soton.ac.uk	
University of Southampton	
Highfield
Southampton (UK)
SO17 1BJ


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

Date: 20 May 1999 17:14:12 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: CSV to DBF Format
Message-Id: <374434d4@newsread3.dircon.co.uk>

Richard Webber <rw@soton.ac.uk> wrote:
> Hello,
> 
> I'm trying to create a perl program which will take csv files up to 500MB in
> size, and convert them to DBF format.  I've looked at the DBI:XBase module,
> however, I don't have a database server to connect to, and simply want to
> output the dbf format files.
> 
> Does anyone have any perl code which will do this job, or failing that, does
> anyone know the format for dbf files so that I can write perl code myself?
> 

You dont need an database server - XBase doesnt use one, fortunately for 
for you here is a post I made earlier.

/J\

From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: DBF Format
Date: 19 Mar 1999 00:00:00 GMT
Message-ID: <7cuig8$o4$1@gellyfish.btinternet.com>
X-Perl-Mongers: London.pm
References: <7cru78$dbu$1@nnrp1.dejanews.com>
Organization: Gellyfish software
User-Agent: tin/pre-1.4-19990216 ("Styrofoam") (UNIX) (Linux/2.2.0 (i686))
Reply-To: Jonathan Stowe <gellyfish@btinternet.com>
Newsgroups: comp.lang.perl.misc

On Thu, 18 Mar 1999 22:20:38 GMT mtcorey@my-dejanews.com wrote:
> I was told that it was possible to use the DBD::xBase module to write data
> out in DBF format.  I have never used the DBD::xBase module, so I am totally
> lost.  What I need to do is extract the data from a Sybase SQL Server
> database (this I can do using sybperl), but I have no idea how to write the
> extracted data out in DBF format using DBD::xBase.  Has anyone ever performed
> this?  If so any help would be greatly appreciated.  Thanks.
> 

The beauty of DBI is that you have the same interface for any supported
database (within the constraints of that database of course).  Here is a
quick example (Using what seems to have become my ubiquitous phonebook
text file ) - The only drawback of using DBD::XBase is that it doesnt
support indexes at the moment :


#!/usr/bin/perl -w

use strict;

use DBI;
my $dbh = DBI->connect("DBI:XBase:.") or die $DBI::errstr;

my $create_statement = <<EOQUERY;
CREATE TABLE phonebook 
(
   surname  CHAR(20),
   forename CHAR(30),
   title    CHAR(30),
   number   CHAR(15),
   location CHAR(10),
   dept     CHAR(5)
)
EOQUERY

$dbh->do($create_statement);

my $sth = $dbh->prepare("INSERT INTO phonebook VALUES (?,?,?,?,?,?)")
                                       or die $dbh->errstr();

open(PHONE,"phonebook.txt") or die "Couldnt open - $!\n";

while(<PHONE>)
{
  my ( $surname,
       $forename,
       $title,
       $number,
       $location,
       $dept ) = split /,/,$_ ;

$sth->execute($surname,
              $forename,
              $title,
              $number,
              $location,
              $dept) or die $sth->errstr();
}

close(PHONE);

Of course here I have created the DBF table which might not be necessary
in your application ...



-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: Thu, 20 May 1999 11:28:07 -0400
From: "Stephen Warren" <swarren@www.wwwdotorg.org>
Subject: Re: Is it a file or a link?
Message-Id: <7i19p4$97i$1@owl.slip.net>

John Horne <john@jhorne.csd.plym.ac.uk> wrote in message
news:37428a99@palantir.pbs.plym.ac.uk...
> Hello,
>
> I am trying to write a section of perl which will be looking
> in a directory containing a lot of 'files'. However, I need to be
> able to discern between a real (?) file and a symbolic (soft) link.
>
> The test 'if ( -f $filename)' will be positive if the file is real
> or a link. The test 'if (-l $filename)' will tell me if it is a link,
> and I know I could combined them into
>   'if (-f $filename && ! -l $filename)'
> to let me know if it is a real file (i.e. not a link). But is there
> an easier way? I have a lot of tests to do and the use of this combined
> form seems a bit clumsy. I thought perhaps a '-F' test to say it's a
> real file and '-f' remains as a file or link.

If efficiency is your concern, then the perldoc that details either the
function stat, or -f/-l etc should mention the implicit file _ (IIRC) that
effectively stores the result of the last stat() (or -f etc IIRC) so you
might get away with something like:

    if ( -f $filename && ! -l _ )

Anyway, the above syntax may be way off, but it's there in the docs.

--
Stephen Warren, Snr Systems Engineer, Technology House, San Francisco
mailto:swarren@techhouse.com                http://www.techhouse.com/
mailto:swarren@wwwdotorg.org                http://www.wwwdotorg.org/
              MIME, S/MIME and HTML mail are acceptable





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

Date: 20 May 1999 16:37:59 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: Is it a file or a link?
Message-Id: <7i1dp7$hcg$2@fcnews.fc.hp.com>

Stephen Warren (swarren@www.wwwdotorg.org) wrote:
: John Horne <john@jhorne.csd.plym.ac.uk> wrote in message
: news:37428a99@palantir.pbs.plym.ac.uk...
: > Hello,
: >
: > I am trying to write a section of perl which will be looking
: > in a directory containing a lot of 'files'. However, I need to be
: > able to discern between a real (?) file and a symbolic (soft) link.
: >
: > The test 'if ( -f $filename)' will be positive if the file is real
: > or a link. The test 'if (-l $filename)' will tell me if it is a link,
: > and I know I could combined them into
: >   'if (-f $filename && ! -l $filename)'
: > to let me know if it is a real file (i.e. not a link). But is there
: > an easier way? I have a lot of tests to do and the use of this combined
: > form seems a bit clumsy. I thought perhaps a '-F' test to say it's a
: > real file and '-f' remains as a file or link.

: If efficiency is your concern, then the perldoc that details either the
: function stat, or -f/-l etc should mention the implicit file _ (IIRC) that
: effectively stores the result of the last stat() (or -f etc IIRC) so you
: might get away with something like:

:     if ( -f $filename && ! -l _ )

: Anyway, the above syntax may be way off, but it's there in the docs.

Nope. -l needs lstat. -f uses stat. What you did provides the handy
error message:

  The stat preceding -l _ wasn't an lstat at -e line 1.

Now _that's_ a clear error message!

Andrew


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

Date: Thu, 20 May 1999 16:00:57 GMT
From: null@effierover.com (Effie Rover)
Subject: Re: Looking for Phonetic Program in Perl
Message-Id: <3744300a.429363948@news.iinc.com>

On Wed, 19 May 1999 13:02:59 -0500, Ed Bogart <bogart@exis.net> wrote:


>It's been 20 years since I did any computational psycholinguistics (anyone
>remember SNOBOL?) but unless things have changed a _lot_, it can't be done. The
>problem is that the phonetic value of a string is an emergent property, not
>closely encode. It's easy for us using our massively parallel brains but verrrry
>hard for computers. Adding pictures to the mess is sure to make add another
>magnitude to the difficulty.

Thanks very much for the informed response. Actually, I do remember
SNOBOL, although I never programmed near it. :-) 

OK, I figured this wasn't going to be easy, but I don't need exact
matches, either. I'm not advertising this thing as perfect, and it's
to generate the rebus, not solve it. Words like steak, stake, take,
sake, wake, cake, etc will all be replaced (in my program) by a
picture of a nicely grilled T-Bone with some letters added or
subtracted, so really all I need is the word stem or approximations
thereof. 

>You might be able to over power it but it would require a complete dictionary of
>all the words and syllables with all their phonetic equivalents built in. Some
>large, well funded groups have tried problems like this and not got very far.

This is the approach I was trying to avoid, although I wouldn't be
averse to a static dictionary of syllables once I've gotten the words
broken down that far. I've heard something about a really terrific
hyphenation routine in (I think) Tex. Has anyone heard of that and can
point out where I might see the algorithm?

  -- Loy

Loy Ellen Gross AKA Effie Rover
The email address above goes straight to /dev/null :-)
effie -at- effierover -dot- com * http://www.effierover.com
Effie Rover's Fantasy Role Playing Gamer's Library
---------------------------------------------------------------
Protect privacy, boycott Intel: http://www.bigbrotherinside.org
---------------------------------------------------------------


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

Date: Thu, 20 May 1999 10:48:56 -0600
From: "Derald Powell" <derald_powell@hp.com>
Subject: MS WORD97 Macro Question
Message-Id: <7i1efh$ins$1@fcnews.fc.hp.com>

After recording a word97 macro, how do you make it availabe for execution by
a perl script.
I know this THE perl newsgroup, but I can't find a word newsgroup, nor
information on accessing
word scripts.  Any help appreceiated.  You can send replies to
cis118instructor@yahoo.com if you like.
Thanks in advance.




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

Date: Thu, 20 May 1999 16:31:37 GMT
From: NukeEmUp@ThePentagon.com (David Cantrell)
Subject: Re: No classes.zip file found
Message-Id: <37443806.4939442@news.insnet.net>

On Wed, 19 May 1999 20:05:07 +0300, cederstrom@kolumbus.REMOVE_THIS.fi
(Juho Cederstrom) enlightened us thusly:

>How about this one:
>
>print "$_ is Perl!\n"		if	/^[Pp]erl(\n)?$/;
>print "$_ is *NOT* Perl!\n"	unless	/^[Pp]erl(\n)?$/;
>
>Now it recognises even perl and Perl\n (when somebody forgets to use
>chomp).
>
>BTW: Are there better ways to write that one? I don't like using two
>same regexes that way. And I like [if ...else] neither:

print "$_ is ".((/^perl(\n)?$/i)?'':'*NOT* ')."perl!\n";

By using /i it'll also recognise the mis-spelling PERL as well which
may or may not be a good thing.

[Copying newsgroup posts to me by mail is considered rude]

-- 
David Cantrell, part-time Unix/perl/SQL/java techie
                full-time chef/musician/homebrewer
                http://www.ThePentagon.com/NukeEmUp


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

Date: Thu, 20 May 1999 11:49:28 -0400
From: "Stephen Warren" <swarren@www.wwwdotorg.org>
Subject: Re: out of memory!
Message-Id: <7i1b16$9f0$1@owl.slip.net>

Marc Eilens <M.Eilens@DeutschePost.de> wrote in message
news:3743CE12.2DE4@DeutschePost.de...
> Hi everybody,
>
> I've written one of my first perl-scripts and have got a question about
> memory usage.
>
> The task is to read a file and split different rows into different
> files.
> I open the file and then read the complete file with the while(<>) loop.
> Then I deal with the different rows.
> Running the script on a file of about 100 KB works fine. But when
> running it on a file of 2.5 Meg I get the message "out of memory!". It
> seems that the file was read in correctly (debug-statement is written
> out after the while-loop). But after that, there somewhere seems to be
> no more memory.

An obvious solution would be to read the input file in line-by-line if your
splitting algorithm doesn't require any context. The storage for input data
would then be vastly reduced.

i.e. instead of:

    @ar = <FILE> ;
    foreach $elem ( @ar )
    {
       # process $elem
    }

You'd do:

    while ( <FILE> )
    {
       process $_
    }

--
Stephen Warren, Snr Systems Engineer, Technology House, San Francisco
mailto:swarren@techhouse.com                http://www.techhouse.com/
mailto:swarren@wwwdotorg.org                http://www.wwwdotorg.org/
              MIME, S/MIME and HTML mail are acceptable





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

Date: Thu, 20 May 1999 11:26:34 -0500
From: Matt <Matthew@swt.edu>
Subject: pattern matching probs...
Message-Id: <374437BA.1DF3A6DC@swt.edu>

Ok, trying to do something like MSFP's include bot, but it's not
working:

$html =~ s/$pattern(.*?)$endpattern/$pattern$result$endpattern/i;

It never finds the regular expression! FYI,
$pattern="<!--mattbot header-->";
$endpattern="<!--mattbot end-->";
$result=(some html stuff that it's supposed to put between the two tags)

$html is a long string, somewherein is contained:
 .
 .
 .
<!--mattbot header-->
This text should be replaced...
<!--mattbot end-->
 .
 .
 .

What am I doing wrong? TIA,
-Matt Williamson




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

Date: Thu, 20 May 1999 09:54:06 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: pattern matching probs...
Message-Id: <MPG.11adde065b707d7b989acc@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <374437BA.1DF3A6DC@swt.edu> on Thu, 20 May 1999 11:26:34 -
0500, Matt <Matthew@swt.edu> says...
 ...
> $html =~ s/$pattern(.*?)$endpattern/$pattern$result$endpattern/i;
 ... 
> $html is a long string, somewherein is contained:
> .
> <!--mattbot header-->
> This text should be replaced...
> <!--mattbot end-->
> .
> 
> What am I doing wrong? TIA,

I'm glad that my crystal-ball supposition about multiple lines was 
correct.  And you were smart to take the 'semi-newbie' crud out of the 
Subject.

But responding to your own post would have kept the thread together.  
Someone pointed out here yesterday that the newsreader threads by means 
of the References: header, not by parsing the Subject: header.  This is 
good.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 20 May 1999 16:39:19 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: PERLFUNC: scalar - force a scalar context
Message-Id: <374439ab.20692938@news.skynet.be>

Tom Christiansen wrote:

>    There is no equivalent operator to force an expression to be
>    interpolated in list context because in practice, this is never
>    needed. If you really wanted to do so, however, you could use the
>    construction `@{[ (some expression) ]}', but usually a simple
>    `(some expression)' suffices.

There's also the { () = ... } construct, but this MAY FAIL, in
particular with split(), because of it's built-in optimization. Example:

	$_ = "1 2 3";
	$count = (() = split);
	print $count;

This prints "1", not "3".

Do we really not need it? Sure, split() in a scalar context returns the
desired count, but all I'm saying is that I think it's short-sighted to
say "we don't need it, because we have this trick". Especially if such
tricks are not full-proof.

	Bart.


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

Date: Thu, 20 May 1999 11:29:10 -0400
From: Mark Conlin <Mark.Conlin@bridge.bellsouth.com>
Subject: Problems with @INC, path gets added but use still not working
Message-Id: <37442A46.9976B583@bridge.bellsouth.com>

Okay, this is what I am doing.

The perl modules have all been installed in this directory
/bto/appl/orbit/lib
As the FAQ states...

	BEGIN { unshift(@INC, '/bto/appl/orbit/lib') }

Adds this to my @INC path list, I even print it to make sure

	print @INC; 

results in /bto/appl/orbit/lib...other stuff

So I try to do this

	use Sys::Hostname;

results in this "undefined subroutine &main::hostname"



Mark


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

Date: Thu, 20 May 1999 09:32:03 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: semi-newbie: pattern matching probs...
Message-Id: <MPG.11add8e063adf523989acb@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <3744348D.951FBD61@swt.edu> on Thu, 20 May 1999 11:13:02 -
0500, Matt <Matthew@swt.edu> says...
> Ok, trying to do something like MSFP's include bot, but it's not
> working:
> 
> $html =~ s/$pattern(.*?)$endpattern/$pattern$result$endpattern/i;
> 
> It never finds the regular expression! FYI,
> $pattern="<!--mattbot header-->";
> $endpattern="<!--mattbot end-->";
> $result=(some html stuff that it's supposed to put between the two tags)
> 
> What am I doing wrong? TIA,

In all likelihood, the $pattern and $endpattern are on separate lines in 
the multi-line input string $html, so the '.*?' isn't matching.  Add the 
/s modifier (so '.' now matches "\n" also), and try again.

If $pattern and $endpattern do not change during the program execution, 
add the /o modifier also, for efficiency.  This is not the bug.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 20 May 1999 11:43:14 -0500
From: Matt <Matthew@swt.edu>
To: Larry Rosler <lr@hpl.hp.com>
Subject: Re: semi-newbie: pattern matching probs...
Message-Id: <37443BA2.7895FB41@swt.edu>

Larry Rosler wrote:

> [Posted and a courtesy copy mailed.]
>
> In article <3744348D.951FBD61@swt.edu> on Thu, 20 May 1999 11:13:02 -
> 0500, Matt <Matthew@swt.edu> says...
> > Ok, trying to do something like MSFP's include bot, but it's not
> > working:
> >
> > $html =~ s/$pattern(.*?)$endpattern/$pattern$result$endpattern/i;
> >
> > It never finds the regular expression! FYI,
> > $pattern="<!--mattbot header-->";
> > $endpattern="<!--mattbot end-->";
> > $result=(some html stuff that it's supposed to put between the two tags)
> >
> > What am I doing wrong? TIA,
>
> In all likelihood, the $pattern and $endpattern are on separate lines in
> the multi-line input string $html, so the '.*?' isn't matching.  Add the
> /s modifier (so '.' now matches "\n" also), and try again.
>
> If $pattern and $endpattern do not change during the program execution,
> add the /o modifier also, for efficiency.  This is not the bug.
>
> --
> (Just Another Larry) Rosler
> Hewlett-Packard Company
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com

Yep...that did it, thanks!...and sorry about the subject change.  When I
decided to include the $html string info (which proved to be pertinent), I
accidentally left part of the subject out.

Much obliged!
-Matt Williamson



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

Date: Thu, 20 May 1999 11:45:45 -0400
From: "Stephen Warren" <swarren@www.wwwdotorg.org>
Subject: Re: su and perl
Message-Id: <7i1aq7$9dt$1@owl.slip.net>

Steve Muir <wemuis@itwol.bhp.com.au> wrote in message
news:3743619C.7770C00C@itwol.bhp.com.au...
> Jean-Louis Leroy wrote:
> > In article <37429190.B8F830CB@itwol.bhp.com.au>, Steve Muir wrote:
> >
> > > $ suprog -u <username> -p <password>
> >
> > Are you aware that any user will be able to read the
> > <username> and <password> by means of a simple `ps -ef'?
> Thanks for the reply....
> Yes, I am aware of the basic security risk but I need to able to
> automate an su to another user.

You might want to try driving the su using expect (or the Perl module for
it). You might then be able to pass user name and password over a
file-handle instead of the command-line.

--
Stephen Warren, Snr Systems Engineer, Technology House, San Francisco
mailto:swarren@techhouse.com                http://www.techhouse.com/
mailto:swarren@wwwdotorg.org                http://www.wwwdotorg.org/
              MIME, S/MIME and HTML mail are acceptable





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

Date: 20 May 1999 15:01:58 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: undef of namespaces
Message-Id: <7i1856$q1f$1@pegasus.csx.cam.ac.uk>

Marc Dietrich  <g059@mailserv.uni-giessen.de> wrote:
>
>Hello Ronald,
>
>I wrote this script:
>
>#!/usr/local/bin/perl
>
>$Q::a = "Hello World!";
>undef %Q::;
>print "$Q::a\n";
>
>the output is:
>
>$./hello.pl
>Hello World!
>$

The name lookup of $Q::a is done at compile time.   Compare what happens
if you add a BEGIN block (and to make it really instructive, make sure you
have -w set):

BEGIN {
    $Q::a = "Hello World!";
    undef %Q::;
}
print "$Q::a\n";


Mike Guy


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

Date: 20 May 1999 16:12:12 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: undef of namespaces
Message-Id: <7i1c8s$hcg$1@fcnews.fc.hp.com>

M.J.T. Guy (mjtg@cus.cam.ac.uk) wrote:
: Marc Dietrich  <g059@mailserv.uni-giessen.de> wrote:
: >#!/usr/local/bin/perl
: >
: >$Q::a = "Hello World!";
: >undef %Q::;
: >print "$Q::a\n";
: >
: >the output is:
: >
: >$./hello.pl
: >Hello World!
: >$

: The name lookup of $Q::a is done at compile time.   Compare what happens
: if you add a BEGIN block (and to make it really instructive, make sure you
: have -w set):

: BEGIN {
:     $Q::a = "Hello World!";
:     undef %Q::;
: }
: print "$Q::a\n";

Yet another reason to not muck around with namespace. Like I've said
previously: it's weird, and likely won't work like you expect. Moral
of this story: if you can't do it with globs, you're either not trying
hard enough, or you really don't want to do it anyways.

Andrew


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

Date: Thu, 20 May 1999 11:54:01 -0400
From: "Stephen Warren" <swarren@www.wwwdotorg.org>
Subject: Re: Validating a subnet mask...
Message-Id: <7i1b9m$9gf$1@owl.slip.net>

Mitch <portboy@home.com> wrote in message news:3743A51D.A67E1758@home.com...
> I need to validate the subnet mask inputed by the user based on some ip
> address.  So if you user typed in IP 205.217.218.67, and then typed in
> 255.55.255.0, the ip address should obviously be wrong, and the error
> returned to the user.
>
> Solutions I've tried.  I started out with making sure everything was a
> digit.  Then obviously that failed cuz 255.55.255.0 will work.
>
> Seeing that I'm bad with regular expressions and matching, could someone
> help me with figuring this one out?

Subnet masks are (in binary) a sequence of ones followed by a sequence of
zeros. So, you need to take each octet of the IP, convert it to a
zero-filled 8-bit binary number, catenate them all together and then do the
following:

    $bin =~ /^1+0+$/ ;

or something along those lines.

--
Stephen Warren, Snr Systems Engineer, Technology House, San Francisco
mailto:swarren@techhouse.com                http://www.techhouse.com/
mailto:swarren@wwwdotorg.org                http://www.wwwdotorg.org/
              MIME, S/MIME and HTML mail are acceptable





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

Date: Thu, 20 May 1999 16:38:05 GMT
From: -{WinterWolf}- <anakim@my-dejanews.com>
Subject: Re: Verifying passwd in FreeBSD
Message-Id: <7i1dpe$5q0$1@nnrp1.deja.com>


> Why cant you use the getpw* builtins rather than going at the passwd
> file directly - they should do the right thing regardless of the
> underlying mechanism.
>
> /J\
> --
> Jonathan Stowe <jns@gellyfish.com>

I did try that but all the getpw* builtins return is the entry in the
passwd file which is simply an *. I need the actual encrypted string.
which it turns out is stored in plain text in the master.passwd file.

I ended up answering my own question several hours after posting, but
thank you for your reply. Incidently, I am also having problems getting
my script to setuid. I've chmod'ed it to 4775 and it's owned by root (I
want it to setuid root) but when I run it as my user the both the real
and effective uid's remain that of my user. It doesn't set the effective
uid to root. Any help you can offer there would be appreciated.


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


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

Date: Thu, 20 May 1999 16:59:35 GMT
From: charlie@antipope.org (Charlie Stross)
Subject: wait(), zombies, and solaris: why won't my children die?
Message-Id: <slrn7k8fsh.p75.charlie@cs.ed.datacash.com>

On a Linux system, when you fork a child it's reasonable to tidy
up afterwards by saying something like

    $SIG{CHLD} = sub { print STDERR "$$ reaped child ", wait , "\n"; };  

But on Solaris, well, we obviously ain't in Kansas any more. Doing
this seems to result in the parent process dying. Taking out the
SIGCHILD handler altogether, meanwhile, spawns zillions of zombies 
(yes, it's a forking server I'm working on, and the children insist
on being wait()'ed for.)

Is there something really weird about the way SIGCHILD is handled
on Solaris? A preliminary look at the manpages suggests that there's
a lot of extra information transmitted with signals, and I'm scratching
my head over where to begin.


-- Charlie

Jesus wants to save you.
Allah wants to protect you.
Cthulhu wants to have you for lunch.


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

Date: Thu, 20 May 1999 12:41:45 -0300
From: "Fridirick Giasson" <fred@decatomb.com>
Subject: We need your help ( doc, link , etc ) !!!
Message-Id: <37442D39.54C1E7EE@decatomb.com>

Hello,


We want to expand this information base and to improve our
document libraries,  our links and our newsgroup section.
We would like your help to achieve this. With you, we will be helping a
lot of the world's coders. Our goal is to help you develop cutting edge
applications, by providing the resources you need so you will never give
up. If you have an URL to add or a discussion group address, please send
it to:  

dev@decatomb.com


If you have a document ( test, html, doc, etc), attach it to an email
addressed to:  
               
dev@decatomb.com



developper coner : http://www.decatomb.com/dev/


thank's you for your help 

Fridirick Giasson
Developper of Decatomb Production
fred@decatomb.com


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

Date: Thu, 20 May 1999 15:59:18 GMT
From: jkane@my-dejanews.com
Subject: write() not printing TOP format
Message-Id: <7i1bgk$3qu$1@nnrp1.deja.com>

The write() function is not doing what I want it to!  Of course,
operator error is the likely suspect here. :{ )

I am trying to write() to a file handle with formatted text so I can
print it.  The first time it writes, all is fine.  But the second, and
subsequent times, the TOP header is missing on the first line.  After
it prints 60 lines it then adds new ones, but it doesn't do the first
one.

YES, I am setting ($- = 0)!  If I send to STDOUT, it works great every
time.  If I set $~ to the file handle, it just sends to STDOUT unless I
specifically use write($~);.  I thought from reading the books, that $~
sets the value put after write if I just use write;?  Am I WRONG???

Any ideas????

$ perl -v
This is perl, version 5.003 with EMBED
        built under hpux at May 29 1997 09:08:14
        + suidperl security patch

For the curious, here is my code.

----------------------------------------------------
sub ReadFile {

if ("@_" eq "SCREEN") {

   # Set the format.
#   $~ = 'SCREEN';          # Did not help either!
   $~ = 'STDOUT';           # If this sub is called again after PRINT.
   # Set the page length
   $= = $ScreenLines;
   # Set top of page.
   $- = 0;

# Could be elsif ("@_" eq "PRINTER"), but then would need a failure
output.
# Assuming if it isn't a Screen output, make it 60 lines for a printer.
} else {

   # Open the printer device.
   # Well actaully, this is just a file until I get printing ready!
   open(PRINTER, ">$PrinterDevice") || die "Couldn't open
$PrinterDevice: $!\n";

   # Set the format.
   $~ = 'PRINTER';
   # Set the page length
   $= = $PrinterLines;
   # Set top of page.
   $- = 0;

}

# Open the log file for reading.
open(LOGR, "$Logfile") || die "Couldn't open $Logfile: $!\n";

# While reading in the lines of the file ...
while (<LOGR>) {

($a, $b, $c, $d, $e, $f, $g) = split(/,/, $_);

# Set the header to use.
$^ = 'TOP';

# If you write to a file instead of STDOUT, $- goes to 0 every line!
####  DIAGNOSTIC LINES  ####
# This outputs "Top STDOUT_TOP, Lines 60, Left 0, Format PRINTER."
#   on every single line.  Left $- never changes!
print "Top $^, Lines $=, Left $-, Format $~.\n";

# Write the report.
write($~);
#write;

   # Lets make some page breaks! If lines left are zero.
   if ($- eq "0" && "@_" ne "PRINT") {
       print "Press Enter to continue (or \"q\" to quit.) ... ";
       chop($ReadIn = <STDIN>);
       # If the user entered q, quit the lister.
       last if ($ReadIn =~ /[Qq]/);
   }

}

# Close the log file.
close(LOGR);
close(PRINTER);

# One more pause before losing the last screen. (Except if you just
paused.)
if ($- ne "0" && "@_" ne "PRINT") {
   print "Press Enter to to return to the menu ... ";
   $ReadIn = <STDIN>;

}

###  Set up the Page Format ###
format TOP =
                             Log

Field 1       2       3      Date       Time      Place    Who
_________  _____  ________ _________ __________ ________ _________

 .

format PRINTER_TOP =
                             Log

Field 1       2       3      Date       Time      Place    Who
_________  _____  ________ _________ __________ ________ _________

 .

format STDOUT =
@<<<<<<<<< @<<<<< @<<<<<<<<@<<<<<<<<<@<<<<<<<<< @<<<<<<<<@<<<<<<<<<
$a, $f, $e, $b, $c, $d, $g
 .

format PRINTER =
@<<<<<<<<< @<<<<< @<<<<<<<<@<<<<<<<<<@<<<<<<<<< @<<<<<<<<@<<<<<<<<<
$a, $f, $e, $b, $c, $d, $g
 .

### End of Page Formatting ###

# Reset all the defaults.
&ReadIni;

}
-----------------------------------------------------



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


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

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

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