[15715] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3128 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 22 21:05:49 2000

Date: Mon, 22 May 2000 18:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <959043910-v9-i3128@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 22 May 2000     Volume: 9 Number: 3128

Today's topics:
    Re: "Static" hash across recurisive function <rootbeer@redcat.com>
    Re: Ask Expert about Perl5 DBM files <rootbeer@redcat.com>
    Re: Basic scripting question <godzilla@stomp.stomp.tokyo>
    Re: Building a hash array <lr@hpl.hp.com>
    Re: Building a hash array <rootbeer@redcat.com>
    Re: Converting special chars... <lr@hpl.hp.com>
    Re: Converting special chars... <uri@sysarch.com>
    Re: Converting special chars... <flavell@mail.cern.ch>
    Re: DBI and apostrophes <lr@hpl.hp.com>
        DBM File Limitations? <garcia868@yahoo.com>
    Re: Does Perl not support the MSG_WAITALL flag for recv <Jonathan.L.Ericson@jpl.nasa.gov>
    Re: Does Perl not support the MSG_WAITALL flag for recv <rootbeer@redcat.com>
    Re: Help with 500 Internal Server Error <hyagillot@tesco.net>
    Re: IP Address Query (Charles DeRykus)
        Modules - Newbie question <simon@fsite.com>
    Re: Modules: creating man pages <rootbeer@redcat.com>
    Re: Modules: using relative file paths to them <apietro@my-deja.com>
    Re: Modules: using relative file paths to them <rootbeer@redcat.com>
    Re: Pattern match ? (Craig Berry)
    Re: Perl pipe, IO, open3 <rootbeer@redcat.com>
        PerlMUD + Curses + Nethack??? <spragg@cs.ucdavis.edu>
    Re: pl2exe missing from ActivePerl <r28629@email.sps.mot.com>
    Re: Poll - IP voting timeouts......? (Cav)
    Re: read in a file and delete first 8 lines <lr@hpl.hp.com>
    Re: read in a file and delete first 8 lines (Craig Berry)
    Re: Reintegrating win into CPAN (Was Re: What is the CP <jeph@ucool.com>
    Re: Reposting, can't retrieve my hash from an oher scri <Jonathan.L.Ericson@jpl.nasa.gov>
    Re: Sendmail problem <webmaster@animationlibrary.com>
    Re: Sendmail problem <webmaster@animationlibrary.com>
    Re: Visibility of package lexicals in debugger <rootbeer@redcat.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 22 May 2000 16:46:11 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: "Static" hash across recurisive function
Message-Id: <Pine.GSO.4.10.10005221644010.23375-100000@user2.teleport.com>

On Tue, 23 May 2000, Jay Buffington wrote:

> Subject: "Static" hash across recurisive function
> 
> I've written a recursive function which prompts the user for input. 

It looks as if your structure is something like this:

    BEGIN {
	my %whatever;

	sub anything {
		# access %whatever in here
		# may call &anything recursively
	}
    }

Is that it? If so, I think you've got it right. Although, if you're not
needing to initialize the hash in your BEGIN block, you could leave off
the keyword BEGIN and save yourself six characters of typing. :-)

Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 22 May 2000 16:07:52 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Ask Expert about Perl5 DBM files
Message-Id: <Pine.GSO.4.10.10005221606540.23375-100000@user2.teleport.com>

On Mon, 22 May 2000, Qiang Wu wrote:

> Subject: Ask Expert about Perl5 DBM files

Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.

    http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post

>      I want to convert a text file to a DBM file. This text file
> contains 150000 records. 

Didn't Randal already answer this in c.l.p.modules? Please, read
news.announce.newusers to learn about crossposting. Thanks!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 22 May 2000 17:40:25 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Basic scripting question
Message-Id: <3929D379.F183BF97@stomp.stomp.tokyo>

e adams wrote:

> I'm  new Perl user and would like to know if there is a way to write
> script that, for example, deletes every 3rd line in a file. I am able to
> substitute every 3rd line with a blank line but I can not delete the
> line unless I go into an editor and do it manually.

> Thank you for any advice

Hi again Mr. Adams!

I am back with a script I did not promise.

Heh!

This is my ususal schizoid style which I don't
display very often. My testing scripts, my beta
scripts, tend to draw flies like fresh mule manure.

This test script contains a lot more programming
than ever needed. However, I enjoy writing playful
scripts like this. In looking this over, you will
discover why I never use pragma hints, warnings
and all that. I don't need them and, they are 
nothing but a nuisance to me.

Once you figure out this script, you will discover
it contains all kinds of diagnostic tools and
warnings, including an automatic backup for safety.
Much of those tools can be removed; they are very
redundant but serve an excellent purpose in script
development and debugging.

Based on your comment "I am able to substitute
every 3rd line...." my presumption is you can
analyze this script and understand it without
any real need for comments by me, having worked
with scripts of your own.

