[13598] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1008 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 6 21:05:30 1999

Date: Wed, 6 Oct 1999 18:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <939258310-v9-i1008@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 6 Oct 1999     Volume: 9 Number: 1008

Today's topics:
    Re: (?p{}) was [Re: Backreference in Regex Code Block?] <ltl@rgsun5.viasystems.com>
    Re: (?p{}) was [Re: Backreference in Regex Code Block?] <kbandes@home.com>
    Re: (?p{}) was [Re: Backreference in Regex Code Block?] (Ilya Zakharevich)
    Re: [OFFTOPIC] Tad's Back! WAS:Regexp/Interpolation que <cassell@mail.cor.epa.gov>
    Re: array for network simulator <makkulka@cisco.com>
    Re: Checking for processes <hazard@eznetN-O~S'P&A`M.net>
    Re: checking for string in multiple line scalar (part I (Tad McClellan)
    Re: Damn Comma Delmitation <emschwar@rmi.net>
        Doh!  Adding to HASH when reading!?!?!?! <skyhigh@intergalactica.com>
    Re: extracting perldoc documentation <cLive@direct2u.co.uk>
    Re: File exists? <mike@dice.net>
    Re: File exists? <uri@sysarch.com>
    Re: GD Modul Version 1.19 for win32 ? <cassell@mail.cor.epa.gov>
        Help - Perl regular expression question! jennyng@my-deja.com
    Re: HELP! Passing vars to sub not working <sjohns17@uic.edu>
    Re: HELP! Passing vars to sub not working <maksim@mail.utexas.edu>
    Re: how to change a '\' to '/' ? (Larry Rosler)
    Re: how to change a '\' to '/' ? <cassell@mail.cor.epa.gov>
    Re: Killfiles <jb4mt@verbatims.com>
    Re: Killfiles <uri@sysarch.com>
    Re: Killfiles <cassell@mail.cor.epa.gov>
    Re: Perl & java <sjohns17@uic.edu>
    Re: Perplexed with newlines while sending mail <cassell@mail.cor.epa.gov>
        POSIX::setuid problem??? <maksim@mail.utexas.edu>
        POSIX::setuid problem??? <maksim@mail.utexas.edu>
    Re: POSIX::setuid problem??? (Alan Curry)
    Re: previous link <cassell@mail.cor.epa.gov>
    Re: Redirecting output to /dev/null (Scot Hacker)
    Re: regexp question modified: last non-empty occurrence (Gerry JJ Dyn-O-Myte Walker)
    Re: Regular Expressions with  =?iso-8859-1?Q?=D4=D5=D6= <cLive@direct2u.co.uk>
    Re: To Abigail re: reading current threads <jb4mt@verbatims.com>
    Re: To Abigail re: reading current threads <uri@sysarch.com>
    Re: To Abigail re: reading current threads <jb4mt@verbatims.com>
    Re: using strict, no soft references!! now what? <cLive@direct2u.co.uk>
    Re: using strict, no soft references!! now what? <uri@sysarch.com>
    Re: using strict, no soft references!! now what? <cassell@mail.cor.epa.gov>
    Re: We do complex Perl Programming <cassell@mail.cor.epa.gov>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 6 Oct 1999 22:50:32 GMT
From: lt lindley <ltl@rgsun5.viasystems.com>
Subject: Re: (?p{}) was [Re: Backreference in Regex Code Block?]
Message-Id: <7tgjno$cob$1@rguxd.viasystems.com>

Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:

:>Given a p-modifier (`P'ostponed), the "interpolated variables" are
:>considered to contain regular expressions.  They are "interpolated"
:>not when REx is compiled, but at *run time*.

:>Say,

:>	$foo = qr{ < $foo >		# Postponed $foo in brackets
:>		  |			# Or nothing
:>		 }px;

Is the "Or nothing" required to break out successfully with a valid
match?  I suppose without it the last recursive attempt would always
fail, so the match would always return false.  But would it ever
be useful to do that?  Why not make it smart enough to return
true when the innermost $foo attempt fails?

:>will match any sequence of nested < and >, as in "<<<<<>>>>>".

:>Current *workaround* against non-existing //p is {?p{EXPR}}.  It
:>evaluates EXPR at run time, then uses the result as the regular
:>expression to match at the given position.

:>	$foo = qr{ < (?p{$foo}) >	# Postponed $foo in brackets
:>		  |			# Or nothing
:>		 }px;

Maybe this is really a superior syntax.  At least this way, you can
give a quantifier to it and avoid the Or nothing.

$foo = qr{ < (?p{$foo})? > }x;

Of course when you say "current", you mean a current development
release of perl.

I can see how this could be useful, but what the heck happens to
backreferences?  Recursive backreferences?  Could you somehow pass
them back up or would you have to do something with (?{some code}) to
gather them up as they were matched?

$string = '<<<third term>second term>first term>';

$foo = qr{ < $foo (.+?) >
	  (?{ push @terms, $1 })
	|
	}px;

Hmm.  I think backtracking would bite me here, and since I don't have
a version of perl that supports this construct to play with, I hope I
can be forgiven for not testing it.  With something this complex, I
know I'm overlooking something.  Actually, all I did with my example
was confuse myself.  I hope you put lots of prints in the "re 'debug'"
pragma to help see this thing in action. :-)

Regardless of whether or not my example is actually reasonable, what
is the plan for backreferences in the "postponed" interpolation?


-- 
// Lee.Lindley   /// I used to think that being right was everything.
// @bigfoot.com  ///  Then I matured into the realization that getting
////////////////////   along was more important.  Except on usenet.


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

Date: Thu, 07 Oct 1999 00:26:56 GMT
From: Kenneth Bandes <kbandes@home.com>
Subject: Re: (?p{}) was [Re: Backreference in Regex Code Block?]
Message-Id: <37FBE904.3852B6E1@home.com>

Ilya Zakharevich wrote:
> [A complimentary Cc of this posting was sent to lt lindley
> <lee.lindley@bigfoot.com>],
> who wrote in article <7tg0n3$778$1@rguxd.viasystems.com>:
> > :>Just use (?p{}) instead.
> >
> > All of the other fish ignored the lure, but I'm a sucker for
> > shiny new regexp toys, so I'll bite.  What does (?p{}) do (or what
> > will it do when I eventually get a perl that has it)?

No, I also bit, having posted the original message to which Ilya was
responding.  (?p{}) worked fine in the development release (5.005_61),
at least on my little tests.

By the way, this will necessitate a change to the FAQ (#4),
in particular the question, "How do I find matching/nesting 
anything?"  The answer there is,

"This isn't something that can be done in one regular
expression, no matter how complicated."

Strictly speaking, this is still true, since (strictly speaking)
an expression with (?p{}) is no longer a regular expression.
However, I guess you could say that a single Perl pattern match
can find matching/nesting things.

Ken Bandes


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

Date: 7 Oct 1999 01:05:29 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: (?p{}) was [Re: Backreference in Regex Code Block?]
Message-Id: <7tgrkp$b6n$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to lt lindley 
<lee.lindley@bigfoot.com>],
who wrote in article <7tgjno$cob$1@rguxd.viasystems.com>:
> :>	$foo = qr{ < $foo >		# Postponed $foo in brackets
> :>		  |			# Or nothing
> :>		 }px;
> 
> Is the "Or nothing" required to break out successfully with a valid
> match?  I suppose without it the last recursive attempt would always
> fail, so the match would always return false.  But would it ever
> be useful to do that?  Why not make it smart enough to return
> true when the innermost $foo attempt fails?

Make *what* smart enough?

> Maybe this is really a superior syntax.  At least this way, you can
> give a quantifier to it and avoid the Or nothing.
> 
> $foo = qr{ < (?p{$foo})? > }x;

You can do the same with ($foo)?.

> Of course when you say "current", you mean a current development
> release of perl.

Of course.

> I can see how this could be useful, but what the heck happens to
> backreferences?  Recursive backreferences?  Could you somehow pass
> them back up or would you have to do something with (?{some code}) to
> gather them up as they were matched?

The "internal" match creates no backreferences.  It is absolutely
opaque from the point of view of the outer REx: "point" is moved,
nothing else happens.

> $string = '<<<third term>second term>first term>';
> 
> $foo = qr{ < $foo (.+?) >

You do not use . with these constructs.  Most probably you want
something like [^<>].

> 	  (?{ push @terms, $1 })
> 	|
> 	}px;

Well, the above $foo naming convention is good for a stupid example,
but for real stuff you need real names.

  $nested = qr( (
		  (?> [^<>]+ )		# Grab all non-<>
		 |
		  < $nested >
		)* )p;

(without grabbing stuff).  If you want nesting at the start only, it
becomes

  $nested = qr( < ($nested)? [^<>]* > )p;

and if you want grabbing

  $nested = qr( < (?: ($nested) (?{ push @ans, $1}) )? [^<>]* > )p;

> Hmm.  I think backtracking would bite me here, and since I don't have
> a version of perl that supports this construct to play with, I hope I
> can be forgiven for not testing it.

Backtracking requires saving the value of @ans:

  $nested = qr( < (?: ($nested)
		      (?{ local $#tans; push @tans, $1})
		  )?
		  [^<>]*
		> )p;

And probably you want putting this $nested guy inside an $envelop, and
do

  $envelop = qr(  (?{ local @tans })
		  $nested
		  (?{ @ans = @tans })
	       )p;

so that the above local's do not annihilate @tans until you had a
chance to read the contents.

> With something this complex, I know I'm overlooking something.

The idea is to make these things *simple*.  Support of backtracking
with (?{}) needs improvement.  But I did not see any feedback on this
from you guys.

> Regardless of whether or not my example is actually reasonable, what
> is the plan for backreferences in the "postponed" interpolation?

There are some plans for "hierarchical" matches.  See archives of p5p.

Ilya


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

Date: Wed, 06 Oct 1999 17:30:52 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: [OFFTOPIC] Tad's Back! WAS:Regexp/Interpolation question
Message-Id: <37FBE9BC.F9534484@mail.cor.epa.gov>

Tad McClellan wrote:
[snip]
>    My name is Tad McClellan.

"HELLO TAD!!"
 
>    I am a Usenetaholic.
> 
>    It has been 2 months since my last post.
> 
>    What were those 12 steps again?

Nice to see you back.  Have fun with the family?
[See, I remember that farewell post.]

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


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

Date: Wed, 06 Oct 1999 16:05:52 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: array for network simulator
Message-Id: <37FBD5CF.949E5A0D@cisco.com>

{ Pat Trainor wrote:

> What approaches could I use to not only represent the routers and the
> connecting networks between them ....

> So, should a hash be created for each node? Optimally a BW assignment for
> each leg should be possible,...

Read chapter (8).
Mastering Algorithms With Perl
 ---  by Jon Orwant
before you start on anything like this.
--



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

Date: Wed, 06 Oct 1999 11:19:46 -0400
From: WoV <hazard@eznetN-O~S'P&A`M.net>
Subject: Re: Checking for processes
Message-Id: <7tfpon$l7c$2@news.wrc.xerox.com>

mazachan@yahoo.com wrote:
> 
> Hi, I am fairly new to perl and I was wondering, is there a way to
> continuously check for processes that are running without making a
> system call to "ps" and just putting it into a loop? I am looking for a
> more efficient way of doing this. Thanks.

This is probably not a "cool" way of doing it, but what I do is to
do a getpgrp on the PID in a while loop with a sleep.

When the result of the getpgrp comes back -1, then I know the ID is
gone.  I have only used this in a limited scope, not sure if this is
generally applicable but it may be worth testing.

HTH
 - Al


-- 
"Never put off 'til tomorrow what you can delegate today"

To contact me remove "N-O~S'P&A`M " from my address


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

Date: Wed, 6 Oct 1999 15:36:30 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: checking for string in multiple line scalar (part II)
Message-Id: <ub8gt7.3oi.ln@magna.metronet.com>

Fokko Wesselius (fokko.wesselius@ict.nl) wrote:

: I still don't get the thing working, whether it uses /g options or not, 


   There are other options besides m//g

   Maybe one of those would help.

   Did you read about them in perlre.pod?


: it
: only get's the first ICT label. 


   Because that is what you asked for.

   Ask for something else if you want something else  :-)


: $version_label =

: "ICT1999-05-0228.1.1-2" = 2.*\n
: "Release_1.0_VWi611_19990826" = 1.1\n
: "Baseline_19990928_VWI611_Phase_2_Rework" = 1.1\n
: "ICT1999-05-0228.1.1-1" = 1.*\n
: "Release_1.2_P_VWI611_1" = 1.1\n
: "Release_1.3_P_VWI611_1" = 1.1\n


   That is not legal Perl syntax, so I dunno what you are trying to
   say there.

   It is Not Good to post pseudo-Perl in the Perl newsgroup.

   Please post real code if you want real help.


: But I want to know how many times "ICT label is found. and I want to push
: the lines in a array.


   I threw in another "line" with q/"ICT/ not at the beginning of a line,
   just to be sure that we don't find/count it.


-------------------------
#!/usr/bin/perl -w
use strict;

my $version_label = q(
"ICT1999-05-0228.1.1-2" = 2.*\n
"Release_1.0_VWi611_19990826" = 1.1\n
"don't match me "ICT
"Baseline_19990928_VWI611_Phase_2_Rework" = 1.1\n
"ICT1999-05-0228.1.1-1" = 1.*\n
"Release_1.2_P_VWI611_1" = 1.1\n
"Release_1.3_P_VWI611_1" = 1.1\n
);

my @lines;
push @lines, $1 while $version_label =~ /^("ICT.*)/mg;

print 'there are ', scalar(@lines), " lines in \@lines\n";
-------------------------


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


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

Date: 06 Oct 1999 17:44:05 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Damn Comma Delmitation
Message-Id: <xkfiu4kawca.fsf@valdemar.col.hp.com>

Kenneth Bandes <kbandes@home.com> writes:
> Actually, the indexing in the FAQ could be a little better.  None
> of the following queries will find the relevent entry:

<snip>

> this despite the fact, which folks here never tire of pointing 
> out, that the data is separated, not delimited, by commas.
> 
> By the way, the FAQ refers to Text::CSV, but not the more current
> module, Text::CSV_XS.

<snip some more>

I'm sure TomC isn't about to turn down any diffs you'd care to share with 
him. :^)  We've only just recently got HTML::Parser mentioned instead of
HTML::Parse, because only recently has anybody given him a diff.

-=Eric
-- 
"Cutting the space budget really restores my faith in humanity.  It
eliminates dreams, goals, and ideals and lets us get straight to the
business of hate, debauchery, and self-annihilation."
                -- Johnny Hart


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

Date: Thu, 7 Oct 1999 02:38:08 +0200
From: "Thomas" <skyhigh@intergalactica.com>
Subject: Doh!  Adding to HASH when reading!?!?!?!
Message-Id: <7tgq5c$s9$1@gordon.dalnet.se>

Could someone please explain the behaviour of this short example.

This code is just an example that describes
a behaviour i can't understand.

In my real package the contents of $hash is added
at runtime and is dynamic. Eg. it could contain the key
'one', 'two', 'three' ... or god knows what..;).

