[11918] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5518 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 29 13:08:18 1999

Date: Thu, 29 Apr 99 10:00:22 -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, 29 Apr 1999     Volume: 8 Number: 5518

Today's topics:
    Re: "learning perl" does not seem to be written well <emschwar@rmi.net>
    Re: "learning perl" does not seem to be written well (Benjamin Franz)
        "Text file busy" error (Timothy Larson)
    Re: "Text file busy" error <gellyfish@gellyfish.com>
    Re: "Text file busy" error (Thomas Wade Vaughan)
    Re: A simpler way to do this? (Larry Rosler)
    Re: A simpler way to do this? (Tad McClellan)
        Call and exe program from perl <U903506@ntu.edu.sg>
    Re: Call and exe program from perl <tim@timbury.com>
        cgi-html generated in different frame <ev@kzed.com>
        Enterprise on Novell w/Perl Scripts - Update <hpman@erols.com>
    Re: Enterprise on Novell w/Perl Scripts - Update <gellyfish@gellyfish.com>
    Re: Enterprise on Novell w/Perl Scripts <hpman@erols.com>
        FreeBSD 3.0 pw -h  <flee@theshop.net>
        FTP problem with windows NT <abc@abc.com>
        Handle path in www <clbjo@mai.liu.se>
    Re: Impythonating PERL? <cassell@mail.cor.epa.gov>
    Re: Is this the best way to get a substring? <jeromeo@atrieva.com>
    Re: Is this the best way to get a substring? (Larry Rosler)
    Re: Is this the best way to get a substring? (Randal L. Schwartz)
    Re: Need help on "hex($1)" (Larry Rosler)
        Net::FTP question <mgarber@answerthink.com>
        newbie in need... <nobody+reachable_in_lcc_idt_lab@gatech.edu>
    Re: newbie: Replace \n with <br>\n <aqumsieh@matrox.com>
    Re: PERL & Y2K (I R A Aggie)
    Re: PERL & Y2K (David Cantrell)
        perlcc compilation problem <Jari.Jankala@era.ericsson.se>
    Re: perldoc HELP, Was How to use Net::FTP in perl?? <e.h.bogart@larc.nasa.gov>
    Re: pow() ? to the power of ? (Tad McClellan)
    Re: Question: Opening and closing files. (Larry Rosler)
    Re: What does this error message mean? <aqumsieh@matrox.com>
        Win95/98 file locking <collin.starkweather@colorado.edu>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 29 Apr 1999 09:24:36 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: "learning perl" does not seem to be written well
Message-Id: <xkf1zh3laa3.fsf@valdemar.col.hp.com>

Uri Guttman <uri@sysarch.com> writes:
> why it is hard to grok by some people is hard for me to grok. =~ is one
> of perl's more important ops as you don't need oodles of builtin funcs
> to support all the things =~ does. 

I agree!  =~ is a very useful operator, and Perl would be much the poorer 
for the lack of it.

*BUT*

All I was saying was that up until I'd encountered Perl, I'd never seen a 
=~ - like operator before, and it took some adjusting to for me to really 
grok the usefulness of it.  Again, this was Perl 4, so there wasn't any
perldoc, and the Camel just confused me.  I understand it now.  It's very 
easy once you understand it.  But coming from a language like C or
(any) assembly, it's something that's not (IMO) immediately intuitive,
that's all.

-=Eric


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

Date: Thu, 29 Apr 1999 16:28:11 GMT
From: snowhare@long-lake.nihongo.org (Benjamin Franz)
Subject: Re: "learning perl" does not seem to be written well
Message-Id: <vM%V2.9069$oU1.700078@typhoon-sf.snfc21.pbi.net>

In article <xkf1zh3laa3.fsf@valdemar.col.hp.com>,
Eric The Read  <emschwar@rmi.net> wrote:
>*BUT*
>
>All I was saying was that up until I'd encountered 
>Perl, I'd never seen a =~ - like operator before, 
>and it took some adjusting to for me to really 
>grok the usefulness of it.  Again, this was Perl 4, 
>so there wasn't any perldoc, and the Camel just confused 
>me.  I understand it now.  It's very easy once you 
>understand it.  But coming from a language like C or
>(any) assembly, it's something that's not (IMO) 
>immediately intuitive, that's all.

For me, going to Perl, the =~ operator wasn't a problem 
since I had already learned regexs for 'sed' and 'awk'
to solve problems I had writing my first CGI scripts.