This is the part of true interest to you, a loop
which kicks out every third line as you ask and,
I have removed my tools, screen prints and warnings
for clarity. This array @Test has already been 
created earlier:

$line_counter = 1;

open (NEW, ">test.txt");

foreach $new_line (@Test)
 {
  if ($line_counter < 3)
   { 
    print NEW $new_line; 
    $line_counter++;
   }
  elsif ($line_counter = 3)
   { 
    $line_counter = 1;
    next; 
   }
 }

As you can see, every third line is
skipped over by "next;" in printing
your new file, only those you want
are printed.

Playing with those numbers, will
adjust this to skip any set number
of lines as you wish. Play with this.

To run this Test Script, create an 
empty file named, "backup.txt" and
upload, read and write on. My test.txt
contents are given below. Same permissions.
Many servers allow a script to create a file
where one didn't exist before and, many
servers do not. You will need to test this.
To be safe, create your files and upload.
Once you are done playing, then test your
server to discover if you can create a file
on the fly. Heh! If you have Perl on your
home machine, you wouldn't be asking this
question of yours, right? Anyhow, you know
what to do, what to modify to adapt this
to your specific needs.

Set it up, cross your fingers, point your
browser to this and be amazed! Hmm... don't
forget to change first line Perl locale.
This script is portable, Perl 4 or Perl 5
works just fine.

Look Ma! No strict, no -w, no nothing
and it kicks butt all over Perl 5!


I hope I have truly helped you in
my own way and, hope to have given
you a small smile.

Godzilla!


Oh yeah, don't flip your wig the second
and third time you run this script. What
happens is not a bug. You will figure out
what is happening, kinda like Pac Woman
munching words...




TEST SCRIPT:
______________


#!/usr/local/bin/perl

print "Content-Type: text/plain\n\n";

open (TEST, "test.txt");
@Test = <TEST>;
close (TEST);

if (@Test)
 { print "Old File Open. Array Created.\n\n"; }

open (BACKUP, ">backup.txt") || &Backup_Error;

sub Backup_Error
 { 
  print "FUBAR! Can't open my backup file!";
  exit;
 }

print "Backup File Open. \n\n Printed to your backup file:\n\n";

foreach $backup_line (@Test)
 {
  if (!($backup_line))
   {
    print "OH NO! Backup File Print Is FUBAR!";
    exit;
   }
  print BACKUP $backup_line; 
  print $backup_line;
 }

close (BACKUP);

print "\n\n";

$line_counter = 1;
open (NEW, ">test.txt") || &New_Error;

sub New_Error
 {
  print "Yikes! Can't open a new file!";
  exit;
 }

print "New File Open. \n\n Printed to your new file:\n\n";

foreach $new_line (@Test)
 {
  if (!($new_line))
   {
    print "OH NO! New File Print Is FUBAR!";
    exit;
   }
  if ($line_counter < 3)
   { 
    print NEW $new_line; 
    print $new_line;
    $line_counter++;
   }
  elsif ($line_counter = 3)
   { 
    $line_counter = 1;
    next; 
   }
 }
 close (NEW);

exit;


CONTENTS OF TEST.TXT:
_____________________

This Is Line One
This Is Line Two
This Is Line Three
This Is Line Four
This Is Line Five
This Is Line Six
This Is Line Seven
This Is Line Eight
This Is Line Nine
This Is Line Ten



PRINTED RESULTS:
________________

Old File Open. Array Created.

Backup File Open. 

 Printed to your backup file:

This Is Line One
This Is Line Two
This Is Line Three
This Is Line Four
This Is Line Five
This Is Line Six
This Is Line Seven
This Is Line Eight
This Is Line Nine
This Is Line Ten


New File Open. 

 Printed to your new file:

This Is Line One
This Is Line Two
This Is Line Four
This Is Line Five
This Is Line Seven
This Is Line Eight
This Is Line Ten


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

Date: Mon, 22 May 2000 16:10:56 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Building a hash array
Message-Id: <MPG.13935e60f303928b98aab2@nntp.hpl.hp.com>

In article <Pine.GSO.4.10.10005221353100.23375-
100000@user2.teleport.com> on Mon, 22 May 2000 13:55:43 -0700, Tom 
Phoenix <rootbeer@redcat.com> says...
> On Mon, 22 May 2000 jimmy_mcnamara@my-deja.com wrote:

 ...

> > $ARGV[5] will be of the form jim~jack~jill. This is probably a very
> > trivial question but can I make a hash array of that data so I can
> > access it using something similar to the following construct:
> 
> > foreach (@$AccountAliasList)
> 
> Maybe you want this?
> 
>     $AccountAliasList = [ split /j*/, $ARGV[5] ];
> 
> Then again, probably not; there's no hash in there. Cheers!

