[9952] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3545 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 26 01:03:00 1998

Date: Tue, 25 Aug 98 22: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           Tue, 25 Aug 1998     Volume: 8 Number: 3545

Today's topics:
    Re: [Upgrade Prob] 5.005 causes "to late for -T" errors (Mark-Jason Dominus)
        A perl filter script <pbarone@cape.net>
    Re: A perl filter script <nguyend7@msu.edu>
    Re: A perl filter script (Nathan V. Patwardhan)
    Re: Are $a and $b some special variables? (Sam Holden)
        Argh! NT Perl <webadmin@bigo.net>
        Data::Dumper question (Niels Larsen)
        example (chrono)
        Forcing a browser to re-authenticate with simple HTTP a <ronan.cremin@socor.com>
    Re: Forcing a browser to re-authenticate with simple HT (Martien Verbruggen)
        how can I print 10 digit nos. using 0s as place holders <mhammer@execpc.com>
    Re: how can I print 10 digit nos. using 0s as place hol (Bob Trieger)
    Re: how can I print 10 digit nos. using 0s as place hol (Larry Rosler)
    Re: how can I print 10 digit nos. using 0s as place hol <ljz@asfast.com>
        Looking for Advice <george@tapestry.net>
    Re: Perl compiler <ajohnson@gpu.srv.ualberta.ca>
    Re: Perl compiler (William D. Reardon)
    Re: Perl compiler (Sam Holden)
    Re: Perl compiler (Craig Berry)
    Re: Perl Indenter or Beautifier - Does NOT exist? (Alan Strassberg)
        PERL programming class feedback (Stwugalter)
    Re: Question about calling Perl from Perl (Mark-Jason Dominus)
        qw// vs. (), re. interpolation - error in "Prog Perl"? <b.d.low@unsw.edu.au>
    Re: Scheduling Perl with Win NT AT Svc (Ethan H. Poole)
    Re: Search and replace <hekke@mail1.stofanet.dk>
    Re: Search and replace (Larry Rosler)
    Re: Search and replace (Patrick Timmins)
    Re: String terminators <dan@fearsome.net>
    Re: String terminators (Mike Stok)
        use vars qw($a) vs. my ($a) <b.d.low@unsw.edu.au>
    Re: use vars qw($a) vs. my ($a) (Martien Verbruggen)
        Where can I find socket.ph? <andylee@prodigy.net>
    Re: Where can I find socket.ph? (Nathan V. Patwardhan)
    Re: Why dont people read the FAQs <nguyend7@msu.edu>
    Re: Y2K Date Support (Craig Berry)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 25 Aug 1998 21:14:51 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: [Upgrade Prob] 5.005 causes "to late for -T" errors in scripts
Message-Id: <6rvnib$jb8$1@monet.op.net>

In article <35DD7A9F.7E91@usa.net>,
Matthew Wickline  <Matthew.Wickline@usa.net> wrote:
>If I remove -T from all my cgi scripts' #! lines, will pre-checking with
>-cT be enough to ensure that they're taint-safe?

No, not at all.  Taint checking is done at run time, not at compile time.  
-cT is (almost) exactly the same as using plain -c.




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

Date: Tue, 25 Aug 1998 21:45:04 -0300
From: Phil Barone <pbarone@cape.net>
Subject: A perl filter script
Message-Id: <35E35A90.216E1F58@cape.net>

What I would like to do is write a simple perl filter for my mail
messages.

1.) grab the incoming mail message(use .forward file?)
2.) grab some info from it(I know how to do this once i get it into the
script)
3.) send the modified message it on its way for my mail reader for
reading

What I don't know is how/where to implement such a thing. An example
would be nice.
I have loaded Graham Barr's MailTools kit, but don't know how to use it!

Thanks for any help.
pbarone@harris.com





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

Date: 26 Aug 1998 03:53:51 GMT
From: Dan Nguyen <nguyend7@msu.edu>
Subject: Re: A perl filter script
Message-Id: <6s00sf$556$1@msunews.cl.msu.edu>

In comp.lang.perl.misc Phil Barone <pbarone@cape.net> wrote:
Don't reinvent the wheel.  Try the unix util procmail



-- 
           Dan Nguyen            | There is only one happiness in
        nguyend7@msu.edu         |   life, to love and be loved.
http://www.cse.msu.edu/~nguyend7 |                   -George Sand



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

Date: Wed, 26 Aug 1998 04:03:36 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: A perl filter script
Message-Id: <sOLE1.146$Ed2.1670957@shore>

Phil Barone (pbarone@cape.net) wrote:

: 1.) grab the incoming mail message(use .forward file?)

All the .forward file will do is send input to a script with a
specified username, like: |/path/to/scriptname your_username

: 2.) grab some info from it(I know how to do this once i get it into the
: script)

Read STDIN; I'd suggest using an array.  One of the Mail modules will
let you do this (you might check out Mail::Filter for the filter rules
and Mail::Folder for the folder-writing stuff).  Or you can check out
Mail::Internet for the head() and body() methods from which you can
roll your own.  (Just bouncing around some suggestions.)

: 3.) send the modified message it on its way for my mail reader for
: reading

open a mail folder (file), and write to it; flock()ing wouldn't be a
bad idea.  :-)  Then you can read this folder with your mail client.

I'd suggest testing this on a home machine or on a machine where you
don't receive mail from the outside world.  If something breaks in
your code or your .forward file, you don't want to lose any mail.

Oh yes, and don't forget to check -c (syntax) and -w (warnings) before
you put the filter into effect.

--
Nate Patwardhan|root@localhost
"Fortunately, I prefer to believe that we're all really just trapped in a
P.K. Dick book laced with Lovecraft, and this awful Terror Out of Cambridge
shall by the light of day evaporate, leaving nothing but good intentions in
its stead." Tom Christiansen in <6k02ha$hq6$3@csnews.cs.colorado.edu>


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

Date: 26 Aug 1998 03:29:11 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Are $a and $b some special variables?
Message-Id: <slrn6u7087.6iv.sholden@pgrad.cs.usyd.edu.au>

On 25 Aug 1998 18:00:24 GMT, Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
>[A complimentary Cc of this posting was sent to Russ Allbery 
><rra@stanford.edu>],
>who wrote in article <m3af4t8lpi.fsf@windlord.Stanford.EDU>:
>> > ...  which is a long-standing bug in the warn()er.  I wonder why nobody
>> > would fix it...
>> 
>> Because figuring out whether a routine could have been called from a sort
>> routine is impossible in the general case and adding more specific special
>> cases just makes the whole situation even more confusing.
>
>But why people think you need to figure this out?  A presence of sort
>is what is important.

I could always call the sub as a sort routine from a completely seperate file.
Then again I could always be evaling user input which could use one of my
subs as a sort...

Sam




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

Date: Tue, 25 Aug 1998 23:34:15 -0500
From: Jeff Riffle <webadmin@bigo.net>
Subject: Argh! NT Perl
Message-Id: <35E39047.E7E84AE2@bigo.net>

I've installed Win32 Perl and PerlScript and Perl for IIS and don't know
where to go from here, the batch files ran without error and the
associations are there, the read/execute has been set on the cgi-bin dir
and the files run from the command line but not from the web, .pl files
when typed in the browser actually open the prompt box "save file or
open"

Would appreciate any help.

Please cc reply to webadmin@bigo.net



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

Date: 26 Aug 1998 01:37:51 GMT
From: niels@vivo.mph.msu.edu (Niels Larsen)
Subject: Data::Dumper question
Message-Id: <6rvotf$eje$1@msunews.cl.msu.edu>


Greetings. The following code,

----
use Data::Dumper;

$hashRef = { "hello" => "world" };

$struct->{$hashRef} = 1;

print Data::Dumper->Dump ([$struct]), "\n";
----

produces 

----
$VAR1 = {
          'HASH(0x80b78d0)' => 1
        };
----

Maybe a total dummy question, but should the output not show
the hash reference expanded? 

Niels Larsen, niels@vitro.cme.msu.edu 

(hooray for Perl and its modules)


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

Date: Wed, 26 Aug 1998 02:49:23 GMT
From: mkv@internetwis.com (chrono)
Subject: example
Message-Id: <360abb2d.8023736@news.internetwis.com>

Could someone please make me an example of how to call a perl script from a html
form and report something back to the form? If you'd be so kind, please email me
at mkv@internetwis.com.

				Drew Vogel


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

Date: Wed, 26 Aug 1998 00:35:56 GMT
From: "Ronan Cremin" <ronan.cremin@socor.com>
Subject: Forcing a browser to re-authenticate with simple HTTP authentication
Message-Id: <Ey9tnx.5Cs@isocor.com>

I need to write a CGI (Perl) script that will force a browser to
re-authenticate with the web server before getting  another file. This is to
allow people to "log-out" after browsing a site that uses standard HTTP
authentication, to prevent others from seeing confidential files after a
session using a public browser.

Any ideas would be appreciated.

rc




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