In fact, the presence of the =~ operator and the grep 
function is *why* I chose to learn Perl - it let me quit 
using awkward chained calls to 'awk' and 'sed'.

-- 
Benjamin Franz
ObNostalgia: My very first CGI script, written in CSH, 
             is still in production use almost 5 years 
			 later. It is a massive four lines long. :) 


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

Date: 29 Apr 1999 15:43:58 GMT
From: larsot2@krypton.mankato.msus.edu (Timothy Larson)
Subject: "Text file busy" error
Message-Id: <7g9unu$qfm$1@nitrogen.mankato.msus.edu>

Sometimes my Perl script won't run and I get a 500 error from the web
server.  When I try it from the command line I get the error "Text file
busy".
What the heck does that mean?  Is it in the bathroom doing some business
and can't be disturbed?  How can a text file be busy?

Any insights appreciated, thanks.

Tim



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

Date: 29 Apr 1999 17:01:43 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: "Text file busy" error
Message-Id: <37288267@newsread3.dircon.co.uk>

Timothy Larson <larsot2@krypton.mankato.msus.edu> wrote:
> Sometimes my Perl script won't run and I get a 500 error from the web
> server.  When I try it from the command line I get the error "Text file
> busy".
> What the heck does that mean?  Is it in the bathroom doing some business
> and can't be disturbed?  How can a text file be busy?
> 

You are on Unix and you are trying to overwrite the binary of a running 
program yes ?  You will have to kill the program before you can overwrite
the file.

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



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

Date: 29 Apr 1999 16:38:17 GMT
From: vaughan@well.com (Thomas Wade Vaughan)
Subject: Re: "Text file busy" error
Message-Id: <7ga1tp$irc$1@its.hooked.net>

Timothy Larson (larsot2@krypton.mankato.msus.edu) wrote:
: Sometimes my Perl script won't run and I get a 500 error from the web
: server.  When I try it from the command line I get the error "Text file
: busy".
: What the heck does that mean?  Is it in the bathroom doing some business
: and can't be disturbed?  How can a text file be busy?

: Any insights appreciated, thanks.

: Tim


Hi Tim,

This text file busy could mean that another application has the file open. Could
it be that you left the file open in your editor?

Tom



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

Date: Thu, 29 Apr 1999 08:27:19 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: A simpler way to do this?
Message-Id: <MPG.11921a31238fcf6a989976@nntp.hpl.hp.com>

In article <372862fd.3760000@news.skynet.be> on Thu, 29 Apr 1999 
13:56:29 GMT, Bart Lateur <bart.lateur@skynet.be> says...
 ...
> 	@bar = /\%(\w+)/g;
              ^  not needed
 
> which would capture all the variable's names. You can then do
> 
> 	foreach(@bar) {
> 		$DEFINED{$_}++;
> 	}
> 
> which would actually count the occurences.

Roll out the hash slice for a one-liner which runs fast.  Just remember 
to test the hash using 'exists $DEFINED{$key}', because all the values 
in %DEFINED are UNdefined.  :-)

    @DEFINED{/%(\w+)/g} = ();

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


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

Date: Thu, 29 Apr 1999 06:55:47 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: A simpler way to do this?
Message-Id: <jrd9g7.n32.ln@magna.metronet.com>

Steve Vertigan (vertigan@bigfoot.com) wrote:
: I'm trying load parse an array for the existence of variables so that the
: following text..

: Dear %firstname %lastname
: Thank you for your message regarding <b>%problem</b>...

: would create the following hash
: $DEFINED{'firstname'} = 1; # or true
: $DEFINED{'lastname'} = 1;
: $DEFINED{'problem'} = 1;


   $defined{$1} = 1 while /%([a-zA-Z0-9]+)/g;


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


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

Date: Thu, 29 Apr 1999 11:50:09 +0800
From: #VIKRAM BALKRISHNAN NATARAJAN# <U903506@ntu.edu.sg>
Subject: Call and exe program from perl
Message-Id: <D0BE198B1C7ED111AD1808002BA613F80CEFE5E1@mail1.ntu.edu.sg>

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01BE91F3.60BB148A
Content-Type: text/plain

Hi
   Anyone knows how to cause perl to execute and exe program say in
c:\vikram ???
  I tried 
   chdir "c:\vikram";
   exec "file.exe"
  but it does not work...
  anybody has an idea?/
Thanks
Vikram