What i want is get an array with the keys of the hash
referenced by '$key'.

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

use strict;

use Data::Dumper;

my $hashkeys;
my $hashkey_array;
my $hash = { 'one'   => { 'red'   => 'cat',
                          'blue'  => 'dog'
                        },
             'three' => { 'red'   => 'cats',
                          'white' => 'horses'
                        }
           };

my $key = "two";

$hashkey_array = [ keys %{ $hash->{$key} } ];

my $debug = Data::Dumper->new([$hash], ['hash']);
print $debug->Dump();

#END
=============================================
-OUTPUT--------------------------------------

$hash = {
          'three' => {
                       'white' => 'horses',
                       'red' => 'cats'
                     },
          'two' => {},
          'one' => {
                     'blue' => 'dog',
                     'red' => 'cat'
                   }
        };
---------------------------------------------

# Why the #$@"¤!"# has 'two' become a new hashkey.
# I don't see the logic in this code being an assignment:

keys %{ $hash->{$key} }

# Do you?
# If you do or not, how should i rewrite the row

$hashkey_array = [ keys %{ $hash->{$key} } ];

# so i don't add the key to the $hash if the key
# doesn't exist.

Regards
Thomas Åhlen (thomas2@dalnet.se)




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

Date: Wed, 06 Oct 1999 16:02:52 -0700
From: cLive hoLLoway <cLive@direct2u.co.uk>
Subject: Re: extracting perldoc documentation
Message-Id: <37FBD51C.F8340F4D@direct2u.co.uk>

