[26727] in Perl-Users-Digest
Perl-Users Digest, Issue: 8820 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 3 00:05:36 2006
Date: Mon, 2 Jan 2006 21:05:06 -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 Mon, 2 Jan 2006 Volume: 10 Number: 8820
Today's topics:
Re: regex bug? robic0
Re: regex bug? robic0
Re: regex bug? <abigail@abigail.nl>
Re: regex bug? robic0
Re: regex bug? <someone@example.com>
Re: regexp: ignoring nested brackets robic0
Re: Shebang not working <abigail@abigail.nl>
Re: Shebang not working robic0
Re: Shebang not working <issakov@t-online.de>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 02 Jan 2006 15:16:24 -0800
From: robic0
Subject: Re: regex bug?
Message-Id: <sscjr1l9u2dsqaq09p59veedqv8pr8rglb@4ax.com>
On Mon, 02 Jan 2006 14:17:43 -0800, Eric Niebler <eric.nospam.niebler@gmail.com> wrote:
>
>Consider the following program:
>
> $str = 'aaA';
> $str =~ /(((?:a))?)+/i;
^
? = zero or one. it found nothing first,
it always finds the first match then looks for others
ie "not defined"
No bug..
------------------------------
Date: Mon, 02 Jan 2006 15:20:37 -0800
From: robic0
Subject: Re: regex bug?
Message-Id: <d5djr11ataq1th81s192tf5klepkvf5ne1@4ax.com>
On Mon, 02 Jan 2006 15:16:24 -0800, robic0 wrote:
>On Mon, 02 Jan 2006 14:17:43 -0800, Eric Niebler <eric.nospam.niebler@gmail.com> wrote:
>
>>
>>Consider the following program:
>>
>> $str = 'aaA';
>> $str =~ /(((?:a))?)+/i;
> ^
>? = zero or one. it found nothing first,
>it always finds the first match then looks for others
>ie "not defined"
>
>No bug..
Oh, capture was turned off thats why it didn't find
anything. Didn't specify anything else to match outside the
non-capture. It matched but it didn't capture.
------------------------------
Date: 03 Jan 2006 02:23:46 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: regex bug?
Message-Id: <slrndrjo1i.lcd.abigail@alexandra.abigail.nl>
Eric Niebler (eric.nospam.niebler@gmail.com) wrote on MMMMDVII September
MCMXCIII in <URL:news:7Ehuf.35$sW2.885@news.uswest.net>:
??
?? Consider the following program:
??
?? $str = 'aaA';
?? $str =~ /(((?:a))?)+/i;
?? if(defined($2)) { print "$2"; }
?? else { print "not defined"; }
??
?? This prints "not defined," and I think that's right. But if I change the
?? regex to /(((a))?)+/i (that is, if I change the third group from
?? non-capturing to capturing), the program prints "A".
??
?? I can't think of a reason why changing group 3 from non-capturing to
?? capturing should have any effect on whether group 2 captures anything.
?? Seems like a regex bug to me. Opinions?
Sounds like a bug to me as well. I'd expect (and -Dr seems to confirm this)
the outer parens (that is, what's in front of the +) to match four times:
the first a, the second a, the A and the empty string.
$2 ought to be undefined, in both cases.
Abigail
--
# Count the number of lines; code doesn't match \w. Linux specific.
()=<>;$!=$=;($:,$,,$;,$")=$!=~/.(.)..(.)(.)..(.)/;
$;++;$*++;$;++;$*++;$;++;`$:$,$;$" $. >&$*`;
------------------------------
Date: Mon, 02 Jan 2006 18:35:33 -0800
From: robic0
Subject: Re: regex bug?
Message-Id: <1gojr1drqkg9p58msh6k0jo39sckngrl9t@4ax.com>
On Mon, 02 Jan 2006 15:20:37 -0800, robic0 wrote:
>On Mon, 02 Jan 2006 15:16:24 -0800, robic0 wrote:
>
>>On Mon, 02 Jan 2006 14:17:43 -0800, Eric Niebler <eric.nospam.niebler@gmail.com> wrote:
>>
>>>
>>>Consider the following program:
>>>
>>> $str = 'aaA';
>>> $str =~ /(((?:a))?)+/i;
>> ^
>>? = zero or one. it found nothing first,
>>it always finds the first match then looks for others
>>ie "not defined"
>>
>>No bug..
>
>Oh, capture was turned off thats why it didn't find
>anything. Didn't specify anything else to match outside the
>non-capture. It matched but it didn't capture.
Yep, the no capture just stops $3, $1 and $2 should have picked it up.
The real problem stems fro (?:..) which is experimental.
If that is experimental, what do you expect from it?
Why do you get A from /((((((((((a)))))))))))?/+++++/i anyway?
shouldn't you get 'a' from that!!!!!!!?????????????
------------------------------
Date: Tue, 03 Jan 2006 02:38:45 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: regex bug?
Message-Id: <Vsluf.28553$m05.2840@clgrps12>
Eric Niebler wrote:
>
> Consider the following program:
>
> $str = 'aaA';
> $str =~ /(((?:a))?)+/i;
> if(defined($2)) { print "$2"; }
> else { print "not defined"; }
>
> This prints "not defined," and I think that's right. But if I change the
> regex to /(((a))?)+/i (that is, if I change the third group from
> non-capturing to capturing), the program prints "A".
>
> I can't think of a reason why changing group 3 from non-capturing to
> capturing should have any effect on whether group 2 captures anything.
> Seems like a regex bug to me. Opinions?
>
> FWIW, I'm running ActiveState perl v5.8.7 815 for Win32.
When using (((a))?)+ $3 is not optional so it must capture something and since
it is inside $2 then $2 will also capture the same thing. When using
(((?:a))?)+ it is the same as saying ((a)?)+ where the contents of $2 are
optional.
John
--
use Perl;
program
fulfillment
------------------------------
Date: Mon, 02 Jan 2006 16:24:13 -0800
From: robic0
Subject: Re: regexp: ignoring nested brackets
Message-Id: <mpgjr19va3uuj9o73nq8aj8kg9iag9arfh@4ax.com>
On Mon, 2 Jan 2006 11:03:41 +0530, kaveh@delete_this.river-valley.com (Kaveh) wrote:
>I have the following expression:
>
>\mymacro{abcd {abcdgte{asdfSA}ksd} {ASDFD}sdfsd} ;laksjd;lkfajs
>
>I want to grab the first bracket and the matching one at the end,
>including any enclosed, correctly neseted brackets. What is the best way
>of doing this? Is it possible with one regexp?
In general, this is not possible with regular expressions.
Otherwise, someone would write that regex so we could all throw the
voluminous printable and non-printable character combinations at it
possible. I say this after just coming from such a regex research
proof of concept.
Anybody dispute this, post the regex.
------------------------------
Date: 03 Jan 2006 02:29:12 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Shebang not working
Message-Id: <slrndrjobo.lcd.abigail@alexandra.abigail.nl>
Sam CARMALT (scarmalt@swconsult.ch) wrote on MMMMDVII September MCMXCIII
in <URL:news:2hthr156j56j53ioc42hcjuq601qdlac09@4ax.com>:
[] I'm having trouble launching a Perl script with the shebang operator.
[] OS is SuSE 9.2 Professional. So far, I haven't had any helpful
[] insights at comp.os.linux.suse, and hope this isn't too far from Perl
[] to post here.
[]
[] Complete Perl script:
[]
[] #! /usr/bin/perl
[]
[] print "Hello, World\n";
[]
[] This is contained in a file of 3 lines, left-justified, created with
[] vi. It is saved with a directory entry of
[]
[] -rwxrwxrwx 1 root root 44 Dec 31 15:32 hworld.pl
[]
[] In the /usr/bin directory, I find the following entry
[]
[] -rwxr-wr-w 3 root root 1160321 Oct 2 2004 perl
[]
[] which leads me to believe that permissions are OK.
If your permissions read '-rwxr-wr-w' you have a serious problem.
That shouldn't be possible. My guess is that the permission is
'-rwxrw-rw-', which is also a serious problem - but one that's
entirely your fault. It means you have a perl binary that's only
executable by root, but that's writable by everyone! Can you say
security hole large enough to drive a truck through?
[] Now, here is how things work:
[]
[] #perl hworld.pl
[] Hello, World
[] #hworld.pl
[] bash: hworld.pl: command not found
[] #./hworld.pl
[] bash: ./hworld.pl: /usr/bin/perl: bad interpreter: Permission denied
[] # ./hworld.pl
[] bash: ./hworld.pl: /usr/bin/perl: bad interpreter: Permission denied
[] #. hworld
[] bash: hworld: No such file or directory
[] #. hworld.pl
[] bash: print: command not found
[] #
Yup. Consistent with a permission of '-rwxrw-rw-'.
The permission ought to be '-rwxr-xr-x'.
[] From these I conclude that there is something going wrong with the
[] shebang line and getting started. Any pointers as to what I need to
[] change will be appreciated. (Obviously, I need to fix this in order
[] to use Perl in a CGI environment :)].
Perhaps you should hand in your super user licence, and first learn
Unix before continueing.
Abigail
--
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
print } sub __PACKAGE__ { &
print ( __PACKAGE__)} &
__PACKAGE__
( )
------------------------------
Date: Mon, 02 Jan 2006 18:45:28 -0800
From: robic0
Subject: Re: Shebang not working
Message-Id: <ivojr112fk74pb629v4mjbt2vv679821be@4ax.com>
On 03 Jan 2006 02:29:12 GMT, Abigail <abigail@abigail.nl> wrote:
>Sam CARMALT (scarmalt@swconsult.ch) wrote on MMMMDVII September MCMXCIII
>in <URL:news:2hthr156j56j53ioc42hcjuq601qdlac09@4ax.com>:
>[] I'm having trouble launching a Perl script with the shebang operator.
>[] OS is SuSE 9.2 Professional. So far, I haven't had any helpful
>[] insights at comp.os.linux.suse, and hope this isn't too far from Perl
>[] to post here.
>[]
>[] Complete Perl script:
>[]
>[] #! /usr/bin/perl
>[]
>[] print "Hello, World\n";
>[]
>[] This is contained in a file of 3 lines, left-justified, created with
>[] vi. It is saved with a directory entry of
>[]
>[] -rwxrwxrwx 1 root root 44 Dec 31 15:32 hworld.pl
>[]
>[] In the /usr/bin directory, I find the following entry
>[]
>[] -rwxr-wr-w 3 root root 1160321 Oct 2 2004 perl
>[]
>[] which leads me to believe that permissions are OK.
>
>If your permissions read '-rwxr-wr-w' you have a serious problem.
>That shouldn't be possible. My guess is that the permission is
>'-rwxrw-rw-', which is also a serious problem - but one that's
>entirely your fault. It means you have a perl binary that's only
>executable by root, but that's writable by everyone! Can you say
>security hole large enough to drive a truck through?
>
>[] Now, here is how things work:
>[]
>[] #perl hworld.pl
>[] Hello, World
>[] #hworld.pl
>[] bash: hworld.pl: command not found
>[] #./hworld.pl
>[] bash: ./hworld.pl: /usr/bin/perl: bad interpreter: Permission denied
>[] # ./hworld.pl
>[] bash: ./hworld.pl: /usr/bin/perl: bad interpreter: Permission denied
>[] #. hworld
>[] bash: hworld: No such file or directory
>[] #. hworld.pl
>[] bash: print: command not found
>[] #
>
>Yup. Consistent with a permission of '-rwxrw-rw-'.
>
>The permission ought to be '-rwxr-xr-x'.
>
>[] From these I conclude that there is something going wrong with the
>[] shebang line and getting started. Any pointers as to what I need to
>[] change will be appreciated. (Obviously, I need to fix this in order
>[] to use Perl in a CGI environment :)].
>
>Perhaps you should hand in your super user licence, and first learn
>Unix before continueing.
Now was that perhaps thrown in gratutiously? Don't hold back now, tell him
what your really think of him. Is that a kind way of saying "Jee buddy
your a super user fuck-up and I can say that because I spotted your fopa
and your too damned stupid to recognize it. Have a nice day!"
>
>
>Abigail
------------------------------
Date: Tue, 03 Jan 2006 04:58:37 +0100
From: Mihail <issakov@t-online.de>
Subject: Re: Shebang not working
Message-Id: <dpcspd$l1n$01$1@news.t-online.com>
Josef Moellers wrote:
> Mihail wrote:
>
>> I can reproduce your problem with DOS-edited file.
>> The character at the end of the string confuse the
>> interpreter.
>
>
> No, you most likely can't. The error message in your case is very cryptic:
> josef@bounty:~> ./test.pl
> : bad interpreter: No such file or directory
> josef@bounty:~> perl test.pl
> Hello, world
Yes, the error is similar, but not exactly the same.
May be the filesystem is mounted noexec?
BTW, perldoc perlfaq7 has several ideas about the problem.
------------------------------
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 8820
***************************************