[17887] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 47 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 12 11:05:37 2001

Date: Fri, 12 Jan 2001 08:05:15 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <979315514-v10-i47@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 12 Jan 2001     Volume: 10 Number: 47

Today's topics:
        $CGI::POST_MAX query fudokai@my-deja.com
    Re: $CGI::POST_MAX query dtbaker_dejanews@my-deja.com
    Re: a question on scope dtbaker_dejanews@my-deja.com
        ANNOUNCE: New Tk::ObjScanner can view pseudo hashes <domi@komarr.grenoble.hp.com>
    Re: array slices <iltzu@sci.invalid>
    Re: array slices <peb@bms.umist.ac.uk>
        Bit Map <carlo@netverk.net>
    Re: Clearing a hash. (Helgi Briem)
    Re: Help: Installation Failed (Helgi Briem)
    Re: HTTP::Request encoding query iain_hogg@my-deja.com
    Re: Jobs: Senior Software Engineer <brannon@lnc.usc.edu>
    Re: Jobs: Senior Software Engineer <brannon@lnc.usc.edu>
    Re: Jobs: Senior Software Engineer <brannon@lnc.usc.edu>
    Re: Jobs: Senior Software Engineer (Peter L. Berghold)
    Re: Jobs: Senior Software Engineer <michael-a-mayo@worldnet.att.net>
    Re: Jobs: Senior Software Engineer (Tad McClellan)
    Re: Jobs: Senior Software Engineer (Richard Zilavec)
    Re: kill with SIGTERM not working (Anno Siegel)
    Re: match from the end or match the last (Martien Verbruggen)
    Re: match from the end or match the last <joe+usenet@sunstarsys.com>
        Murex Applications <robert.parkes@dpp.co.uk>
    Re: Murex Applications (Bernard El-Hagin)
        name of var $_ is pointing to? <prlawrence@lehigh.edu>
    Re: name of var $_ is pointing to? (Rafael Garcia-Suarez)
        Need to extract last 2 "fields" in a comma sep string stuart_munn@my-deja.com
    Re: Need to extract last 2 "fields" in a comma sep stri <zarathustra@enviroweb.org>
    Re: Need to extract last 2 "fields" in a comma sep stri (Rafael Garcia-Suarez)
    Re: Need to extract last 2 "fields" in a comma sep stri <mtaylorlrim@my-deja.com>
    Re: Need to extract last 2 "fields" in a comma sep stri <bart.lateur@skynet.be>
    Re: Need to extract last 2 "fields" in a comma sep stri <dperham@dperham.eng.tvol.net>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 12 Jan 2001 13:41:01 GMT
From: fudokai@my-deja.com
Subject: $CGI::POST_MAX query
Message-Id: <93n1hb$9qn$1@nnrp1.deja.com>

I'm putting together a Perl CGI script to be installed on my ISP. Since users
will be able to post messages I want to provide what DOS protection I can.
I've found docs stating that setting $CGI::POST_MAX to a value limits the max
size of a posting. I tried setting this to 1024 (just to try it out) and cut
and pasted a lrge text file into a TEXTAREA box but it was all accepted
without comment. Does $CGI::POST_MAX work with TEXTAREA? I'm working with my
own object created from CGI and the constructor looks like this ...sub new { 
my ($s,$config,$user) = @_;  my $self = new CGI;  $self- >{config}  = new
nm_config($config);  $self- >{user}  = new nm_user();  $self- >{news}  = new
nm_data();  $self- >{message}  = undef;  bless($self);	$CGI::POST_MAX =
1024;  return $self;}Am I using the $CGI::POST_MAX correctly or is there
something I've missed?- Alan


Sent via Deja.com
http://www.deja.com/


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

Date: Fri, 12 Jan 2001 15:14:10 GMT
From: dtbaker_dejanews@my-deja.com
Subject: Re: $CGI::POST_MAX query
Message-Id: <93n6vp$eog$1@nnrp1.deja.com>

In article <93n1hb$9qn$1@nnrp1.deja.com>,
  fudokai@my-deja.com wrote:
> I'm putting together a Perl CGI script to be installed on my ISP.
Since users
> will be able to post messages I want to provide what DOS protection I
can.
> I've found docs stating that setting $CGI::POST_MAX to a value limits
the max
> size of a posting.
----------------------------