> Hi- Is there a way to view perldoc documentation in  a wordprocessor? I've
> been viewing it in dos by typing perldoc ??? .  This is an unconfortable way
> of reading for me.  I'd also like to be able to print the documentation.

If you are using ActivePerl, there is a web version of the docs in the
c:/perl/html directory.

If you are not using ActiveState perl port, I suggest you do...

http://www.activestate.com/ActivePerl/

cLive ;-)



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

Date: Wed, 06 Oct 1999 23:37:27 GMT
From: Mike Heller <mike@dice.net>
Subject: Re: File exists?
Message-Id: <37FBDCFB.C861A55A@dice.net>

Thanks for your help everyone, but  I still have not solved the problem.
Here is more info:

I'm using LWP::Simple to get the head info from a url.  Code:

if (head($base_url)) {
  print "file exists\n";
}
else {
  print "file does not exist\n";
}

The problem is that our server (and many others) use a .htaccess file to
re-direct 404 errors to another page so I get the results of that page.
So, even if the file does not exist, I get re-directed to a file that does
exist and I get this header returned.  Any way around this problem?

Mike



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

Date: 06 Oct 1999 20:18:12 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: File exists?
Message-Id: <x7r9j8owfv.fsf@home.sysarch.com>

>>>>> "MH" == Mike Heller <mike@dice.net> writes:

  MH> I'm using LWP::Simple to get the head info from a url.  Code:

  MH> The problem is that our server (and many others) use a .htaccess file to
  MH> re-direct 404 errors to another page so I get the results of that page.
  MH> So, even if the file does not exist, I get re-directed to a file that does
  MH> exist and I get this header returned.  Any way around this problem?