Date: Wed, 26 Aug 1998 02:48:22 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Forcing a browser to re-authenticate with simple HTTP authentication
Message-Id: <WHKE1.1$Pm.499@nsw.nnrp.telstra.net>

In article <Ey9tnx.5Cs@isocor.com>,
	"Ronan Cremin" <ronan.cremin@socor.com> writes:
> I need to write a CGI (Perl) script that will force a browser to
> re-authenticate with the web server before getting  another file. This is to
> allow people to "log-out" after browsing a site that uses standard HTTP
> authentication, to prevent others from seeing confidential files after a
> session using a public browser.

This is not a perl question. For future reference, you should ask
questions about CGI, HTML and HTTP in one of the
comp.infosystems.www.* groups. You should also probably read the CGI
and HTTP specifications.

That said: You just write a CGI script that sends back a 401
(unauthorized) response message. See RFC 1945 for the exact format.

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: Tue, 25 Aug 1998 22:07:16 -0500
From: Mike Hammernik <mhammer@execpc.com>
Subject: how can I print 10 digit nos. using 0s as place holders
Message-Id: <6rvtsg$9kb@newsops.execpc.com>

I'm trying to create file that contain a 10 digit string. The first 6
digits are given by the user. I then need to count but I need to keep
the number in the 10 digit format. For example
If given 111222 I now need to construct a file that contains

1112220001
1112220002
 .
 .
1112229999

The best code I can use right now is

#! /usr/bin/perl -w

print "Enter digits: ";
$digits =<>;
chomp $digits;
open (FILE, ">digifile") or die "Can't open digifile";
for ( $i=1; $i<= 1000; $i++) {
$n="000"."$i";printf (FILE "%s%s\n", $digits, $n);
)

Of course every time I go from 10 to 100 or 100 to a thousand I get an
extra digit.  Do I have to set it up in three steps or is there a easier
method that I haven't bkundered across.

Thanks in advance for your assistance.

Hammer


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

Date: Wed, 26 Aug 1998 03:15:55 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: how can I print 10 digit nos. using 0s as place holders
Message-Id: <6rvure$ii8$1@strato.ultra.net>

[ posted and mailed ]

Mike Hammernik <mhammer@execpc.com> wrote:
-> I'm trying to create file that contain a 10 digit string. The first 6
-> digits are given by the user. I then need to count but I need to keep
-> the number in the 10 digit format. For example
-> If given 111222 I now need to construct a file that contains
-> 
-> 1112220001
-> 1112220002
-> ..
-> ..
-> 1112229999
-> 
-> The best code I can use right now is
-> 
-> #! /usr/bin/perl -w
-> 
-> print "Enter digits: ";
-> $digits =<>;
-> chomp $digits;
-> open (FILE, ">digifile") or die "Can't open digifile";
-> for ( $i=1; $i<= 1000; $i++) {
-> $n="000"."$i";printf (FILE "%s%s\n", $digits, $n);
-> )

check out the docs on printf and sprintf.

If your 10 digit number is `always' going to be comprised of 6 and 4 digit 
variables, try this:


untested:

#! /usr/bin/perl -w

print "Enter digits: ";
chomp($digits = <STDIN>);
open (FILE, ">digifile") or die "Can't open digifile: $!"; 
for $i (1..1000)  {
        printf (FILE "%06d%04d\n", $digits, $i);
}


HTH

Bob Trieger
sowmaster@juicepigs.com
" Cost a spammer some cash: Call 1-800-400-1972 
  Ext: 1949 and let the jerk that answers know 
  that his toll free number was sent as spam. "


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

Date: Tue, 25 Aug 1998 20:34:30 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: how can I print 10 digit nos. using 0s as place holders
Message-Id: <MPG.104d2224a8a4704e9897ed@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <6rvtsg$9kb@newsops.execpc.com> on Tue, 25 Aug 1998 22:07:16 -
0500, Mike Hammernik <mhammer@execpc.com> says...
> I'm trying to create file that contain a 10 digit string. The first 6
> digits are given by the user. I then need to count but I need to keep
> the number in the 10 digit format. For example
> If given 111222 I now need to construct a file that contains
> 
> 1112220001
> 1112220002
> .
> .
> 1112229999
 ...
> for ( $i=1; $i<= 1000; $i++) {
> $n="000"."$i";printf (FILE "%s%s\n", $digits, $n);
> )
> 
> Of course every time I go from 10 to 100 or 100 to a thousand I get an
> extra digit.  Do I have to set it up in three steps or is there a easier
> method that I haven't bkundered across.

Far easier!  The answer lies in the (s)printf function, which you have 
used without awareness of its power.  You should do `perldoc -f sprintf`.

The statement you are looking for is this:

printf (FILE "%d%.4d\n", $digits, $i);

where the parentheses you have used are optional.  Print your data as 
decimal integers (which the function will convert into strings), and 
zero-pad the second one to four digits.  (In this case, the format could 
also be written as "%d%04d\n".)

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


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

Date: 26 Aug 1998 00:40:25 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: how can I print 10 digit nos. using 0s as place holders
Message-Id: <ltpvdonyo6.fsf@asfast.com>

Mike Hammernik <mhammer@execpc.com> writes:

> I'm trying to create file that contain a 10 digit string. The first 6
> digits are given by the user. I then need to count but I need to keep
> the number in the 10 digit format. For example
> 
> [ ... ]
> 
> #! /usr/bin/perl -w
> 
> print "Enter digits: ";
> $digits =<>;
> chomp $digits;
> open (FILE, ">digifile") or die "Can't open digifile";
> for ( $i=1; $i<= 1000; $i++) {
> $n="000"."$i";printf (FILE "%s%s\n", $digits, $n);
> )
> 
> [ ... ]

Try this `for' loop instead of your last three lines:

  for ($i = 1; $i <= 1000; $i++) {
     printf FILE ("%s%04d\n", $digits, $i);
  }