I found a bug in older versions of this... it didnt catch oversize
postings for me either. you have a choice of fixing the source of CGI.pm
or when you write the uploaded file you can count the bytes your self as
you save it, and die if you hit your limit.

I posted an example of this a couple weeks ago in an example of
uploading image files. Try dejanews search for subject containing
"solution" and "upload" .

D


Sent via Deja.com
http://www.deja.com/


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

Date: Fri, 12 Jan 2001 15:01:12 GMT
From: dtbaker_dejanews@my-deja.com
Subject: Re: a question on scope
Message-Id: <93n67i$e37$1@nnrp1.deja.com>

In article <ntts5tghcnim901o1kbeqnh6vlue95thnd@4ax.com>,
  Jeff Helman <jhelman@wsb.com> wrote:

> If you are running at least 5.6.0 (which gives you lexical warning
> control), the following line in your script will silence these beasts.
>
> no warnings 'once';
>------------------------

interesting....

I'm not running 5.6 yet. Partly because none of the webhosts I use have
upgraded yet. I'll just continue "un-elegantly" for now.

D


Sent via Deja.com
http://www.deja.com/


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

Date: 12 Jan 2001 15:24:30 +0100
From: Dominique Dumont <domi@komarr.grenoble.hp.com>
Subject: ANNOUNCE: New Tk::ObjScanner can view pseudo hashes
Message-Id: <t5u8der79cdv55@corp.supernews.com>


Hello

Tk::ObjScanner provides a GUI to scan perl data including the
attributes of an object.

Starting from version 1.020:
- pseudo hashes are also correctly viewed.
- a demo is installed so Tk's widget demo will feature ObjScanner

The scanner is a composite widget made of a HList and a text window
(actually a TK::ROText). This widget acts as a scanner to the object
(or hash ref) passed with the 'caller' parameter. The scanner will
retrieve all keys of the hash/object and insert them in the HList.

When the user double clicks on a key, the corresponding value will be added
in the HList.

If the value is a scalar, the scalar will be displayed in the text window.
(Which is handy if the value is a multi-line string)

This module was written with perl5.6.0 and Tk 800.022

See the embedded documentation in the module for more details.

Note that test program (in the 't' directory) can be run interactively
this way :

 perl t/xxx.t 1

Comments and suggestions are always welcome.

Many thanks to Achim Bohnet for all the tests, patches (and reports) he 
made. Many improvements were made thanks to his efforts.

Thanks to Rudi Farkas for the 'watch' patch.
Thanks to Slavec Rezic for the pseudo-hash prototype.



Share and enjoy.

-- 
Dominique_Dumont@grenoble.hp.com




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

Date: 12 Jan 2001 12:38:20 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: array slices
Message-Id: <979302091.12229@itz.pp.sci.fi>

In article <3A5DDBF6.E38F6483@bms.umist.ac.uk>, Paul Boardman wrote:
>
>My dataset is very large and contains many tabs with no data inbetween. 
>I was wondering if this could be the source of the problem.

Source of *what* problem?

