[11896] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5496 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 27 12:07:00 1999

Date: Tue, 27 Apr 99 09: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           Tue, 27 Apr 1999     Volume: 8 Number: 5496

Today's topics:
    Re: "learning perl" does not seem to be written well <bowman@montana.com>
    Re: "learning perl" does not seem to be written well <emschwar@rmi.net>
    Re: ==> Starting subroutines in here documents <== (I.J. Garlick)
    Re: ==> Starting subroutines in here documents <== (Tad McClellan)
    Re: ==> Starting subroutines in here documents <== (Andrew Allen)
    Re: Administration Scripts Win-NT Perl (Jere Julian - Personal Account)
    Re: autoincrement magic a..z (Larry Rosler)
    Re: autoincrement magic a..z (Clinton Pierce)
        Comparing contents of one doc w/ another. <stevenabell@hotmail.com>
    Re: Comparing contents of one doc w/ another. <Michael.Cameron@no.spam.technologist.com>
    Re: Country of a visitor (Michel Dalle)
    Re: Country of a visitor <emschwar@rmi.net>
        DBD/ODBC for Informix Win32 with Cygwin (Joonas Timo Taavetti Kekoni)
    Re: FAQ 4.31: How do I pad a string with blanks or pad  (Larry Rosler)
    Re: FAQ not applicable (was: Eliminate elements from ar (Andrew Allen)
        get current time in milliseconds (Wei Tang)
    Re: get current time in milliseconds <Michael.Cameron@no.spam.technologist.com>
    Re: GIF in web page (Michel Dalle)
        How can I make an auto-url with a search and replace? <rtficial@dds.nl>
    Re: Monitoring the state of a serial port HELLLPPPPP (Jere Julian - Personal Account)
    Re: Multiline comments in perl <jeromeo@atrieva.com>
    Re: Perl Editors On Win32 <vvb@ibm.net>
    Re: Perl RegEx question (Bart Lateur)
    Re: Perl RegEx question <dgris@moiraine.dimensional.com>
        Postponing interpolation? (Anneke Treep)
    Re: Postponing interpolation? <jdf@pobox.com>
    Re: question about guestbook <devries-devries@wxs.nl>
        rmtree issues <chad13@bellsouth.net>
    Re: searching perl documentation (Tad McClellan)
    Re: stupid single quote " wipes out REST OF TEXT (Benjamin Franz)
    Re: stupid single quote " wipes out REST OF TEXT (Tad McClellan)
    Re: stupid single quote " wipes out REST OF TEXT NOSPAMcrstlblu@planet.eon.net
    Re: system calls from Apache using perl <bill@fccj.org>
    Re: what's wrong with $x = $y or "" (Juho Cederstrom)
    Re: what's wrong with $x = $y or "" (Larry Rosler)
    Re: where do I look for a free lance script writers? <davidk@nospam.cnct.com>
    Re: Where do the spaces come from <rhardicr@hotmail.com>
    Re: Where do the spaces come from (Tad McClellan)
        Win32, Word <bdaly@averstar.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Tue, 27 Apr 1999 06:47:27 -0600
From: "bowman" <bowman@montana.com>
Subject: Re: "learning perl" does not seem to be written well
Message-Id: <dmiV2.2209$n5.8214@newsfeed.slurp.net>


Bob Trieger <sowmaster@juicepigs.com> wrote in message
>
> Make that 3 of us. The only experience I had was COBOL on an IBM
> mainframe. I was feeling pretty stupid by the time I finished the first
> chapter. Boy was I relieve when I started chapter 2.

4.  Being an old systems hack, I always sneered at scripting languages. Perl
makes C++ STL source read like a Stephen King novel in comparison.

Think I'll cast a Snake before Perls.  At least I can see the markings on
the python's back, whilst perls are just shiny little indigestible nuggets.





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

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

Henry Hartley <hartleh1@westat.com> writes:
> Well, they are going to have to make SOME assumptions.  For instance,
> they assume you are an English speaker and don't bother translating
> into French, German or Sanskrit.  As to your comment about the =~
> operator, it is introduced on page 11, is described as the "match
> operator" in a paragraph of text and used in a simple code sample which
> illustrates its use. 

Yeah, but let's face it, the =~ operator is conceptually kinda weird.
Even as an experienced programmer coming to Perl, it threw me for a loop
the first time.  I couldn't really grok what it was doing-- if you have a 
m/// on the rhs, then it's just a binding, but the exact same operator
with a s/// or y/// operator changes the value of the lhs.  It's not hard 
to figure out what it's doing, but it's something that I hadn't seen
before I came to Perl.

-=Eric


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

Date: Tue, 27 Apr 1999 13:03:47 GMT
From: ijg@csc.liv.ac.uk (I.J. Garlick)
Subject: Re: ==> Starting subroutines in here documents <==
Message-Id: <FAuMyB.1CK@csc.liv.ac.uk>

In article <37258414.C50B736D@sun.com>,
Andreas Fischer <Andreas.Fischer@Sun.COM> writes:
> Hello,
> I've got a little problem, how can I start subroutines in here
> documents?
> Example:
> 

Not sure where I got the following syntax from but I have been using it
rather extensively off late. It may well have been from this very news
group and if so many thanks to that unsung benefactor.

> #!/usr/local/bin/perl -w
> 
> sub lurch
> {
> 	$x="abcdefghijklmn";
> 	@tmp=split(//,$x);
> 	$y=join("\n",@tmp);
> 	return($y);
> }

Yukk.
perhaps one of the gurus could point out a better way of doing the above
using map as well. Anyone?

> 
> print <<"BLA";
          ^   ^
you don't need those double quotes, I think they are the default.

> abcdefghijkl$z=do lurch

Change above line to
abcdefghijkl${ \(lurch() }

> BLA
> 
> Thanks in advance
> 
> Andi 
> 

-- 
Ian J. Garlick
ijg@csc.liv.ac.uk

"It's men like him that give the Y chromosome a bad name."



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

Date: Tue, 27 Apr 1999 03:50:45 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: ==> Starting subroutines in here documents <==
Message-Id: <l8q3g7.7l4.ln@magna.metronet.com>

Andreas Fischer (Andreas.Fischer@Sun.COM) wrote:

: I've got a little problem, how can I start subroutines in here
: documents?


   here-docs are just another form of (double, in your case)
   quoted string.

   So you call subroutines the same way you would call them
   in a double quoted string.

   Which is too ugly for me to repeat.

   So just call the sub first and save the result in a scalar,
   then interpolate the scalar:


: sub lurch
: {
: 	$x="abcdefghijklmn";
: 	@tmp=split(//,$x);
: 	$y=join("\n",@tmp);
: 	return($y);

   You can replace that entire function body and use not
   temporary variables if you like:

      return join("\n", split //, 'abcdefghijklmn');

: }



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


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

Date: 27 Apr 1999 15:32:59 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: ==> Starting subroutines in here documents <==
Message-Id: <7g4lbb$qpv$2@fcnews.fc.hp.com>

I.J. Garlick (ijg@csc.liv.ac.uk) wrote:
: > sub lurch
: > {
: > 	$x="abcdefghijklmn";
: > 	@tmp=split(//,$x);
: > 	$y=join("\n",@tmp);
: > 	return($y);
: > }

: Yukk.
: perhaps one of the gurus could point out a better way of doing the above
: using map as well. Anyone?

Maybe:

return (my $y=$x)=~s/.(?=.)/$&\n/g;

but are you sure you don't want a newline at the end??

return (my $y=$x)=~s/./$&\n/g;

Andrew


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

Date: 27 Apr 1999 15:09:40 GMT
From: julianje@mercury.interpath.com (Jere Julian - Personal Account)
Subject: Re: Administration Scripts Win-NT Perl
Message-Id: <7g4jvk$646$3@gaddy.interpath.net>

David Cassell (cassell@mail.cor.epa.gov) wrote:

: Did you know that the O'Reilly `octopus' book NT Administration is
: all Perl?  Have you checked out Dave Roth's latest book?  Both are
: excellent sources of NT admin info.

They are great references BUT be warned that the 'octopus' book is written 
several perl versions back and much porting is necessary for actual use.  They
are still, however, indespensible.

I have taken their basis and made a script that adds users in bulk or one at a 
time to my system with all directories, permissions, etc. handled.  Great for
consistency and I don't have to remember to set all those settings every
time!.

I'll be happy to pass it along if interested.

I am working on a GUI for it to make my IT Driector happy! ;-)

-Jere
Network Admin, LADD Upholstery
mailto:jjulian@laddnet.com


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

Date: Tue, 27 Apr 1999 07:43:40 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: autoincrement magic a..z
Message-Id: <MPG.118f6cf3a02d4a7698994b@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <37255BFE.7A6D8B86@sgi.com> on Mon, 26 Apr 1999 23:41:02 -
0700, Ben Gilbert <bgilbert@sgi.com> says...
 ... 
> As to the second part of my question ... why doesn't it work in reverse?

Well, what would the result of this be:

  my $x = 'b';  print --$x, --$x;

One might find getting 'undef' in the sequence to be a rude surprise, 
but there is no 'better' result, is there?

I'll bet that The Larry thought of that in designing this capability.  
:-)

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


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

Date: Tue, 27 Apr 1999 14:35:03 GMT
From: cpierce1@ford.com (Clinton Pierce)
Subject: Re: autoincrement magic a..z
Message-Id: <3725c9dc.1809201@news.ford.com>

On Mon, 26 Apr 1999 23:41:02 -0700, Ben Gilbert <bgilbert@sgi.com> wrote:
>As to the second part of my question ... why doesn't it work in reverse?

(mixing metaphors horribly here)

Magic autoincrement is like sausage.  You're getting something good.
Knowing how it's made isn't really important and would surely diminish the
dining experience.  Most importantly, it's the fine details that prevent
you from making it into a pig again.

-- 
Clinton A. Pierce       "If you rush a Miracle Man, you get rotten
clintp@geeksalad.org        Miracles."  -- Miracle Max, The Princess Bride
http://www.geeksalad.org


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

Date: Tue, 27 Apr 1999 12:57:17 GMT
From: "stevenabell" <stevenabell@hotmail.com>
Subject: Comparing contents of one doc w/ another.
Message-Id: <NuiV2.87$k_1.221@c01read05.service.talkway.com>

Dear All,

I am trying to compare the contents of a series of documents with a
"standard" document, to see if there is a match. The standard
document contains a list of terms, of the form:

term1
term2
term3
etc

The other documents which must be compared also have their contents
arranged in the above fashion. So, "doc1" might contain the following:

term2
term3

In which case I would want to rename "doc1" to "doc1.html" and place
that in a directory somewhere else. All the files above are resident
on a UNIX server.

Though I realise the solution to this may be somewhere in the FAQ, I
did manage to look through them sometime last week to no avail, and
for some reason have not been able to access them since. Any ideas or
solutions to the above would be sincerely appreciated.

Hope you are all in good health,

Steve Bell

--
Posted via Talkway - http://www.talkway.com
Exchange ideas on practically anything (tm).



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

Date: Tue, 27 Apr 1999 15:42:22 +0000
From: Michael Cameron <Michael.Cameron@no.spam.technologist.com>
To: stevenabell <stevenabell@hotmail.com>
Subject: Re: Comparing contents of one doc w/ another.
Message-Id: <3725DADD.23B8DEA7@no.spam.technologist.com>

stevenabell wrote:

> Though I realise the solution to this may be somewhere in the FAQ, I
> did manage to look through them sometime last week to no avail, and
> for some reason have not been able to access them since. Any ideas or
> solutions to the above would be sincerely appreciated.

Was that at the same time as you were browsing them in relation to your
other posts?  If so then I suggest you read the replies telling you how
to get "in" to the documents which you have copies of on your local
system.

Some questions for you:
Why is your time any more valuable than mine?
Why am I bothering to reply?

If you continue to post before trying to solve your own problems then
you will soon find that no one will reply.

You might (if you can get "in") try looking at String::Approx or Diff
but I suspect when you say "documents" that you might not mean just text
in which case you may be beyond all hope of redemption.

I hope this helps but suspect that it will not.

Regards,

Michael Cameron


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

Date: Tue, 27 Apr 1999 14:57:14 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: Country of a visitor
Message-Id: <7g4c02$8vg$3@news.mch.sbs.de>

In article <3724D426.5B80B47C@gsig-net.qc.ca>, selectthree@gsig-net.qc.ca wrote:
>OK.  I wasn't enough clear, I guest.
>
>I want to program a counter for my site and for the others that will
>want it and I want to be able to track the country of origin of a
>visitor (like Nedstat counter (http://usa.nedstat.net), for example,
>does).
>
>Does somebody know the code to
>first, detect the server's adress (like when I post on MSNBC, it is
>written that I come from modem37.gsig-net.qc.ca, as example)

Aha. Have a look at some examples at the CGI Resource Index :
http://www.cgi-resources.
com/Programs_and_Scripts/Perl/Logging_Accesses_and_Statistics/

Basically, it works like this :-)
1) enable DNS lookup on your website, or :
use gethostbyaddr on all REMOTE_ADDR entries of your logfile
2) split off the domain from the resulting hostname (e.g. ca)
3) translate to the country (e.g. Canada)