don't use LWP::Simple. use the regular LWP which will allow you to tell
youif you got a real page or a server error.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Wed, 06 Oct 1999 17:31:54 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: GD Modul Version 1.19 for win32 ?
Message-Id: <37FBE9FA.7DB8D445@mail.cor.epa.gov>

Andreas Schulz wrote:
> 
> Was there a win32 version of the gd modul Version 1.19 ? If yes where can I
> find it, because the new Version 1.21 supports only png instead of gif.

Answered in c.l.p.modules already.  But you ddin't crosspost
your question, so it doesn't show up here.  

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


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

Date: Thu, 07 Oct 1999 00:15:40 GMT
From: jennyng@my-deja.com
Subject: Help - Perl regular expression question!
Message-Id: <7tgon1$m3s$1@nnrp1.deja.com>

Hi,

I've spent days to try to get the following w/ no success.  I was
wondering if anyone knows how to do the following w/ Perl regular
expression (or any other way w/ Perl):

if (( $pattern in $line ) && ( $pattern in $line is not w/in [bigger
pattern] )) {
  replace $pattern w/ $replacement
}

Example:
$pattern = "bcd";
[bigger pattern] is "abcde"
$line = "lllbcdlllabcdelllbcd";
$replacement = "wyz";
The above will change $line to "lllwyzlllabcdelllwyz".

Any help or suggestion is greatly appreciated.  Thank you very much in
advance.

- Jenny


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 6 Oct 1999 17:57:06 -0500
From: Seth David Johnson <sjohns17@uic.edu>
Subject: Re: HELP! Passing vars to sub not working
Message-Id: <Pine.A41.4.10.9910061755350.354652-100000@tigger.cc.uic.edu>

On Thu, 7 Oct 1999, Marc Fearby wrote:

> sub DbConnect {
>     my ($user,$pass) = $_;

     my ($user,$pass) = @_;

> sub DoSql {
>     my $dbh = $_;

     my $dbh = shift;


-Seth
 www.pdamusic.com



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

Date: Wed, 06 Oct 1999 18:04:10 -0500
From: Max Khrapov <maksim@mail.utexas.edu>
Subject: Re: HELP! Passing vars to sub not working
Message-Id: <37FBD56A.AF633423@mail.utexas.edu>

Marc Fearby wrote:
> 
> Hi, I'm relatively new to Perl - I've read loads of documentation and
> tutorials and think I've got variable passing to sub-routines figured
> out, except when I try to pass a variable  to a sub-routine which I got
> from another sub-routine, it doesn't work :-(  Below is my short program
>
***************************************
> sub DoSql {
>     my $dbh = $_;
***************************************
> 
> E-mail: marc@fearby.com
> ICQ:    13045454

All of your subroutines have the same mistake. Arguments are passed to a
subroutine in array
@_, NOT as $_ . Try this:

sub mysub {
   my $dbh = shift;

OR,

sub mysub {
   my $dbh = $_[0];

OR,

sub mysub {
   my($a, $b, $c) = @_;

Have fun,

Max


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

Date: Wed, 6 Oct 1999 16:13:19 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: how to change a '\' to '/' ?
Message-Id: <MPG.1265776c3f690c1798a051@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <37FBB45D.DAB67C4D@mail.cor.epa.gov> on Wed, 06 Oct 1999 
13:43:09 -0700, David Cassell <cassell@mail.cor.epa.gov> says...

 ...

> But tr/// is a much better choice when making single-character
> translations.  Like:
> 
>     tr{\}{/} foreach (@lines);
> 
> or
>     
>     tr#\#/# foreach (@lines);     # if you prefer to break
>                                   # bad comment-strippers :-)

Prepare to blush.

      tr{\\}{/} foreach (@lines);

      tr#\\#/# foreach (@lines);    # if you prefer to break
                                    # bad comment-strippers :-)

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


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

Date: Wed, 06 Oct 1999 17:35:31 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: how to change a '\' to '/' ?
Message-Id: <37FBEAD3.C6B50658@mail.cor.epa.gov>

Larry Rosler wrote:
> 
> [Posted and a courtesy copy mailed.]
> 
> In article <37FBB45D.DAB67C4D@mail.cor.epa.gov> on Wed, 06 Oct 1999
> 13:43:09 -0700, David Cassell <cassell@mail.cor.epa.gov> says...

> >     tr{\}{/} foreach (@lines);

> Prepare to blush.
> 
>       tr{\\}{/} foreach (@lines);

D'OH!  I'm blushing already.

Even worse, I did the same thing in a real program just last 
week.  So much for learning through experience.

Maybe I should go back to my old job as Matt Wright's sidekick.
:-)

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


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

Date: Wed, 06 Oct 1999 23:36:14 GMT
From: "George Jempty" <jb4mt@verbatims.com>
Subject: Re: Killfiles
Message-Id: <O1RK3.889$ry3.9087@news.rdc1.ne.home.com>

I know I'm in this bozo's killfile, but one of the benefits of starting this
thread is that I've learned who all the pompous jerks are

> Boy.. split infinitives, ungrammatical construction, and a
> misconfigured newsreader at home. I guess I'll have to be more careful
> reading news at home :)
>
> Martien





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

Date: 06 Oct 1999 20:10:12 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Killfiles
Message-Id: <x71zb8qbdn.fsf@home.sysarch.com>

>>>>> "GJ" == George Jempty <jb4mt@verbatims.com> writes:

  GJ> I know I'm in this bozo's killfile, but one of the benefits of
  GJ> starting this thread is that I've learned who all the pompous
  GJ> jerks are

look in a mirror sometime georgie boy.

go away. soon.

uri


-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Wed, 06 Oct 1999 17:37:20 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
To: George Jempty <jb4mt@verbatims.com>
Subject: Re: Killfiles
Message-Id: <37FBEB40.70E5831B@mail.cor.epa.gov>

[courtesy cc e-mailed]

George Jempty wrote:
> 
> I know I'm in this bozo's killfile, but one of the benefits of starting this
> thread is that I've learned who all the pompous jerks are
> 
> > Boy.. split infinitives, ungrammatical construction, and a
> > misconfigured newsreader at home. I guess I'll have to be more careful
> > reading news at home :)
> >
> > Martien

George, please.  In the part of Martien's post which you
snipped, he makes it clear that he is talking about HIS OWN
previous post.  Not yours.  It's a joke.  At his own expense.

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


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

Date: Wed, 6 Oct 1999 17:48:09 -0500
From: Seth David Johnson <sjohns17@uic.edu>
Subject: Re: Perl & java
Message-Id: <Pine.A41.4.10.9910061746130.55440-100000@tigger.cc.uic.edu>

On Wed, 6 Oct 1999, Surya P Kommareddy wrote:

> Hi all,
>     I would like to use Javascript inside perl programs. If this is possible
> please inform me which version of Perl to be installed. I searched the web
> but I could find only how to use perl script inside java.

You can print javascript to a browser (via cgi) just like anything else.
Best you read up on CGI in general.

-Seth
 www.pdamusic.com



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

Date: Wed, 06 Oct 1999 17:29:47 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Perplexed with newlines while sending mail
Message-Id: <37FBE97B.A8EB1ECF@mail.cor.epa.gov>

Graham W. Boyes wrote:
> 
> I'm a little perplexed here...
> I'm trying to open a file and send it to an e-mail address.  The file
> is HTML based, so I want to ignore the newlines already in the HTML
> file, and replace all the <BR>'s with newlines.  Ex,
[snip] 
> I have tried different methods replacing <BR> with \n, (tr, s, etc...)
> but when I receive the e-mail with different clients, the result is not
> consistent.  For example, with Internet Mail, I received *three*
> newlines at the <BR> and with Pegasus I received the message in one
> long line.

I think you'll have to show us some example code with some
output.  I see several possibilities for problems, but I
can't be sure without seeing what you wrote.  For example:

tr/<BR>/\n/;    # if this is one of the things you tried

won't do at all what you expected it to.  Try it on a
simple string like:
    "a word and a <BR> and <=> and <<-- some MORE BLOBS !!"
and you'll see what I mean.

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


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

Date: Wed, 06 Oct 1999 18:29:58 -0500
From: Max Khrapov <maksim@mail.utexas.edu>
Subject: POSIX::setuid problem???
Message-Id: <37FBDB76.B6C99379@mail.utexas.edu>

Hello!

I'm running Red Hat 6.0, linux-i386, perl 5.005_03. I want to execute a
program at boot time, but as an unpriveleged user. The program itself
cannot change its real UID (proprietary, no source), so I wanted to
write a wrapper to change the UID and exec it. I ended up doing it in C
as I could not get Perl to change its UID (of course I was running it as
root). The Perl program was claiming it had a new UID but it (and
children) all showed up in ps -ef as UID root and they all had root
privileges. Here is an illustration:

$ su -
# ls -ld .
drwx------  18 root     root         1024 Oct  6 17:48 ./
# perl -e '
> use POSIX "setuid";
> print "$<\n";
> setuid(501);
> print "$<\n";
> exec "touch", "I_was_here";'
0
501
# ls -l I_was_here
-rw-r--r--   1 root     root            0 Oct  6 18:27 I_was_here
# exit
$

So, you see the problem? Is it a Perl (module) bug, or I didn't use it
correctly?

Have fun,

Max


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

Date: Wed, 06 Oct 1999 18:42:15 -0500
From: Max Khrapov <maksim@mail.utexas.edu>
Subject: POSIX::setuid problem???
Message-Id: <37FBDE57.58792B66@mail.utexas.edu>

Hello!

I'm running Red Hat 6.0, linux-i386, perl 5.005_03. I want to execute
a
program at boot time, but as an unpriveleged user. The program itself
cannot change its real UID (proprietary, no source), so I wanted to
write a wrapper to change the UID and exec it. I ended up doing it in
C
as I could not get Perl to change its UID (of course I was running it
as
root). The Perl program was claiming it had a new UID but it (and
children) all showed up in ps -ef as UID root and they all had root
privileges. Here is an illustration:

$ su -
# ls -ld .
drwx------  18 root     root         1024 Oct  6 17:48 ./
# perl -e '
> use POSIX "setuid";
> print "$<\n";
> setuid(501);
> print "$<\n";
> exec "touch", "I_was_here";'
0
501
# ls -l I_was_here
-rw-r--r--   1 root     root            0 Oct  6 18:27 I_was_here
# exit
$

So, you see the problem? Is it a Perl (module) bug, or I didn't use
it
correctly?

Have fun,

Max


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

Date: Wed, 06 Oct 1999 23:42:35 GMT
From: pacman@defiant.cqc.com (Alan Curry)
Subject: Re: POSIX::setuid problem???
Message-Id: <L7RK3.3021$eM4.239312@typ11.nn.bcandid.com>

In article <37FBDB76.B6C99379@mail.utexas.edu>,
Max Khrapov  <maksim@mail.utexas.edu> wrote:
>Hello!
>I'm running Red Hat 6.0, linux-i386, perl 5.005_03. I want to execute a
>program at boot time, but as an unpriveleged user.

su -c prog

>                                                   The program itself
>cannot change its real UID (proprietary, no source),

Everybody say "awwwwww"

>                                                     so I wanted to
>write a wrapper to change the UID and exec it. I ended up doing it in C
>as I could not get Perl to change its UID

What functions did you use in C? Not setuid() I'd guess.

># perl -e '
>> use POSIX "setuid";
>> print "$<\n";
>> setuid(501);
>> print "$<\n";
>> exec "touch", "I_was_here";'
>0
>501
># ls -l I_was_here
>-rw-r--r--   1 root     root            0 Oct  6 18:27 I_was_here

As expected since your euid is still 0.

>So, you see the problem? Is it a Perl (module) bug, or I didn't use it
>correctly?

setuid() changes the real uid. File creation uses the effective uid. You need
to set $>
-- 
Alan Curry    |Declaration of   | _../\. ./\.._     ____.    ____.
pacman@cqc.com|bigotries (should| [    | |    ]    /    _>  /    _>
--------------+save some time): |  \__/   \__/     \___:    \___:
 Linux,vim,trn,GPL,zsh,qmail,^H | "Screw you guys, I'm going home" -- Cartman


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

Date: Wed, 06 Oct 1999 17:25:49 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: previous link
Message-Id: <37FBE88D.123A872@mail.cor.epa.gov>

ICEMOUNTAIN@prodigy.net wrote:
> 
> Thanks for the help.

You're welcome.

> I dont have an error checking thing. Do I put -w on
> after #usr/bin/local/perl/.

That's one good tool.  Another [for CGI] is the -T flag.
But error-checking on open()s and close()s means checking
to see whether your open() even worked before you move on.
Like this:

open FOO, "<$filename"    or die_nice "failed to open $filename: $!";

where die_nice would be a subroutine which would output
your results to a webpage instead of to STDOUT .

> I just started perl and never had a book to
> learn, I just learn as I go.

You might want to read some of the docs which come with
Perl.  To get a feel for what is provided, type:

    perldoc perl

at a command prompt on a machine where you have Perl.
[You can get Perl on your own machine pretty easily, too.]

> My website is only for 1982 - 1992 Camaros, so
> I dont have to worry about the year 2000 thing.

<Yorkshire accent>
Luxury!  Why when I was a boy...
</Yorkshire accent>

> On my computer my post
> didn't have any other replies besides yours, was there some on your
> computer?

IIRC, there were two other posts on my newsfeed.  There may
have been more which didn't show up.  

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


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

Date: Thu, 07 Oct 1999 01:04:35 GMT
From: bounce.waxwing@dnai.com (Scot Hacker)
Subject: Re: Redirecting output to /dev/null
Message-Id: <DkSK3.9162$L4.726331@typ12.nn.bcandid.com>

On Wed, 06 Oct 1999 01:44:14 -0700, Wise Guy wrote:

>This looks like a O/S-level problem rather than anything to do with
>Perl.

Hmm... I don't think so. Everything I've done in perl so far on BeOS has 
worked perfectly, and again, I can redirect to /dev/null from the shell
just fine. There's definitely some perl syntax I'm not grokking fully.

>What might be happening is that the output may have been taken care of
>but what might be displayed onto the screen is the error message.

The message ouputted to the generated HTML page is exactly the same as the
one I get in the shell if I *don't* redirect to /dev/null.

>Try this :-
>
>hey SoundPlay set file of track 0 to file\(filename\) > /dev/null 2>&1
>
>OR
>
>hey SoundPlay set file of track 0 to file\(filename\) >& /dev/null

Just tried both of those, no cigar. Same problem.

>depending on what shell u are using.

bash 2.0. BeOS is POSIX-compliant, so I really don't see how this could be
an OS level problem, but I don't know for sure. Are there other techniques
for issuing system-level commands that I might be able to use instead of
system()? 

Thanks for the response,

Scot


-- 

The BeOS Tip Server: http://www.betips.net/
The BeOS Bible: http://www.birdhouse.org/beos/bible/
The Alt.OS Usability Challenge: http://www.betips.net/challenge/


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

Date: 6 Oct 1999 23:58:31 GMT
From: gerry@xmission.com (Gerry JJ Dyn-O-Myte Walker)
Subject: Re: regexp question modified: last non-empty occurrence...
Message-Id: <slrn7vnoh7.hpq.gerry@xmission.xmission.com>

Thanks for those that answered my original question.  However, I now
must complicate my original problem slightly.  I need to now find the
last occurrence of bold text which contains actual printable text
before the <ul>.*</ul> expression, ignoring possible bold sections
containing no printable text (but may possibly contain non-printable
stuff).

For example:

$_ = "I want <b>to</b> find this <b>thing</b> <b><font face=Arial></b> 
<b> </b><ul>...</ul>";


In the above text, I would want to extract "thing", and not the two
useless bold sections that follow.

Again, thanks for all the help,

Gerry


In article <MPG.12632613c07f972798a035@nntp.hpl.hp.com>, Larry Rosler wrote:
>In article <slrn7vieri.o01.gerry@xmission.xmission.com> on 4 Oct 1999 
>23:42:43 GMT, Gerry JJ Dyn-O-Myte Walker <gerry@xmission.com> says...
>> How do I extract the last occurrence of an expression occurring before
>> another expression.  For example in the following string:
>
>... (reproduced below)
>
>> I want to to extract only the last bold item (which is "text" in this
>> example) which occurs before the list <ul>.*<\/ul>
>
>#!/usr/local/bin/perl -w
>use strict;
>
>$_ = 'A <b> lot </b> of <b> html </b> text, some of it in <b> bold </b>.  I
>want to extract the last <b> bold </b> section of <b> text </b> prior
>to a list of items - <ul> <li> item one </ul> - maybe more <b> bold </b>
>still.';
>
>m%.*<b>\s*(.*?)\s*</b>.*<ul>%s and print "|$1|\n";
>
>-- 
>(Just Another Larry) Rosler
>Hewlett-Packard Laboratories
>http://www.hpl.hp.com/personal/Larry_Rosler/
>lr@hpl.hp.com


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

Date: Wed, 06 Oct 1999 16:39:54 -0700
From: cLive hoLLoway <cLive@direct2u.co.uk>
Subject: Re: Regular Expressions with  =?iso-8859-1?Q?=D4=D5=D6=D8=8C=8A=D9=DA=DB=DC=DD=9F=DE=E0=E1=E2=E3=E4=E5=E6=E7=E8=E9=EA?=  characters
Message-Id: <37FBDDCA.4B8C6A7E@direct2u.co.uk>

Bill Moseley wrote:
> 
> I've got a routine that is passed a list of 'words' and then bolds the
> words in a HTML document by substituting the 'word' with'<B>word</B>'.
> 
> Up until now I've used \b to find a word boundary -- I don't want to
> bold words within a longer word (if my word is 'dry' I don't want to
> bold the 'dry' in 'laundry').
> 
> s[\bdry\b][<b>dry</b>]g;
> 
> My question is in dealing with 8 bit characters such as:
> ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØŒŠÙÚÛÜÝŸÞàáâãäåæçèéêëìíîïðñòóôõöøœšßùúûüýþÿ
> 
> How should I match a word boundary?  I'm unclear if use locale will
> help.  Or do I need to create my own word boundary as described in
> "Creating custom RE engines" in perlre?
> 
> I also have the case being passed a word like "perl*" and then I want to
> bold anything that begins with perl through the end of the word
> boundary.

interesting one that, and one that will become a major quagmire if it's
not thought through... time to look up those ISO char set tables.

I guess a lot of it will depend on whether the text you are parsing is
just "plain" text, or whether it could contain extended punctuation: ©®€
etc - on my machine, those three characters render as copyright symbol,
reg trademark symbol and the Euro currency symbol. On your machine, they
could be quite different.

Also, whether the text will always be in the same ISO character set.

If you do have only one character set to work from, it should be pretty
easy to define each character as a word or non-word character, and take
it from there.

On the other hand, if your non-word characters are pretty limited, eg:
just :;'",.(){}[]/!$%-+=
it might be easier to define these as 'word boundary' characters.

I'm sure the reg-exp-heads here will have some neat way of turning this
all into a one line answer, but that's my thoughts...

cLive ;-)



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

Date: Thu, 07 Oct 1999 00:20:52 GMT
From: "George Jempty" <jb4mt@verbatims.com>
Subject: Re: To Abigail re: reading current threads
Message-Id: <EHRK3.893$ry3.9138@news.rdc1.ne.home.com>

> Take this to email oh pretty please? Please?
>
> e.

Thanks so much; now, even though I don't address Uri directly, I get abusive
email from him.  And in the meantime you have shown yourself to be an
insufferable brown-nosing hypocrite.

George Jempty




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

Date: 06 Oct 1999 20:42:45 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: To Abigail re: reading current threads
Message-Id: <x7n1twovay.fsf@home.sysarch.com>

>>>>> "GJ" == George Jempty <jb4mt@verbatims.com> writes:

  >> Take this to email oh pretty please? Please?
  >> 
  >> e.

  GJ> Thanks so much; now, even though I don't address Uri directly, I
  GJ> get abusive email from him.  And in the meantime you have shown
  GJ> yourself to be an insufferable brown-nosing hypocrite.

who is brown nosing? elaine? you pathetic fool. she will sic HB on you and
you will finally be gone from here. as for abusive email, i also post
my abuse of you so my contempt is public.

go away. often.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Thu, 07 Oct 1999 00:56:22 GMT
From: "George Jempty" <jb4mt@verbatims.com>
Subject: Re: To Abigail re: reading current threads
Message-Id: <WcSK3.895$ry3.9280@news.rdc1.ne.home.com>

> PS: I'm NOT going away

OK, I actually will go away, temporarily, and if and when I come back my
goal is that no one will identify me as the perpetrator of this thread.  I
still think I'm at least partially right on my original issue, but it seems
nobody else does, so I have to re-evaluate.  Anyway, I've done a great job
of obscuring what my original issue was, and I sincerely apologize to
everybody in the group who didn't like it, except for the ones who enjoyed
it!

George Jempty




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

Date: Wed, 06 Oct 1999 16:22:09 -0700
From: cLive hoLLoway <cLive@direct2u.co.uk>
Subject: Re: using strict, no soft references!! now what?
Message-Id: <37FBD9A1.7072F2D8@direct2u.co.uk>

Martien Verbruggen wrote:
> 
> On Tue, 05 Oct 1999 18:09:14 -0700,
>         cLive hoLLoway <cLive@direct2u.co.uk> wrote:
> 
> > What I want to be able to do is then use the soft reference ${$2} next
> > if that element doesn't exist, and failing that, assign the value
> > 'null';
> 
> Trust me, that is _not_ what you want to do. if you won't trust me on
> that, then you will have to get rid of strict 'refs';
> 

> use strict;
> no strict 'refs';
>
> should do it.

I'm iterating through a bunch of variable names. some of these relate to
elements sent from a form, some are global variable names used in the
script. I guess I need to define which is which rather than letting the
script decide as it goes.
 
> But that means that you are now prone to many possible
> problems.

Any chance of elaboration on these problems?

pretty please :-)

cLive ;-)



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