>while(<>){
>	my @line = split(/\t/);
>	print join "\t", @line[0..177,179..244,247..934,969..$#line];
>}

Hmm.. ah!  Your problem, I suppose, is that you're losing trailing
tabs?  And if you had warnings enabled, you probably got a bunch of
those without knowing why.

It's not caused by the slice, though.  It's caused by split() omitting
trailing empty fields by default.  Just write it like this:

  while(<>){
      my @line = split(/\t/, $_, -1);
      print join "\t", @line[0..177,179..244,247..934,969..$#line];
  }

And while I'm at it, I might as well make sure it works even on lines
which don't happen to have enough fields:

  while(<>){
      chomp;
      my @line = split(/\t/, $_, -1);
      print(join("\t", grep defined($_),
                 @line[0..177, 179..244, 247..934, 969..$#line]),
            "\n");
  }

There.  The grep avoids problems if there are less then 935 fields on
any line, and by chomping and replacing the newline the code will work
even if the last field happens to be one of those that are removed.

Of course, if you know there will always be at least 970 fields then
the first solution will work just as fine.

-- 
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real!  This is a discussion group, not a helpdesk.  You post
 something, we discuss its implications.  If the discussion happens to
 answer a question you've asked, that's incidental." -- nobull in clpm



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

Date: Fri, 12 Jan 2001 14:03:45 +0000
From: Paul Boardman <peb@bms.umist.ac.uk>
Subject: Re: array slices
Message-Id: <3A5F0EC1.F7057514@bms.umist.ac.uk>


> >My dataset is very large and contains many tabs with no data inbetween.
> >I was wondering if this could be the source of the problem.
> 
> Source of *what* problem?

sorry...  getting absent minded in my old age.

> 
> >while(<>){
> >       my @line = split(/\t/);
> >       print join "\t", @line[0..177,179..244,247..934,969..$#line];
> >}
> 
> Hmm.. ah!  Your problem, I suppose, is that you're losing trailing
> tabs?  And if you had warnings enabled, you probably got a bunch of
> those without knowing why.

damn.  Thats what happens when you try and knock out a quick script at
the end of the day...  I did a very stupid thing and forgot to enable
warnings!  That was really dumb!

Again I apologise for wasting your time.

> 
> It's not caused by the slice, though.  It's caused by split() omitting
> trailing empty fields by default.  Just write it like this:
> 
>   while(<>){
>       my @line = split(/\t/, $_, -1);
>       print join "\t", @line[0..177,179..244,247..934,969..$#line];
>   }

I've never had a problem with split like this before so I thought it was
my array slice syntax that was at fault but couldn't figure out why.

Cheers for the solution.

I will make sure I'm not being as dumb next time before posting.

Paul


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

Date: Fri, 12 Jan 2001 15:54:42 -0000
From: "carlo costa" <carlo@netverk.net>
Subject: Bit Map
Message-Id: <3a5f9945.0@news.isholf.is>

Hello there,

Das exist any "Entry Widget" which accepts a bitmap as entry ?

thanks

carlo

P.S.

Have nice week end.





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

Date: Fri, 12 Jan 2001 11:30:20 GMT
From: helgi@NOSPAMdecode.is (Helgi Briem)
Subject: Re: Clearing a hash.
Message-Id: <3a5ee8be.251580593@news.itn.is>

On Fri, 12 Jan 2001 00:37:06 GMT, west999@my-deja.com wrote:

>Hi,
>
>I have a script that assigns a bunch of keys/values to a hash.  At some
>point in that script I would like to "clear" the hash, that is to say
>get rid of all of the keys/values.
>
>I do not want to redeclare the hash.
>

>So far I have tried:
>undef %hash;
>
>and
>
>%hash = "";
>
>Neither works, the old key/values persist.
>
>Any ideas?
>
This is doubleplustrange.  Can you show
us some real code?  Are you sure
you are modifying the same script you are 
running? 

Are you sure you are printing the same 
hash as you are undefining/clearing?

Both have happened to me a few times.

I tried:
my %hash;
$hash{'b'} = 'barney';
print %hash;

Prints: bbarney
then:

my %hash;
$hash{'b'} = 'barney';
%hash = "";
print %hash;

No output.

And:
my %hash;
$hash{'b'} = 'barney';
undef %hash;
print %hash;

No output.

Regards,
Helgi Briem


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

Date: Fri, 12 Jan 2001 15:36:01 GMT
From: helgi@NOSPAMdecode.is (Helgi Briem)
Subject: Re: Help: Installation Failed
Message-Id: <3a5f22f2.266480809@news.itn.is>

On Fri, 12 Jan 2001 04:42:44 GMT, Haiyan Wang
<qiuminh@my-deja.com> wrote:

>I download ActivePerl-5.6.0.623-MSWin32-x86-multi-thread.zip and try
>to install it. It gives me an error Internal Error 2336. 5,
>C:\WINNT\Installer\
>
>The OS is Win2000 Workstation.

My guess is that you don't have MS Installer, although
it shoudl come standard with Win2K.  
This product is required to install the
ActivePerl-5.6.0.623-MSWin32-x86-multi-thread,msi
file contained in your zip file.

You can get it at:
http://download.microsoft.com/download/platformsdk/wininst/1.0/WIN98/EN-US/IntelSDK.msi

Regards,
Helgi Briem


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

Date: Fri, 12 Jan 2001 11:39:18 GMT
From: iain_hogg@my-deja.com
Subject: Re: HTTP::Request encoding query
Message-Id: <93mqd6$4ea$1@nnrp1.deja.com>

In article <93ldsd$rm$1@nnrp1.deja.com>,
  gungeek@my-deja.com wrote:
> In article <93la7l$t68$1@nnrp1.deja.com>,
>   iain_hogg@my-deja.com wrote:
> > Hi,
> >
> > Take the following HTTP::Request :
> >
> > $tgt = 'http://www.acme.com/cgi/test.cgi?val=bar|';
> > $req = new HTTP::Request('GET' => $tgt);
> >
> > Now, when this request is made at some point it is encoded (in iso
> latin 1 I
> > think) into a HTTP request that looks like
> >
> > GET http://www.acme.com/cgi/test.cgi?val=bar%7C
> >
> > where '|' has become '%7C'
> >
> > So what I'd like to know is if there is any way to prevent this
> encoding
> > taking place?  I don't mind changing perl source and recompiling if
>
> If it wasn't encoded, it wouldn't be a valid URL, and you might get
> a "Malformed Request" response.  Why do you want to do this?
>

The cgi-bin script I'm trying to work with (which I can't change) does not
unencode its input i.e. change '%7C' back to '|', so I need to send the
cgi-bin arguments un-encoded. Incidentally, I've been capturing IE and Opera
HTTP GET requests, and they don't encode '|' at all, whether in the URL or as
cgi arguments.

--
Iain


Sent via Deja.com
http://www.deja.com/


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

Date: Fri, 12 Jan 2001 13:37:46 GMT
From: Terrence Brannon <brannon@lnc.usc.edu>
Subject: Re: Jobs: Senior Software Engineer
Message-Id: <lbitnkc2mt.fsf@lnc.usc.edu>

jerome@activeindexing.com (Jerome O'Neil) writes:

> Uri Guttman <uri@sysarch.com> elucidates:
> 
> >   TB> He posted a Perl job posting in a Perl newsgroup. Because this is
> >   TB> where Perl programmers are. I don't mind that.
> > 
> > <flame war starting>
> > 
> > well, then post anything about any job that is for a company that may
> > have heard about perl in here. there are jobs groups just for that
> > purpose. this group is to discuss perl, not perl jobs.
> 
> <dons asbestos pants>
> 
> A Perl job is certainly a miscelaneous topic regarding Perl.

AMEN!!!!!

You speak my thoughts better than me Jerome. 

-- 
Terrence Brannon
Carter's Compass...
    I know I'm on the right track when by deleting code I'm adding
    functionality.


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

Date: Fri, 12 Jan 2001 13:39:50 GMT
From: Terrence Brannon <brannon@lnc.usc.edu>
Subject: Re: Jobs: Senior Software Engineer
Message-Id: <lbg0ioc2jd.fsf@lnc.usc.edu>

merlyn@stonehenge.com (Randal L. Schwartz) writes:

> >>>>> "Terrence" == Terrence Brannon <brannon@lnc.usc.edu> writes:
> 
> Terrence> He posted a Perl job posting in a Perl newsgroup. Because this is
> Terrence> where Perl programmers are. I don't mind that.
> 
> It's not yours to choose.  Policy is established by the people who
> bring you the news, and they hang out in news.admin.misc.  It's not

I didn't know this.

> anything that can be voted on by the users of this group, so don't
> even start.

Stay in comp.lang.perl.moderated. That place will have no unsolicited
job posts.

-- 
Terrence Brannon
Carter's Compass...
    I know I'm on the right track when by deleting code I'm adding
    functionality.


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

Date: Fri, 12 Jan 2001 13:47:01 GMT
From: Terrence Brannon <brannon@lnc.usc.edu>
Subject: Re: Jobs: Senior Software Engineer
Message-Id: <lb66jkc27e.fsf@lnc.usc.edu>

merlyn@stonehenge.com (Randal L. Schwartz) writes:

> >>>>> "Terrence" == Terrence Brannon <brannon@lnc.usc.edu> writes:
> 
> Terrence> He posted a Perl job posting in a Perl newsgroup. Because this is
> Terrence> where Perl programmers are. I don't mind that.
> 
> It's not yours to choose.  Policy is established by the people who
> bring you the news, and they hang out in news.admin.misc.  It's not

can we make a move to have comp.lang.perl.jobs created? I think this
would be a great thing.

-- 
Terrence Brannon
Carter's Compass...
    I know I'm on the right track when by deleting code I'm adding
    functionality.


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

Date: Fri, 12 Jan 2001 14:17:05 GMT
From: peter@uboat.berghold.net (Peter L. Berghold)
Subject: Re: Jobs: Senior Software Engineer
Message-Id: <slrn95u4f0.idl.peter@uboat.berghold.net>

On Thu, 11 Jan 2001 22:22:32 -0500, 
	Tad McClellan <tadmc@augustmail.com> wrote:
>
>Discussing jobs here will bring the Recruiters and their
>shotgun-approach machine-posted spam in great teeming
>slimey globs.
>
>There will be 1000 posts a day here.
>

Amen to that. We don't need no stinkin' recruiters further degrading 
the signal to noise ratio.....


-- 
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Peter L. Berghold                        Peter@Berghold.Net
"Linux renders ships                     http://www.berghold.net
 NT renders ships useless...."           


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

Date: Fri, 12 Jan 2001 14:30:14 GMT
From: "Michael Mayo" <michael-a-mayo@worldnet.att.net>
Subject: Re: Jobs: Senior Software Engineer
Message-Id: <WxE76.796$5y1.57593@bgtnsc06-news.ops.worldnet.att.net>

"Jerome O'Neil" <jerome@activeindexing.com> wrote
> A Perl job is certainly a miscelaneous topic regarding Perl.

Do you really want the NG to be flooded with hundreds of wanted ads?

            -Mike





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

Date: Fri, 12 Jan 2001 07:49:39 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Jobs: Senior Software Engineer
Message-Id: <slrn95tvb3.ui.tadmc@tadmc26.august.net>

Terrence Brannon <brannon@lnc.usc.edu> wrote:
>merlyn@stonehenge.com (Randal L. Schwartz) writes:
>
>> >>>>> "Terrence" == Terrence Brannon <brannon@lnc.usc.edu> writes:
>> 
>> Terrence> He posted a Perl job posting in a Perl newsgroup. Because this is
>> Terrence> where Perl programmers are. I don't mind that.
>> 
>> It's not yours to choose.  Policy is established by the people who
>> bring you the news, and they hang out in news.admin.misc.  It's not
>
>can we make a move to have comp.lang.perl.jobs created? 
     ^^
     ^^ got a mouse in your pocket?  :-)  :-)


You can make a move to create a newsgroup. How to do that is
off-topic here, try the news.* hierarchy. Start with news.groups.

This is "hard to do", but you can take a shot at it if you want
(it may consume a good deal of your time to push it through).

The more important question would be 

   "might the "move" succeed (pass a vote)?"

I think the odds are greatly against it passing...


OTOH, you can create an alt.* newsgroup instead with much
less trouble.



One argument that helps support the need for a new group is a
high-traffic mailing list for the same topic.

There is a Perl jobs mailing list (perl-jobs-announce) that gets
only a dribble of use, but that may be just due to lack of publicity.

   http://www.pm.org/mailing_lists.shtml

(no machines there yet)


>I think this
>would be a great thing.


I think the machines would spew so much that finding "real jobs"
would be a needle in a haystack thing.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Fri, 12 Jan 2001 15:17:25 GMT
From: rzilavec@tcn.net (Richard Zilavec)
Subject: Re: Jobs: Senior Software Engineer
Message-Id: <3a5f1e6d.67886774@news.tcn.net>

On Thu, 11 Jan 2001 22:58:07 GMT, Terrence Brannon
<brannon@lnc.usc.edu> wrote:

>
>He posted a Perl job posting in a Perl newsgroup. Because this is
>where Perl programmers are. I don't mind that.

I think this NG gets enough traffic already, I can't imagine resumes
and job postings here too.

--
 Richard Zilavec
 rzilavec@tcn.net


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

Date: 12 Jan 2001 14:23:25 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: kill with SIGTERM not working
Message-Id: <93n40t$geo$2@mamenchi.zrz.TU-Berlin.DE>

Nick Wilson <nickw@ot.com.au> wrote in comp.lang.perl.misc:
>I posted this a couple of days ago but my newsreader was playing
>around,
>
>I have a perl script (exec.pl) which creates another process via
>
>$pid= open FH, "runtest.pl |" || die "could not run $cmd\n";
>
>which is eventually killed after a timeout.
>
>kill 15, $pid
>
>Now inside my runtest.pl I set up a sig handler for term (15).
>
>$SIG{TERM} = \&got_signal;
>
>sub got_signal {
>
>  print "runtests.pl: got_signal";
>  .. do other stuff....
>}
>
>Trouble is I can't seem to get the signal handler to work. If I use a
>command
>line to kill -15 runtest.pl then it works, but when called from another perl
>script it doesn't work ?
>
>Can anyone point me to what is going on ?

Yes, probably.  When you run runtest.pl via the open you show, its
output (to STDOUT) is caught by the pipe and directed to the filehandle
FH.  When runtest.pl's signal handler prints to STDOUT, that is where
the output goes.  Print what FH gives you, the last line should be
the one you're missing.  Well, perhaps not the last one, since it
isn't clear if your signal handler dies eventually.  If it doesn't
the program will continue to run.

Anno



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

Date: Fri, 12 Jan 2001 22:19:35 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: match from the end or match the last
Message-Id: <slrn95tq27.50v.mgjv@martien.heliotrope.home>

On Fri, 12 Jan 2001 18:44:22 +0930,
	Wyzelli <wyzelli@yahoo.com> wrote:
> "Martien Verbruggen" <mgjv@tradingpost.com.au> wrote in message
> news:slrn95td7h.50v.mgjv@martien.heliotrope.home...
>> On Fri, 12 Jan 2001 12:29:47 +0800,
>>
>> s/(.*)y/Y/;
>>
> 
> Missing $1 is the substitution? :)  It aint that late in Sydney yet....

Oops, indeed. as you also said in your other post:

s/(.*)y/$1Y/;

At least I did get it right in the larger bit, later on :}

And it mightn't have been late, but that says nothing about how awake I
was :)

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | 
Commercial Dynamics Pty. Ltd.   | Curiouser and curiouser, said Alice.
NSW, Australia                  | 


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

Date: 12 Jan 2001 10:59:19 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: match from the end or match the last
Message-Id: <m3itnk4v8o.fsf@mumonkan.sunstarsys.com>

mgjv@tradingpost.com.au (Martien Verbruggen) writes:

> On Fri, 12 Jan 2001 12:29:47 +0800,
> 	John Lin <johnlin@chttl.com.tw> wrote:
> > Dear all,
> > 
> > In regular expression, is there a modifier or any idiomic way to
> > match from the end (backward)?  Let's say if the modifier is 'b', then
> > 
> > ($_ = 'xyzxyzxyz') =~ s/y/Y/b;  print;
> > 
> > results in:
> > 
> > 'xyzxyzxYz'    instead of    'xYzxyzxyz'
> 
> Is the question really something like : How do I only change the _last_
> occurence of a match with s///
> 
> Regular expressions in Perl always match forward. But in this particular
> case you can make use of the fact that quantifiers, by default, are
> greedy:
> 
> s/(.*)y/Y/;
         ^
ITYM s/(.*)y/$1Y/ here.  Here's a harder case to consider (using above "b")

($_ = "xyz3xyz3343 A" ) =~ s/\d+//b; print;

results in "xyz3xyz A".  

Short of reversing the string, the only regexp I can think of for this 
one is 

s/\d+(?=\D*$)//;

This one works by ensuring that the remainder of the string matches a 
complementary search pattern. Complementing a general regexp to make
this technique work can be very difficult, though.  Even the original
example requires some trickery-

s/y(?=[^y]*$)/Y/;

> PS. Interestingly enough, I couldn't find anything about this in the
> FAQ. If no one knows any documentation that talks about this, I might
> write one and submit it.

Within the "s///g" description, there is an anectodal remark in 

% man perlop
 ...
            Occasionally, you can't use just a /g to get all
            the changes to occur.  Here are two common cases:

               # put commas in the right places in an integer
               1 while s/(.*\d)(\d\d\d)/$1,$2/g;      # perl4
               1 while s/(\d)(\d\d\d)(?!\d)/$1,$2/g;  # perl5
 ...

The camel adds a bit more rationale for these examples-

        Occasionally, you can't just use a /g to get all the changes 
        to occur, either because the substitutions have to happen 
        right-to-left, or because you need the length of $` to change 
        between matches.


I'm not aware of a general strategy for doing this; it could be plain-old
ignorance though.  It will be enlightening to read the documentation
you come up with - equidistribution of greed is always a topic of 
interest ;)

-- 
Joe Schaefer



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

Date: Fri, 12 Jan 2001 11:44:30 -0000
From: "Rob Parkes" <robert.parkes@dpp.co.uk>
Subject: Murex Applications
Message-Id: <79C76.36$l%3.73657@newsr1.u-net.net>

Does anybody know what Murex is? I think its a banking application used by
german investment banks? any idea's?

Robert Parkes

robert.parkes@dpp.co.uk




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

Date: Fri, 12 Jan 2001 12:07:26 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Murex Applications
Message-Id: <slrn95tsro.2q0.bernard.el-hagin@gdndev25.lido-tech>

On Fri, 12 Jan 2001 11:44:30 -0000, Rob Parkes <robert.parkes@dpp.co.uk>
wrote:
>Does anybody know what Murex is? I think its a banking application used by
>german investment banks? any idea's?

By what twisted logic did you come to the conclusion that this was the
place to ask?

Cheers,
Bernard
--
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'


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

Date: Fri, 12 Jan 2001 10:11:14 -0600
From: "Phil R Lawrence" <prlawrence@lehigh.edu>
Subject: name of var $_ is pointing to?
Message-Id: <93n6sq$mcu@fidoii.CC.Lehigh.EDU>

How can I get the name of the var/glob/inner_thingee that $_ is currently
referencing?

Something like this would be cool:

foreach ($boo, $baz, $bif) {
    # Do something to change $_
    print LOG $_->true_name, ": $_\n";
}

resulting in:

___my.log_______
boo: changed_boo
baz: changed_baz
bif: changed_bif

Thanks,
Phil R Lawrence




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

Date: Fri, 12 Jan 2001 15:30:10 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: name of var $_ is pointing to?
Message-Id: <slrn95u8og.1cr.rgarciasuarez@rafael.kazibao.net>

Phil R Lawrence wrote in comp.lang.perl.misc:
> How can I get the name of the var/glob/inner_thingee that $_ is currently
> referencing?
> 
> Something like this would be cool:
> 
> foreach ($boo, $baz, $bif) {
>     # Do something to change $_
>     print LOG $_->true_name, ": $_\n";
> }
> 
> resulting in:
> 
> ___my.log_______
> boo: changed_boo
> baz: changed_baz
> bif: changed_bif

So, reformulating your problem : you want to know to what thingy is
aliased the loop variable in a foreach loop. Note that this thingy
hasn't necessarily a name.

If you really want to, you can use reference comparisons :

  my ($a,$b,$c) = qw/A B C/;
  foreach ($a,$b,$c) {
    print "a: $a\n" if \$_ eq \$a;
    print "b: $b\n" if \$_ eq \$b;
    print "c: $c\n" if \$_ eq \$c;
  }

but, as you see, this is not very convenient.

I don't know what your original problem is, but I suggest to use a hash.

-- 
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Fri, 12 Jan 2001 13:09:28 GMT
From: stuart_munn@my-deja.com
Subject: Need to extract last 2 "fields" in a comma sep string
Message-Id: <93mvm5$891$1@nnrp1.deja.com>

Help,

I'm struggling with regexp... I want to extract the last 2 "fields" in
a string that uses "," as a separator.

I can't use split as the number of fields in each string varies and
sometimes the , is part of the text, but not for that last two fields.

Any solutions would be MUCH appreciated.

Regards

Stuart Munn


Sent via Deja.com
http://www.deja.com/


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

Date: Fri, 12 Jan 2001 13:43:55 GMT
From: "Vogelfrei" <zarathustra@enviroweb.org>
Subject: Re: Need to extract last 2 "fields" in a comma sep string
Message-Id: <vSD76.4573$jM3.177963@newsread2.prod.itd.earthlink.net>


<stuart_munn@my-deja.com> wrote in message
news:93mvm5$891$1@nnrp1.deja.com...
> Help,
>
> I'm struggling with regexp... I want to extract the last 2 "fields" in
> a string that uses "," as a separator.
>
> I can't use split as the number of fields in each string varies and
> sometimes the , is part of the text, but not for that last two fields.
>

Check out Text::ParseWords




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

Date: Fri, 12 Jan 2001 13:49:01 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Need to extract last 2 "fields" in a comma sep string
Message-Id: <slrn95u2qr.pr.rgarciasuarez@rafael.kazibao.net>

stuart_munn@my-deja.com wrote in comp.lang.perl.misc:
> Help,
> 
> I'm struggling with regexp... I want to extract the last 2 "fields" in
> a string that uses "," as a separator.

my ($penultimate_field,$last_field) = ($string =~ /,([^,]+),([^,]+)$/);

-- 
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
#!/usr/bin/perl -p
BEGIN { *ARGV=*DATA }
__END__
Just another Perl hacker,


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

Date: Fri, 12 Jan 2001 13:36:00 GMT
From: Mark <mtaylorlrim@my-deja.com>
Subject: Re: Need to extract last 2 "fields" in a comma sep string
Message-Id: <93n180$9lr$1@nnrp1.deja.com>

In article <93mvm5$891$1@nnrp1.deja.com>,
  stuart_munn@my-deja.com wrote:
> Help,
>
> I'm struggling with regexp... I want to extract the last 2 "fields" in
> a string that uses "," as a separator.
>
> I can't use split as the number of fields in each string varies and
> sometimes the , is part of the text, but not for that last two fields.
>
> Any solutions would be MUCH appreciated.
>
> Regards
>
> Stuart Munn
>
> Sent via Deja.com
> http://www.deja.com/
>
I'm not worth a hoot with regex. My solution until I found the right
way would be to split the variable into an array and pop the elements
into variables.

@array = split(/,/,$varriable);
$var1 = pop @array;
$var2 = pop @array;

Mark



--
Please reply to this newsgroup as my Deja mail
is used as a spam catcher only!


Sent via Deja.com
http://www.deja.com/


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

Date: Fri, 12 Jan 2001 14:39:46 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Need to extract last 2 "fields" in a comma sep string
Message-Id: <kp5u5tsi4ph58kgbmoki5u1qq32i4uc8lh@4ax.com>

stuart_munn@my-deja.com wrote:

>I'm struggling with regexp... I want to extract the last 2 "fields" in
>a string that uses "," as a separator.
>
>I can't use split as the number of fields in each string varies and
>sometimes the , is part of the text, but not for that last two fields.

Oh yes you can. There are special indices for counting from the back.

	($one, $two) = (split /,/)[-2,-1];

-- 
	Bart.


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

Date: 12 Jan 2001 09:39:44 -0500
From: Doug Perham <dperham@dperham.eng.tvol.net>
Subject: Re: Need to extract last 2 "fields" in a comma sep string
Message-Id: <81y9wg3kcv.fsf@wgate.com>

stuart_munn@my-deja.com writes:

> Help,
> 
> I'm struggling with regexp... I want to extract the last 2 "fields" in
> a string that uses "," as a separator.
> 
> I can't use split as the number of fields in each string varies and
> sometimes the , is part of the text, but not for that last two fields.

sure you can.  just split the string on ',' and grab the last two - who
cares if it split the other stuff in the wrong place?  If you're only
concerned with the last two fields and they are 'well formed' (not
having commas) then you have nothing to fear. Just do something like


  my @array = split(/,/, $string);
  next unless @array >= 2;
  my @last_two_fields = splice @array, -2;

of course you could avoid 'split' and use

  my @last_two_fields = $string =~ m/([^,]+),([^,]+)$/;
  next unless @last_two_fields == 2;
> 
> Any solutions would be MUCH appreciated.


> 
> Regards
> 
> Stuart Munn
> 
> 
> Sent via Deja.com
> http://www.deja.com/


-- 
Doug Perham                                          o{..}o     
dperham@wgate.com                                moo! (oo)___   
WorldGate Communications, Inc.                        (______)\ 
                                                      / \  / \  


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

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 V10 Issue 47
*************************************


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