------_=_NextPart_001_01BE91F3.60BB148A
Content-Type: text/html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2232.0">
<TITLE>Call and exe program from perl</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>Hi</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp; Anyone knows how to cause perl to execute and exe program say in c:\vikram ???</FONT>
<BR><FONT SIZE=2>&nbsp; I tried </FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp; chdir &quot;c:\vikram&quot;;</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp; exec &quot;file.exe&quot;</FONT>
<BR><FONT SIZE=2>&nbsp; but it does not work...</FONT>
<BR><FONT SIZE=2>&nbsp; anybody has an idea?/</FONT>
<BR><FONT SIZE=2>Thanks</FONT>
<BR><FONT SIZE=2>Vikram</FONT>
</P>

</BODY>
</HTML>
------_=_NextPart_001_01BE91F3.60BB148A--



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

Date: Thu, 29 Apr 1999 12:45:40 -0400
From: "Tim" <tim@timbury.com>
Subject: Re: Call and exe program from perl
Message-Id: <925404281.882.13@news.remarQ.com>

You might try     system ("c:\\vikram\\file.exe");
The first backslash tells perl to interpret the second backslash as
a "\" character.

    #VIKRAM BALKRISHNAN NATARAJAN# wrote in message ...
    Hi
       Anyone knows how to cause perl to execute and exe program say in
c:\vikram ???
      I tried
       chdir "c:\vikram";
       exec "file.exe"
      but it does not work...
      anybody has an idea?/
    Thanks
    Vikram





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

Date: Thu, 29 Apr 1999 12:20:14 -0400
From: "Eddy Viscous" <ev@kzed.com>
Subject: cgi-html generated in different frame
Message-Id: <7ga4i4$kni@news-central.tiac.net>

Hello all,
This may be an easy one...maybe not.  I have a script that searches a
database and returns results.  I want these result to appear in a different
frame than the one that the script's form is in.  Can this be done?  If so
how.

Thanks

EV




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

Date: Thu, 29 Apr 1999 11:39:37 -0400
From: "Rich Billingsley" <hpman@erols.com>
Subject: Enterprise on Novell w/Perl Scripts - Update
Message-Id: <7g9uf9$kv2$1@autumn.news.rcn.net>

In my previous post I did not give enough information, I apologize for that.
So here is more information which I hope is enough to get some sort of clue
why this happens.  If more information is needed PLEASE email me and let me
know.


Enterprise Version: 3.07 (Novell Build)
Novell Version 4.11
Perl Version  5.0307(?)


"cgi.pm"

$CGI::revision = '$Id: CGI.pm,v 1.29 1998/03/24 22:11:50 lstein Exp lstein
$';
$CGI::VERSION='2.39';


"cgi-lib.pl"

# Perl Routines to Manipulate CGI input
# cgi-lib@pobox.com
# $Id: cgi-lib.pl,v 2.18 1999/02/23 08:16:43 brenner Exp $

"Chicago-upload.cgi"

#!/usr/bin/perl

require("cgi.pm");
binmode(STDIN);
binmode(STDOUT);
### binmode(STDERR);
### binmode($File_Handle);
### binmode(OUTFILE);



The process will transfer text and ".doc" file fine.  When attempting to
transfer "wpd", "zip", "gif", "jpg" and other binary or compressed files, it
appears that the header comes through but terminates before the boundry is
reached.  Even when it completes without errors, only 256 bytes are
transfered.  The file sizes are anywhere from 1K to 5M but still only 256
bytes are transfered.

Thanks

Rich Billingsley






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

Date: 29 Apr 1999 16:58:21 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Enterprise on Novell w/Perl Scripts - Update
Message-Id: <3728819d@newsread3.dircon.co.uk>

Rich Billingsley <hpman@erols.com> wrote:
> In my previous post I did not give enough information, I apologize for that.
> So here is more information which I hope is enough to get some sort of clue
> why this happens.  If more information is needed PLEASE email me and let me
> know.
> 


You didnt need to start a new thread - in fact I had answered your question
in your previous post.  If you didnt understand it consult the documentation.

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



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

Date: Thu, 29 Apr 1999 11:22:14 -0400
From: "Rich Billingsley" <hpman@erols.com>
Subject: Re: Enterprise on Novell w/Perl Scripts
Message-Id: <7g9ten$gvt$1@autumn.news.rcn.net>

OK, If you need more info, here is the info

Enterprise Version: 3.07 (Novell Build)
Novell Version 4.11
Perl Version  5.0307(?)


"cgi.pm"

$CGI::revision = '$Id: CGI.pm,v 1.29 1998/03/24 22:11:50 lstein Exp lstein
$';
$CGI::VERSION='2.39';


"cgi-lib.pl"