Analog can do it for you, I think.

Cheers,

Michel.

--
aWebVisit - extracts visitor information from WWW logfiles and shows
the top entry, transit, exit and 'hit&run' pages, the links followed
inside your website, the time spent per page, the visit duration etc.
For more details, see http://gallery.uunet.be/Michel.Dalle/awv.html


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

Date: 27 Apr 1999 09:25:02 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Country of a visitor
Message-Id: <xkfiuaim6gh.fsf@valdemar.col.hp.com>

Pierre-Luc <selectthree@gsig-net.qc.ca> writes:
> Note : for those who think it's useless to have the country of a
> visitor, I think that it is usefull to see if your site interests people
> away from your own country, and in wich proportion.

Maybe I'm missing something.

Why don't you just ask?

-=Eric


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

Date: 27 Apr 1999 13:26:36 GMT
From: jkekoni@cc.hut.fi (Joonas Timo Taavetti Kekoni)
Subject: DBD/ODBC for Informix Win32 with Cygwin
Message-Id: <7g4duc$gghm$1@midnight.cs.hut.fi>

Can I compile and get DBD/ODBC to work with Informix in Win32 (NT)
platform by compiling it with cygwin? Has anyone done that?

I am not intrested in DBD/Informix since it requires extra priced
componets from Informix ( and i can always system() the command
line tools, despite it is ugly.)

