[30421] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1664 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 20 18:10:14 2008

Date: Fri, 20 Jun 2008 15:09:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 20 Jun 2008     Volume: 11 Number: 1664

Today's topics:
    Re: calling external program tiff2pdf <bill@ts1000.us>
    Re: extract all hotmail email addresses in a file and s <szrRE@szromanMO.comVE>
    Re: extract all hotmail email addresses in a file and s <m@rtij.nl.invlalid>
    Re: extract all hotmail email addresses in a file and s <m@rtij.nl.invlalid>
    Re: FAQ 8.2 How come exec() doesn't return? <ced@blv-sam-01.ca.boeing.com>
    Re: FAQ 8.2 How come exec() doesn't return? <m@rtij.nl.invlalid>
    Re: Filtering a string <someone@example.com>
        How do I make a sub like open that accepts both FILEHAN <damercer@comcast.net>
    Re: How do I make a sub like open that accepts both FIL <ben@morrow.me.uk>
        How do you call the part with the underscore in this  s gauthier@holnx2.dyndns.org
    Re: How do you call the part with the underscore in thi <ben@morrow.me.uk>
    Re: How do you call the part with the underscore in thi gauthier@holnx2.dyndns.org
    Re: How do you call the part with the underscore in thi <jimsgibson@gmail.com>
    Re: Learning Perl <g....c.e@gmail.com>
    Re: Perl DBI Module: SQL query where there is space in  <wgumgfy@gmail.com>
    Re: Perl Script <m@rtij.nl.invlalid>
    Re: Print Spanish characters in Perl? <smallpond@juno.com>
    Re: Substituting in a group <samikr@gmail.com>
    Re: Substituting in a group <samikr@gmail.com>
    Re: Substituting in a group <ben@morrow.me.uk>
    Re: Substituting in a group <someone@example.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 20 Jun 2008 12:08:25 -0700 (PDT)
From: Bill H <bill@ts1000.us>
Subject: Re: calling external program tiff2pdf
Message-Id: <fcc8e61e-671a-40a1-941b-3651ee0dda19@z66g2000hsc.googlegroups.com>

On Jun 19, 4:27=A0pm, James muffin <n...@zomg.tk> wrote:
> > Hi
>
> > I cut and pasted. =A0The solution is you need to give a list as I
> > mentioned earlier.
>
> Its not though, I've never done that(given a list), and using the code
> you posted it works for me. Something else is up...
>
> I used this as the full program:
>
> my $filename=3D"fred.tiff";
> my $newfile=3D"john.pdf";
> system ("tiff2pdf -o $newfile $filename");
>
> worked just fine.

I had a similar issue with system and imagemagik. From the command
prompt the command and the passed parameters worked great, from
system() it never worked. I finally figured out for some reason I have
to give the full path to imagemagik in the system() command for it to
work. Not sure if this will work for you but did for me.

Bill H


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

Date: Fri, 20 Jun 2008 13:59:05 -0700
From: "szr" <szrRE@szromanMO.comVE>
Subject: Re: extract all hotmail email addresses in a file and store in separate file
Message-Id: <g3h5mq0a1t@news4.newsguy.com>

Martijn Lievaart wrote:
> On Fri, 20 Jun 2008 11:32:27 +0200, Dr.Ruud wrote:
>
>> Martijn Lievaart schreef:
>>> On Thu, 19 Jun 2008 08:38:40 +0200, Martijn Lievaart wrote:
>>
>>>> perl -nie 'if (/\@hotmail.com@$/) { s/"//g; print; }' text_file
>>>
>>> Or even:
>>>
>>> perl -nie 's/"//g; print if /\@hotmail.com@$/' text_file
>>
>> Don't you mean this?
>>
>>     perl -ne 's/"//g; print if /\@hotmail\./' text_file
>
> I think I ment this:
>
> perl -ni -e 's/"//g; print if /\@hotmail.com@$/' text_file
>
> (-i makes a backup, -ie probably takes the 'e' as the backup suffix.)