Date: 06 Oct 1999 20:16:47 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: using strict, no soft references!! now what?
Message-Id: <x7vh8kowi8.fsf@home.sysarch.com>

>>>>> "ch" == cLive hoLLoway <cLive@direct2u.co.uk> writes:


  ch> I'm iterating through a bunch of variable names. some of these
  ch> relate to elements sent from a form, some are global variable
  ch> names used in the script. I guess I need to define which is which
  ch> rather than letting the script decide as it goes.
 
if they are from a form, you shouldn't need symrefs. a hash is fine. 
for the global vars, make them into hash and index by their name. to
merge the two just append one hash to the other:

@hash{ keys %form_hash } = values %form_hash ;

  >> But that means that you are now prone to many possible
  >> problems.

  ch> Any chance of elaboration on these problems?

symrefs will hide bugs from you. it is more annoying to explain or show
than just telling you (and others) not to use them unless you REALLY
know what you are doing. symrefs can allow bugs to propogate so that the
cause and effect of the bug are widely separated which is very tricky to
debug.

symrefs are meant to be used when hacking the symbol tables behind the
scenes or when doing other black magic. regular refs and hashes can do
all symrefs do in normal code and are simpler to code and debug.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Wed, 06 Oct 1999 17:40:46 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: using strict, no soft references!! now what?
Message-Id: <37FBEC0E.C44099BC@mail.cor.epa.gov>