I think that when you wrote the regex for that split your mind was 
elsewhere.

    ... split /~/, ...

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


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

Date: Mon, 22 May 2000 16:36:46 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Building a hash array
Message-Id: <Pine.GSO.4.10.10005221634340.23375-100000@user2.teleport.com>

On Mon, 22 May 2000, Larry Rosler wrote:

> > > $ARGV[5] will be of the form jim~jack~jill. 

> >     $AccountAliasList = [ split /j*/, $ARGV[5] ];

> I think that when you wrote the regex for that split your mind was 
> elsewhere.

No, I was splitting it into empty string, im~, ack~, and ill. 

>     ... split /~/, ...

Okay, that's another way to split the string. The OP had talked about
getting "lines" from the split, so I don't see why your way is any better
than mine. :-)

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 22 May 2000 17:08:52 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Converting special chars...
Message-Id: <MPG.13936bed75ba1a1598aab4@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <x7g0rae0ue.fsf@home.sysarch.com> on Mon, 22 May 2000 
21:23:06 GMT, Uri Guttman <uri@sysarch.com> says...
> >>>>> "DAP" == David A Pegram <dpegram@paragen.com> writes:
> 
>   DAP> How can I convert a special character within a string to some other
>   DAP> character?
> 
>   DAP> For example, I'd like to convert "ö" to "o".
> 
> $string =~ tr/\366/o/ ;

What do you have against this:

  $string =~ tr/ö/o/ ;

I just copied and pasted that character from the post, without looking 
it up.  A better approach in general, I think -- more readable and 
extendable.

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


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

Date: Tue, 23 May 2000 00:30:37 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Converting special chars...
Message-Id: <x7d7meds5y.fsf@home.sysarch.com>

>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:

  LR> 21:23:06 GMT, Uri Guttman <uri@sysarch.com> says...
  >> >>>>> "DAP" == David A Pegram <dpegram@paragen.com> writes:
  >> 
  DAP> How can I convert a special character within a string to some other
  DAP> character?
  >> 
  DAP> For example, I'd like to convert "ö" to "o".
  >> 
  >> $string =~ tr/\366/o/ ;

  LR>   $string =~ tr/ö/o/ ;

  LR> I just copied and pasted that character from the post, without looking 
  LR> it up.  A better approach in general, I think -- more readable and 
  LR> extendable.

amusing. the email you sent shows the o with umlaut. gnus shows \366 (a
single keystroke). so the packages have different display modes for high
chars. i typed in the \366 (4 strokes, golf luser) as i didn't know it
was a single stroke.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Tue, 23 May 2000 02:39:20 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Converting special chars...
Message-Id: <Pine.GHP.4.21.0005230228030.2604-100000@hpplus01.cern.ch>

On Mon, 22 May 2000, Larry Rosler wrote:

> > $string =~ tr/\366/o/ ;
> 
> What do you have against this:
> 
>   $string =~ tr/ö/o/ ;

Indeed.  And that should work in any character coding which includes
the said character (assuming of course that the Perl prog was
transferred properly cross-platform), whereas the other version only
works in those codes where ö is represented by \366.

And now the question (which I don't recall being clearly addressed in
the perlport document, unlike its careful treatment of the newline
issue).  Presumably, on the Mac platform, 8-bit characters are
expected to be in macRoman code (in which ö certainly isn't \366),
and on the IBM mainframe it would be different again.

HTML has it pretty jammy whey we only have to write &ouml; to get
around the problem ;-)

> A better approach in general, I think -- more readable and 
> extendable.

And portable, in principle, if people only know how to transfer text
files properly cross-platform (but that's a bit of a lost art these
days, what with 95% of today's users being newbies and assuming that
everyone else works in windows-1252 coding just like they do).  Things
were much clearer around 1992 when Pirard published his classic
document.

By the way, what's "special" about these characters?  ;-)  It's not
as if they are punctuation or anything.





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

Date: Mon, 22 May 2000 16:05:56 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: DBI and apostrophes
Message-Id: <MPG.13935d2d2ab4aa0098aab1@nntp.hpl.hp.com>

In article <392919C6.B004D6BD@nospam.com> on Mon, 22 May 2000 13:28:06 
+0200, Marco Natoni <blah@nospam.com> says...
> Nick Liebmann wrote:
> > I have done a bodge fix on the a mysql call using the DBI module
> > if($artistname =~ /\'/){$artistname =~ s/\'/\\'/;}

To Nick:

Testing before substituting is a waste of CPU cycles.  And single-quote 
isn't a regex metacharacter.  And maybe someday the string will have 
more than one single-quote.

    $artistname =~ s/'/\\'/g;

> > eg $artistname =  "Gary O'Dea"
> > after ---- $artistname =  "Gary O\'Dea"
> > this puts an escape character before the apostrophe.
> 
>   Muble... Have you considered the quotemeta sub?
> 
> 	$ perldoc -f quotemeta