# Perl Routines to Manipulate CGI input
# cgi-lib@pobox.com
# $Id: cgi-lib.pl,v 2.18 1999/02/23 08:16:43 brenner Exp $

"Chicago-upload.cgi"


Thanks


David Cassell <cassell@mail.cor.epa.gov> wrote in message
news:372774EF.5F99E933@mail.cor.epa.gov...
> Rich Billingsley wrote:
> >
> > Enterprise Version: 3
> > Novell Version 4.11
> > Perl Version  5
> >
> > Trying to use a "file upload" script.  Works with standard text files
> > but not with binary or documents that contain images.
>
> And the Perl part of oyur question is....???
>
> If I make a totally unsupported guess that your `upload' program
> is in Perl, and that the protocol is FTP, then you probably need
> to change the mode from `ASCII' to `binary'.
>
> > Any clue?
>
> Yes.  That you haven't supplied the information needed to answer
> your question.  If the answer above is correct, then you don't even
> have a Perl question.  You have a protocol problem dressed up in a
> llama's coat.
>
> > Also the script using is one found on the internet and modified to work
> > on Novell with Netscape Enterprise.
>
> This is really not helpful at all.  How can anyone else know
> more aobut the problem from hearing that it is one of a billion
> Perl scripts found on the net?  Or that it is modified, in an
> unspecified way?
>
> You should receive an e-mail from gnat about posting here.  Please
> read that e-mail carefully, and adhere to the basic tenets within.
> Then next time you have a Perl question, you should be able to get
> a more useful, less discouraged answer.
>
> Thank you,
> David
> --
> David Cassell, OAO                            cassell@mail.cor.epa.gov
> Senior Computing Specialist                      phone: (541) 754-4468
> mathematical statistician                          fax: (541) 754-4716




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

Date: Thu, 29 Apr 1999 11:48:27 -0500
From: Fredrick DeQuan Lee <flee@theshop.net>
Subject: FreeBSD 3.0 pw -h 
Message-Id: <Pine.BSF.4.05.9904291142450.19330-100000@pineapple.theshop.net>