Uri Guttman wrote:
> 
> >>>>> "ch" == cLive hoLLoway <cLive@direct2u.co.uk> writes:
[snipperoo]
>   ch> Any chance of elaboration on these problems?
> 
> symrefs will hide bugs from you. it is more annoying to explain or show
> than just telling you (and others) not to use them unless you REALLY
> know what you are doing. symrefs can allow bugs to propogate so that the
> cause and effect of the bug are widely separated which is very tricky to
> debug.

I suggest reading Mark-Jason Dominus' discussion on the 
subject at 
    http://www.plover.com/~mjd/perl/#varvarname
so this doesn't have to be recounted in this NG.

Suffice it to say symrefs can lead to hideously obscure
bugs in your code which may only show up in rare [but
deadly] circumstances.  

And they're icky.  :-)

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


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

Date: Wed, 06 Oct 1999 17:32:40 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: We do complex Perl Programming
Message-Id: <37FBEA28.D5462EDF@mail.cor.epa.gov>

Michel Dalle wrote:
> 
> sehgal@del2.vsnl.net.in (Sahil) wrote in <7th2f6$n1u$1@news.vsnl.net.in>:
> >Hi,
> >We are an E-commerce based company and do any type of complex Perl
> >programming in record time.
> 
> Congratulations. What is your record up to now ? :o

Oh.  I thought they meant 'complex' programming.  As in
'a large part of it is imaginary'.   :=)

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


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 1008
**************************************


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