Oof.  Quoting metacharacters for regexes has nothing to do with quoting 
metacharacters for SQL.

The DBI module provides a quote() function that does what is requested.  
But it is better to use placeholders in preparing the SQL and supply the 
parameters as arguments for the 'execute'.  But this isn't a Perl issue 
any longer.

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


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

Date: Mon, 22 May 2000 17:03:19 -0700 (PDT)
From: J Garcia <garcia868@yahoo.com>
Subject: DBM File Limitations?
Message-Id: <20000523000319.16271.qmail@web1608.mail.yahoo.com>

I am planning to use DBM file to implement a simple
database on my site.

How do I find out which DBM format is support by my
hosting service? Thanks for responding.



__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/


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

Date: Mon, 22 May 2000 15:40:14 -0700
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: Does Perl not support the MSG_WAITALL flag for recv?
Message-Id: <3929B74E.ECD1927@jpl.nasa.gov>

Lorin Hochstein wrote:
> I tried to use a recv call with a flag of MSG_WAITALL, and I got an error of
> "Your vendor has not defined Socket macro MSG_WAITALL" (both on Windows NT
        ^^^^^^
> and on Linux, same error). Does Perl not support this flag?

In this context (Socket.pm diagnostic message), 'vendor' means the
people who supply the system calls (such as recv).  Perl links to your
system's version of recv, which (apparently) doesn't support
MSG_WAITALL.  On Linux type 'man recv' for the flags recv will receive. 
I don't know where to find equivilent documentation on Windows NT.

From 'perldoc -f recv':
  Takes the same flags as the system call of the same name.

Jon
-- 
Knowledge is that which remains when what is
learned is forgotten. - Mr. King


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

Date: Mon, 22 May 2000 16:53:56 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Does Perl not support the MSG_WAITALL flag for recv?
Message-Id: <Pine.GSO.4.10.10005221651560.23375-100000@user2.teleport.com>

On Mon, 22 May 2000, Jon Ericson wrote:

> Lorin Hochstein wrote:
> > I tried to use a recv call with a flag of MSG_WAITALL, and I got an error of
> > "Your vendor has not defined Socket macro MSG_WAITALL" (both on Windows NT
>         ^^^^^^
> > and on Linux, same error). Does Perl not support this flag?
> 
> In this context (Socket.pm diagnostic message), 'vendor' means the
> people who supply the system calls (such as recv).  

No, I think it's the people who supply the .h files for the system calls.
Of course, those should probably be the same people. :-)

> Perl links to your system's version of recv, which (apparently)
> doesn't support MSG_WAITALL.

Not necessarily. Maybe that constant wasn't available from Socket.pm, but
that doesn't mean that the system's recv(3) doesn't support that
parameter.

Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 22 May 2000 23:25:39 +0100
From: "B Kemp" <hyagillot@tesco.net>
Subject: Re: Help with 500 Internal Server Error
Message-Id: <8gccak$39a$1@barcode.tesco.net>


>Yup, I'm an old fart but at least I'm still ripping 'em...
>
>RW


OK and I've been paid for programming for less than a year, but I learnt
programming on a TRS80 - in the early 80's.
and I still go BUG, FIX, BUG, FIX,BUG, FIX, BUG, FIX,BUG, FIX, BUG, FIX,BUG,
FIX, BUG, FIX,BUG, FIX, BUG, FIX,BUG, FIX, BUG, FIX,BUG, FIX, BUG, FIX,BUG,
FIX, BUG, FIX,BUG, FIX, BUG, FIX,BUG, FIX, BUG, FIX,BUG, FIX, BUG, FIX,




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

Date: Mon, 22 May 2000 21:12:54 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: IP Address Query
Message-Id: <FuzC9I.A38@news.boeing.com>

In article <39293055.5AF6400@media-saturn.com>,
soulfly  <hackel@media-saturn.com> wrote:
>Hello,
>
>can anyone help me in getting the ipaddress from winx/nt machines with a
>perl-script.
>

Try Net::DNS. Reportedly, the latest development
version Net-DNS-0_13b11 works on Win/NT. See:
http://www.fuhr.org/~fuhr/. 

(There's no pre-built that I'm aware of so you'll 
need nmake from Microsoft too). 

If you simply need the IP of the local Win/NT
host where the script runs, you could probably
just schlepp the IP out of 'ipconfig' though 
there may be better ways:

my $netinfo = `ipconfig`;   
if ($?) { die "ipconfig failed: $?\n" } 
my ($ip) = $netinfo =~ /.*IP.*?(\S+)$/ms; 

--
Charles DeRykus


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

Date: Mon, 22 May 2000 16:13:59 +0100
From: "Simon McGregor" <simon@fsite.com>
Subject: Modules - Newbie question
Message-Id: <39294e83.0@shiva.ukisp.net>