Can someone either post or email me an example of a script that uses the
'pw' command to set passwords or add users. The man page has thoroughly
confused me. I've tried opening pipes to it in perl by:
open(PW,"|pw -h");
and
open(PW,"pw-h|);
with no success. Any help out there? TIA.

L8r,
Flee

--------------------------------------------------------
Fredrick DeQuan Lee		The Internet Shop
Tech. Geek			5801 N. May Ave. #101
				Oklahoma City, OK 73112
flee at theshop dot net		Voice: (405) 848-7000
http://www.theshop.net		Fax:   (405) 848-5477
--------------------------------------------------------



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

Date: Thu, 29 Apr 1999 16:39:14 +0100
From: "Richard Gordon" <abc@abc.com>
Subject: FTP problem with windows NT
Message-Id: <37287d33.0@nnrp1.news.uk.psi.net>

I have a fairly simple perl script which connects to various servers and
pulls down files. The script work 99% of the time on NT Server 4 (100% on
UNIX)  but occasionally when attemping to connect to a server using the
"new" constructor of the Net::FTP object the perl script seems to hang. It
eventually takes up 99% of NT's cpu power bringing everthing else to a stop.
I then have to kill the process and run it again, it then always seems to
work.

I was wondering if anybody else had seen this behavour or new what might
cause it.

Thanks in advance

Richard Gordon




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

Date: Thu, 29 Apr 1999 17:49:15 +0200
From: Claes Bjorklund <clbjo@mai.liu.se>
Subject: Handle path in www
Message-Id: <37287F7B.41C6@mai.liu.se>

Hi 
This script lets the user go through one www adress only to access an
other, but it it works almost, have problem when the page has relative
path. Tried to check if there is a complete path  or not and then
replace but can't handle all situations

Thankful for some ideas

\Claes 

#!/usr/local/bin/perl -w

print "Content-type: text/html\n\n";

use LWP::Simple;

$http=$ENV{QUERY_STRING};
@a=split(/\//,$http);
$www=$a[2];
$re="http://www.address.to/the/script/anonym.pl?";

$hr=qq(href=");
$re2="$hr$re";
$re3=$re2.'http://'.$www;

$doc = get $http;
#$doc =~ s/\012/\015/g; #For Mac
$doc =~s/href\s+=\s+\"/href=\"/gi;
$doc =~s/href=\"/$re2/gi;
$doc =~s/$re2\?\//$re3\//gi;

print $doc;

-- 
****************************************************


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

Date: Thu, 29 Apr 1999 09:48:51 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Impythonating PERL?
Message-Id: <37288D73.B52B4E8F@mail.cor.epa.gov>

Avery Andrews wrote:
> 
> In <slrn7ie5op.n42.gabor@vnode.vmunix.com> gabor@vmunix.com (Gabor) writes:
> 
> >In comp.lang.perl.misc, Avery Andrews <andrews@Turing.Stanford.EDU> wrote :
> ># It seems to me that it would be cool to be able to use python-style
> ># whitespace-formatting when you wanted it, writing something like:
> 
> >If you want to program in Python, why don't you program in Python?
> >This kind of idiocy is just that, idiocy.
> 
> Actually, I do both (tho at a rather low leve of proficiency), & while
> I like PERL better for getting little things done quick, I waste
> a lot of time looking for errors because of the punctuation, which
> often causes the detected error to appear considerably after the
> real mistake.  So I'd like to have my cake and eat it too.
> 
> Anyway, since you have to lay code out that way to make it readable
> later, what's so dumb about using the whitespace to lose the
> punctuation?

Avery, I don't have any experience with this sort of code-munging in
Perl, but I've seen it done a number of ways in C.  It usually leads to
one of several problems.  The code becomes unmaintainable, except by 
the user.  If the user changes programming styles or has style
mandates put upon him by PHB's, havoc ensues.  If the coder learns
new language features or wants to move to more advanced programming
in that language, the code-munging often gets in the way.  And the
user gets used to code looking a certain way, so that texts and
other programs don't help as much as they might.

I would strongly advise against it.

But the comp.lang.python people might find it amusing.

David
-- 
David Cassell, OAO                            cassell@mail.cor.epa.gov
Senior Computing Specialist                      phone: (541) 754-4468
mathematical statistician                          fax: (541) 754-4716


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

Date: Thu, 29 Apr 1999 08:09:13 -0700
From: Jerome O'Neil <jeromeo@atrieva.com>
To: badbob01@my-dejanews.com
Subject: Re: Is this the best way to get a substring?
Message-Id: <37287619.3BBB4DBB@atrieva.com>

badbob01@my-dejanews.com wrote:

> Then when browsing the newsgroups, I discovered heaven:
> 
> $_ = "12abcd";
> /[0-9]+/;
> $substr = $&;
> # so $substr is "12"!!!
> So is this the best/only way to get a specific substring matching a pattern?

You want to use backtracking.  Using your example, you could save one or
more digits at the begining of a string followed one or more non digits
thusly:

/^(\d+)\D+/;

The parens will initialize $1 to whatever they matched.

> Is there a way to get around using  $_ ?

$_ is your friend.  He might be a bit ugly on first sight,  but is realy
kind of cute, and usefull.  You can bind another scalar to a regex using
the binding operator =~.

$newstring =~ /^(\d+)\D+/;
$digits = $1;

For all the exciting detail on regular expressions, backtracking and $1,
read the perlre document that came with your perl distribution.  You
might also want to read up on the binding operator, and other usefull
operators in perlop.

Good Luck!

-- 
Jerome O'Neil, Operations and Information Services
Atrieva Corporation, 600 University St., Ste. 911, Seattle, WA 98101
jeromeo@atrieva.com - Voice:206/749-2947 
The Atrieva Service: Safe and Easy Online Backup  http://www.atrieva.com


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

Date: Thu, 29 Apr 1999 08:36:53 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Is this the best way to get a substring?
Message-Id: <MPG.11921c72d46bb504989977@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <7g9j4t$9au$1@nnrp1.dejanews.com> on Thu, 29 Apr 1999 
12:26:07 GMT, badbob01@my-dejanews.com <badbob01@my-dejanews.com> 
says...
> I'm trying to extract a pattern from a string. At first, I substituted out
> what I *didn't* want and what was left is what I want:
> 
> $bigstr = "12abcd";
> ($substr = $bigstr) =~ s/[a-z]+//;
> # so $substr is "12"
> 
> But this method is indirect and gets tricky when the undesired part doesn't
> fit into an easy pattern.
> 
> Then when browsing the newsgroups, I discovered heaven:

Heaven is the Perl docs:  perlre and perlop.  The newsgroups are 
Purgatory.

> $_ = "12abcd";
> /[0-9]+/;
> $substr = $&;
> # so $substr is "12"!!!
> 
> So is this the best/only way to get a specific substring matching a pattern?

No/no.  Use capturing parentheses instead (see below).

> Is there a way to get around using  $_ ?

Sure.  But many of us consider using the $_ default to be a convenience.

my ($substr) = $string =~ /(\d+)/;

Doing the same thing a bit more slowly:

$string =~ /(\d+)/;
my $substr = $1;

Have a happy read!  (And invest in the book 'Learning Perl' instead of 
trying to learn it from the newsgroups, which tend to focus on more 
arcane issues.)

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


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

Date: 29 Apr 1999 09:57:18 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Is this the best way to get a substring?
Message-Id: <m1zp3rl5zl.fsf@halfdome.holdit.com>

>>>>> "Jerome" == Jerome O'Neil <jeromeo@atrieva.com> writes:

Jerome> $newstring =~ /^(\d+)\D+/;
Jerome> $digits = $1;

Bad code.  Very hard to track down coding error, because it *looks* right.

Hint - what if the regex match fails?  What $1 are you getting?

Right... the PREVIOUS $1 from the PREVIOUS successful match.

Bad code.

Never look at $1 unless you are inside a conditionally executed
chunk of code dependant on the success of your match of interest.

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: Thu, 29 Apr 1999 08:07:51 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Need help on "hex($1)"
Message-Id: <MPG.119215a08eda0b7f989975@nntp.hpl.hp.com>

In article <7g9g9f$6vp$1@nnrp1.dejanews.com> on Thu, 29 Apr 1999 
11:37:19 GMT, Don Roby <droby@copyright.com> says...
 ...
> $part_of_url =~ s/([^a-zA-Z0-9_.-])/uc sprintf("%%%02x",ord($1))/eg;

Just a tiny didactic note:  You can use the format "%%%02X" (upper-case 
X) and skip the uc().

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


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

Date: Thu, 29 Apr 1999 12:09:34 -0400
From: Manuel Garber <mgarber@answerthink.com>
Subject: Net::FTP question
Message-Id: <3728843E.E030F3CB@answerthink.com>

  Does anybody knows how to use Net::FTP  constructor to open a
connection  to nonstandard port.

  The documentation is cryptic for me.

 $ftp = Net::FTP->new("host",  [OPTIONS]);

  where
"OPTIONS are passed in a hash like fashion, using key and value pairs."

options include "Port".

  But I cannot guess how to actually set the port I need.

  Thanks in advance!!!!




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

Date: Thu, 29 Apr 1999 12:53:42 -0400
From: IDT Lab User <nobody+reachable_in_lcc_idt_lab@gatech.edu>
Subject: newbie in need...
Message-Id: <37288E95.68058E40@gatech.edu>

Greetings from Georgia Tech:

I might astound with my ignorance, but...

I'm trying to get the Unicode::map8 and Unicode::string modules set up
on my ActiveState port of Perl. I've learned the following...

1) I'm led to believe that these modules can't be installed with PPM

2) When I try to use pmake after "perl makefile.pm" I get errors --
which arise from (I think) the fact that Perl can't find cl.exe


3) I have no idea why I don't have "cl.exe", as it seems a perfectly
reasonable thing to have and everybody should get a free one from the
government. I'm still trying to figure out what it does.

