[28469] in Perl-Users-Digest
Perl-Users Digest, Issue: 9833 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 11 14:05:53 2006
Date: Wed, 11 Oct 2006 11:05:06 -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 Wed, 11 Oct 2006 Volume: 10 Number: 9833
Today's topics:
Re: [META] LWP and Unicode <rvtol+news@isolution.nl>
Re: Can I call Perl module from TCL or vice versa? (reading news)
Re: Can I call Perl module from TCL or vice versa? <mark.clementsREMOVETHIS@wanadoo.fr>
Re: Can I call Perl module from TCL or vice versa? <mark.clementsREMOVETHIS@wanadoo.fr>
Filtering duplicates out of an array <bigus@abdcdefghijk.com>
Re: Filtering duplicates out of an array <someone@example.com>
Re: Filtering duplicates out of an array <bigus@abdcdefghijk.com>
Re: Filtering duplicates out of an array <bigus@abdcdefghijk.com>
Re: Firefox Won't Execute My Perl Script <mgarrish@gmail.com>
Re: Firefox Won't Execute My Perl Script <sherm@Sherm-Pendleys-Computer.local>
Re: Firefox Won't Execute My Perl Script <peace.is.our.profession@gmx.de>
Re: IO::Prompt with Keymap <dale.gerdemann@googlemail.com>
Re: LWP and Unicode <hjp-usenet2@hjp.at>
Re: Perl ActiveX: A VBA string passed to my control is <rvtol+news@isolution.nl>
Re: Perl Async .10 <toddenglish@gmail.com>
replace variable with same variable <wireless200@gmail.com>
Re: replace variable with same variable <bart@nijlen.com>
Re: replace variable with same variable <bik.mido@tiscalinet.it>
Re: replace variable with same variable <someone@example.com>
Re: replace variable with same variable <mritty@gmail.com>
Re: replace variable with same variable <bart@nijlen.com>
Re: replace variable with same variable <uri@stemsystems.com>
Re: Running scripts on the Exceed usenet@DavidFilmer.com
Re: Running scripts on the Exceed <peretz.eyal@gmail.com>
Re: Running scripts on the Exceed usenet@DavidFilmer.com
split html file steeve_dun@SoftHome.net
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 11 Oct 2006 09:37:53 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: [META] LWP and Unicode
Message-Id: <egie9b.1f8.1@news.isolution.nl>
Ben Morrow schreef:
> Peter J. Holzer:
>> MIME is current practice on usenet.
>
> Really??? I was under the impression it was considered rude.
I consider MIME is very much accepted. (And your "?"-key broken. :)
No doubt MIME is considered rude by some. As are articles in non-ASCII
without a declaring (MIME) Content-Type header field.
Nobody likes illegible or damaged messages.
> [UTF-8]
> I can't read it: I get either lots of squares or sometimes (not
> sure why) lots of question marks.
The squares point to missing characters in the current font.
Question marks are used for character codes that don't exist in the
locale of the text display.
> I don't know if this is what you mean by
> 'cause problems', but I am much less likely to reply to people
> who post requiring understanding of utf8.
Perl 6 has Latin1-alternatives for (most of?) its Unicode dependent
syntax.
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Wed, 11 Oct 2006 08:13:50 GMT
From: "Mumia W. (reading news)" <paduille.4059.mumia.w@earthlink.net>
Subject: Re: Can I call Perl module from TCL or vice versa?
Message-Id: <2J1Xg.10012$o71.6950@newsread3.news.pas.earthlink.net>
On 10/11/2006 01:44 AM, AD wrote:
> Mumia W. (reading news) wrote:
>> On 10/10/2006 10:51 PM, AD wrote:
>>> Hi,
>>>
>>> Can anyone tell whether its possible to call perl module from TCL or
>>> tcl module from Perl?
>>>
>>> Thanks,
>>>
>>> Amit Dixit
>>>
>> You can call a Perl *program* from TCL and vise versa. Using modules is
>> more difficult. The perl module "Tcl" will allow you to write TCL code
>> in the middle of a perl program.
>>
>> http://search.cpan.org/search?query=Tcl&mode=module
>>
>>
>> HTH
>>
>>
> Thanks,
> I tried that but say suppose I have created a package in TCL and I want
> that to be called from Perl will that be possible? If yes then How?
>
You're welcome. Please bottom-post in this newsgroup. It's not possible
to directly use TCL packages in perl. You could create a TCL program
that uses the TCL package, and you could invoke the TCL program, however.
--
Mumia W.
paduille.4059.mumia.w@earthlink.net
This is a temporary e-mail to help me catch some s-p*á/m.
------------------------------
Date: Wed, 11 Oct 2006 11:23:58 +0200
From: Mark Clements <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: Can I call Perl module from TCL or vice versa?
Message-Id: <452cb829$0$5072$ba4acef3@news.orange.fr>
Mumia W. (reading news) wrote:
> On 10/11/2006 01:44 AM, AD wrote:
>> Thanks,
>> I tried that but say suppose I have created a package in TCL and I want
>> that to be called from Perl will that be possible? If yes then How?
>>
>
> You're welcome. Please bottom-post in this newsgroup. It's not possible
> to directly use TCL packages in perl. You could create a TCL program
> that uses the TCL package, and you could invoke the TCL program, however.
>
Inline::TCL?
------------------------------
Date: Wed, 11 Oct 2006 11:33:00 +0200
From: Mark Clements <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: Can I call Perl module from TCL or vice versa?
Message-Id: <452cba48$0$25937$ba4acef3@news.orange.fr>
Mark Clements wrote:
> Mumia W. (reading news) wrote:
>> On 10/11/2006 01:44 AM, AD wrote:
>>> Thanks,
>>> I tried that but say suppose I have created a package in TCL and I want
>>> that to be called from Perl will that be possible? If yes then How?
>>>
>>
>> You're welcome. Please bottom-post in this newsgroup. It's not
>> possible to directly use TCL packages in perl. You could create a TCL
>> program that uses the TCL package, and you could invoke the TCL
>> program, however.
>>
>
> Inline::TCL?
sorry - Inline::Tcl.
------------------------------
Date: Wed, 11 Oct 2006 11:04:25 +0100
From: "Bigus" <bigus@abdcdefghijk.com>
Subject: Filtering duplicates out of an array
Message-Id: <egifj9$452$1@south.jnrs.ja.net>
Hi
I have a multidimensional array where each element of the array contains
data like this:
$array[0][0] = 'email@address.com';
$array[0][1] = 'mailer.somewhere.com';
$array[0][2] = 'error message';
There might be more than one element in the array with the same email
address, but where the mailer and error are different. I want to make the
array only contain unique email addresses, ie: filter out duplicate email
addresses.
There's a nice compact one-liner for making non-multidimensional arrays
uniqye, ie:
@array = do {my %h; grep {!$h {$_} ++} @array;
Can that be modified to do what I want?
Thanks
Bigus
------------------------------
Date: Wed, 11 Oct 2006 10:31:16 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Filtering duplicates out of an array
Message-Id: <UJ3Xg.17077$H7.11961@edtnps82>
Bigus wrote:
>
> I have a multidimensional array where each element of the array contains
> data like this:
>
> $array[0][0] = 'email@address.com';
> $array[0][1] = 'mailer.somewhere.com';
> $array[0][2] = 'error message';
>
> There might be more than one element in the array with the same email
> address, but where the mailer and error are different. I want to make the
> array only contain unique email addresses, ie: filter out duplicate email
> addresses.
>
> There's a nice compact one-liner for making non-multidimensional arrays
> uniqye, ie:
>
> @array = do {my %h; grep {!$h {$_} ++} @array;
>
> Can that be modified to do what I want?
@array = do {my %h; grep {!$h {$_->[0]} ++} @array;
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: Wed, 11 Oct 2006 11:47:31 +0100
From: "Bigus" <bigus@abdcdefghijk.com>
Subject: Re: Filtering duplicates out of an array
Message-Id: <egii43$4tb$1@south.jnrs.ja.net>
"John W. Krahn" <someone@example.com> wrote in message
news:UJ3Xg.17077$H7.11961@edtnps82...
>> There's a nice compact one-liner for making non-multidimensional arrays
>> uniqye, ie:
>>
>> @array = do {my %h; grep {!$h {$_} ++} @array;
>>
>> Can that be modified to do what I want?
>
> @array = do {my %h; grep {!$h {$_->[0]} ++} @array;
oh, of course, the reference. doh!
thanks v.much
Bigus
------------------------------
Date: Wed, 11 Oct 2006 13:32:38 +0100
From: "Bigus" <bigus@abdcdefghijk.com>
Subject: Re: Filtering duplicates out of an array
Message-Id: <egio96$6ra$1@south.jnrs.ja.net>
"John W. Krahn" <someone@example.com> wrote in message
news:UJ3Xg.17077$H7.11961@edtnps82...
>> There's a nice compact one-liner for making non-multidimensional arrays
>> uniqye, ie:
>>
>> @array = do {my %h; grep {!$h {$_} ++} @array;
>>
>> Can that be modified to do what I want?
>
> @array = do {my %h; grep {!$h {$_->[0]} ++} @array;
actually, there is a related question - how do you make it case insensitive?
This doesn't work:
@array = do {my %h; grep {!$h {lc($_->[0])} ++} @array;
Bigus
------------------------------
Date: 11 Oct 2006 04:35:51 -0700
From: "Matt Garrish" <mgarrish@gmail.com>
Subject: Re: Firefox Won't Execute My Perl Script
Message-Id: <1160566551.798338.229090@i3g2000cwc.googlegroups.com>
Sherm Pendley wrote:
> robic0 writes:
>
> > On Tue, 10 Oct 2006 03:25:04 GMT, "J=FCrgen Exner" <jurgenex@hotmail.co=
m> wrote:
> >
> >>steve.ziring@gmail.com wrote:
> >>> I have a perl script that executes successfully in MSIE,
> >>
> >>I highly doubt that unless you are talking about Perlscript, a language=
that
> >>is _VERY_ rarely used.
> >>
> >>jue
> >>
> > Hey Jew there must be something that is Perl used heavily in page produ=
ction.
> > Jeez what could it be. Oh well, it must be a fuckin secret........
>
> 'PerlScript' ne 'Perl'. Perl is used heavily. PerlScript - ActiveState's
> Windows Scripting Host support for Perl - is very rarely used.
>
True and not so true. There's actually not that much that you can't do
in PerlScript that you can do in Perl (at least from a Web development
perspective), which is why I use it whenever I have to build ASP pages.
PerlScript is Perl, but adds access to ASP functionality. It kicks the
snot out of VB, even if it's implementation of the ASP model is a
little flaky in places.
Matt
------------------------------
Date: Wed, 11 Oct 2006 10:36:27 -0400
From: Sherm Pendley <sherm@Sherm-Pendleys-Computer.local>
Subject: Re: Firefox Won't Execute My Perl Script
Message-Id: <m2mz82vs0k.fsf@Sherm-Pendleys-Computer.local>
"Matt Garrish" <mgarrish@gmail.com> writes:
> Sherm Pendley wrote:
>> robic0 writes:
>>
>> > On Tue, 10 Oct 2006 03:25:04 GMT, "Jürgen Exner" <jurgenex@hotmail.com> wrote:
>> >
>> >>steve.ziring@gmail.com wrote:
>> >>> I have a perl script that executes successfully in MSIE,
>> >>
>> >>I highly doubt that unless you are talking about Perlscript, a language that
>> >>is _VERY_ rarely used.
>> >>
>> >>jue
>> >>
>> > Hey Jew there must be something that is Perl used heavily in page production.
>> > Jeez what could it be. Oh well, it must be a fuckin secret........
>>
>> 'PerlScript' ne 'Perl'. Perl is used heavily. PerlScript - ActiveState's
>> Windows Scripting Host support for Perl - is very rarely used.
>>
>
> True and not so true. There's actually not that much that you can't do
> in PerlScript that you can do in Perl (at least from a Web development
> perspective), which is why I use it whenever I have to build ASP pages.
'very rarely' ne 'never'. :-)
> PerlScript is Perl, but adds access to ASP functionality.
Not just ASP. You can also use it in client-side <script> elements - if,
that is, the client is IE and ActiveState's Perl is installed on the client.
It's the client-side use of PerlScript that Jürgen was talking about, and
it's as rare as honest politicians.
Robic0 took Jürgen's statement as saying that *Perl itself* is rarely used.
I guess he just can't resist an opportunity to make a fool of himself in
public.
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: Wed, 11 Oct 2006 17:24:17 +0200
From: Mirco Wahab <peace.is.our.profession@gmx.de>
Subject: Re: Firefox Won't Execute My Perl Script
Message-Id: <egj2iv$8f7$1@mlucom4.urz.uni-halle.de>
Thus spoke Sherm Pendley (on 2006-10-11 16:36):
> "Matt Garrish" <mgarrish@gmail.com> writes:
>> Sherm Pendley wrote:
>>> robic0 writes:
>>> > Hey Jew there must be something that is Perl used heavily in page production.
>>> > Jeez what could it be. Oh well, it must be a fuckin secret........
>>> 'PerlScript' ne 'Perl'. Perl is used heavily. PerlScript - ActiveState's
>>> Windows Scripting Host support for Perl - is very rarely used.
>> True and not so true. ...
>
> 'very rarely' ne 'never'. :-)
> ...
> Robic0 took Jürgen's statement as saying that *Perl itself* is rarely used.
> I guess he just can't resist an opportunity to make a fool of himself in
> public.
Maybe there's still some truth in it
(aehm, I mean - "with the Perl usage"),
in a sense that Perl lives by a bunch
of clever guys and it will die with them,
-- like the swords in warfare died with
the men who lived by them ...
Regards
Mirco
------------------------------
Date: 11 Oct 2006 00:09:38 -0700
From: "Dale" <dale.gerdemann@googlemail.com>
Subject: Re: IO::Prompt with Keymap
Message-Id: <1160550578.622970.124800@e3g2000cwe.googlegroups.com>
anno4000@radom.zrz.tu-berlin.de wrote:
> Use a hash instead of nested ?:
A hash is, I suppose, better. But my real concern was that I had to
hack a new version of IO::Prompt. Would there be any way to use
IO::Prompt (or a similar module) as is, and still apply a special
keymap?
Dale
------------------------------
Date: Wed, 11 Oct 2006 18:39:29 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: LWP and Unicode
Message-Id: <slrneiq7i1.946.hjp-usenet2@yoyo.hjp.at>
On 2006-10-11 03:03, Ben Morrow <benmorrow@tiscali.co.uk> wrote:
> Quoth "Peter J. Holzer" <hjp-usenet2@hjp.at>:
>> On 2006-10-10 18:15, JÃŒrgen Exner <jurgenex@hotmail.com> wrote:
>> > Ted Zlatanov wrote:
>> >> On 6 Oct 2006, benmorrow@tiscali.co.uk wrote:
>> >>> It's not a question of this group's charter, it applies generally on
>> >>> Usenet. There is no header in a Usenet article that specifies a
>> >>> charset, so no way to use anything other than the default ASCII.
>>
>> Content-Type: text/plain; charset=...
>>
>> Introduced in RFC 1341 (June 1992). It is true that RFC 1036 was never
>> updated, but MIME is current practice on usenet.
>
> Really??? I was under the impression it was considered rude.
If it is, then most posters in this group are rude (well, some people
think this is the case even without MIME :-)).
I have currently 2805 messages from this group in my spool, 1954 of
which (70%) are MIME messages. Of these, about 1400 use ISO-8859-1,
about 400 use US-ASCII, about 70 UTF-8, and about 30 ISO-8859-15.
MIME is really a rather generic framework for encapsulating (almost)
arbitrary content into RFC-822 messages. Among other things it provides
for are hierarchically structured multipart messages where each part can
have a different type (commonly called "attachments"), declaration of
charsets used in the body and some headers, and transfer encodings to
cope with non-8bit-clean transports.
Of these, only charset declarations are (AFAIK) widely used on usenet:
Multipart messages are not needed (except maybe in binary groups, but
even there uuencode and yenc are preferred), because usenet messages
usually contain only plain text - other text formats (like HTML) never
caught on.
Transfer encodings aren't needed because NNTP is in practice 8bit clean.
The charset parameter is needed whenever a message contains non-ASCII
characters. This is of course frequently the case when the language
isn't English, but it also happens in English - for example in names (I
notice your newsreader butchered Jürgen's name in the attribution line)
or because the topic of the conversation is about something which isn't
easy to express in US-ASCII (for example, unicode problems are a
frequent topic in this newsgroup). So a newsreader may not need to
support all 5 MIME RFCs, but if it doesn't at least support text/plain
with the most frequent charsets and RFC 2047, it's at least a bit of a
pain.
>> >>> I agree in principle: some form of charset header should be added, or
>> >>> the charset should simply be specified to be UTF8. But until it is,
>> >>> please refrain from using it.
>> >>
>> >> So there are really two questions:
>> >>
>> >> 1) are there any newsreaders that would cause problems when they found
>> >> UTF-8 encoded text?
>
> I can't read it: I get either lots of squares or sometimes (not sure
> why) lots of question marks. I don't know if this is what you mean by
> 'cause problems',
As I understood Ted he was talking about more serious problems than an
occasional unreadable character: Crashes of the Newsreader and/or the
terminal (or - more likely these days - the graphics subsystem of the
OS). I would also consider it a serious problem if the first appearance
of a UTF-8 character garbles the rest of the line or even the article.
Garbling the subject line is also bad (and depressingly frequent), but
not much of a problem in this group, because the subject is usually a
short English phrase and therefore unlikely to contain non-ascii
characters.
hp
--
_ | Peter J. Holzer | > Wieso sollte man etwas erfinden was nicht
|_|_) | Sysadmin WSR | > ist?
| | | hjp@hjp.at | Was sonst wäre der Sinn des Erfindens?
__/ | http://www.hjp.at/ | -- P. Einstein u. V. Gringmuth in desd
------------------------------
Date: Wed, 11 Oct 2006 10:24:36 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Perl ActiveX: A VBA string passed to my control is treated as a doubel-quoted string
Message-Id: <egigvq.1h0.1@news.isolution.nl>
david.f.jenkins@usa.net schreef:
> Over the evening, I discovered this: I have unnecessarily compounded
> the problem by writing some Perl calls and using double-quoted
> strings. Because of interpolation, I was misled into thnking that
> the calls from VBA were being treated similarly.
And that is (one of the reasons of) why you should only post here with
short-but-complete code. Help yourself before asking others. While
creating that short-but-complete code, you will often pinpoint the
problem, and learn a lot.
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: 11 Oct 2006 08:33:13 -0700
From: "Todd English" <toddenglish@gmail.com>
Subject: Re: Perl Async .10
Message-Id: <1160580793.761460.11710@m7g2000cwm.googlegroups.com>
> > My original post on this topic apparently never showed up. The problem
> > seems to come from the "kill 9,..." in Async's sub DESTROY. An Async child
> > will inherit a copy of the objects to all of its older siblings from the
> > parent. When the child exits, it will kill all of it's older siblings.
> > Thus the program only works correctly if the children terminate in the same
> > order that they began, so that a younger child never has an extent older
> > sibling to kill out of order.
>
> Oh, of course! Thats explains the erratic behavior.
>
> > I have no idea why the kill is there, and getting rid of it makes the
> > problem go away.
>
> If at all, only the main process should do it.
I'm sorry that I didn't get a chance to reply to this sooner. I really
appreciate all of the help I received from this group. Thank you.
I would like to submit a patch to the author of the async module and
was hoping some of you might give it a quick once over to make sure my
changes are sane. I also thought that it wouldn't be a bad idea to post
a patch for the next newb who finds this problem just in case the
modules maintainer (Mark Jason Dominus) doesn't fix the problem (I
still haven't heard back from him).
Thank you again for all of your help,
Todd English
-----------------Begin Diff--------------------
--- ../../Async-0.10/Async.pm 2000-01-26 22:50:28.000000000 +0000
+++ ./Async.pm 2006-10-06 11:40:21.000000000 +0000
@@ -25,6 +25,7 @@
};
bless $self => $pack;
} else { # child
+ select((select($w), $|=1)[0]);
close $r;
my $result = $task->();
print $w $result;
@@ -32,7 +33,7 @@
}
}
-# return true iff async process is complete
+# return true if async process is complete
# with true `$force' argmuent, wait until process is complete before
returning
sub ready {
my ($self, $force) = @_;
@@ -43,7 +44,7 @@
vec($fdset, $self->{FD}, 1) = 1;
while (select($fdset, undef, undef, $timeout)) {
my $buf;
- my $nr = read $self->{PIPE}, $buf, 8192;
+ my $nr = sysread $self->{PIPE}, $buf, 8192;
if ($nr) {
$self->{DATA} .= $buf;
} elsif (defined $nr) { # EOF
@@ -61,7 +62,11 @@
# Return error message if an error occurred
# Return false if no error occurred
sub error {
- $_[0]{ERROR};
+ my $ret = $_[0]{ERROR};
+ if($ret){
+ $self->async_close();
+ }
+ return $ret;
}
# Return resulting data if async process is complete
@@ -69,21 +74,28 @@
# a true $force argument waits for the process to complete before
returning
sub result {
my ($self, $force) = @_;
+ my $ret;
if ($self->{FINISHED}) {
- $self->{DATA};
+ $ret = $self->{DATA};
} elsif ($force) {
$self->ready('force completion');
- $self->{DATA};
- } else {
- return;
+ $ret = $self->{DATA};
}
+ if($ret){
+ $self->async_close();
+ }
+ return $ret;
}
-sub DESTROY {
- my ($self) = @_;
- my $pid = $self->{PID};
- kill 9 => $pid; # I don't care.
- waitpid($pid, 0);
+sub async_close {
+ my ($self) = @_;
+ if( defined( $self->{PID} ) && $self->{PID} != getppid() ) {
+ $pid = $self->{PID};
+ kill 9 => $pid;
+ waitpid( $pid, 0 );
+ } else {
+ wait();
+ }
}
package AsyncTimeout;
@@ -123,9 +135,18 @@
sub result {
require Storable;
+ my $ret;
my $self = shift;
my $rc = $self->SUPER::result(@_);
- return defined $rc ? Storable::thaw($rc) : $rc;
+ if( defined $rc ){
+ $ret = Storable::thaw($rc);
+ }
+ else{
+ $ret = $rc;
+ }
+
+ $self->async_close();
+ return $ret;
}
1;
------------------------------
Date: 11 Oct 2006 08:48:41 -0700
From: "David" <wireless200@gmail.com>
Subject: replace variable with same variable
Message-Id: <1160581720.964659.85710@m7g2000cwm.googlegroups.com>
I have a perl script where I match on a phrase to add something after
that phrase:
$line=~s/PILOT_INC=4,/PILOT_INC=4, NGHBR_SRCH_MODE = 0,/g;
However, the "4" can be variable, say, anything between 2 and 8.
I'd like to do something like this:
$line=~s/PILOT_INC=\d,/PILOT_INC=\d, NGHBR_SRCH_MODE = 0,/g;
Of course this won't work.
Do I need to first save the number into a variable and then put that
variable into the regex replace phrase or can it be done within the
global search and replace regex line above?
regards, David
------------------------------
Date: 11 Oct 2006 08:56:25 -0700
From: "Bart Van der Donck" <bart@nijlen.com>
Subject: Re: replace variable with same variable
Message-Id: <1160582185.932213.68620@c28g2000cwb.googlegroups.com>
David wrote:
> I have a perl script where I match on a phrase to add something after
> that phrase:
> $line=~s/PILOT_INC=4,/PILOT_INC=4, NGHBR_SRCH_MODE = 0,/g;
>
> However, the "4" can be variable, say, anything between 2 and 8.
>
> I'd like to do something like this:
> $line=~s/PILOT_INC=\d,/PILOT_INC=\d, NGHBR_SRCH_MODE = 0,/g;
> Of course this won't work.
#!/perl
use strict;
use warnings;
my $line="PILOT_INC=6,";
$line=~s/PILOT_INC=[2-8],/$& NGHBR_SRCH_MODE = 0,/g;
print $line;
Hope this helps,
--
Bart
------------------------------
Date: 11 Oct 2006 17:57:13 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: replace variable with same variable
Message-Id: <mr4qi2hnd3tm4lbldi3b2r5566n0gmubmn@4ax.com>
On 11 Oct 2006 08:48:41 -0700, "David" <wireless200@gmail.com> wrote:
>Subject: replace variable with same variable
Please put the subject of your post in the Subject line.
>I have a perl script where I match on a phrase to add something after
>that phrase:
>$line=~s/PILOT_INC=4,/PILOT_INC=4, NGHBR_SRCH_MODE = 0,/g;
>
>However, the "4" can be variable, say, anything between 2 and 8.
How 'bout [2-8]?
>I'd like to do something like this:
>$line=~s/PILOT_INC=\d,/PILOT_INC=\d, NGHBR_SRCH_MODE = 0,/g;
>Of course this won't work.
>
>Do I need to first save the number into a variable and then put that
>variable into the regex replace phrase or can it be done within the
>global search and replace regex line above?
You want the numbered variables associated with capturing parens. Read
more about them in perldoc perlre.
HTH,
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Wed, 11 Oct 2006 16:20:38 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: replace variable with same variable
Message-Id: <qR8Xg.5591$P7.3209@edtnps90>
David wrote:
> I have a perl script where I match on a phrase to add something after
> that phrase:
> $line=~s/PILOT_INC=4,/PILOT_INC=4, NGHBR_SRCH_MODE = 0,/g;
>
> However, the "4" can be variable, say, anything between 2 and 8.
>
> I'd like to do something like this:
> $line=~s/PILOT_INC=\d,/PILOT_INC=\d, NGHBR_SRCH_MODE = 0,/g;
> Of course this won't work.
>
> Do I need to first save the number into a variable and then put that
> variable into the regex replace phrase or can it be done within the
> global search and replace regex line above?
$line =~ s/(?<=PILOT_INC=[2-8],)/ NGHBR_SRCH_MODE = 0,/g;
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: 11 Oct 2006 10:00:33 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: replace variable with same variable
Message-Id: <1160586032.756810.197990@i42g2000cwa.googlegroups.com>
Bart Van der Donck wrote:
> David wrote:
>
> > I have a perl script where I match on a phrase to add something after
> > that phrase:
> > $line=~s/PILOT_INC=4,/PILOT_INC=4, NGHBR_SRCH_MODE = 0,/g;
> >
> > However, the "4" can be variable, say, anything between 2 and 8.
> >
> > I'd like to do something like this:
> > $line=~s/PILOT_INC=\d,/PILOT_INC=\d, NGHBR_SRCH_MODE = 0,/g;
> > Of course this won't work.
>
> #!/perl
> use strict;
> use warnings;
> my $line="PILOT_INC=6,";
> $line=~s/PILOT_INC=[2-8],/$& NGHBR_SRCH_MODE = 0,/g;
> print $line;
Please don't do that. Using the $&, $', and $` variables slow down ALL
regular expressions in the entire program even if you only use any of
them once.
$line =~ /(PILOT_INC=[2-8])/$1 NGHBR_SRCH_MODE = 0,/g;
Paul Lalli
------------------------------
Date: 11 Oct 2006 10:16:48 -0700
From: "Bart Van der Donck" <bart@nijlen.com>
Subject: Re: replace variable with same variable
Message-Id: <1160587008.611034.263060@e3g2000cwe.googlegroups.com>
Paul Lalli wrote:
> Bart Van der Donck wrote:
> > $line=~s/PILOT_INC=[2-8],/$& NGHBR_SRCH_MODE = 0,/g;
>
> Please don't do that. Using the $&, $', and $` variables slow down ALL
> regular expressions in the entire program even if you only use any of
> them once.
>
> $line =~ /(PILOT_INC=[2-8])/$1 NGHBR_SRCH_MODE = 0,/g;
Any idea how many milliseconds will be lost ? :-)
--
Bart
------------------------------
Date: Wed, 11 Oct 2006 13:59:38 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: replace variable with same variable
Message-Id: <x7bqoivilx.fsf@mail.sysarch.com>
>>>>> "BVdD" == Bart Van der Donck <bart@nijlen.com> writes:
BVdD> Paul Lalli wrote:
>> Bart Van der Donck wrote:
>> > $line=~s/PILOT_INC=[2-8],/$& NGHBR_SRCH_MODE = 0,/g;
>>
>> Please don't do that. Using the $&, $', and $` variables slow down ALL
>> regular expressions in the entire program even if you only use any of
>> them once.
>>
>> $line =~ /(PILOT_INC=[2-8])/$1 NGHBR_SRCH_MODE = 0,/g;
BVdD> Any idea how many milliseconds will be lost ? :-)
beyond the slowdown (which will affect every s/// which grabs and each
time they run so it can add up), those vars are implicit while () and $1
are explicit. you can also have multiple $1 grabs but only the 3 parts
of $& and friends. also $& is rarely used (especially by experienced
perl hackers) so it isn't as easily understood by newbies or at first
glance. $1 is much clearer and more uniform. there is actually no need
for $& as it can be done with () and $1. in fact i believe perl6 dropped
those (but then again p6's rules are parsecs beyond p5's regexes).
so use $& as you wish. but most others don't like it and won't use it.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 11 Oct 2006 01:17:12 -0700
From: usenet@DavidFilmer.com
Subject: Re: Running scripts on the Exceed
Message-Id: <1160554632.731827.111290@m73g2000cwd.googlegroups.com>
EZP wrote:
> Hi David,
> can u please right me an example script, let say that the script will
> make the "ls" command
Sure.
#!/usr/bin/perl
use strict; use warnings;
use Net::SSH;
print ssh_cmd( {
host => 'host.name',
command => 'ls',
} );
__END__
--
David Filmer (http://DavidFilmer.com)
------------------------------
Date: 11 Oct 2006 02:45:11 -0700
From: "EZP" <peretz.eyal@gmail.com>
Subject: Re: Running scripts on the Exceed
Message-Id: <1160559911.297695.35790@k70g2000cwa.googlegroups.com>
Thanks a lot David, u r the truly king of perl
again thanks a lot
EZP
------------------------------
Date: 11 Oct 2006 03:15:03 -0700
From: usenet@DavidFilmer.com
Subject: Re: Running scripts on the Exceed
Message-Id: <1160561703.891904.18340@h48g2000cwc.googlegroups.com>
EZP wrote:
> Thanks a lot David, u r the truly king of perl
Actually, I'm the court jester (fool) of Perl. But even the court
jester has a couple of good tricks.
Good luck.
--
David Filmer (http://DavidFilmer.com)
------------------------------
Date: 11 Oct 2006 03:15:27 -0700
From: steeve_dun@SoftHome.net
Subject: split html file
Message-Id: <1160561727.036518.21430@m7g2000cwm.googlegroups.com>
Hi,
What I want is to cut/split a html file into several html files, each
time it meets a defined sting.
Is there a HTML package to do so. Because, it must deal with opened
tags.
Example:
***********************************
<html>
<body>
A B
<div class="mydiv">
C D
[cut_here]
E F
</div>
G H
</body>
</html>
***********************************
to get 2 files : 1.html
*****************
<html>
<body>
A B
<div class="mydiv">
C D
</div>
</body>
</html>
*****************
and 2.html
*****************
<html>
<body>
<div class="mydiv">
E F
</div>
G H
</body>
</html>
*****************
Thank you
-steeve.
------------------------------
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 V10 Issue 9833
***************************************