[27349] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9054 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 15 09:05:48 2006

Date: Wed, 15 Mar 2006 06:05:04 -0800 (PST)
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, 15 Mar 2006     Volume: 10 Number: 9054

Today's topics:
    Re: A Problem With GD <tassilo.von.parseval@rwth-aachen.de>
        Accessing package data through variable <a-brahme@ti.com>
    Re: Can I skip tokens in RegExp backreferences? <invalid@earthlink.net.invalid>
    Re: Can I skip tokens in RegExp backreferences? <uri@stemsystems.com>
    Re: Can I skip tokens in RegExp backreferences? <invalid@earthlink.net.invalid>
    Re: Can I skip tokens in RegExp backreferences? <invalid@earthlink.net.invalid>
    Re: Can I skip tokens in RegExp backreferences? <invalid@earthlink.net.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 15 Mar 2006 10:37:30 +0100
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: A Problem With GD
Message-Id: <47q5itFgsmpqU1@news.dfncis.de>

Also sprach robic0:

> But given the RGB function above, calling RGB(255,255,255) would be more appropriate.
> The difference is evals are mostly used, if its your purpose, to dynamically
> generate unknown code at runtime, then its evaluated. In the RGB case its a known form.
> In C/C++, macros are used for "substitution" by the pre-compiler. All instances of the
> macro are substituted for "real" code before compiling. Thats why there's always the
> perviable, "Beware of Macro's sideaffects" by certain documentation, since many C/C++
> constructs are macro's that are not intrinsics. For instance, long, short and byte
> are macro's.

As to all I know, this is utter nonsense. Do you have any documents
backing up that 'short' and 'long' are macros?

Tassilo
-- 
use bigint;
$n=71423350343770280161397026330337371139054411854220053437565440;
$m=-8,;;$_=$n&(0xff)<<$m,,$_>>=$m,,print+chr,,while(($m+=8)<=200);


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

Date: Wed, 15 Mar 2006 19:27:47 +0530
From: Amit Brahme <a-brahme@ti.com>
Subject: Accessing package data through variable
Message-Id: <dv96gt$h43$1@home.itg.ti.com>

Hi,

	I want to know if perl can do following thing.

------------------------------------------------------------------------
I've a package and some variables defined in it, like below, in file 
lets say "junk1.pm".

******************
package junk1;
$foo = "xyz";
$abc = "123";
******************

In my program I write a code like

******************
require "junk1.pm";
$myrf = "junk1";
print $junk1::foo;
******************


What I want is: instead of using

print $junk1::foo;

I want to use $myrf (which is defined as "junk1") to access variable 
"foo" in package junk1.

I tried

print ${$myrf}::foo;

but perl gives error for this that it found barework foo. Is there any 
way I can do something like this?

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

Thanks and regards
Amit


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

Date: Wed, 15 Mar 2006 06:03:37 GMT
From: Someone Else <invalid@earthlink.net.invalid>
Subject: Re: Can I skip tokens in RegExp backreferences?
Message-Id: <Z6ORf.4368$k75.205@newsread3.news.atl.earthlink.net>

A. Sinan Unur wrote:

> Someone Else <invalid@earthlink.net.invalid> wrote in news:cSJRf.4199
> $sL2.327@newsread2.news.atl.earthlink.net:
> 
> 
>>What I want to do is to use a regular expression like:
>>
>>     /([+-]\s*\d+)/;
[replacing part of your snip] but I don't want to capture the 
\s* as part of $1.

> 
> 
> ...
> 
> 
>>What I am looking for is something like:
>>
>>     /([+-](?:\s*)\d+)/;
[replacing more of your snip] but not quite. Not only don't I 
want to capture the \s* in $2, but I want to exclude it from the 
enclosing $1.

> 
> 
> #!/usr/bin/perl
> 
> use strict;
> use warnings;
> 
> my $s = '+ 42';
> $s =~ /([+-])\s*(\d+)/;
> print "$1$2\n";
[...]

> Why not state the precise problem instead of throwing variations at us?