I ask, then
1) Is there an easier way to get these packages into ActiveState Perl?

2) Any programs/steps I'm missing?

3) Instant tranferral of all Perl knowledge.


Thanks kindly,

Daniel McQuillen
gt7592b@prism.gatech.edu
www.lcc.gatech.edu/~dmcquill
www.mcquillenillustration.com
****************************************************
A monk asked Chao-chou, "Has the dog Buddha nature or not?"
Chao-chou said, "Mu."
Monk's response (lost to history), "uhm...what?"






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

Date: Thu, 29 Apr 1999 10:44:14 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: newbie: Replace \n with <br>\n
Message-Id: <x3yg15j7agy.fsf@tigre.matrox.com>


"Scott Oseychik" <scott@simsbury.com> writes:

> 
> <snip>
> 
> > > > Here's my code so far, but I can't seem to get it to work:
> > > >
> > > > #!c:\perl\bin -w
> 
> > > Am I missing something here, oris c:\perl\bin a good program?
> 
> </snip>
> 
> 
> On Win32, this is valid...thanks for the feedback.

I believe the question was whether it should be c:\bin\perl instead of
c:\perl\bin. I guess (but I'm not sure) that it has to do with how the
shebang line works on win32. The OS will look for perl.exe in its
standard path (NOT in the shebang). But, if the first line starts with
'#!' and if the word 'perl' appears in it, then the interpreter takes
into consideration any command line flags, like '-w', that appear in
the shebang.

Am I right?



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

Date: 29 Apr 1999 15:19:38 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: PERL & Y2K
Message-Id: <slrn7igu95.48p.fl_aggie@stat.fsu.edu>

On Thu, 29 Apr 1999 14:00:23 GMT, Bart Lateur
<bart.lateur@skynet.be>, in <37296561.4372194@news.skynet.be> wrote:

+ >+ I e-mailed them back and asked "So, it is a programmer mind reader?"
+ >+ The guy mailed me back and said people are buying it.

+ >OH DEER LORD.

+ The *good thing* is that if it turns out that this thing failed to catch
+ a few Y2K bugs, you could probably succesfully prosecute the company for
+ not delivering what they promised.

Fine in theory. But this presumes you can find the culprit...I have a
feeling this is a "fly-by-night" deal...

James


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

Date: Thu, 29 Apr 1999 16:05:11 GMT
From: NukeEmUp@ThePentagon.com (David Cantrell)
Subject: Re: PERL & Y2K
Message-Id: <37298292.16310483@news.insnet.net>

On Thu, 29 Apr 1999 14:00:23 GMT, bart.lateur@skynet.be (Bart Lateur)
enlightened us thusly:

>>Sneex wrote:
>>+                                        ... saying they had
>>+ a perl code scanner which helps you fix all perl Y2k issues.
>>+
>>+ I e-mailed them back and asked "So, it is a programmer mind reader?"
>>+ The guy mailed me back and said people are buying it.
>
>The *good thing* is that if it turns out that this thing failed to catch
>a few Y2K bugs, you could probably succesfully prosecute the company for
>not delivering what they promised.

If they promised that it "helps you fix all perl Y2k issues" then
provided it catches just ONE glitch, it has _helped_ towards your goal
of fixing them all ;-)