Maybe I'm missing something, but I don't understand why you have an @ 
near the end of your regex just before the $ ? I can't find any mention 
of it in perldoc or my Perl Pocket Refererence, but it's possible I'm 
missing something.

Thanks.

-- 
szr 




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

Date: Fri, 20 Jun 2008 22:27:55 +0200
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: extract all hotmail email addresses in a file and store in separate file
Message-Id: <pan.2008.06.20.20.27.55@rtij.nl.invlalid>

On Fri, 20 Jun 2008 11:32:27 +0200, Dr.Ruud wrote:

> Martijn Lievaart schreef:
>> On Thu, 19 Jun 2008 08:38:40 +0200, Martijn Lievaart wrote:
> 
>>> perl -nie 'if (/\@hotmail.com@$/) { s/"//g; print; }' text_file
>> 
>> Or even:
>> 
>> perl -nie 's/"//g; print if /\@hotmail.com@$/' text_file
> 
> Don't you mean this?
> 
>     perl -ne 's/"//g; print if /\@hotmail\./' text_file

I think I ment this:

perl -ni -e 's/"//g; print if /\@hotmail.com@$/' text_file

(-i makes a backup, -ie probably takes the 'e' as the backup suffix.)

M4


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

Date: Fri, 20 Jun 2008 23:40:52 +0200
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: extract all hotmail email addresses in a file and store in separate file
Message-Id: <pan.2008.06.20.21.40.52@rtij.nl.invlalid>

On Fri, 20 Jun 2008 13:59:05 -0700, szr wrote:

> Maybe I'm missing something, but I don't understand why you have an @
> near the end of your regex just before the $ ? I can't find any mention
> of it in perldoc or my Perl Pocket Refererence, but it's possible I'm
> missing something.

Your missing nothing. I'm blind.

M4


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

Date: Fri, 20 Jun 2008 12:07:42 -0700 (PDT)
From: "comp.llang.perl.moderated" <ced@blv-sam-01.ca.boeing.com>
Subject: Re: FAQ 8.2 How come exec() doesn't return?
Message-Id: <b3b089a9-d9d5-4099-96b2-581fb3161acd@x1g2000prh.googlegroups.com>

On Jun 20, 4:09 am, Bill H <b...@ts1000.us> wrote:
> ...
> Here is the issue, maybe you all will have a solution.
>
> In a perl cgi, I would like to do some file maintenance (remove old
> temporary files, session files etc) when a user accesses a program but
> I don't want to make them wait for it. Which command would I use to
> invoke a different perl program that is totally detached from the
> running one (runs in the background) and could still be running when
> the user is finished with the original program and not cause any delay
> (other than using more resources on the server) in the original
> program.
>
> The only solution I can think of (and it probably is the best) is to
> make the maintenance program a cron job since it has no interaction
> with the user but I think it would be a cleaner solution to only have
> the maintenance program executed when something needs to be
> maintained.
>

You could close stdout as soon as the
CGI program no longer needs it (or even
in an END block) and then launch the secondary program in the
background:

END {
  close STDOUT or die "close: $!";
  system("secondary.pl &");
}

This appears to work on Solaris.
As mentioned though, you may need
need to close stderr or even in
some cases use POSIX setsid.


--
Charles DeRykus


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

Date: Fri, 20 Jun 2008 23:42:40 +0200
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: FAQ 8.2 How come exec() doesn't return?
Message-Id: <pan.2008.06.20.21.42.39@rtij.nl.invlalid>

On Fri, 20 Jun 2008 04:09:15 -0700, Bill H wrote:

> The only solution I can think of (and it probably is the best) is to
> make the maintenance program a cron job since it has no interaction with
> the user but I think it would be a cleaner solution to only have the
> maintenance program executed when something needs to be maintained.

Others have given other solutions, but this is indeed a good one. Another 
one would be to create a daemon that is triggered form the webpage.

M4


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

Date: Fri, 20 Jun 2008 21:05:28 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Filtering a string
Message-Id: <sYU6k.298$yg7.202@edtnps82>

