[28312] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9676 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 2 14:05:48 2006

Date: Sat, 2 Sep 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           Sat, 2 Sep 2006     Volume: 10 Number: 9676

Today's topics:
        3 problems with perl. <nimrodna@bgu.ac.il>
    Re: 3 problems with perl. <nobull67@gmail.com>
    Re: Can I monitor the execution of a perl script <nobull67@gmail.com>
    Re: Creating a subset of a hash? <rvtol+news@isolution.nl>
    Re: lwp and utf8 characters <mgarrish@gmail.com>
        What's wrong with my installation <michaelnx@gmail.com>
    Re: What's wrong with my installation <michaelnx@gmail.com>
    Re: What's wrong with my installation <my_email@no_spam.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 2 Sep 2006 10:35:19 -0700
From: "nimrodna" <nimrodna@bgu.ac.il>
Subject: 3 problems with perl.
Message-Id: <1157218519.413695.238940@i42g2000cwa.googlegroups.com>

1. , I'm having problem with balanced parenthesis. I found this code in
the net:
my $paren = qr/\(([^()]+|(??{ $paren }))*\)/x;
This code supposes to handle my problem.
I'm working with perl 5.8, and it won't compile.
The error message is: "Global symbol "$paren" requires explicit package
name at (re_eval 1) line 2.".

2. How can I Use constants and variables inside a substitute operator
(s///).

3. Manipulate matched chars. When matched a number I need to add the
same value to each matched chararcter.



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

Date: 2 Sep 2006 10:58:02 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: 3 problems with perl.
Message-Id: <1157219882.431247.183980@p79g2000cwp.googlegroups.com>


nimrodna wrote:

> Subject: 3 problems with perl.

Please put the subject of your post in the Subject of your post.

If you have 3 separate subjects, make 3 separate posts.

> 1. , I'm having problem with balanced parenthesis.

>Are you?

How is that relevant?

> I found this code in
> the net:
> my $paren = qr/\(([^()]+|(??{ $paren }))*\)/x;
> This code supposes to handle my problem.

Appart from the suprious my() this same code can be found in "perlre"
the section  of the Perl on-line documentation that covers regular
expressions.

> I'm working with perl 5.8, and it won't compile.
> The error message is: "Global symbol "$paren" requires explicit package
> name at (re_eval 1) line 2.".

That's right. Lexically scoped variable declarations apply from the
point after declaration statement to the end of the lexical scope.  You
cannot refer to the variable _within_ the statement in which it is
declared.

Note also that (??{ ... }) blocks suffer from the same problem as
nested subroutines with respect to lexical variables.  (See perldiag's
explaination of the "will not remain shared" warning).

Avoid this by using only package variables when communicating with
(??{...}) blocks.

local our $paren;
$paren = qr/\(([^()]+|(??{ $paren }))*\)/x;

> 2. How can I Use constants and variables inside a substitute operator
> (s///).

Variables interpolate just like they do in double-qouted strings.

Constants are functions and can be interpolated as per the FAQ "How do
I expand function calls in a string?". Hmmm perhaps it's about time to
try again submitting a doc patch to change the unhelpful word "expand"
to "interpolate".

> 3. Manipulate matched chars. When matched a number I need to add the
> same value to each matched chararcter.

Sorry, I can't understand what you mean by add a value to a character.

In Perl regular expressions you can use () to capture stuff into
special variables and you can then use those variables in expressions
to calculate values.



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

Date: 2 Sep 2006 10:37:39 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: Can I monitor the execution of a perl script
Message-Id: <1157218659.108221.41150@m79g2000cwm.googlegroups.com>


linq936@hotmail.com wrote:
> I wonder if there is any simple way
> to monitor the execution of the script just like I can run "set -xv" in
> BASH and see BASH script running?

You can get fairly close with

PERLDB_OPTS="NonStop AutoTrace" perl -d myscript.pl



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

Date: Sat, 2 Sep 2006 16:58:45 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Creating a subset of a hash?
Message-Id: <edcdc0.19c.1@news.isolution.nl>

usenet@DavidFilmer.com schreef:
> Dr.Ruud:

>> What is ugly about that?
>>
>>   $odd{$_} = $number{$_} for qw/1 3/ ;
>
> I guess it's because my mental parser hits the line multiple times.

I often prefer "for" to "map", but nothing beats a single clear line.


A "map EXPR,LIST" alternative:

  my %odd = map +( $_ => $number{$_} ), qw/1 3/ ;


A "map EXPR BLOCK" alternative:

  my %odd = map { $_ => $number{$_} } qw/1 3/ ;


For fun:

  my %odd = map { ($_*=2)+=1 => $number{$_} } -2..5 ;

-- 
Affijn, Ruud

"Gewoon is een tijger."




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

Date: 2 Sep 2006 08:53:01 -0700
From: "Matt Garrish" <mgarrish@gmail.com>
Subject: Re: lwp and utf8 characters
Message-Id: <1157212381.845275.120560@h48g2000cwc.googlegroups.com>


devs@usa.net wrote:

> hello,
> i am trying to write a bot to download wkipedia artictles using
> WWW:Wikipedia, a subclass of LWP::UserAgent. pages returned by the
> wikipedia
> server contains utf8 characters such as LATIN CAPITAL LETTER O WITH
> DIAERESIS. however, i see that the lwp module is not handling the
> search
> results as utf8 encoded. i see that th e character =D6 is treated as
> three
> individual bytes and not a single character. how do i specify that the
> lwp useragent must handle utf8 chars?
>

You need to disable header parsing. You have read and are adhering to
the free documentation license that applies to all content on that site
in creating this bot, right?

Matt



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

Date: 2 Sep 2006 08:08:31 -0700
From: "Michael" <michaelnx@gmail.com>
Subject: What's wrong with my installation
Message-Id: <1157209711.245243.151710@74g2000cwt.googlegroups.com>

Hi,

I just installed ActivePerl-5.8.8.819-MSWin32-x86-267479 on my windows
XP. Then I opened an notepad to write the following code

#! /usr/bin/perl -w
print "Hello, world.\n";

Then I did not see a perl icon in my windows explorer. Why? Shall I do
anything else? What's the usage of Perl Package Manager? How to run
Perl?

Thanks a lot in advance!

Michael



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

Date: 2 Sep 2006 08:35:42 -0700
From: "Michael" <michaelnx@gmail.com>
Subject: Re: What's wrong with my installation
Message-Id: <1157211342.366924.5520@p79g2000cwp.googlegroups.com>

Problem solved. cuz I need to save it to pl instead of plx. 

Thanks!



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

Date: Sat, 02 Sep 2006 17:38:20 +0200
From: Truty <my_email@no_spam.com>
Subject: Re: What's wrong with my installation
Message-Id: <mn.14227d69f71f4f37.52132@nospam.com>

Michael avait prétendu :
> Problem solved. cuz I need to save it to pl instead of plx. 
>
> Thanks!

lol, I had the same error.




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

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


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