What happens when you install a Perl module?
And can someone explain to me in plain language what the difference between
"use" and "require" is? I can't quite seem to see what "use" is doing (and
in general I haven't got my head around the way Perl does object
orientation).

I'm asking partly because I want to know if it's possible to use the
functionality of a Perl module in a script without having the necessary
permissions to actually install the module. We develop a lot of scripts
which end up on sites we don't host, so installing a module is sometimes out
of the question.


Thanks,

--
Simon




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

Date: Mon, 22 May 2000 16:01:10 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Modules: creating man pages
Message-Id: <Pine.GSO.4.10.10005221559210.23375-100000@user2.teleport.com>

On Mon, 22 May 2000, A Pietro wrote:

> h2xs creates a man page from the POD, I think.
> 
> But how can I read the manual page for MyModule::Config?

Have you tried perldoc? That should work, although you may need to tell it
where your module is. 

> I have tried man MyModule etc... but no luck.

Well, if your man command is properly configured and your module is
properly installed, that should work - but it's easy to get the MANPATH
wrong. Of course, that's beyond the scope of this newsgroup. :-)

Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 22 May 2000 23:13:10 +0100
From: "A Pietro" <apietro@my-deja.com>
Subject: Re: Modules: using relative file paths to them
Message-Id: <8gcbds$do9$1@sshuraaa-i-1.production.compuserve.com>

>Take a look at the lib module, but also, I think you might
be very interested in the FindBin module<

I have found FindBin on CPAN (although I can't work out what it does from
the ReadMe!)

where is the lib module ??

AP




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

Date: Mon, 22 May 2000 16:10:38 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Modules: using relative file paths to them
Message-Id: <Pine.GSO.4.10.10005221609300.23375-100000@user2.teleport.com>

On Mon, 22 May 2000, A Pietro wrote:

> where is the lib module ??

It's already installed on your system, if you've got Perl properly
installed. Maybe you want one of these commands?

    perldoc lib
    perldoc -l lib

Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 23 May 2000 00:08:11 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Pattern match ?
Message-Id: <sijivbn4o1160@corp.supernews.com>

Lee (lee@factory.co.kr) wrote:
: If there are alphabetic and numeric characters in a word like
: "a34r34thy643d2",
: how to delete all of alphabetic characters in that world.
: 
: This "a34r34thy643d2"
: should be "34346432".

If you're sure that it will be limited to the English alphabet (normal
ASCII), then tr/A-Za-z//d is probably your best bet.

-- 
   |   Craig Berry - cberry@cinenet.net
 --*--  http://www.cinenet.net/users/cberry/home.html
   |   "The road of Excess leads to the Palace
      of Wisdom" - William Blake


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

Date: Mon, 22 May 2000 16:51:09 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Perl pipe, IO, open3
Message-Id: <Pine.GSO.4.10.10005221646310.23375-100000@user2.teleport.com>

On Mon, 22 May 2000, Clinton Mahoney wrote:

> 	I'm trying to use a perl script to send data to the Unix passwd
> command to allow a perl script to use it to change a password.

This is a frequent request. 

> 	It's not really important that that I'm using passwd - I've just
> been trying to get anything to work to open a process with piped input.

The standard passwd command does not like to read the password from a
pipe. You could use Expect.pm instead.

> 	I've been trying to use IPC open3 which doesn't work.  I can't
> even get this to work:
> 	
> 	open (HANDLE, "| somecommand");
> 
> 	All it does is executes "somecommand" and doesn't even look at
> whatever I try to write to HANDLE - it's just a completely
> uncontrolled process.

Well, this depends upon the command. If it reads from standard input, it
should read what you write to the HANDLE.

> 	I've even downloaded scripts people have already written and I
> get the same thing.

Well, either these scripts are broken, or your perl is. Did it pass the
tests in 'make test' before you installed it?

> 	open (MAIL, "| /usr/sbin/sendmail")
>         print MAIL "To: user@domain.com"

If you don't show us the code you're really using, we probably won't be
able to help.

> 	All I get is "user... Recipient names must be specified" which is
> what you get when you invoke sendmail without any arguments.  

Maybe you're invoking sendmail without any arguments. That seems likely to
me!

Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 22 May 2000 22:20:38 GMT
From: Adam Trace Spragg <spragg@cs.ucdavis.edu>
Subject: PerlMUD + Curses + Nethack???
Message-Id: <8gcbrm$gdt$1@mark.ucdavis.edu>

Hey all...  I've had wonderful success in ripping the hell out of PerlMud 
and creating my own online multiplayer text game.

Furthermore, my friend and I just finished creating (and just started playing)
and Play-By-Email game.  Perl is absolutely perfect for this purpose, and made
the project really easy and fun.