The `%04d' within printf's format string takes care of prepending the
proper number of leading zeros onto the value of the counter.  Of
course, this only works for 0 <= $i <= 9999 (or -999 <= $i <= 9999 if
you don't mind the possible appearance of a dash within your generated
string).

> Thanks in advance for your assistance.

I hope this helps.


-- 
 Lloyd Zusman   ljz@asfast.com
 perl -e '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
 $t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
 $x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x\n"'


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

Date: 26 Aug 1998 04:24:17 GMT
From: "George H" <george@tapestry.net>
Subject: Looking for Advice
Message-Id: <01bdd0a8$10190440$3896cdcf@hp-customer>

I have a problem I am trying to solve that has me miffed.

Basically, I want to run 2 cgi's on 2 different servers from the same web
page form passing the same 'QUERY_STRING' to each program.  Currently the
form executes a local cgi ... but I would like to pass the same information
to another cgi on another machine as well.

Would it be best to open a socket connection to the server and manipulate
the database that way? or ... there is a similar cgi on the distant server
 ... can I pass it the query string with a HTTP request.  Anyone run into
something like this in the past?

Regards,

George


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

Date: Tue, 25 Aug 1998 20:06:10 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Perl compiler
Message-Id: <35E35F82.4A38118E@gpu.srv.ualberta.ca>

Tushar Samant wrote:
!
! cberry@cinenet.net writes:
! > You're holding a loaded gun to your head and claiming that the
! > safety is on as you begin to squeeze the trigger.  He's noticing
! > that the safety is *not* on, and shouting "Put that f*cking
! > thing down, *now*!"  In such circumstances, politeness must
! > yield to urgency. :)
! > 
! 
! Wrong thing to say to someone you don't know. It's an important
! point for the whole thread, I think: you DO NOT know. It's tacky
! to go stridently evangelizing into an unknown culture --
! ESPECIALLY when you are convinced that yours is the one true way.
! "Not getting" the hoarding-and-obfuscation mentality means that
! that culture is unknown. The same point applies to any remarks
! about the value of the program. Assigning your own programs very
! little value might be a sign of winning modesty. But doing the
! same to someone else's -- even extremely trivial -- programs is
! just damn rude, when you know neither the context nor the value
! system in operation. Finally, the consistent and automatic
! invocation of Good and Evil on the smallest moment is offensive,
! and so is any far-fetched analogy to "science" or "anti-science"
! or whatever. Let's get real. If you don't know if it's possible
! to obfuscate a program, or don't care to tell how, shut up.

uh, what the hell was that about?
Seems to me that Craig was explaining why embedded passwords
are not a very good idea be they plaintext or compiled/obfuscated.
I did not see Craig exhibit any of the behaviour you seem to be
attributing to him ... perhaps you were just venting in general
and excersising your right to stand up and speak out for the
'hoarding-and-obfuscation' culture --- fine, but please try to be
careful to make that clear when thrusting your views into the
middle of a thread.

regards
andrew


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

Date: Wed, 26 Aug 1998 01:37:27 GMT
From: wdr1@pobox.com (William D. Reardon)
Subject: Re: Perl compiler
Message-Id: <Ey9wIG.258@midway.uchicago.edu>

In article <Ey9LJ1.AH2@world.std.com>,
Andrew M. Langmead <aml@world.std.com> wrote:
>wdr1@pobox.com (William D. Reardon) writes:
>
>>	Just an innocent question, but assuming she's on unix, wouldn't
>>compiling help in that she could then set it to be executable, but
>>unreadable?
>
>Unfortunately, no. On Unix, scripts must be readable by the UID of the
>process executing them. How could they be run by the interpreter if
>they can't be read?

	Isn't the whole point of compiling that the interpreter is no
longer needed?

-Bill
-- 
William Reardon							 wdr1@pobox.com
Hold fast to dreams, for if dreams die, life is a broken bird that cannot fly.
                  -Langston Hughes


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

Date: 26 Aug 1998 03:12:35 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Perl compiler
Message-Id: <slrn6u6v92.6iv.sholden@pgrad.cs.usyd.edu.au>

On Tue, 25 Aug 1998 21:57:09 GMT, Honza Pazdziora <adelton@fi.muni.cz> wrote:
>On Tue, 25 Aug 1998 18:59:46 GMT, William D. Reardon <wdr1@pobox.com> wrote:
>
>> 	Just an innocent question, but assuming she's on unix, wouldn't
>> compiling help in that she could then set it to be executable, but
>> unreadable?
>
>I'd say you are right, but if we come to this point, isn't it better
>to just compile the C wrapper once (just change id and run perl
>script) and have the freedom of changing the Perl script whenever
>you like, without additional recompilation?

On solaris this method doesn't work very well at hiding passwords...

Lets see here's the example (That I'm trying now...)

;cat test.c
main()
{
	char *pass = "The magical password";
	sleep(1000); /* give us time to send a signal */
}
;gcc test.c
;ls -l ./a.out
---x--x--x   1 user1 users       23348 Aug 26 12:57 ./a.out
;id
uid=1234(user1) gid=123(users)
;su user2
Password:
;strings a.out
a.out: Permission denied
;./a.out &
7654
;kill -6 7654
7654 abort - core dumped
;ls -l core
-rw-------   1 user2  users      100468 Aug 26 12:59 core
;strings core | grep password
The magical password

Oh dear user2 managed to read the password from the execute only executable...

Sam



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

Date: 26 Aug 1998 04:31:41 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Perl compiler
Message-Id: <6s033d$dj$1@marina.cinenet.net>

I R A Aggie (fl_aggie@thepentagon.com) wrote:
: In article <6rv36h$bdj$4@marina.cinenet.net>, cberry@cinenet.net (Craig
: Berry) wrote:
: 
: +   * Free software has many advantages
: +   * Proprietary software has many differing advantages
: +   * Neither is morally superior to the other.
: + 
: + The last assertion is the key, of course.
: 
: Maybe my perspective is weird, but morality _usually_ has little to do with
: software. Microsoft products, viruses, spam engines and the like being 
: notable exceptions.

Exactly my point.  Tom C (among others) tries to cast the fr?eeware issue
in moral terms.  And inflammatory moral terms, at that.  I object to this. 

: + Yes, and locks on doors can be picked or broken.  The idea is that if my
: + code/possessions are *harder* to steal, the odds go down that they will be
: + stolen.
: 
: Go read Feynman's treatise on locks sometime. Its a hoot. Mechanical
: locks are incredibly simple mechanisms, and they really haven't changed
: much in a couple of hundred years...

I've read it, and agree it's great.

: Such things discourage 'crimes of opportunity'. They will not discourage
: someone who is determined.

Thus reducing the mean expected number of thefts I will experience, which
is good enough for me.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "Ripple in still water, when there is no pebble tossed,
       nor wind to blow..."


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

Date: 25 Aug 1998 18:52:53 -0700
From: alan@bali.seg.wj.com (Alan Strassberg)
Subject: Re: Perl Indenter or Beautifier - Does NOT exist?
Message-Id: <6rvppl$bti$1@bali.seg.wj.com>

In article <35E32E83.AD8D7324@verio.com>, Kenneth Lum  <kin@verio.com> wrote:

>Surprised to know that there isn't a Perl Indenter or Beautifier?

	Whazzat ?

	http://www.consultix.wa.com/yumpy/

				alan
-- 
alan@wj.com


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

Date: 26 Aug 1998 03:35:25 GMT
From: stwugalter@aol.com (Stwugalter)
Subject: PERL programming class feedback
Message-Id: <1998082603352500.XAA15352@ladder03.news.aol.com>

Has anyone taken courses from American Research Group in Cary, NC. We are
thinking of sending 3 of our people to a PERL programming class, but we do not
know of their reputation. TIA

Stuart E. Wugalter
Academic Technology Support
swugalt@calstatela.edu


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

Date: 25 Aug 1998 21:01:00 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Question about calling Perl from Perl
Message-Id: <6rvmoc$ja8$1@monet.op.net>


In article <m31zq58klf.fsf@windlord.Stanford.EDU>,
Russ Allbery  <rra@stanford.edu> wrote:
>system means that the system has to start a shell, 

The shell's only used if necessary.  In particular, if the command
contains no shell metacharacters, no newlines, and does not begin with
". ", "exec ", or "VAR=", the shell isn't used, and Perl does the fork
and exec directly.  (I may have left some item off this list.)

>both more overhead and subject to more potential portability
>problems.

On the other hand, I think it can be hard to overstate the benefits of
a modular design and `small tools' approach.