-- 
Dave, who's been reading Chomsky's "Manufacturing Consent" too much.


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

Date: Thu, 29 Apr 1999 18:26:51 +0200
From: Jari =?iso-8859-1?Q?J=E4nk=E4l=E4?= <Jari.Jankala@era.ericsson.se>
Subject: perlcc compilation problem
Message-Id: <3728884B.774F655D@era.ericsson.se>

Hi !

I hope that you can help me with a perlcc question.

When I try to run perlcc on a Windows NT machine to compile my test
program test.pl I get the message:

Can't use an undefined value as a symbol reference at C:\Perl\lib/B.pm
at line 225.

It seems that the variable $output_fh is not properly set.

I have tried a number of hours to figur out what has happened.

The test file is really simple:
print "HEJ\n";


Do you have any idea what could help me ?

I use Activstate Perl.

BR JARI





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

Date: Thu, 29 Apr 1999 12:45:44 -0400
From: Ed Bogart <e.h.bogart@larc.nasa.gov>
Subject: Re: perldoc HELP, Was How to use Net::FTP in perl??
Message-Id: <37288CB8.25C3158@larc.nasa.gov>

"Stephen O. Lidie" wrote:
> 
> Ed Bogart <e.h.bogart@larc.nasa.gov> wrote:
> > Tony Curtis wrote:
> >>
> >> Re: perldoc HELP, Was How to use Net::FTP in perl??,
> >> Ed <e.h.bogart@larc.nasa.gov> said:
> >>
> >> Ed> I have asked this before with no answers so here
> >> Ed> goes again. I am using perl version 5.004_04
> >> Ed> built for IP19-irix on an SGI 02 and have not
> >> Ed> been able to get perldoc to work with any
> >> Ed> modules. Trying the above, using all 3 forms
> >> Ed> from perldoc perldoc, I get;
> >>
> >> Maybe this version of perl was built with no
> >> documentation installed (you can do this during the
> >> configuration with the reply "none" at the
> >> appropriate point)?
> >>
> > As I explained in response to the IRA Aggie's post, it looks like all
> > the modules are installed and perldoc works fine when used in the
> > 'perldoc -f somefunction' form. It only returns an error when I as for
> > _module_ information.
> 
> > I could understand in no docs were included in the build but can some be
> > there and not others?
> 
> Try:
> 
>         perldoc -v
> 
> That will list exactly where perldoc is searching.  On IRIX 6.x perl is
> bundled with the OS, so the IRIX perldoc may appear in your PATH earlier
> than the perldoc you think you have, thus, missing all your local modules.
> 
> Yell if that doesn't help ....