NOW what I'd like to do is create some sort of multiplayer online 'graphical'
game using the Curses library a la Nethack.  My home machine is Win32, and I
have had absolute no luck (strike that... lots of BAD luck) getting the Curses
perl mod installed.  (Has anyone done this under Win32?  Is it possible?)

So...  assuming I get a Linux machine up and running, and can successfully use
Curses, how will this mix with someone telnetting in to the server?

I'm not sure if I know how to say what I'm trying to say.  I guess "how well 
does a Curses based application run over an internet link?"

Anyone have any thoughts or ideas on this?  Has anyone tried something similar?
I'm definitely of the "try-and-see" school of thought, but since I can't
immediately try, I thought I'd take a little poll...

Thanks
Adam



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

Date: Tue, 23 May 2000 08:42:17 +0800
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: pl2exe missing from ActivePerl
Message-Id: <3929D3E9.DC1885A7@email.sps.mot.com>

Tom Phoenix wrote:
> 
> On Mon, 22 May 2000, Tk Soh wrote:
> 
> > I have been looking for the pl2exe utility which, per the FAQ, should be
> > bundled with the installation,
> 
> Can you tell me where in the FAQ you read this?

here's the output of my 'find-grep':
---------
 ./faq/Windows/ActivePerl-Winfaq4.html:
<P>The pl2exe utility is similar to pl2bat, but it puts an executable
header on your perl script, that have been run through pl2exe.</P>

 ./faq/Windows/ActivePerl-Winfaq5.html:
file association feature. You can use pl2exe or pl2bat to convert a Perl
script to an executable or
---------

-TK


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

Date: 22 May 2000 23:27:31 GMT
From: caviatte@aol.comNoSpam (Cav)
Subject: Re: Poll - IP voting timeouts......?
Message-Id: <20000522192731.27866.00000853@ng-fw1.aol.com>

>>One way would be like this pseudo-code, which looks surprisingly like
Perl code:
    my $access_file = '/tmp/.i_was_accessed';
    my $last_access = -M $access_file;
    if (defined $last_access and $last_access > 1/24) {
	# Not accessed during the past hour, probably
	touch $access_file;	# or otherwise ensure the m-time is set
	output PAGE 1;
    } else {
	# We've been accessed too recently
	output PAGE 2;
    }
Cheers!<<



Thanks a million, Tom.  :-)


           >>>  Cav  <<<

Cav's Roller Coaster Tycoon Depot
     http://rct.prohosting.com
 PLEASE STOP BY FOR A VISIT



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

Date: Mon, 22 May 2000 16:56:20 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: read in a file and delete first 8 lines
Message-Id: <MPG.139368ff1628b6ff98aab3@nntp.hpl.hp.com>

In article <39296F81.EB320FD1@wsb.com> on Mon, 22 May 2000 17:33:19 GMT, 
Jeff Helman <jhelman@wsb.com> says...

 ...

> Okay, based on this it looks like you want to extract the <PRE>...</PRE>
> segment, and include the enclosing <PRE> tags.  How 'bout this:
> 
> ## EFFICIENTLY READ THE FILE INTO SCALAR $File
> open INF, "whatever.html";  ## YOUR FILENAME HERE

You omitted the test and diagnostic for failure to open the file!

> binmode INF;  ## IF YOU ARE RUNNING ON WINDOWS

No.  The file should be handled as a text file.

> read INF, $File, -s INF;

Well, that certainly seems to be the most efficient way.  :-)

> close INF;
> 
> ## REGEX TO LOSE ANYTHING AROUND THE <PRE></PRE> TAGS
> $File =~ s/.+<PRE>.+?</PRE>.+/$1/ie;
> 
> Hope this helps,

No, it won't help, for several reasons.

1.  It won't compile, because of the unescaped slash in the second tag.  
Use alternate delimiters.

2.  It won't match, because '.' doesn't match a newline.  Use the /s 
modifier.

3.  There are no parentheses in the regex to capture what is matched.

4.  It will produce chaos, because you have specified that the captured 
string be evaluated as a Perl expression.  Drop the /e modifier.