Not that it isn't possible to make a big ugly program even worse my
cutting it up into random pieces and then sewing them back together
like Frankenstein's monster.



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

Date: Wed, 26 Aug 1998 12:08:00 +1000
From: Benjamin Low <b.d.low@unsw.edu.au>
Subject: qw// vs. (), re. interpolation - error in "Prog Perl"?
Message-Id: <35E36E00.E30BA8E@unsw.edu.au>

"Programming Perl", 2nd ed., tells me on p. 41 that () is the Customary
form of the Word List quoting operator, the Generic form being qw//.

The perl 5.004 docs tell me there is no Customary form.

Is the book in error? (This issue isn't mentioned in the errata).
Certainly something like

	@a = (a, b, c, d);

works the same as

	@a = qw(a b c d);

But when I try

	use vars ($a, $b, $c);

perl bails. (I know < use vars qw($a $b $c) > is the "normal" way of
doing it, but I think the qw looks a bit ugly :-).

Presumably the () is trying to interpolate the identifiers which happen
to look like variables, whereas the true qw op doesn't?
(I just tried @a = ($a, $b, $c) and it is empty)...

-- 
 Benjamin Low
 Web Programmer, Communications Unit, University of New South Wales
 (02) 9385 1138  b.d.low@unsw.edu.au  b.d.low@ieee.org


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

Date: 26 Aug 1998 04:36:43 GMT
From: ehp@gte.net (Ethan H. Poole)
Subject: Re: Scheduling Perl with Win NT AT Svc
Message-Id: <6s03cr$mb7$1@news-2.news.gte.net>

In article <35e32568.12389651@news.btinternet.com>, Gellyfish@btinternet.com 
says...
>
>On Mon, 24 Aug 1998 15:32:39 -0600, Alex Tatistcheff wrote :
>
>In principal there is no problem with running a Perl program using the
>schedule service but as with most things on NT there are some gotchas
>but these are to do with NTness rather than Perlness so I wont go into
>any detail but to say:
>
>A) Check the permissions of the account that the schedule service is
>running under.
>B) You may also have problems with detached process and certain
>networking functions