I think I did state the precise question at the outset (although 
you snipped much of the relevant part). It's a question of Perl 
syntax and semantics, not of whether the problem can be 
addressed in other ways. There are obvious workarounds. I 
mentioned one, to distinguish workarounds from the underlying 
question. You seem to have reproduced a few variants of that 
workaround.

My question remains whether Perl regular expressions provide a 
clean way to capture the "[+-]" and "\d+" of "/([+-]\s*\d+)/" in 
$1, without capturing the "\s*".

-- David
To make invalid valid, reverse the letters



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

Date: Wed, 15 Mar 2006 01:29:18 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Can I skip tokens in RegExp backreferences?
Message-Id: <x7wtew43wh.fsf@mail.sysarch.com>


no.

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: Wed, 15 Mar 2006 06:31:44 GMT
From: Someone Else <invalid@earthlink.net.invalid>
Subject: Re: Can I skip tokens in RegExp backreferences?
Message-Id: <kxORf.4374$k75.1559@newsread3.news.atl.earthlink.net>

Rick Scott wrote:

> (Someone Else <invalid@earthlink.net.invalid> uttered:)
> 
>>What I am looking for is something like:
>>
>>     /([+-](?:\s*)\d+)/;
>>
>>but not quite. Not only don't I want to capture the \s* in $2, 
>>but I want to exclude it from the enclosing $1.
>>
>>Any ideas?
>>
>>...it's still easy to use:
>>
>>     @a = /\s*([+-])\s*(\d+)/g;
>>
>>and then concatenate every pair of entries in @a. 
> 
> 
> That's exactly the solution I was about to suggest -- capture two 
> groups, then concatenate them.
[...]

> Have you tried and benchmarked this simpler solution yet?  Looking for
> more efficient ways to do things is always laudable, but until you
> know whether or not your solution is intractably slow, you don't
> really know whether or not you actually have a problem worth solving.

I'm already using the simple solution (and it runs just fine), 
but it's ugly when mixed into the larger parsing problem. It's 
mostly just an issue I never ran into before, although it looks 
like a natural thing to want to do. I couldn't find a clean way 
to handle it, so I thought I'd ask.

> Cheers,
> Rick

And cheers to you.

-- David
To make invalid valid, reverse the letters



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

Date: Wed, 15 Mar 2006 06:38:04 GMT
From: Someone Else <invalid@earthlink.net.invalid>
Subject: Re: Can I skip tokens in RegExp backreferences?
Message-Id: <gDORf.4375$k75.3703@newsread3.news.atl.earthlink.net>

Dr.Ruud wrote:

> Someone Else schreef:
> 
> 
>>What I want to do is to use a regular expression like:
>>
>>     /([+-]\s*\d+)/;
>>
>>to parse some fairly complicated algebraic expressions; but I
>>don't want to capture the \s* as part of $1. [...]
>>it's still easy to use:
>>
>>     @a = /\s*([+-])\s*(\d+)/g;
>>
>>and then concatenate every pair of entries in @a. But as I said,
>>the real application is much more complicated.
> 
> 
> If that second approach is not feasible, and I can't guess why not, than
> you'd better add a step:
> 1. remove all meaningless whitespace etc.
>    s/([+-])[[:blank:]]+(\d)/$1$2/g;
> 2. do the captures

Yes, there are several perfectly servicable workarounds. I was 
just wondering whether it could be done directly. It would be a 
lot cleaner (in the context of the larger parsing problem) if 
there were a way.

> But my real advise is to use Yacc/Lex, because then you can convert 40
> MB in a few seconds.

Now that _would_ be overkill (:-).

-- David
To make invalid valid, reverse the letters



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

Date: Wed, 15 Mar 2006 06:56:42 GMT
From: Someone Else <invalid@earthlink.net.invalid>
Subject: Re: Can I skip tokens in RegExp backreferences?
Message-Id: <KUORf.12644$S25.10011@newsread1.news.atl.earthlink.net>

Uri Guttman wrote:

> no.
> 
> uri

I suspected as much, but thanks for confirming it.

-- David
To make invalid valid, reverse the letters



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

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


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