Untested (because I wouldn't recommend this approach in any case):

  $File =~ s%.+(<PRE>.+?</PRE>).+%$1%is;

It would be a good idea to enhance the value of your intended 
helpfulness by posting only tested code, unless explicitly stated 
otherwise.

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


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

Date: Tue, 23 May 2000 00:27:42 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: read in a file and delete first 8 lines
Message-Id: <sijk3u2bo1145@corp.supernews.com>

Clemmons, David [NGC:B995:EXCH] (clemmons@nSoPrAtMelnetworks.com) wrote:
: I need to read in a html file, then delete the first 8 lines (html tags)
: of the file.  I also want to delete the last two html tags.  The files
: that I will be reading in, were previously saved by another script I
: wrote... so I know exactly what the files will look like.
: 
: Here is what the file will look like:
[snip]
: Here is the code that I wrote that works.  Is there a better/easier way?
: 
:   if ( -e "$pathname" ) {                   # if the file exists, open it
:     open(READ_FILE,$pathname);

This would usually be done in one step, by checking the result of open.
Among other problems, your way involves a potential race condition.  Also,
the double quotes around $pathname in the conditional are redundant.

:     $g=0;                                   # init file line counter scalar
:     while (<READ_FILE>) {
:       $$ifile[$g] .= $_;                    # save each line to an associative array
:       $$ifile[$g] =~ s/<\/body>//g;         # delete the </body> tag
:       $$ifile[$g] =~ s/<\/html>//g;         # delete the </html> tag
:       $g++ }                                # counter for length (number of lines) of file
:     close(READ_FILE); }
:   else {                                    # file does not exist
:     print ("FILE CANNOT BE OPENED \n"); }
:   for ($p = 8; $p <= $g; $p++) {
:     print $$ifile[$p]; }                    # print out the file based on the number of lines
:                                             # do not print the first 8 lines

That seems like an awful lot of work!  I'm also unclear on why you used
references to access lines.  Here's how I'd do it, if I knew the file were
small enough to get into memory all at once without a problem (which will
be true for any reasonable html page).

  open READ_FILE, "< $pathname" or die $!;
  my @lines = <READ_FILE>;
  close READ_FILE;

  splice @lines, 0, 8;
  splice @lines, -2;
  print @lines;

Alternatively, replacing the last three lines with 

  print @lines[8..$#lines-2];

does the same thing even more concisely, though I find it less pleasing.

-- 
   |   Craig Berry - cberry@cinenet.net
 --*--  http://www.cinenet.net/users/cberry/home.html
   |   "The road of Excess leads to the Palace
      of Wisdom" - William Blake


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

Date: 22 May 2000 19:04:17 -0500
From: Jeph <jeph@ucool.com>
Subject: Re: Reintegrating win into CPAN (Was Re: What is the CPAN module repository  (url) name that can beused for PPM/VPM?)
Message-Id: <peijiss47vbak2e7kjo2d7uth7idd9vbdm@4ax.com>

Thanks Jeff for clarifying my question.  I did go to FAQ2 and looked
at all the 5 or 6 repository links listed there.  Unfortunately none
of them contains the 3 interesting modules for Unicode, which are only
available from CPAN.  I asked the CPAN repository question because my
"perl Makefile.PL" attempt for compiling one of the 3 CPAN modules
failed, and I didn't know what's wrong.  I really hope the CPAN
modules can be installed easily by using PPM/VPM.  Thanks.

Eric


On Sat, 20 May 2000 12:40:59 -0700, Jeff Zucker <jeff@vpservices.com>
wrote:

>Elaine Ashton wrote:
>> 
>> in article 392569e9.6500036@news2.newscene.com, Eric Liao at
>> ekliao@mediaone.net quoth:
>> 
>> > Does it exist?  THanks.
>> 
>> http://www.activestate.com/ActivePerl/docs/faq/ActivePerl-faq2.html
>> 
>> e.
>
>From earlier posts it's evident Eric already knows this.   He was asking
>about unicode.pm and where to find it since he couldn't nmake it from
>CPAN and knew it wasn't on AS.
>
>So it is acutally an interesting question.  There is no equivalent of
>CPAN for windoze .ppd files, or for that matter for linux .rpm files. 
>AS lists only their own .ppd files.  Others have begun to make
>repositories, for example, Simon Oliver has developed an excellent
>repository specializing in database ppds at
>http://www.bi.umist.ac.uk/packages. Simon's repository is listed on
>www.perl.com, but not on CPAN, AFAIK.  And if one uses cpan.search.org,
>the .ppd files are, of course, not listed.  So should CPAN itself
>consider including .ppd files, allowing authors to upload them along
>with the .gz files?   Or even more radical -- should makeMaker or h2xs
>or something be modified in such a way that one could create a
>Makefile.PL that would accept a switch telling it whether it should run
>in makefile mode or ppd mode and if the later to essentially run ppm
>rather than creating a makefile.  
>
>Sorry for the rambles, just some questions I have had in the back of my
>mind about how to make the CPAN and installation process more similar
>for all users.  There are still a zillion readme files out there that
>make no mention of ppm and therefore many newbies who go to CPAN and
>then come here asking what the heck make is, or why it doesn't work for
>them.



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

Date: Mon, 22 May 2000 16:51:05 -0700
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: Reposting, can't retrieve my hash from an oher script
Message-Id: <3929C7E9.B6D27551@jpl.nasa.gov>

Vincent wrote:
> I already posted this problem but didn't get any answer. So if anyone knows
> something about it I would be very thankfull about him.

In general, reposting the same question doesn't help.  I couldn't
understand what you were asking the first time and reposting hasn't made
it any easier for me.

> This is the problem.
> I have two scripts.
>     *The first one : 'startup.pl' is called when I restart Apache. In this
> script I put every html pages in a hash.
> At this moment, My hash is full, I can print it, and there is no preblem.
> 
>     *The second one : 'play' is called anytime I am looking a page which
> call
> this script. But there I can't retrieve the page anymore. My Hash if empty.
> 
> So, in brief, my hash do exist because I can print it when I restart Apache,
> but  5 seconds after when an other script try to retrieve the information
> from this hash it says that this hash is empty.

In other words, you were hoping to share a variable between two separate
scripts.  You will have to put the value of the variable from the first
script somewhere that the second script can retrieve it.  Perhaps you
will want to put it into a file.  Perhaps the Apache server has some
facility to do this for you.

Jon
-- 
Knowledge is that which remains when what is
learned is forgotten. - Mr. King


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

Date: Mon, 22 May 2000 18:34:42 -0400
From: "Yevgeniy Leshchinskiy" <webmaster@animationlibrary.com>
Subject: Re: Sendmail problem
Message-Id: <8gccmm$je3$1@bob.news.rcn.net>

Thanks for your reply.
I am the webmaster, the CEO, the sysadmin, all in one :) . How can I check
if the server end is broken?
Regarding the reffers,  I checked, and the script doesn't use them.


Hope to hear from you soon,

Sincerely,
Yevgeniy Leshchinskiy
webmaster@animationlibrary.com
Animation Library
http://www.animationlibrary.com


Nick Liebmann <Nick@ucecom.com> wrote in message
news:NKaW4.4814$1W6.91196@news2-win.server.ntlworld.com...
>
> Sounds like the router has gone down...
>
> I've had the same problem, working on a unix server, the problem we
> encoutered was that the routing handles may have to be changed. Our fire
> wall went down and reset evreything. You need check with your webmaster to
> check that it is working from the server end.
>
> Also, you say that you used it on other sites, have you put a  refferer in
> the script? Basically blocks all domains from using the script apart from
> the ones specified.
>
> Regards
>
> Nick
>
>
>




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

Date: Mon, 22 May 2000 18:37:17 -0400
From: "Yevgeniy Leshchinskiy" <webmaster@animationlibrary.com>
Subject: Re: Sendmail problem
Message-Id: <8gcd20$lcb$1@bob.news.rcn.net>

Thanks for the reply, Tony.
I asked there, but no response yet :(.
I have tried to send emails to all kinds of address on different servers,
but the result was the same, so I think the problem isn't on the receiving
end.
Regarding the network topology, I am not sure what you mean. How can I check
it?

Hope to hear from you soon,

Sincerely,
Yevgeniy Leshchinskiy
webmaster@animationlibrary.com
Animation Library
http://www.animationlibrary.com


Tony Curtis <tony_curtis32@yahoo.com> wrote in message
news:87d7meg125.fsf@limey.hpcc.uh.edu...
>
> I'd go and ask this in comp.mail.sendmail if I were you.
>
> If sendmail is receiving and queueing the messages then
> it's out of perl's hands.
>
>
> [ off-topic for clpm, added as a +ve footnote ]
>
> It sounds like either the sites you're trying to send to
> aren't accepting messages at the moment, or they are
> generating soft fails due to the machine's mail setup or
> location in IP-space (maybe on a soft-blocked SPAM list).
>
> Then again it could be the network topology: is there a
> route out from this machine like there is for the other
> machine?
>
> hth
> t




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

Date: Mon, 22 May 2000 15:37:29 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Visibility of package lexicals in debugger
Message-Id: <Pine.GSO.4.10.10005221529210.23375-100000@user2.teleport.com>

On 22 May 2000 msouth@fulcrum.org wrote:

> 	##########
> 	# Foo.pm #
> 	##########
> 
> 	#!perl -w

It's unusual to use that line inside a module, but (as it's a mere
comment) it shouldn't hurt anything - except it might make your
maintenance programmer think warnings are being used, whether they are or
not.

> 	use lib qw/./;

If taint checks aren't in force, that shouldn't be necessary. And if they
are, it would be dangerous. So, why is it there?

> 	package Foo;
> 
> 	my $package_lexical = 'foo';

Of course, a lexical isn't in a package.... (That's a misleading name,
like "dairy-free creamer". :-)  But that variable is scoped to be valid
from here to the end of the enclosing file.

> This is what I expect--in Foo::yelp $package_lexical is visible.

Well, yes, but not because it's Foo::yelp, but because the code is within
the scope of the name of the lexical.

> However, when I run it through the debugger, $package_lexical seems
> to be visible (to the debugger) only while stepping through subroutines 
> where it is explicitly referenced:

Well, this may change with different versions of the debugger. But I think
it'll probably stay this way, unless you submit a patch. :-)

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

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 V9 Issue 3128
**************************************


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