Let me add a (C) that caught me off guard once (admittedly, being an NT guru 
I should have known... but then we all have our moments <g>):

C) Make sure your script has the proper drive letter(s) hard coded into it.  
Relative directories will be relative to wherever the AT service happens to 
default to (often C:) which can result in your script attempting to reference 
nonexistent directories.

-- 
Ethan H. Poole            | Website Design and Hosting,
                          | CGI Programming (Perl & C)..
========Personal========= | ============================
* ehp @ gte . net *       | --Interact2Day--
http://home1.gte.net/ehp/ | http://www.interact2day.com/



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

Date: Wed, 26 Aug 1998 03:10:51 +0200
From: "Henrik =?iso-8859-1?Q?J=F8rgensen?=" <hekke@mail1.stofanet.dk>
To: ABeldowi@newyorklife.com
Subject: Re: Search and replace
Message-Id: <35E3609B.66F87E1@mail1.stofanet.dk>

Yo!

This one works for me:

=~ s#(http://.*)(\W)#<A HREF="$1">$1</A>$2#ig;

It simply replaces an URL by <A HREF="URL">URL</A>

Have fun

--Hekke


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

Date: Tue, 25 Aug 1998 20:53:14 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Search and replace
Message-Id: <MPG.104d268236144a589897ee@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <35E3609B.66F87E1@mail1.stofanet.dk> on Wed, 26 Aug 1998 
03:10:51 +0200, Henrik =?iso-8859-1?Q?J=F8rgensen?= 
<hekke@mail1.stofanet.dk> says...
> Yo!
> 
> This one works for me:
> 
> =~ s#(http://.*)(\W)#<A HREF="$1">$1</A>$2#ig;
> 
> It simply replaces an URL by <A HREF="URL">URL</A>