-- 
	_-  Joonas Kekoni       OH2MTF	    I                           -_
	_-internet:	jkekoni@cc.hut.fi   I       DO NOT EAT.         -_
	_-slowmail:	j{mer{ntaival 7a176 I                           -_
	_-		02150Espoo          I      It is a monitor      -_
	_-		Finland/Europe      I                           -_


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

Date: Tue, 27 Apr 1999 07:26:14 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: FAQ 4.31: How do I pad a string with blanks or pad a number with zeroes?
Message-Id: <MPG.118f68d14663a84998994a@nntp.hpl.hp.com>

[Posted and a courtesy copy sent to Bart Lateur and Uri Guttman.]

In article <372560bf.1136343@news.skynet.be> on Tue, 27 Apr 1999 
08:20:39 GMT, Bart Lateur <bart.lateur@skynet.be> says...
> Tom Christiansen wrote (quoting uri):
> >  How do I pad a string with blanks or pad a number with zeroes?
> 
> >    The simplest method use the `sprintf' function. It can pad on the
> >    left or right with blanks and on the left with zeroes.
> >
> >        # Left padding with blank:
> >        $padded = sprintf( "%${pad_len}s", $text ) ;
> 
> Funny that this FAQ doesn't mention pack().
> 
> 	# Left padding with blank:
> 	$padded = pack("A$pad_len",$text);
> 
> There's a difference with sprintf() when length($text)>$pad_len:
> 
>  * pack() -> break off string so resulting length is $pad_len
>  * sprintf() -> resulting string is longer than $pad_len

This thread is getting confused about the difference between left 
padding and left alignment.  (I was confused and gave a wrong answer, 
and now this one is wrong.)

According to perlfunc, pack "A$pad_len" produces *trailing* padding 
(i.e., right padding, hence left alignment).  The Perl documentation of 
sprintf says that '-' "left-justifies within the field" (hence right 
padding).  I don't have my C Standard at hand, but IIRC, the term used 
there is left alignment.

Uri, as you wrote this, can you straighten it out using the same 
terminology as the other docs?  They focus on which end of the string is 
aligned, not which end of the string is padded.  (And please use more 
standard punctuation?  TomC nailed someone the other day about a space 
before the semicolon, and you do it all the time.  :-)

           $padded = sprintf("%${pad_len}s", $text);

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


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

Date: 27 Apr 1999 15:29:28 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: FAQ not applicable (was: Eliminate elements from array with second array?)
Message-Id: <7g4l4o$qpv$1@fcnews.fc.hp.com>

lou@visca.com wrote:

: @skips = qw(cgi-bin messages oldstuff ppd test archives)

: What I wanted was an efficient code to check each of the elements in @found
: for any string in @skips, regular-expression-wise. So, for example, any and
: all @found elements that contained the string '/oldstuff/'
: (/www/visca/oldstuff/index.html, /www/visca/clueless/oldstuff/sitemap.cgi,
: etc.) would be eliminated.

: Andrew's code:

: my $re=join("|",@skips);
: @found=grep(!m{/($re)/}o,@found);

: ...was exactly what I was looking for:

You're welcome!

In addition, you could embed the regexp check into your finddepth so
you can do a File::Find::prune on "undesirable" paths.

Andrew


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

Date: 27 Apr 1999 13:02:33 GMT
From: wtang@cs.ualberta.ca (Wei Tang)
Subject: get current time in milliseconds
Message-Id: <7g4ch9$bk6$1@scapa.cs.ualberta.ca>

Hi, 

How can I get the current time in milliseconds since 1970 rather than in
seconds? The time function in Perl is not enough.

Thanks.


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

Date: Tue, 27 Apr 1999 15:45:05 +0000
From: Michael Cameron <Michael.Cameron@no.spam.technologist.com>
To: Wei Tang <wtang@cs.ualberta.ca>
Subject: Re: get current time in milliseconds
Message-Id: <3725DB81.D5E1A159@no.spam.technologist.com>

Wei Tang wrote:
> 
> Hi,
> 
> How can I get the current time in milliseconds since 1970 rather than in
> seconds? The time function in Perl is not enough.
> 
> Thanks.

This depends on your system but if your system will support hi-res
timing you should get the Time::HiRes module from CPAN.

HTH,

Michael


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

Date: Tue, 27 Apr 1999 15:08:52 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: GIF in web page
Message-Id: <7g4clt$aia$1@news.mch.sbs.de>

In article <37257F2C.F9980CD7@webline.dk>, Kaare Rasmussen <kar@webline.dk> wrote:
>I want to make a GIF file and present it in a web page. Both are made
>dynamically. So I imagine I have to create the GIF file with a temporary
>name (eg. $$.gif or so) and make a <IMG SRC="$$.gif". But then I have to
>run a cron job every so often to purge old files.
>
>Does a more elegant solution exist, something that will automatically
>purge the GIF file?

You could include something like this in your script :

while ($file = <*.gif>) {
        next unless -M $file > 1;
        unlink $file;
}

(or a shorter period, if you have a lot of images there)

Michel.

--
aWebVisit - extracts visitor information from WWW logfiles and shows
the top entry, transit, exit and 'hit&run' pages, the links followed
inside your website, the time spent per page, the visit duration etc.
For more details, see http://gallery.uunet.be/Michel.Dalle/awv.html


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

Date: Tue, 27 Apr 1999 17:59:42 +0200
From: "Albert Brand" <rtficial@dds.nl>
Subject: How can I make an auto-url with a search and replace?
Message-Id: <7g4mpo$6hl$1@dinkel.civ.utwente.nl>

Let's take this string:

"Go to http://come.to/inf-inity "

And i would like to have it converted to:

"Go to <a href="http://come.to/inf-inity">come.to/inf-inity</a> "

Can you do this with a simple search and replace?

--
Albert Brand
a.g.brand@student.utwente.nl
http://come.to/inf-inity
ICQ 17859927




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

Date: 27 Apr 1999 14:57:55 GMT
From: julianje@mercury.interpath.com (Jere Julian - Personal Account)
Subject: Re: Monitoring the state of a serial port HELLLPPPPP
Message-Id: <7g4j9j$646$2@gaddy.interpath.net>

Jonathan Stowe (gellyfish@gellyfish.com) wrote:
: It might be useful if you suggested in what way the FAQ didnt provide
: the answer it might also be useful if you indicated what you were trying
: to do, what problems you were having and show us the piece of code
: that you are having difficulty with 


I too am having problems not solved by the FAQ.  Using Linux and perl 5.003 
trying to read data from a telephone PBX.  These display fine on a PC running
Procomm, etc.

#!/usr/local/bin/perl

$logpath = "/usr/local/src/phone";
$logfile = "mylog";
$port    = "cur5"; # port 6 on a RocketPort Serial card.

$SIG{HUP} = \&sig_hup;

open(LOG, ">$logpath/$logfile") or die "Can't open $logpath/$logfile: $!\n";
open(PORT, "</dev/$port") or die "Can't open $port: $!\n";

$old_fh=select(LOG);  $| = 1;select($old_fh);      # Make unbuffered

while($_ = <PORT>) {
  print LOG $_;
}

close PORT;
close LOG;
print "Done.\n";

sub sig_hup {
  $SIG{HUP} = \&sig_hup;
  print STDERR "STDERR: Rotating CDR Log file\n";
  close LOG or die "Can't close $logpath/$logfile: $!\n";;
  rename "$logpath/$logfile", "$logpath/$logfile.0"
    or die "Can't rename: $!\n";
  open(LOG, ">$logpath/$logfile") or die "Can't open $logpath/$logfile: $!\n";
}    

I get stray characters and the PBX shuts down the line claiming invalid
characters are comming in.  The data should be fixed record length records
that I'll process monthly.

Please help,
-Jere Julian
Network Admin, LADD Upholstery
mailto:julianje@laddnet.com


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

Date: Tue, 27 Apr 1999 08:38:15 -0700
From: Jerome O'Neil <jeromeo@atrieva.com>
Subject: Re: Multiline comments in perl
Message-Id: <3725D9E7.8EE4858B@atrieva.com>

David Cassell wrote:
> 
> Jerome O'Neil wrote:
> > Ye Gods!  Why has thou forsaken C-style comments?!!!
> 
> It's fine by me.  But then when I write C code, I do it in an
> analogous way to my Perl code...
> 
> ############################################################
> #  I put stuff in boxes anyway, so readers can see it.     #
> ############################################################

/************************
Ook!
*************************/

-- 
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: Tue, 27 Apr 1999 17:32:17 +0200
From: "Vincent Vanbiervliet" <vvb@ibm.net>
Subject: Re: Perl Editors On Win32
Message-Id: <3725d7bf@news.uk.ibm.net>


Ian Taite <ian.taite@nospam.zen.co.uk> wrote in message
news:Qc4V2.20256$Hh5.2084@news-reader.bt.net...
> Anyone know of a free full screen editor running under Windows NT
> that's Perl aware? i.e. colour codes the program source
> Ian.
>
If you're also into HTML-ing, I'd recommend HomeSite (not free though, but
worth it)

Vincent




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

Date: Tue, 27 Apr 1999 14:51:50 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Perl RegEx question
Message-Id: <3726ce40.29168964@news.skynet.be>

chris losinger wrote:

>Name     : here is some good stuff
>
>my script needs to get everything after the ":".
>
>currently, this works for most messages :
>
>	if ( m/^Name\s*: (.+)$/ )
>	{
>		($name) = ($1);
>	}		
>
>but, what i've found is that sometimes the messages come in with
>0x0a/0x0d pairs (DOS CR/LF) at the end of the lines, instead of just
>0x0a. This causes my little regex to fail and set $name to blank.

I expect the reverse: "0x0d" first. I don't quite follow why this would
return an empty result. A trailing CR, yes.

Maybe the CR is at the front of the line?

>so, my question is, how can i handle these situations ?

A simple

	tr/\r//d;

should suffice.

	Bart.


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

Date: 27 Apr 1999 09:00:37 -0600
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Perl RegEx question
Message-Id: <m3hfq26rca.fsf@moiraine.dimensional.com>

my_addr_is-chrisdl@pagesz.net (chris losinger) writes:

> but, what i've found is that sometimes the messages come in with
> 0x0a/0x0d pairs (DOS CR/LF) at the end of the lines, instead of just
> 0x0a. this causes my little regex to fail and set $name to blank.
> 
> so, my question is, how can i handle these situations ?

Strip the CRs first.

    s/\r//g;

dgris
-- 
Daniel Grisinger          dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print 
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'


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

Date: 27 Apr 1999 15:21:30 GMT
From: anneke@echelon.nl (Anneke Treep)
Subject: Postponing interpolation?
Message-Id: <3xvOrducOdpb-pn2-1GxxN6vdgXmU@compaa.echelon.nl>

Hi all,

I have written a program that will print out a letter, which has a
standard layout with just a few variable words in it. These variables
are set during a while loop which gets data from a database.

The thing is that it doesn't look really nice/maintainable to have the
while loop like this if the letter is longer than say half a page:

while (getrowfromdatabase) {
    # here I read the variables into $sons etc ...
    my $s = ($sons != 1 ? "s" : "" );
    print "
I have $sons son$s
 ..etc. 
";
    # perhaps more logic follows here
}

So I would prefer to replace the print statements with just 
"letter();"
and say *at the end of my script* something like:

sub letter {
    print "
I have $sons son$s
 ..etc.
";

But if I do so the variables $sons and $s need to be global, which is
something I don't really want either :-(
The problem is that I can't postpone the interpretation *until* I am 
in
the while loop unless I put the letter-definition there too (which 
still
doesn't keep it separate).

Any suggestions so that I can:
- put the letter-definition at the very end of my script;
- use variables local to my while loop in the letter;
Any elegant solution is acceptable - my main concern is the 
maintainability for occasional perl users. I don't want to use forms
though (for reasons that are irrelevant here).

Thanks!

--
Anneke Treep                                 | email:     
anneke@echelon.nl
                                             | web:          
www.echelon.nl
ECHELON consultancy and software development | phone:   +31 (0)53 48 
36 585
PO Box 545, 7500AM Enschede, The Netherlands | fax:     +31 (0)53 43 
36 222



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

Date: 27 Apr 1999 11:57:59 -0400
From: Jonathan Feinberg <jdf@pobox.com>
To: anneke@echelon.nl
Subject: Re: Postponing interpolation?
Message-Id: <m3ogkajbso.fsf@joshua.panix.com>

anneke@echelon.nl (Anneke Treep) writes:

> sub letter {
>     print "
> I have $sons son$s
> ..etc.
> ";
> 
> But if I do so the variables $sons and $s need to be global, which is
> something I don't really want either :-(

Create a hash, send the hash or a ref to it.

  $template{name} = 'bob';
  $template{age} = '13 1/2';
  letter(\%template);
  sub letter {
     my $t = shift;
     print "$t->{name} is $t->{age} years old.\n";
  }


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


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

Date: Tue, 27 Apr 1999 14:25:02 +0200
From: "S.L. de Vries" <devries-devries@wxs.nl>
Subject: Re: question about guestbook
Message-Id: <3725AC9E.896558B4@wxs.nl>

This is the form in 'add.html':

      <FORM METHOD="POST"
ACTION="http://home.fiberia.com/sjoonvc/guest.cgi">
     <TR><TD><B>Naam:</B></TD><TD><INPUT TYPE=TEXT NAME=name
SIZE=60></TD></TR>
     <TR><TD><B>E-Mail:</B></TD><TD><INPUT TYPE=TEXT NAME=email
SIZE=60></TD></TR>
     <TR><TD><B>URL:</B></TD><TD><INPUT TYPE=TEXT NAME=url VALUE=http://
SIZE=60></TD></TR>
     <TR><TD><B>Woonplaats:</B></TD><TD><INPUT TYPE=TEXT NAME=city SIZE=15>
<B>Provincie:</B><INPUT TYPE=TEXT NAME=state SIZE=8>
         &nbsp;&nbsp;&nbsp;&nbsp;<B>Land:</B><INPUT TYPE=TEXT NAME=country
VALUE=Netherlands SIZE=10></TR>
     <TR><TD VALIGN=top><B>Tekst:</B></TD><TD><TEXTAREA NAME=comments
COLS=51 ROWS=8></TEXTAREA></TD></TR>
     <TR><TD>&nbsp;&nbsp;</TD><TD></TD></TR>
     <TR><TD></TD><TD><INPUT TYPE=image SRC="graphics/add.gif"
BORDER=no></TD></TR>
    </table>
    </FORM>

Here are a few lines of the script:

#Checks to see that the comments, name and e-mail address were added!
&no_name unless $FORM{'name'};
&no_comments unless $FORM{'comments'};
&no_email unless $FORM{'email'};

sub no_name {
   print "Content-type: text/html\n\n";
   print "<HTML>\n";
   print "<TITLE>No Name</TITLE>\n";
   print "<BODY BGCOLOR=#FFFFFF>\n";
   print "<CENTER><IMG SRC=\"$base$gif2\"></CENTER><BR>\n";
   print "You forgot to fill in your Name. We need this in order to\n";
   print "process your entry. Please add your name in the blank
below.<p>\n";
   print "<TABLE  CELLSPACING=3 CELLPADDING=2>\n";
   print "<FORM METHOD=POST ACTION=\"$cgi\">\n";
   print "<TR><TD><B>Name:</B></TD><TD><INPUT TYPE=TEXT NAME=\"name\" ";
   print "SIZE=50></TD></TR>\n";
<cut>

When you fill in the whole guestbook, you get an error that you didn't fill
in your name.



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

Date: Tue, 27 Apr 1999 08:23:41 -0400
From: Chad Holliday <chad13@bellsouth.net>
Subject: rmtree issues
Message-Id: <3725AC4D.73CD2FB4@bellsouth.net>

Hello,
I have a question about the rmtree function in File::Path.  I am running
Perl on multiple platforms,
(several Unix, NT, OS/2) mostly at 5.004 or higher.

While running on Unix, if I have a symbolic link in a directory that
points to a file that has already
been deleted/unlinked, for some reason Perl cannot unlink this link,
complaining
that no write access is available.  If the link is deleted before the
file, everything works ok.  Example:
 ...
rmtree( "file.txt", 1, 1 );
rmtree( "link_to_file.txt", 1, 1 );     # This will NOT be deleted
 ...
rmtree( "link_to_file.txt", 1, 1 );
rmtree( "file.txt", 1, 1 );           # Works ok

Is this normal behavior?  Do I need to dictate somehow to rmtree an
"order" of deletion, or is there a
better way?  Ideally, I would like to simply pass rmtree a directory
that may contain subdirectories,
files, and symbolic links, and not have to worry about it.

Also, the reason I am using the optional "1" third parameter to rmtree,
is that rmtree will go into an infinite
loop if it does not have the necessary permissions to delete a file.

Thank you,

Chad Holliday



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

Date: Tue, 27 Apr 1999 05:42:43 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: searching perl documentation
Message-Id: <jq04g7.7l4.ln@magna.metronet.com>

Eric Smith (eric@fruitcom.com) wrote:
: To avoid getting picked on for not finding something in the FAQ or docs
: before posTing, I figured there must be a simple way to do keyword
: searching through the perl documentation on my system.  The best I could
: come up with was the rather awkward:
: what () { man /usr/man/man1/perl*|grep -i $1 } #Mapped to a bash function

: This is inflexible, silly and does not give the name of the file where
: matched because `-H' reports stdinput of course.

: What's better? 


   Uhh, how about Perl is better?    :-)


      perl -ne 'print "$ARGV: $_" if /searchterm/i' /path/to/pod/*.pod


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


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

Date: Tue, 27 Apr 1999 13:41:15 GMT
From: snowhare@long-lake.nihongo.org (Benjamin Franz)
Subject: Re: stupid single quote " wipes out REST OF TEXT
Message-Id: <%7jV2.4992$oU1.448094@typhoon-sf.snfc21.pbi.net>

[posted and mailed] 

In article <371ab702.2789788@news.planet.eon.net>,
 <NOSPAMcrstlblu@planet.eon.net> wrote:
>
>I've got this mysterious problem with a crummy " quotation mark,
>in my flatfile dbm database, I have several lines of text which have a crummy
>quotation mark in them (5'10") to be exact,... the 5'10" appears right smack in
>the middle of the text,....
>
>when I OPEN the dbm, extract, and display the text in THE FIRST SCRIPT, no prob,
>it gets displayed in its' entirety,....
>when i pass the value into a hidden formfield and forward to the next
                              ^^^^^^^^^^^^^^^^
>script,???? I LOSE EVERYTHING AFTER THE CRUDDY QUOTATION MARK...

That is your problem. This is a mistake with how you are using HTML. 
You must *escape* characters that will confuse an HTML parser before 
using them in a FORM field (or anywhere else in HTML documents for that
matter).

 $_ =  $height;
 s/\&/\&amp;/gois;
 s/"/\&quot;/gois;
 s/'/\&apos;/gois;
 s/</\&lt;/gois;
 s/>/\&gt;/gois;
 print "<INPUT TYPE=\"HIDDEN\" NAME=\"HEIGHT\" VALUE=\"$_\">\n";

 -- 
 Benjamin Franz


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

Date: Tue, 27 Apr 1999 05:53:30 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: stupid single quote " wipes out REST OF TEXT
Message-Id: <qe14g7.7l4.ln@magna.metronet.com>

NOSPAMcrstlblu@planet.eon.net wrote:

: I've got this mysterious problem with a crummy " quotation mark,


   Note that you do not have a Perl problem since the double
   quote is not giving Perl any problems.

   The double quote is giving you HTML problems.

   Have you looked very carefully at the HTML containing 
   your hidden field?


: quotation mark in them (5'10") to be exact,... the 5'10" appears right smack in

: when i pass the value into a hidden formfield and forward to the next
: script,???? I LOSE EVERYTHING AFTER THE CRUDDY QUOTATION MARK...


: strange, I've tried various things with the (=~tr/"//;), (=~tr/\"//;) and so on
: to no avail,... any suggestions?


   Find out how to deal with embedding double quotes in HTML.

   And then program Perl (or C, or Visual Basic, or...) to do that.


: sorry to bother you


   Sometimes it is hard to tell what kind of problem you have,
   and therefore hard to tell which newsgroup to post to,
   you guessed wrong  :-)

   HTML is discussed in the HTML newsgroup:

      comp.infosystems.www.authoring.html


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


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

Date: Tue, 27 Apr 1999 15:31:49 GMT
From: NOSPAMcrstlblu@planet.eon.net
Subject: Re: stupid single quote " wipes out REST OF TEXT
Message-Id: <371ae549.6843781@news.planet.eon.net>

On Tue, 27 Apr 1999 05:53:30 -0400, tadmc@metronet.com (Tad McClellan) wrote:
>   The double quote is giving you HTML problems.

	it's a single quote, and it "POSSIBLY" might be entered into
	a textbox, on a form, by someone.... eg:

		I am 5'10" tall and etc

	there is only ONE quote in the text above,
	this would be entered into a textfield, on a form, and then
	saved to a DBM file - EVERYTHING works to that point!

	if i call a script which extracts this text from the DBM
	and prints it to the screen it prints PERFECTLY! however,
	if i feed that value into ANOTHER HIDDEN form field,
	and try to pass it to another script the NEXT SCRIPT
	drops everything AFTER THE SINGLE QUOTE when
	it prints it to the browser???
>
>   Have you looked very carefully at the HTML containing 
>   your hidden field?

	yes it's a perfectly ordinary, functional, "CGI SCRIPT" which
	prints an ELEMENTARY html form to the browser perfectly
>
>   Sometimes it is hard to tell what kind of problem you have,
>   and therefore hard to tell which newsgroup to post to,
>   you guessed wrong  :-)
>   HTML is discussed in the HTML newsgroup:
>      comp.infosystems.www.authoring.html
>    Tad McClellan

	" ? "


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

Date: Tue, 27 Apr 1999 08:19:59 -0400
From: "Bill Jones" <bill@fccj.org>
Subject: Re: system calls from Apache using perl
Message-Id: <3725ab56.0@usenet.fccj.cc.fl.us>

In article <37246E0A.D7812834@netcologne.de>, Mike <ga-mic@netcologne.de> 
wrote:


> Can anyone help me with this one:
>
> I am starting a cgi script with SSI from Apache 1.2.4
> on RedHat Linux 5.0. This cgi script has got to run another
> script - a bash script on the system ( /etc/ppp/ppp-on ).
> The ppp-on script must go into the background.
>
> the perl command I am using for this is:
>
>  system "/etc/ppp/ppp-on &";
>
> When I run the perl script from the command line it works
> well but when I try to start it with a web browser from the
> Apache something goes wrong:
> The ppp-on script is started but after that the perl script
> does not continue  - so the web browser hangs.
>
> Can you suggest any solution?

Wrong newsgroup, however -

Have you looked to see if the WWW userid can read/execute
the ppp-on script?  Also, you do realize that the environment
passed to a script from a CGI isn't bash script friendly, right?

Also, I am not sure, but I strongly suggest you look into
using a 'fork' -  that system call won't spawn a new thread,
as you intended with the use of '&' in shell context.

HTH,
-Sneex-  :]
_________________________________________________________________________
Bill Jones  | Data Security Specialist | http://www.fccj.org/cgi/mail?dss
FCCJ  |  501 W State St  |  Jacksonville, FL 32202  |  1 (904) 632-3089

Mentoring:  http://tesla.fccj.cc.fl.us/cgi-bin/mentors.pl?cmd=show&uid=24

         Jacksonville Perl Mongers
         http://jacksonville.pm.org/Letter.cgi
         jax@jacksonville.pm.org


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

Date: Tue, 27 Apr 1999 16:38:58 +0300
From: cederstrom@kolumbus.REMOVE_THIS.fi (Juho Cederstrom)
Subject: Re: what's wrong with $x = $y or ""
Message-Id: <slrn7ibffi.1em.cederstrom@vortex.cede.net>

On Tue, 27 Apr 1999 08:15:19 GMT, 
renenyffenegger@my-dejanews.com <renenyffenegger@my-dejanews.com> wrote:
> $x = $y or "";

Nonono. That is same as:

($x = $y) or "";


I think you should use

$x = ( $y or "" );
or
$x = $y || "";

-- 
# This is a Perl-script which will display juhoc's email address
$_  = "ohuj s'ciameda lserdsi sdec tsreAmorlokTubmuTODsfi";
s/(.)(.)(.)(.)/$4$3$2$1/g;s/AT/\@/;s/DOT/\./;print $_."\n";




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

Date: Tue, 27 Apr 1999 08:37:14 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: what's wrong with $x = $y or ""
Message-Id: <MPG.118f7984374f20ad98994c@nntp.hpl.hp.com>

In article <LReV2.9274$mR1.431797@news1.rdc1.on.wave.home.com> on Tue, 
27 Apr 1999 08:48:43 GMT, Andrew Johnson <andrew-johnson@home.com> 
says...
 ...
> if you do want to test defined (other than $y evaluating as true as
> the two above examples do), then you actually have to use a defined
> test. You can do this using the ?: ternary conditional:
> 
> $x = defined($y) ? $y : '';
> 
> which assigns $y to $x if $y is defined, or else it assigns '' to $x.

Or (for the nth time this week :-),

  $x = defined $y && $y;

Maybe if we call it the Rosler Idiom ...

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


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

Date: Tue, 27 Apr 1999 10:10:55 -0400
From: "Dave Kaufman" <davidk@nospam.cnct.com>
Subject: Re: where do I look for a free lance script writers?
Message-Id: <7g4glg$ffb@world2.bellatlantic.net>

www.cgi-resources.com




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

Date: Tue, 27 Apr 1999 12:09:57 +0100
From: Richard H <rhardicr@hotmail.com>
Subject: Re: Where do the spaces come from
Message-Id: <37259B05.ED2E232A@hotmail.com>

John T. Drefke wrote:
> 
> I know how to get my program to work but I also like
> to understand what is really going on behind door number 1.
> 
> I have a file called a.dat which contains:
> aa
> aa
> aa
> 
> Perl code:
> open(f,"<a.dat");
> @x=<f>;
> print "@x";
> 
> Prints:
> aa
>  aa
>  aa
> 
> @x=`cat a.dat`;   #yes I'm using unix
> print "@x";
> 
> also prints
> aa
>  aa
>  aa
> 
> Where did the space in front of aa in lines 2 3 come from??
> 
They come from your use of double quotes,
print @x; gives
aa
aa
aa

Richard H


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

Date: Tue, 27 Apr 1999 05:46:39 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Where do the spaces come from
Message-Id: <v114g7.7l4.ln@magna.metronet.com>

[ quotes moved around into non-Jeopardy order ]


sstarre@my-dejanews.com wrote:
: In article <P1gV2.3449$B55.276363@dfiatx1-snr1>,
:   "John T. Drefke" <jtdrefke@gte.net> wrote:
: > I know how to get my program to work but I also like
: > to understand what is really going on behind door number 1.
: >
: > Perl code:
: > open(f,"<a.dat");
: > @x=<f>;
: > print "@x";


: Perhaps it is something with your implementation, as I tried your example on
: our unix system and I don't see any spaces:


   But you didn't try his example.

   His example interpolates an array into a string.

   Your example doesn't.


:  open F,'<./x';
:  my @l=<F>;
:  foreach (@l) {print;}



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


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

Date: Tue, 27 Apr 1999 12:42:17 GMT
From: Bob Daly <bdaly@averstar.com>
Subject: Win32, Word
Message-Id: <3725B0A9.EBAE93E4@averstar.com>

I'm looking for example code for manipulating MS Word from
a Perl script.....I want to insert captured form data (text file)
into a Word document to generate it on the fly.  

Does anyone know if this is possible?

Thanks,

Bob Daly


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

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

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