OK, I tried 'perldoc -v FTP' and got a listing of 70 subdirectories
(including /usr/local/perl-5.004_04/lib/IP19-irix/5.00404/pod that it
searcher. It still came up with 'No documentation found for "FTP".'

Ed


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

Date: Thu, 29 Apr 1999 06:50:49 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: pow() ? to the power of ?
Message-Id: <9id9g7.n32.ln@magna.metronet.com>

Bill Jones (bill@fccj.org) wrote:
: In article <372727c6.64949187@news1.mi.home.net>, sweet@enterpriseusa.com 

: Interesting, I haven't been able to find what the  ^  is for?

: In math is means:  X raised to power y...

: But, in perl, 4 ^ 2 = 6 (not 16...)


   from perlop.pod:

      Binary "^" returns its operators XORed together bit by bit.


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


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

Date: Thu, 29 Apr 1999 07:52:06 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Question: Opening and closing files.
Message-Id: <MPG.119211eb9b00c036989974@nntp.hpl.hp.com>

In article <37285ba2@newsread3.dircon.co.uk> on 29 Apr 1999 14:16:18 
+0100, Jonathan Stowe <gellyfish@gellyfish.com> says...
> Tony Bowden <tony@blackstar.co.uk> wrote:
> > Abigail <abigail@fnx.com> wrote:
> >> David Cassell (cassell@mail.cor.epa.gov) wrote on MMLXII September
> >> MCMXCIII in <URL:news:37210A44.47C2D26A@mail.cor.epa.gov>:
> > 
> > The 2562nd of September 1993?
> > 
> 
> Thats a FAQ ;-}

But not this FAQ (which might have told Tony that the number
is 2062 :-):

How can I output Roman numerals? 
Get the http://www.perl.com/CPAN/modules/by-module/Roman module. 

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


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

Date: Thu, 29 Apr 1999 10:55:52 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: What does this error message mean?
Message-Id: <x3yeml379xj.fsf@tigre.matrox.com>


rjk@linguist.dartmouth.edu (Ronald J Kimball) writes:

> % perl -wc
>         open F, "somefile";
>         while ($i = <F>) {}
>         __END__
> Value of <HANDLE> construct can be "0"; test with defined() at - line 65535.
> Name "main::i" used only once: possible typo at - line 2.
> - syntax OK
> % 
> 
> Does perl -c usually print out run-time error messages?
> 
> The fact that the message appeared after __END__ simply means that the error
> was output at the end of the compilation stage, not that it was output after
> the program started running.

Ok .. what you say makes sense. But why is the line number
misreported, and why is the behaviour different from:

% perl -wc
open F, "somefile";
do {} while $i = <F>;
Value of <HANDLE> construct can be "0"; test with defined() at - line 2.
__END__
Name "main::i" used only once: possible typo at - line 2.
- syntax OK

and why does the second case report the correct line number?

Shouldn't both produce the exact same opcode? Or is this irrelevant?

Ala



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

Date: Thu, 29 Apr 1999 10:03:28 -0600
From: Collin Starkweather <collin.starkweather@colorado.edu>
Subject: Win95/98 file locking
Message-Id: <372882D0.555357BC@colorado.edu>

This is a multi-part message in MIME format.
--------------81036DEE0E4012BD8D295FC5
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Testing seems to indicate that flock does not work in Win95/98.  Is
there a way to lock a file in Win95/98 that I am unaware of?

I can think of cheezy workarounds (e.g., renaming the file), but would
like to have something that is guaranteed not to survive an unexpectedly
terminated process.

If anyone has tackled this problem before, I would be grateful for any
hints or suggestions.

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Collin Starkweather                                 (303) 492-4784
University of Colorado            collin.starkweather@colorado.edu
Department of Economics          http://ucsu.colorado.edu/~olsonco
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--------------81036DEE0E4012BD8D295FC5
Content-Type: text/x-vcard; charset=us-ascii;
 name="collin.starkweather.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Collin Starkweather
Content-Disposition: attachment;
 filename="collin.starkweather.vcf"

begin:vcard 
n:Starkweather;Collin
tel;work:(303) 492-4784
x-mozilla-html:FALSE
url:http://ucsu.colorado.edu/~olsonco
org:University of Colorado;Department of Economics
version:2.1
email;internet:collin.starkweather@colorado.edu
title:Research Assistant
adr;quoted-printable:;;University of Colorado=0D=0ACampus Box 0256;Boulder;Colorado;80309-0256;USA
fn:Collin Starkweather
end:vcard

--------------81036DEE0E4012BD8D295FC5--



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

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

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