Good Lord, NO!  Try it with, for example, 'http://foo.bar'.  You get

<A HREF="http://foo">http://foo</A>.bar

exactly as you told it.  A URL does not end on the first non-word 
character.

Perhaps you meant something like this (without the hanging =~ syntax 
error):

     s#(http://.*?)(\s|$)#<A HREF="$1">$1</A>$2#ig;

or, simpler and better:

     s#(http://\S+)#<A HREF="$1">$1</A>#ig;

You owe it to all of the readers to try simple things out before posting 
them.

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


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

Date: Wed, 26 Aug 1998 04:33:23 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: Search and replace
Message-Id: <6s036j$36n$1@nnrp1.dejanews.com>

In article <6rut14$gub$1@nnrp1.dejanews.com>,
  ABeldowi@newyorklife.com wrote:
> hi,
>     i am trying to go through file, and everytime i come accross a url
>
> (defined as =~ /http:\/\/.*\..*\.com/ )
>
> I want to basically add html <a href..> tags to it.  so replace url with <a
> href..>url</a> would be helpful.  I spent some time on this, and had the
> following problems using various methods:
[snip]

1. use the global modifier on the substitution ('g' at the end)
2. use some other delimiter for the substitution (eg: s|||; instead of s///;)
3. don't use wild cards if you don't have to (eg \S+ instead of .*something)

eg:

while (<DATA>) {
    s|(http://\S+)|<a href="$1">$1</a>|g;
    print;
}

__DATA__
blah blah http://www.americas.com/ blah blah http://www.guar.com/ blah
blah http://www.equitable.com/life/not_fair.html blah blah
blah the finest being http://www.newyorklife.com/ by far.

Patrick Timmins
U. Nebraska Medical Center

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Wed, 26 Aug 1998 02:13:24 +0100
From: "Daniel Adams" <dan@fearsome.net>
Subject: Re: String terminators
Message-Id: <904094051.18154.0.nnrp-07.c2deb1c5@news.demon.co.uk>


root wrote in message <35E35546.39F04DD5@mediaone.net>...
>When running 2 copies of the same file, (at different times)  I get the
>following error from one of them,
>
>Can't find string terminator "EOF" anywhere before EOF at ./aub line
>1149
>
>line 1149 is this    >line 1149 is this    print <<"EOF";
>
> ....some text.....
>
> EOF
>
> exit(1);
>
>all of the above is enclosed in an if statement...any ideas why this
>would happen


That depends - I may be wrong, but I don't think you should have the ""
round the first EOF. Even if they're not damaging, they're certainly not
neccessary. Also try labelling it i.e.:

print FILE <<EOF;
etc
EOF

Of course, any advice from me is as likely to screw up your code as help you
out, but the latter is always my intention ;-)

--

Dan Adams
dan@fearsome.net





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

Date: 26 Aug 1998 01:23:02 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: String terminators
Message-Id: <6rvo1m$t37@news-central.tiac.net>

In article <35E35546.39F04DD5@mediaone.net>,
root  <mcneilr@mediaone.net> wrote:
>When running 2 copies of the same file, (at different times)  I get the
>following error from one of them,
>
>Can't find string terminator "EOF" anywhere before EOF at ./aub line
>1149
>
>line 1149 is this    print <<"EOF";
>		
>			....some text.....
>
>		EOF
>
>			exit(1);
>
>all of the above is enclosed in an if statement...any ideas why this
>would happen

Is there whitespace before or after the EOF token?  (White space after the
EOF might include rogue ^Ms and the like...)

print <<"EOF";
  one
  two
  EOF
  three
EOF

prints

  one
  two
  EOF
  three

Hope this helps,

Mike
-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: Wed, 26 Aug 1998 12:20:38 +1000
From: Benjamin Low <b.d.low@unsw.edu.au>
Subject: use vars qw($a) vs. my ($a)
Message-Id: <35E370F6.915BF882@unsw.edu.au>

Is there a difference between between the following two constructs?

use vars qw($a, $b, $c);

my ($a, $b, $c);

Both seem to work equally well in a single-module program (with use
strict). (Note I don't know much (i.e. anything) about modules and my
concept of scoping, et al, is in early development...)

Is there a difference or is this another TMT{whatever}? I haven't found
any discussion either way in perusing "Programming Perl" and the docs.

-- 
 Benjamin Low
 Web Programmer, Communications Unit, University of New South Wales
 (02) 9385 1138  b.d.low@unsw.edu.au  b.d.low@ieee.org


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

Date: Wed, 26 Aug 1998 02:56:51 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: use vars qw($a) vs. my ($a)
Message-Id: <TPKE1.2$Pm.499@nsw.nnrp.telstra.net>

In article <35E370F6.915BF882@unsw.edu.au>,
	Benjamin Low <b.d.low@unsw.edu.au> writes:
> Is there a difference between between the following two constructs?
> 
> use vars qw($a, $b, $c);

# perldoc vars

Perl pragma to predeclare global variable names

And:

While the vars pragma cannot duplicate the effect of package lexicals
(total transparency outside of the package), it can act as an
acceptable substitute by pre-declaring global symbols,

> my ($a, $b, $c);

# perldoc -f my

A "my" declares the listed variables to be local (lexically) to the
enclosing block, subroutine, C<eval>, or C<do/require/use>'d file

So, yes, there is a difference.

> Both seem to work equally well in a single-module program (with use
> strict). (Note I don't know much (i.e. anything) about modules and my
> concept of scoping, et al, is in early development...)

As hinted at in the third paragraph in the vars documentation:
Functionally both behave very much the same, if you use them at the
beginning of a program or so. The difference (functionally) is mainly
when you declare these things inside a block.

A good rule of thumb probably would be: Only use 'use vars' if you
have to. Otherwise use my.

When do you have to? When you are using a module that sets a global
variable, which you later want to use. Getopt::Std is one of those, if
you don't pass it a hash reference.

I haven't actually _had_ to use it anywhere yet. Most of the time a
file scoped lexical will do fine.

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: Tue, 25 Aug 1998 22:38:28 -0500
From: "Andy Lee" <andylee@prodigy.net>
Subject: Where can I find socket.ph?
Message-Id: <6rvv9n$4bj4$1@newssvr04-int.news.prodigy.com>

All,
        Where can I find socket.ph? Thanks...


AndyL




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

Date: Wed, 26 Aug 1998 03:49:26 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Where can I find socket.ph?
Message-Id: <aBLE1.144$Ed2.1670957@shore>

Andy Lee (andylee@prodigy.net) wrote:
:         Where can I find socket.ph? Thanks...

You must generate it.  See doc for h2ph.

--
Nate Patwardhan|root@localhost
"Fortunately, I prefer to believe that we're all really just trapped in a
P.K. Dick book laced with Lovecraft, and this awful Terror Out of Cambridge
shall by the light of day evaporate, leaving nothing but good intentions in
its stead." Tom Christiansen in <6k02ha$hq6$3@csnews.cs.colorado.edu>


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

Date: 26 Aug 1998 01:19:12 GMT
From: Dan Nguyen <nguyend7@msu.edu>
Subject: Re: Why dont people read the FAQs
Message-Id: <6rvnqg$agq$1@msunews.cl.msu.edu>

Arved Sandstrom <Arved_37@chebucto.ns.ca> wrote:
: Richard Proctor (Richard@waveney.demon.co.uk) wrote:

: : NB Abigails posts may be curt, but are generaly right and often amusing,
: : and there is an awfull lot of perl to be learnt from her sigs.  

: Curt is a generous description. Sarcastic and obnoxious might be more
: accurate. It struck me when I read one of her replies that she had better
: be perfect (I guess this is where the Hubris comes in), because she's sure
: cutting down on the list of people that might answer a request of hers.

At first I found Abigail's post to be curt.  But now I look forward to
what she has to say or not.  I don't know if Abigail is perfect, but I
can tell you she knows her stuff.  Both in perl and programming in
general.

: There are a few people on this group I regard as experts - they also
: display courtesy and restraint. All hallmarks of being professionals.

You probably regard Tom Christiansen as a true perl guru (I know I
do.)  His posts can be off the wall sometimes.

Actually all I really have to say is read the FAQs and manpages.
Remember about grep (the unix utility not the perl function).

-dan
-- 
           Dan Nguyen            | There is only one happiness in
        nguyend7@msu.edu         |   life, to love and be loved.
http://www.cse.msu.edu/~nguyend7 |                   -George Sand



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

Date: 26 Aug 1998 04:42:21 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Y2K Date Support
Message-Id: <6s03nd$dj$2@marina.cinenet.net>

I R A Aggie (fl_aggie@thepentagon.com) wrote:
: C.H.U.D.s? or is this in the jargon file?

Oh, for pete's sake, doesn't *anybody* read the FAQs anymore?  See
perlfaq17, "Why did a hideous deformed humanoid emerge from the sewers and
eat my brain while I was trying to sort a hash of lists?"

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "Ripple in still water, when there is no pebble tossed,
       nor wind to blow..."


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

Date: 12 Jul 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 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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