[26419] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8589 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 1 00:06:07 2005

Date: Mon, 31 Oct 2005 21:05:29 -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, 31 Oct 2005     Volume: 10 Number: 8589

Today's topics:
         Re: FAQ 3.23 How can I get "#!perl" to work on [MS-DOS <ron@savage.net.au>
         Re: FAQ 3.23 How can I get "#!perl" to work on [MS-DOS <ron@savage.net.au>
        Bug in &= (bitwise or) (Anno Siegel)
    Re: Bug in &= (bitwise or) <tassilo.von.parseval@rwth-aachen.de>
    Re: Bug in &= (bitwise or) <abigail@abigail.nl>
    Re: Bug in &= (bitwise or) <No_4@dsl.pipex.com>
    Re: Bug in &= (bitwise or) <nospam-abuse@ilyaz.org>
    Re: Bug in &= (bitwise or) <nospam-abuse@ilyaz.org>
        FAQ 2.6 What modules and extensions are available for P <comdog@pair.com>
    Re: FAQ 3.23 How can I get "#!perl" to work on [MS-DOS, <matthew.garrish@sympatico.ca>
    Re: FAQ 3.23 How can I get "#!perl" to work on [MS-DOS, <1usa@llenroc.ude.invalid>
        FAQ 4.23 How do I find matching/nesting anything? <comdog@pair.com>
        FAQ 4.74 How do I define methods for every class/object <comdog@pair.com>
        FAQ 6.10 How do I use a regular expression to strip C s <comdog@pair.com>
        FAQ 6.9 What is "/o" really for? <comdog@pair.com>
        List of references <kuujinbo@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 1 Nov 2005 10:40:29 +1100
From:     Ron Savage <ron@savage.net.au>
Subject:  Re: FAQ 3.23 How can I get "#!perl" to work on [MS-DOS,NT,...]?
Message-Id: <2005111104029.823882@ron>

On Fri, 28 Oct 2005 10:46:10 +1000, A. Sinan Unur wrote:

Hi Sinan

> Windows Registry Editor Version 5.00
>
> [HKEY_CLASSES_ROOT\.pl\Shell\ExecCGI]
> "command"=3D"c:\\opt\\perl\\bin\\perl.exe -T \"%1\""

Some people /choose/ not to edit the registry.




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

Date: Tue, 1 Nov 2005 10:44:18 +1100
From:     Ron Savage <ron@savage.net.au>
Subject:  Re: FAQ 3.23 How can I get "#!perl" to work on [MS-DOS,NT,...]?
Message-Id: <2005111104418.597287@ron>

On Fri, 28 Oct 2005 10:42:26 +1000, Matt Garrish wrote:

Hi Matt

>> This works for other drives besides c: of course, if Apache and Perl are
>> installed on d:, say. 

> Why on earth would you do that? What's wrong with leaving perl
> where it is?

There's no need to be so terrified of minor changes in the status quo.

Reliability is the only game in town, and for software to be reliable it=
 should 
be possible to install it on any (fixed) disk.

> The faq was about how to get a shebang to work in Windows, not

[snip utter misunderstanding]




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

Date: 31 Oct 2005 19:38:26 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Bug in &= (bitwise or)
Message-Id: <dk5rri$anu$1@mamenchi.zrz.TU-Berlin.DE>

I am observing this strange behavior:

    # prepare a string
    my $str = 'aa';
    $str &= 'a';                      # shorten it
    print "str: $str\n";              # a single "a" as expected

    # $str = "$str";                  # this heals the defect (if any)

    # something is wrong, though
    die "Ha!\n" unless $str =~ /a+$/; # this dies!

The pattern should, of course, match.  Similar patterns, like /a$/ and
/a+/ do match, but /a+$/ isn't recognized.  Copying the string into itself
normalizes the behavior. "use bytes" makes no difference.

Whether the bug (or am I missing something?) is in &= or the regex
engine (gasp) is anyone's guess.  My money is on string-truncation
by &=.  It would be rarely-exercised code, other bitwise operations
don't shorten.

Anno


-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


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

Date: Mon, 31 Oct 2005 22:01:16 +0100
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: Bug in &= (bitwise or)
Message-Id: <3snf0uFotcprU1@news.dfncis.de>

Also sprach Anno Siegel:

> I am observing this strange behavior:
>
>     # prepare a string
>     my $str = 'aa';
>     $str &= 'a';                      # shorten it
>     print "str: $str\n";              # a single "a" as expected
>
>     # $str = "$str";                  # this heals the defect (if any)
>
>     # something is wrong, though
>     die "Ha!\n" unless $str =~ /a+$/; # this dies!
>
> The pattern should, of course, match.  Similar patterns, like /a$/ and
> /a+/ do match, but /a+$/ isn't recognized.  Copying the string into itself
> normalizes the behavior. "use bytes" makes no difference.
>
> Whether the bug (or am I missing something?) is in &= or the regex
> engine (gasp) is anyone's guess.  My money is on string-truncation
> by &=.  It would be rarely-exercised code, other bitwise operations
> don't shorten.

After the bitwise-and, the string appears not to be NULL-terminated any
longer, at least not at the offset where perl usually finds the NULL
termination. That might be confusing the regex engine. 

For testing what the raw string looks like after the bitwise-and, you
can use:


    use Inline C => Config => BUILD_NOISY => 1;
    use Inline C => <<'EOC';
    
    void test (SV *sv) {
        int i = 0;
        char *c = SvPVX(sv);
	
        while (i++ < SvLEN(sv))
            printf("%i,", *c++);
	    
        sv_dump(sv);
    }
    
    EOC

    my $a = 'aa';
    $a &= 'a';
    test($a);

Then I am not sure myself what the result of

    $s = 'aa' & 'a'

should be.

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


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

Date: 31 Oct 2005 22:29:10 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Bug in &= (bitwise or)
Message-Id: <slrndmd6lm.b9.abigail@alexandra.abigail.nl>

Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMMMCDXLIV
September MCMXCIII in <URL:news:dk5rri$anu$1@mamenchi.zrz.TU-Berlin.DE>:
$$  I am observing this strange behavior:
$$  
$$      # prepare a string
$$      my $str = 'aa';
$$      $str &= 'a';                      # shorten it
$$      print "str: $str\n";              # a single "a" as expected
$$  
$$      # $str = "$str";                  # this heals the defect (if any)
$$  
$$      # something is wrong, though
$$      die "Ha!\n" unless $str =~ /a+$/; # this dies!
$$  
$$  The pattern should, of course, match.  Similar patterns, like /a$/ and
$$  /a+/ do match, but /a+$/ isn't recognized.  Copying the string into itself
$$  normalizes the behavior. "use bytes" makes no difference.
$$  
$$  Whether the bug (or am I missing something?) is in &= or the regex
$$  engine (gasp) is anyone's guess.  My money is on string-truncation
$$  by &=.  It would be rarely-exercised code, other bitwise operations
$$  don't shorten.


I think &= is broken:

    use Devel::Peek;

    my $str1 = "aa"; $str1 &= "a";
    my $str2 = "a";
    my $str3 = "aa" & "a";

    Dump $str1;
    Dump $str2;
    Dump $str3;

    __END__
    SV = PV(0x8183010) at 0x8182ca8
      REFCNT = 1
      FLAGS = (POK,pPOK)
      PV = 0x818a690 "a"
      CUR = 1
      LEN = 3
    SV = PV(0x8183154) at 0x8182cf0
      REFCNT = 1
      FLAGS = (POK,pPOK)
      PV = 0x818c0f8 "a"\0
      CUR = 1
      LEN = 2
    SV = PV(0x8182ff8) at 0x81821e0
      REFCNT = 1
      FLAGS = (POK,pPOK)
      PV = 0x818c0f8 "a"\0
      CUR = 1
      LEN = 2
-- 
   my $qr =  qr/^.+?(;).+?\1|;Just another Perl Hacker;|;.+$/;
      $qr =~  s/$qr//g;
print $qr, "\n";


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

Date: Mon, 31 Oct 2005 22:42:25 +0000
From: Big and Blue <No_4@dsl.pipex.com>
Subject: Re: Bug in &= (bitwise or)
Message-Id: <Lr2dnYZ7LMVCAPveRVnytg@pipex.net>

Anno Siegel wrote:

> I am observing this strange behavior:

    I'm observing one in the subject - given that &= is a bitwise AND.

> 
>     # prepare a string
>     my $str = 'aa';
>     $str &= 'a';                      # shorten it

    Hmmmm...surely you've changed the last character to a NUL byte?

> The pattern should, of course, match.  Similar patterns, like /a$/ and
> /a+/ do match, but /a+$/ isn't recognized.

    Which woudl fit with the string actually being "a\000".

> Whether the bug (or am I missing something?) is in &= or the regex
> engine (gasp) is anyone's guess.  My money is on string-truncation
> by &=.  It would be rarely-exercised code, other bitwise operations
> don't shorten.

    If you "use re qw( debug );" and change the &= line to:

$str &= "\000a";

you'll find that this leaves you with "\000a", so I'n guessing that the 
string you have created does end with a NUL, but Perl is confused as to 
whether it is there?


-- 
              Just because I've written it doesn't mean that
                   either you or I have to believe it.


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

Date: Mon, 31 Oct 2005 23:02:47 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Bug in &= (bitwise or)
Message-Id: <dk67qn$1p6$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Tassilo v. Parseval
<tassilo.von.parseval@rwth-aachen.de>], who wrote in article <3snf0uFotcprU1@news.dfncis.de>:
> After the bitwise-and, the string appears not to be NULL-terminated any
> longer, at least not at the offset where perl usually finds the NULL
> termination. That might be confusing the regex engine. 
> 
> For testing what the raw string looks like after the bitwise-and, you
> can use:

  perl -MDevel::Peek -wle "my $a = q(aa); $a &= q(a); print Dump $a"

  SV = PV(0x40c64) at 0x40a24
    REFCNT = 1
    FLAGS = (PADBUSY,PADMY,POK,pPOK)
    PV = 0x42020 "a"
    CUR = 1
    LEN = 3

As you can see, PV is not null-terminated.  Here is how
null-terminated stuff is output:


  perl -MDevel::Peek -wle "my $a = q(a); print Dump $a"
  SV = PV(0x40c64) at 0x40a24
    REFCNT = 1
    FLAGS = (PADBUSY,PADMY,POK,pPOK)
    PV = 0x42020 "a"\0
    CUR = 1
    LEN = 2

Hope this helps,
Ilya


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

Date: Mon, 31 Oct 2005 23:07:00 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Bug in &= (bitwise or)
Message-Id: <dk682k$1q0$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Anno Siegel
<anno4000@lublin.zrz.tu-berlin.de>], who wrote in article <dk5rri$anu$1@mamenchi.zrz.TU-Berlin.DE>:
>     my $str = 'aa';
>     $str &= 'a';                      # shorten it

>     die "Ha!\n" unless $str =~ /a+$/; # this dies!

> Whether the bug (or am I missing something?) is in &= or the regex
> engine (gasp) is anyone's guess.

Both.

  &= should (as any Perl operation) produce \0-terminated string.

  REx engine (as any Perl operation) should work on non-\0-terminated
  strings too.

The only reason to have \0-termination is to allow the string to be
passed to system calls (like open()) AS IS.

Hope this helps,
Ilya


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

Date: Mon, 31 Oct 2005 23:03:01 +0000 (UTC)
From: PerlFAQ Server <comdog@pair.com>
Subject: FAQ 2.6 What modules and extensions are available for Perl?  What is CPAN?  What does CPAN/src/... mean?
Message-Id: <dk67r5$lcn$1@reader2.panix.com>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with Perl.

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

2.6: What modules and extensions are available for Perl?  What is CPAN?  What does CPAN/src/... mean?

    CPAN stands for Comprehensive Perl Archive Network, a ~1.2Gb archive
    replicated on nearly 200 machines all over the world. CPAN contains
    source code, non-native ports, documentation, scripts, and many
    third-party modules and extensions, designed for everything from
    commercial database interfaces to keyboard/screen control to web walking
    and CGI scripts. The master web site for CPAN is http://www.cpan.org/
    and there is the CPAN Multiplexer at http://www.cpan.org/CPAN.html which
    will choose a mirror near you via DNS. See http://www.perl.com/CPAN
    (without a slash at the end) for how this process works. Also,
    http://mirror.cpan.org/ has a nice interface to the
    http://www.cpan.org/MIRRORED.BY mirror directory.

    See the CPAN FAQ at http://www.cpan.org/misc/cpan-faq.html for answers
    to the most frequently asked questions about CPAN including how to
    become a mirror.

    CPAN/path/... is a naming convention for files available on CPAN sites.
    CPAN indicates the base directory of a CPAN mirror, and the rest of the
    path is the path from that directory to the file. For instance, if
    you're using ftp://ftp.funet.fi/pub/languages/perl/CPAN as your CPAN
    site, the file CPAN/misc/japh is downloadable as
    ftp://ftp.funet.fi/pub/languages/perl/CPAN/misc/japh .

    Considering that there are close to two thousand existing modules in the
    archive, one probably exists to do nearly anything you can think of.
    Current categories under CPAN/modules/by-category/ include Perl core
    modules; development support; operating system interfaces; networking,
    devices, and interprocess communication; data type utilities; database
    interfaces; user interfaces; interfaces to other languages; filenames,
    file systems, and file locking; internationalization and locale; world
    wide web support; server and daemon utilities; archiving and
    compression; image manipulation; mail and news; control flow utilities;
    filehandle and I/O; Microsoft Windows modules; and miscellaneous
    modules.

    See http://www.cpan.org/modules/00modlist.long.html or
    http://search.cpan.org/ for a more complete list of modules by category.

    CPAN is not affiliated with O'Reilly Media.



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

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-2002 Tom Christiansen and Nathan
    Torkington, and other contributors as noted. All rights 
    reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.


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

Date: Mon, 31 Oct 2005 19:52:31 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: FAQ 3.23 How can I get "#!perl" to work on [MS-DOS,NT,...]?
Message-Id: <g%y9f.3292$J14.159671@news20.bellglobal.com>


"Ron Savage" <ron@savage.net.au> wrote in message 
news:2005111104418.597287@ron...
On Fri, 28 Oct 2005 10:42:26 +1000, Matt Garrish wrote:

>>> This works for other drives besides c: of course, if Apache and Perl are
>>> installed on d:, say.

>> Why on earth would you do that? What's wrong with leaving perl
>> where it is?

> There's no need to be so terrified of minor changes in the status quo.

> Reliability is the only game in town, and for software to be reliable it 
> should
> be possible to install it on any (fixed) disk.

If that's your excuse for posting bad information, I'm not buying it. If you 
were concerned about portability, you would do the smart thing and use the 
registry for Windows so you don't have to think about your shebang line at 
all. Creating needless directory structures and moving the executable around 
just to preserve the shebang line is a bit absurd.

Matt 




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

Date: Tue, 01 Nov 2005 01:03:57 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: FAQ 3.23 How can I get "#!perl" to work on [MS-DOS,NT,...]?
Message-Id: <Xns9700CC1FD481Dasu1cornelledu@127.0.0.1>

Ron Savage <ron@savage.net.au> wrote in news:2005111104029.823882@ron:

> On Fri, 28 Oct 2005 10:46:10 +1000, A. Sinan Unur wrote:
> 
> Hi Sinan
> 
>> Windows Registry Editor Version 5.00
>>
>> [HKEY_CLASSES_ROOT\.pl\Shell\ExecCGI]
>> "command"="c:\\opt\\perl\\bin\\perl.exe -T \"%1\""
> 
> Some people /choose/ not to edit the registry.

Some people choose to read the documentation:

See http://httpd.apache.org/docs/2.0/mod/core.html#scriptinterpretersource

Sinan
-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html



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

Date: Tue, 1 Nov 2005 05:03:01 +0000 (UTC)
From: PerlFAQ Server <comdog@pair.com>
Subject: FAQ 4.23 How do I find matching/nesting anything?
Message-Id: <dk6su4$68i$1@reader2.panix.com>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with Perl.

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

4.23: How do I find matching/nesting anything?

    This isn't something that can be done in one regular expression, no
    matter how complicated. To find something between two single characters,
    a pattern like "/x([^x]*)x/" will get the intervening bits in $1. For
    multiple ones, then something more like "/alpha(.*?)omega/" would be
    needed. But none of these deals with nested patterns. For balanced
    expressions using "(", "{", "[" or "<" as delimiters, use the CPAN
    module Regexp::Common, or see "(??{ code })" in perlre. For other cases,
    you'll have to write a parser.

    If you are serious about writing a parser, there are a number of modules
    or oddities that will make your life a lot easier. There are the CPAN
    modules Parse::RecDescent, Parse::Yapp, and Text::Balanced; and the
    byacc program. Starting from perl 5.8 the Text::Balanced is part of the
    standard distribution.

    One simple destructive, inside-out approach that you might try is to
    pull out the smallest nesting parts one at a time:

        while (s/BEGIN((?:(?!BEGIN)(?!END).)*)END//gs) {
            # do something with $1
        }

    A more complicated and sneaky approach is to make Perl's regular
    expression engine do it for you. This is courtesy Dean Inada, and rather
    has the nature of an Obfuscated Perl Contest entry, but it really does
    work:

        # $_ contains the string to parse
        # BEGIN and END are the opening and closing markers for the
        # nested text.

        @( = ('(','');
        @) = (')','');
        ($re=$_)=~s/((BEGIN)|(END)|.)/$)[!$3]\Q$1\E$([!$2]/gs;
        @$ = (eval{/$re/},$@!~/unmatched/i);
        print join("\n",@$[0..$#$]) if( $$[-1] );



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

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-2002 Tom Christiansen and Nathan
    Torkington, and other contributors as noted. All rights 
    reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.


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

Date: Mon, 31 Oct 2005 05:03:01 +0000 (UTC)
From: PerlFAQ Server <comdog@pair.com>
Subject: FAQ 4.74 How do I define methods for every class/object?
Message-Id: <dk48i5$3ti$1@reader2.panix.com>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with Perl.

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

4.74: How do I define methods for every class/object?

    Use the UNIVERSAL class (see UNIVERSAL).



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

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-2002 Tom Christiansen and Nathan
    Torkington, and other contributors as noted. All rights 
    reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.


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

Date: Mon, 31 Oct 2005 17:03:01 +0000 (UTC)
From: PerlFAQ Server <comdog@pair.com>
Subject: FAQ 6.10 How do I use a regular expression to strip C style comments from a file?
Message-Id: <dk5io5$9a5$1@reader2.panix.com>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with Perl.

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

6.10: How do I use a regular expression to strip C style comments from a file?

    While this actually can be done, it's much harder than you'd think. For
    example, this one-liner

        perl -0777 -pe 's{/\*.*?\*/}{}gs' foo.c

    will work in many but not all cases. You see, it's too simple-minded for
    certain kinds of C programs, in particular, those with what appear to be
    comments in quoted strings. For that, you'd need something like this,
    created by Jeffrey Friedl and later modified by Fred Curtis.

        $/ = undef;
        $_ = <>;
        s#/\*[^*]*\*+([^/*][^*]*\*+)*/|("(\\.|[^"\\])*"|'(\\.|[^'\\])*'|.[^/"'\\]*)#defined $2 ? $2 : ""#gse;
        print;

    This could, of course, be more legibly written with the "/x" modifier,
    adding whitespace and comments. Here it is expanded, courtesy of Fred
    Curtis.

        s{
           /\*         ##  Start of /* ... */ comment
           [^*]*\*+    ##  Non-* followed by 1-or-more *'s
           (
             [^/*][^*]*\*+
           )*          ##  0-or-more things which don't start with /
                       ##    but do end with '*'
           /           ##  End of /* ... */ comment

         |         ##     OR  various things which aren't comments:

           (
             "           ##  Start of " ... " string
             (
               \\.           ##  Escaped char
             |               ##    OR
               [^"\\]        ##  Non "\
             )*
             "           ##  End of " ... " string

           |         ##     OR

             '           ##  Start of ' ... ' string
             (
               \\.           ##  Escaped char
             |               ##    OR
               [^'\\]        ##  Non '\
             )*
             '           ##  End of ' ... ' string

           |         ##     OR

             .           ##  Anything other char
             [^/"'\\]*   ##  Chars which doesn't start a comment, string or escape
           )
         }{defined $2 ? $2 : ""}gxse;

    A slight modification also removes C++ comments:

        s#/\*[^*]*\*+([^/*][^*]*\*+)*/|//[^\n]*|("(\\.|[^"\\])*"|'(\\.|[^'\\])*'|.[^/"'\\]*)#defined $2 ? $2 : ""#gse;



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

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-2002 Tom Christiansen and Nathan
    Torkington, and other contributors as noted. All rights 
    reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.


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

Date: Mon, 31 Oct 2005 11:03:01 +0000 (UTC)
From: PerlFAQ Server <comdog@pair.com>
Subject: FAQ 6.9 What is "/o" really for?
Message-Id: <dk4tl5$rmf$1@reader2.panix.com>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with Perl.

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

6.9: What is "/o" really for?


    Using a variable in a regular expression match forces a re-evaluation
    (and perhaps recompilation) each time the regular expression is
    encountered. The "/o" modifier locks in the regex the first time it's
    used. This always happens in a constant regular expression, and in fact,
    the pattern was compiled into the internal format at the same time your
    entire program was.

    Use of "/o" is irrelevant unless variable interpolation is used in the
    pattern, and if so, the regex engine will neither know nor care whether
    the variables change after the pattern is evaluated the *very first*
    time.

    "/o" is often used to gain an extra measure of efficiency by not
    performing subsequent evaluations when you know it won't matter (because
    you know the variables won't change), or more rarely, when you don't
    want the regex to notice if they do.

    For example, here's a "paragrep" program:

        $/ = '';  # paragraph mode
        $pat = shift;
        while (<>) {
            print if /$pat/o;
        }



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

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-2002 Tom Christiansen and Nathan
    Torkington, and other contributors as noted. All rights 
    reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.


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

Date: Tue, 01 Nov 2005 12:48:05 +0900
From: ko <kuujinbo@hotmail.com>
Subject: List of references
Message-Id: <4366e550$1_1@x-privat.org>

I'm either missing something basic or haven't found where this is 
documented. (or both) Could someone please point me in the right direction?

use strict;
use warnings;

# create list of references
my @a = \my (
   %a,        # print statement below => 0
   # %b,      # uncomment & print statement below => 2
);
print scalar @a . "\n";

keith


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

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


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