Bill H wrote:
> Can someone point me to some docs on how I would do this without
> iterating over the whole string (pattern matching?):
> 
> $original = "a malformed%string/containi\"ng characters I don'~t
> want! ...";
> 
> $filter = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_";
> 
> $new = &fix($original);
> 
> $new would now equal:
> 
> amalformedstringcontainingcharactersidontwant

$ perl -le'
$original = "a malformed%string/containi\"ng characters I don\047~t 
want\041 ...";
$filter = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_";

( $new = $original ) =~ s/[^\Q$filter\E]+//ig;
print for $original, $new;
'
a malformed%string/containi"ng characters I don'~t want! ...
amalformedstringcontainingcharactersIdontwant



John
-- 
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall


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

Date: Fri, 20 Jun 2008 13:20:08 -0500
From: "Dan Mercer" <damercer@comcast.net>
Subject: How do I make a sub like open that accepts both FILEHANDLES and undefined vars
Message-Id: <_tqdnVUNSrVKacbVnZ2dnUVZ_uidnZ2d@comcast.com>

I am trying to develop a module with an open like call that can be passed 
either
a FILEHANDLE or an undefined var,  just like open.

   sub etlinput(*;$@)
      {
      ...
      my $fh = qualify_to_ref(shift, caller);

that works fine if I

   etlinput(IN,$file)

but if I

    my $fh;

    etlinput($fh,$file)

I get a bunch of uninitialized value warnings from Symbol.pm

TIA

Dan Mercer

 



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

Date: Fri, 20 Jun 2008 19:57:46 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: How do I make a sub like open that accepts both FILEHANDLES and undefined vars
Message-Id: <a6bti5-r4j.ln1@osiris.mauzo.dyndns.org>


Quoth "Dan Mercer" <damercer@comcast.net>:
> I am trying to develop a module with an open like call that can be passed 
> either
> a FILEHANDLE or an undefined var,  just like open.
> 
>    sub etlinput(*;$@)
>       {
>       ...
>       my $fh = qualify_to_ref(shift, caller);
> 
> that works fine if I
> 
>    etlinput(IN,$file)
> 
> but if I
> 
>     my $fh;
> 
>     etlinput($fh,$file)
> 
> I get a bunch of uninitialized value warnings from Symbol.pm

You need something like

    sub etlinput (*;$@) {
        defined $_[0] or $_[0] = Symbol::gensym;
        my $fh = qualify_to_ref(shift, caller);
        ...
    }

If you are going to call 'open' you can just pass $_[0] and avoid the
somewhat ugly 'GEN0' globs gensym creates.

Ben

-- 
           All persons, living or dead, are entirely coincidental.
ben@morrow.me.uk                                                  Kurt Vonnegut


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

Date: Fri, 20 Jun 2008 11:54:25 -0700 (PDT)
From: gauthier@holnx2.dyndns.org
Subject: How do you call the part with the underscore in this  shift->_date_header('Date',@_)
Message-Id: <73e68d9c-b43b-4b8a-a86b-8c6dabce29bc@k30g2000hse.googlegroups.com>

Looking into HTTP::Headers.pm, I am trying to understand what does the
underscore in line 267 mean.

sub date { shift->_date_header('Date',@_); }

Thefile version/date I used is : # $Id: Headers.pm,v 1.64 2005/12/08
12:11:48 gisle Exp $

I thought it was an overload but after reading a bit it does not look
like this.  Overload dont seem to use an underscore as a valid
operator.  The only code I could find in my Camel book is the "use
fields" page 846 of third edition.  But in this code, it does not have
shift, it has only the object ref:

$rock->{_Pet_pid} = 1234; #private attribute

I have not found documentation about private attributes either.

Question 1:
How do you call this part ->_ within the next line:
sub date                { shift->_date_header('Date',
@_); }

Question 2:
In this line:
sub date                { shift->_date_header('Date',
@_); }
Is the shift representing the first argument of the array @_ from the
inheritance?
Thanks.


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

Date: Fri, 20 Jun 2008 20:34:46 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: How do you call the part with the underscore in this  shift->_date_header('Date',@_)
Message-Id: <mbdti5-nlk.ln1@osiris.mauzo.dyndns.org>


Quoth gauthier@holnx2.dyndns.org:
> Looking into HTTP::Headers.pm, I am trying to understand what does the
> underscore in line 267 mean.
> 
> sub date { shift->_date_header('Date',@_); }

It's part of the method name. $obj->_date_header(...) is calling a
method called '_date_header' on $obj. If you look through
HTTP/Headers.pm, you will find a definition of 'sub _date_header'.

The initial underscore means nothing to Perl. However, it is a common
convention to use a leading underscore to indicate private methods that
other people should not call.

> I thought it was an overload but after reading a bit it does not look
> like this.  Overload dont seem to use an underscore as a valid
> operator.  The only code I could find in my Camel book is the "use
> fields" page 846 of third edition.  But in this code, it does not have
> shift, it has only the object ref:
> 
> $rock->{_Pet_pid} = 1234; #private attribute
> 
> I have not found documentation about private attributes either.

Perl (or rather, the common implementation of Perl objects as blessed
hashrefs) doesn't support the notion of 'private attributes'. Again, a
leading underscore is used to indicate to the reader that this attribute
should not be tampered with.

> Question 2:
> In this line:
> sub date                { shift->_date_header('Date',
> @_); }
> Is the shift representing the first argument of the array @_ from the
> inheritance?

Yes. In a method call the first argument will be the object or class the
method is invoked on.

Ben

-- 
It will be seen that the Erwhonians are a meek and long-suffering people,
easily led by the nose, and quick to offer up common sense at the shrine of
logic, when a philosopher convinces them that their institutions are not based 
on the strictest morality.  [Samuel Butler, paraphrased]       ben@morrow.me.uk


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

Date: Fri, 20 Jun 2008 13:58:38 -0700 (PDT)
From: gauthier@holnx2.dyndns.org
Subject: Re: How do you call the part with the underscore in this  shift->_date_header('Date',@_)
Message-Id: <936675c8-4a3c-4799-91aa-bb1d663cd1cb@8g2000hse.googlegroups.com>

After reading your replies, it became so clear that I was frustrated I
did not get it by myself.

Thanks to all.


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

Date: Fri, 20 Jun 2008 12:36:46 -0700
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: How do you call the part with the underscore in this shift->_date_header('Date',@_)
Message-Id: <200620081236464141%jimsgibson@gmail.com>

In article
<73e68d9c-b43b-4b8a-a86b-8c6dabce29bc@k30g2000hse.googlegroups.com>,
<gauthier@holnx2.dyndns.org> wrote:

> Looking into HTTP::Headers.pm, I am trying to understand what does the
> underscore in line 267 mean.
> 
> sub date { shift->_date_header('Date',@_); }

It is part of the name '_date_header'. The "public" object method
'date' calls the "private" object method _date_header, passing it the
same argument list. The first argument to date is the object reference,
which is shifted off the front of the array @_. The remaining arguments
in @_ are passed to _date_header.

Putting an underscore at the beginning of a method name is a common way
of differentiating private methods, which should not be called from
outside the module, to public ones that can be called. Perl doesn't
have the concept of public and private methods, so authors use a
convention like this to indicate which methods are "public" and which
"private".

-- 
Jim Gibson


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

Date: Fri, 20 Jun 2008 13:12:32 -0700
From: "Gordon Corbin Etly" <g....c.e@gmail.com>
Subject: Re: Learning Perl
Message-Id: <6c2h9iF3esb0hU1@mid.individual.net>

Uri Guttman wrote:
>>>>>> "JC" == Jim Cochrane <allergic-to-spam@no-spam-allowed.org>
>>>>>> writes:
> > On 2008-06-19, Jim Cochrane <allergic-to-spam@no-spam-allowed.org>
> > wrote:
> > > On 2008-06-18, Gordon Corbin Etly <g> wrote:
> > > > Uri Guttman wrote:
> > > >>>>>>> "GCE" == Gordon Corbin Etly <g....c.e@gmail.com> writes:
> > > > > > Uri Guttman wrote:
> > > > > >>>>>>> "GCE" == Gordon Corbin Etly <g....c.e@gmail.com> 
> > > > > >>>>>>> writes:

Just wondering, why do you use the '"ABC" == "Full Name"' declaraction 
but not actually use it? Not hurting anything but seems odd.


> > > > > > > see you don't get it. it isn't broken behavior but 
> > > > > > > behavior
> > > > > > > that shouldn't have been there to begin with. like my $x =
> > > > > > > 1 if 0 stuff which does something that was bad but not
> > > > > > > deprecated until recently.

> > > > > > I do get it. Maybe tell nose thumbing would allow us to
> > > > > >  understand each other better.

> > > > > huh?? and you don't get it. otherwise you wouldn't have been
> > > > > defending the undefensible for so long. and i don't get that
> > > > > you even acknowledge you were wrong about it.

> > > > ...
> > > >
> > > > I wasn't really disputing the documentation, though; I just feel
> > > > it can be useful to test weather an array or hash has been given
> > > > a value since it's inception, or if it has been run through the
> > > > undef() function. I can thing of a few scenarios where it maybe
> > > > be useful to able to check for such a state separately from
> > > > being just empty, much like one might test for undef vs. 0 or 
> > > > "".

> > > What do you mean by "given a value"?  Do you mean "has memory for
> > > the array [or hash] been allocated?"?
> > >
> > > If so, when you that knowledge be useful in a program?

> > Ugh - correction:

> > If so, when do you think that knowledge would be useful in a 
> > program?

> i will be amazed and dazzled if he comes up with a use that all of p5p
> and thousands of experienced perl hackers never thought of
> before.

In all honest I cannot think of a real word example, and I don't believe 
I claimed one before. I just thought there could be situations (like 
some complex class) where it needs to be known if any array or hash has 
been initialized, but after taking some time to really think about it, 
it indeed seems like a useless function, as all you really need to know 
is if it contains anything.


> considering that defined and undef are scalar concepts and
> always have been, any use for them on aggregated is beyond our mortal
> comprehension.

This has become quite clear to me after having sat and gone over it a 
bit. It comes to show there can be times when you feel something seems 
so right and no one agrees and them bam, you suddenly see the light, 
it's a nice feeling :)  (I just wish you could of gotten your point 
across in more pleasant terms, but we arrived in the right place, so 
that's what really matters.)


-- 
G. C. Etly 




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

Date: Fri, 20 Jun 2008 11:24:11 -0700
From: "Waylen Gumbal" <wgumgfy@gmail.com>
Subject: Re: Perl DBI Module: SQL query where there is space in field name
Message-Id: <6c2aucF3elc1rU1@mid.individual.net>

Martijn Lievaart wrote:
> On Thu, 12 Jun 2008 01:21:58 -0700, Waylen Gumbal wrote:
>
> > What you both are demonstrating is the core constant problem on
> > Usenet: failing to communicate; failing to even attempt to
> > understand the other person's point of view. I see people like you
> > respond to people like DeFaria (people who you obviously consider to
> > be inferior) and display a complete inability to see past your own
> > views, and thus you have a never ending fight between the academia
> > types and the more every day types.
>
> FWIW,
>
> I actually tried to communicate with DeFaria. Being on usenet for
> about 20 years I think of myself as kind of a veteran and I hope I
> learned some communication skills in the meantime, especially on
> usenet.
>
> But communication with DeFaria is impossible.
>
> This group should be gentler with newbies, better at assuming someone
> didn't exactly mean what they said. And as communication on usenet and
> communication about programming languages are both tricky, they should
> learn the newbie how to communicate.
>
> And everyone should learn for themselves. How do my preconceptions
> stand in the way of effective communication. Are we turning into an
> inbred group?
>
> But you picked the complete wrong example. DeFaria is hopeless.
> Whatever communication deficiency this group has, DeFaria has it ten
> times over. Don't waste any time on him. Don't use him as an example.

I didn't realize it was so extensive with him. I meant my point in a 
more generalist way, and having gone to google groups and reading up on 
past threads, it seems the initial catalyst was still a communication 
gap, on both sides.

That said, I understand all the frustrations with him and similar 
people, and I understand your points. Thank you for pointing where I was 
in error.

-wg 




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

Date: Fri, 20 Jun 2008 22:26:40 +0200
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: Perl Script
Message-Id: <pan.2008.06.20.20.26.40@rtij.nl.invlalid>

On Fri, 20 Jun 2008 11:34:01 -0500, Ted Zlatanov wrote:

> ML> I agree with your reasoning, except it may introduce another risk.
> If the ML> SSN is just used for an check, so you check it against a
> known record, ML> OK, no problem. But if you use it as a search key,
> there may be a hash ML> collision.
> 
> SHA-1 is 160 bits vs. 128 for MD5, so using SHA-1 would definitely avoid
> collisions.  I'm 99% sure there's no MD5 collisions either for USA-style
> SSNs, which are currently 9 decimal digits and thus will fit in 30 bits.
> Even at 10 digits (which may happen some day), it's just 33 bits.

The fun part about a cryptographic secure hash is that you cannot predict 
this. The chance of two documents hashing to the same value is very 
small, but not zero.

The function of a cryptographic hash is that is is very, very difficult 
to come up with another document that hashes to the same document as the 
one you want to forge.

But whether there are collisions in this particular key space? You cannot 
tell. You are 99% sure. So am I. But it doesn't matter if it's 99% or 1%, 
if it is not 100%, it's not usable as a search key. 

> On the other hand, this means that without some kind of global or local
> salt, every SSN can easily be obtained from the hashed value if one only
> precomputes the table of SSN to MD5 or SHA-1 hashes.

There is that. Very good point! The key space is not that large that a 
brute force without precomputation cannot be ruled out either.

M4


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

Date: Fri, 20 Jun 2008 14:27:23 -0400
From: smallpond <smallpond@juno.com>
Subject: Re: Print Spanish characters in Perl?
Message-Id: <9b729$485bf699$28658@news.teranews.com>

  wrote:
> Bill H <bill@ts1000.us> wrote:
>> On Jun 20, 12:37 am, Jürgen Exner <jurge...@hotmail.com> wrote:
>>> DanB <dbxxxx...@yahoo.com> wrote:
>>>> I am trying to build a set of Spanish flash cards using TK, and I need to
>>>> be able to display the accented characters.  I know that I need to specify
>>>> them in some unicode besides utf-8,
>>> Actually, you don't. Just put them into your code in your favourite
>>> editor and treat them like any ASCII character.
>>>
>>> A problems arise only if your editor saves the file in a different
>>> encoding then your display device expects. Typical examples are e.g.
>>> saving as UTF-8, then including the text in an HTML page but forgetting
>>> to specify UTF-8 as charset. In this case the browser defaults to
>>> ISO-Latin-1 and the non-ASCII characters will be messed up, of course.
>>> Or saving the file as Windows-1252 (or ISO-Latin-1) and then viewing the
>>> output in a DOS Window which for western languages uses OEM CP 850.
>> I know if I am writing some code using Edit.com (yes dos - can't get
>> away from the simplicity of it) I can add the foriegn language
>> characters to my programs just using the ALT+0??? code and it works
>> fine. I haven't tried doing it in a windows based editor.
> 
> Oh, now that you mention it, maybe the OP wasn't asking about how to
> correctly print/display non-ASCII characters from his Perl program but
> about how to enter them on his keyboard in the editor. Two very
> different things.
> The easiest way would be to switch the keyboard into Spanish mode. How
> to do that depends on your OS. 
> If you have to type text in multiple different languages frequently you
> might want to check out those keyboards that have little LCDs on the
> keys, which change to actually match the national layout for the current
> keyboard mode.
> 
> jue


OP is running Linux.  I've found it easiest in that environment to run
KCharSelect and copy/paste into the document.

Adiós


** Posted from http://www.teranews.com **


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

Date: Fri, 20 Jun 2008 12:32:39 -0700 (PDT)
From: aquadoll <samikr@gmail.com>
Subject: Re: Substituting in a group
Message-Id: <cfde9365-554e-4ff7-a897-a1f39f8aaabf@x19g2000prg.googlegroups.com>

On Jun 20, 12:01=A0pm, Willem <wil...@stack.nl> wrote:
> Willem wrote:
>
> ) while (s/(")(.*?)"/$2/) { substr($_,$+[1]-1,$+[2]-$+[1]) =3D~ s/,/#/g }
>
> Of course,
> =A0 while (s/"(.*?)"/$1/) { substr($_,$-[1]-1,$+[1]-$-[1]) =3D~ s/,/#/g }
> is slightly easier.
>
> SaSW, Willem
> --
> Disclaimer: I am in no way responsible for any of the statements
> =A0 =A0 =A0 =A0 =A0 =A0 made in the above text. For all I know I might be
> =A0 =A0 =A0 =A0 =A0 =A0 drugged or something..
> =A0 =A0 =A0 =A0 =A0 =A0 No I'm not paranoid. You all think I'm paranoid, =
don't you !
> #EOT

Thanks for the great discussion - I learnt a few things.
One last question: what does $ and [1] stands for in the above post in
"$-[1]-1"? Where can I find more about that in perldoc?


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

Date: Fri, 20 Jun 2008 12:39:44 -0700 (PDT)
From: aquadoll <samikr@gmail.com>
Subject: Re: Substituting in a group
Message-Id: <e8d43592-4f1f-48b3-9a77-32104d35dc44@a32g2000prf.googlegroups.com>

On Jun 20, 12:01=A0pm, Willem <wil...@stack.nl> wrote:
> Willem wrote:
>
> ) while (s/(")(.*?)"/$2/) { substr($_,$+[1]-1,$+[2]-$+[1]) =3D~ s/,/#/g }
>
> Of course,
> =A0 while (s/"(.*?)"/$1/) { substr($_,$-[1]-1,$+[1]-$-[1]) =3D~ s/,/#/g }
> is slightly easier.
>
> SaSW, Willem
> --
> Disclaimer: I am in no way responsible for any of the statements
> =A0 =A0 =A0 =A0 =A0 =A0 made in the above text. For all I know I might be
> =A0 =A0 =A0 =A0 =A0 =A0 drugged or something..
> =A0 =A0 =A0 =A0 =A0 =A0 No I'm not paranoid. You all think I'm paranoid, =
don't you !
> #EOT

Found it here: http://perldoc.perl.org/perlvar.html#%40-


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

Date: Fri, 20 Jun 2008 20:37:03 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Substituting in a group
Message-Id: <vfdti5-nlk.ln1@osiris.mauzo.dyndns.org>


Quoth aquadoll <samikr@gmail.com>:
> 
> One last question: what does $ and [1] stands for in the above post in
> "$-[1]-1"? Where can I find more about that in perldoc?

$-[1] is the second element of the array @-, which is documented in
perlvar. The syntax is exactly the same as for $a[1] or any other array.

Ben

-- 
        I must not fear. Fear is the mind-killer. I will face my fear and
        I will let it pass through me. When the fear is gone there will be 
        nothing. Only I will remain.
ben@morrow.me.uk                                          Frank Herbert, 'Dune'


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

Date: Fri, 20 Jun 2008 21:25:06 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Substituting in a group
Message-Id: <SeV6k.301$yg7.108@edtnps82>

Willem wrote:
> Willem wrote:
> ) while (s/(")(.*?)"/$2/) { substr($_,$+[1]-1,$+[2]-$+[1]) =~ s/,/#/g }
> 
> Of course,
>   while (s/"(.*?)"/$1/) { substr($_,$-[1]-1,$+[1]-$-[1]) =~ s/,/#/g }
> is slightly easier.

Or use a statement modifier:

substr( $_, $-[1] - 1, $+[1] - $-[1] ) =~ s/,/#/g while s/"(.*?)"/$1/;

Or maybe:

/".*?"/ and substr( $_, $-[0], $+[0] - $-[0] ) =~ tr/,"/#/d;

And avoid using the substitution operator or capturing parentheses.


John
-- 
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 V11 Issue 1664
***************************************


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