[12985] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 395 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 6 00:07:26 1999

Date: Thu, 5 Aug 1999 21:05:11 -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           Thu, 5 Aug 1999     Volume: 9 Number: 395

Today's topics:
        "use constant", not much fun (Andrew Torda)
    Re: Activestate Perl/Dos? Question (elephant)
        DOS "EOF" (CTRL-Z??) (Stuart Slaugh)
    Re: FAQ doesn't work in this case! inlandpac@my-deja.com
    Re: Get Executables path (Abigail)
    Re: MATCH CASES AND PRINT TO A FILE <cassell@mail.cor.epa.gov>
    Re: MP3 Link Extraction (Martien Verbruggen)
    Re: Nastiness contrary to the spirit of perl? <srt@xnet.com>
    Re: Nastiness contrary to the spirit of perl? (Dan Zetterstrom)
    Re: Nastiness contrary to the spirit of perl? <tchrist@mox.perl.com>
    Re: NT Apache Perl <cassell@mail.cor.epa.gov>
    Re: Problem reading forms with perl genelong@my-deja.com
    Re: Problem reading forms with perl <srt@xnet.com>
    Re: Problem reading forms with perl (elephant)
    Re: Problem reading forms with perl <rra@stanford.edu>
        qr{} and quoting pattern metachars <ltl@rgsun5.viasystems.com>
    Re: qr{} and quoting pattern metachars <tchrist@mox.perl.com>
    Re: SSH2, Need a little help <xeno@bigger.aa.net>
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: 6 Aug 1999 13:15:41 +1000
From: torda@rsc.anu.edu.au (Andrew Torda)
Subject: "use constant", not much fun
Message-Id: <37aa535d.0@clarion.carno.net.au>


I am not having much fun with "use constant". It's good for
saying PI=>3.14... but not much fun in many other contexts.
For example, I want to define a constant for a file type
extension. All files of type "moo" will end in "moo":

    use constant FOO=>'moo';

    my $s ="moo_string";
    if ( $s =~ /FOO/) {                # Test always fails
        print "found moo from FOO\n"; }
    if ( $s =~ /moo/) {                # test succeeds
        print "found moo from simple string\n"; }

Is there some fancy perl quoting mechanism to make the first
test above succeed ? Obviously it works if one copies FOO into
some variable and uses that as the pattern.
Similarly, if I want to open a file whose name is given by a
constant, it seems I have to use the concatenation operator
like:

    open (FILE2, '<'.FOO) || die "open fail on ", FOO;
Is there some fancy perl syntax which makes it prettier ? 
Perhaps it is my judgement that it broken and perl hackers
like the constructions above.
Thanks
-Andrew
-- 
This posting is not merely my opinion.  It is the official position
of my employer, the Australian National University.
Andrew Torda, Research School of Chemistry, ANU, ACT 0200, Australia
    andrew.torda@anu.edu.au   http://www.rsc.anu.edu.au/~torda


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

Date: Fri, 6 Aug 1999 13:57:55 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: Activestate Perl/Dos? Question
Message-Id: <MPG.1215084e646e75f2989bf6@news-server>

David Cassell writes ..
>mknickelbein@my-deja.com wrote:
>> But if there were errors, if will print to the screen and not to the
>
>And this is because errors go to STDERR instead, and '>' doesn't
>redirect them.  There's no nice way aorund this if you insist on
>sticking to a strictly-DOS solution.
-
>              ...Note that you can use open() in your perl program
>to do the redirection of both STDOUT and STDERR to an output file,
>even though you can't do it in COMMAND.COM .

I think that this may be a bit of misinformation David .. although I 
don't have a Win9x box to test on - so I cannot say conclusively for all 
versions of DOS

but my NT version of command.com - which is DOS supports the Bourne shell 
file-descriptor redirection thusly

  perl perlfile 1>outputfile 2>&1

I would call this a pretty "nice way" .. certainly no nastier than it's 
UNIX counterpart

-- 
 jason - elephant@squirrelgroup.com -


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

Date: Fri, 06 Aug 1999 03:36:56 GMT
From: ohyeahh@worldnet.att.net (Stuart Slaugh)
Subject: DOS "EOF" (CTRL-Z??)
Message-Id: <37aa5644.38049844@netnews.worldnet.att.net>

I am a new perl programmer.Whenever I attempt to read a list of
strings from STDIN into an array, I am unable to indicate EOF in the 
usual manner; e.g., pressing CTRL-Z. Each time I do this, the program
terminates and I am returned to the command prompt. I am using
ActiveState under Win98. Here is the code: ( this is from an exer-
cise from the "Camel" book)

print "Enter a number: ";
chomp($num = <STDIN>);
print "Enter some strings: ";
@a = <STDIN>;
print "The word is: $a[$num - 1];

I have scoured every bit of documentation that came with ActiveState
and can find no reference to this issue. Any advice would be greatly
appreciated. Thanks.
			Stuart Slaugh


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

Date: Fri, 06 Aug 1999 03:14:09 GMT
From: inlandpac@my-deja.com
Subject: Re: FAQ doesn't work in this case!
Message-Id: <7odjtr$d4o$1@nnrp1.deja.com>

In article <qPqq3.134$Qv2.6197@nsw.nnrp.telstra.net>,
  mgjv@comdyn.com.au (Martien Verbruggen) wrote:
> In article <7od2ra$21u$1@nnrp1.deja.com>,
> 	inlandpac@my-deja.com writes:
> > <IMG SRC="/directory/directory.fds/image/somewhere/
$somevar/file.gif"
> > BORDER="0" WIDTH="47" HEIGHT="24" ALT="Search">
>
> What's that $somevar doing there?

IBM has a site that (believe it or not) uses this in their hrefs and
src!

> > The above HTML tag is not removed when using LWP's HTML::Parser and
I
> > cannot find a way to remove this type of tag through long-form
> > scripting.

Bad choice of wording on my part.  Sorry.

> And why would it be removed? HTML::Parser doesn't remove anything.
> Maybe you should show us the subclass of HTML::Parser that you wrote.

Here it is:

sub Get_Body_Text_Details
{
     $h->content_type('application/x-www-form-urlencoded');
     $h->content_length(length($c));

     $request = new HTTP::Request('GET', $URL, $h, $c);
     $failedCounter = 0;

LPC:$response = $ua->request($request);

     if ($response->is_success)
     {
          $tResponse = $response->content;
          &RemoveJavaScript();

          use HTML::Parse;
          use HTML::FormatText;
          $text = HTML::FormatText->new->format(parse_html($tResponse));

          if($DISPLAY_MODE == 4)
          {
               print "$_\n";
               print "--------------------------\n\n";
          }

          $bodyDetails = $text;

          open(HTML, "$MasterHTMLDirectory/$PLAIN_TEXT_DETAILS_PAGE");
          read(HTML,$_,50000);
          close(HTML);

          s/BODY_DETAILS/$bodyDetails/;
          s/SEARCH_KEYWORD/$keyword/;

          print $_;
     }

     else
     {
          $failedCounter++;

          if($failedCounter < $MAX_FAILED_ATTEMPTS)
          {
               goto LPC;
          }
               else
               {
                    open
(HTML, "$MasterHTMLDirectory/generic_message.htm");
                    read(HTML,$_,50000);
                    close(HTML);

                    s/GENERIC_MESSAGE/Could not connect to $URL/;

                    print $_;
               }
     }
}

That's the basics of it.

CLH


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 5 Aug 1999 22:08:13 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Get Executables path
Message-Id: <slrn7qkkbo.uij.abigail@alexandra.delanet.com>

Michael Wang (mwang@tech.cicg.ml.com) wrote on MMCLXV September MCMXCIII
in <URL:news:7od47v$9jq$1@news.ml.com>:
 .. Abigail <abigail@delanet.com> wrote:
 .. >perl -wle 'print "Prime" if ("m" x shift) !~ m m^\m?$|^(\m\m+?)\1+$mm'
 .. 
 .. # perl -v
 .. This is perl, version 5.004_04 built for sun4-solaris
 ..  
 .. # perl -wle 'print "Prime" if ("m" x shift) !~ m m^\m?$|^(\m\m+?)\1+$mm'
 .. Use of uninitialized value at -e line 1.
 .. 
 .. what is the purpose showing buggy code? Thanks. 


You're not supposed to run the code if you don't grasp the concept of "shift".



Abigail
-- 
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / 
         % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
         BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Thu, 05 Aug 1999 20:26:00 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: MATCH CASES AND PRINT TO A FILE
Message-Id: <37AA55C8.3A786EF3@mail.cor.epa.gov>

CLTCEvans wrote:
> 
> please help, i am a beginner.  i want to use perl to match cases and print true
> results in a file.  how would i do that...here is what i have now:
> 
> #!/usr/local/bin/perl -w

-w is very good.  You might enjoy the benefits of 'use strict' also.

> open(FILE "/path/file");

Hmmm.  You really need to check the returns on your open()s, because
your program will do Very Icky Things otherwise, and you won't know why.

open FILE, 'path/to/file.ext' or die "Can't open file.ext: $!\n";

And you only need single quotes around the filename unless you're doing
some variable interpolation inside there.

Now then.  Open another file for writing:

open OUTFILE, '>/path/to/outfile' or die "Can't open outfile for write:
$!\n";

> while(<FILE>) {

Good.  Reading the file line-by-line saves resources.  When you open
that 2 Gig file, you'll appreciate this more.

>         if(/match_this_expression/) {
>                 what do i need here to print matched cases to another
> file?;

    print OUTFILE $_;  # newline is still on end of line, so no need for
another

>         }
> }

If you have Perl 5.005 you can write that as

    print OUTFILE if /expression/;

But in Perl you can do this in one line, using the options covered
in the perlrun manpage:

perl -wne 'print if /expression/;' < infile > outfile

HTH,
David
--
David Cassell, OAO                               
cassell@mail.cor.epa.gov
Senior Computing Specialist
mathematical statistician


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

Date: Fri, 06 Aug 1999 03:43:19 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: MP3 Link Extraction
Message-Id: <rRsq3.180$Qv2.8600@nsw.nnrp.telstra.net>

In article <7ob66c$kfb$1@nnrp1.deja.com>,
	wired2000@my-deja.com writes:
> Hi,
> 
> I'm looking for an easy way to extra HTTP and FTP links from a webpage
> which end in .mp3 or .mp2 or .XXX

You might want to use a combination of LWP::UserAgent and
HTML::Treebuilder, and its parse and extract_links methods.

Together with URI::URL you can even make it follow those links again.
I've got about 100 lines of crappy code somewhere that I whipped up in
about 20 minutes to check a bundle of things on a website.

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | 
Commercial Dynamics Pty. Ltd.       | What's another word for Thesaurus?
NSW, Australia                      | 


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

Date: Thu, 05 Aug 1999 22:29:55 -0500
From: Steve Yates <srt@xnet.com>
Subject: Re: Nastiness contrary to the spirit of perl?
Message-Id: <37AA56B3.A3489FA9@xnet.com>

James Meacham wrote:
> the overwhelming tone of this newsgroup is one of nastiness, condescension, 
> and intolerance.

	I don't know about overwhelming, but I, too, was a bit surprised at the
harshness in the clp.* groups.  Believe it or not, there are some people
who don't have a strong C background to work from.  I spent a long time
figuring out sprintf syntax because all I saw was that "it's just like
C's sprintf" in various Perl docs, and that it returned a result that
could be assigned to a variable (which got me what I needed).

llornkcor@earthlink.net wrote:
> I think a moderated perl forum might be a good idea.

	Have you tried comp.lang.perl.moderated?  I think it's worse, if
anything, probably because users expect a higher signal/noise ratio. 
Although I have to say the *moderators* are very understanding, at least
the one who helped me figure out my problem via e-mail, even though he
didn't want to post my question about sprintf because he felt it was
basically a FAQ.

Steve


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

Date: Fri, 06 Aug 1999 03:40:08 GMT
From: methabol@hem.passagen.se (Dan Zetterstrom)
Subject: Re: Nastiness contrary to the spirit of perl?
Message-Id: <37ac57aa.57421057@news.algonet.se>

On Fri, 06 Aug 1999 00:39:48 GMT, why@invite.spam wrote:

>I am not choosing a side. I am simply stating my opinion that the
>usefulness of this group is adversely affected by all of the
>"unplesantness". Personally, I ignore lazy people, and let them
>flounder - on usenet, and in the office. 

So you gave up. The people here haven't, and you know why?

Because they care.

//DZ
-- 
Come the end, the only thing remaining
was the darkness in his soul.
Facing his fate with serenity
never to awake from the digital daydream.


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

Date: 5 Aug 1999 21:47:10 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Nastiness contrary to the spirit of perl?
Message-Id: <37aa5abe@cs.colorado.edu>

In comp.lang.perl.misc, elephant@squirrelgroup.com (elephant) writes:
:IMHO there are several reasons why so many novice posts receive RTFM 
:responses so brutally in this newsgroup

This is hardly unique to our little newsgropu.  The whiners whom you're
answering should try to take on comp.lang.c for a while.  The same
calibre of postings as we swat down here are swatted down there as well.
Just try posting a couple of message like these to comp.lang.c:

    "How do I use the open() commmand?" [sic]

    "How do read a form into a variable?"

I dare anyone to post those there and see what you get.  
They don't put up with such idiocy either.  And they'll 
tell you why.

And if the whiners really want cruel and sadistic posts, there are
plenty of infinitely more nasty newsgroups you can involve yourself in,
full of hate and pain.

--tom
-- 
    #define SIGILL 6         /* blech */
        --Larry Wall in perl.c from the 4.0 perl source code


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

Date: Thu, 05 Aug 1999 20:28:05 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: NT Apache Perl
Message-Id: <37AA5645.9ED6758B@mail.cor.epa.gov>

Kent Perrier wrote:
> 
> backwards.saerdna@srm.hc (Andreas Fehr) writes:
> 
> >
> > Did you read the whole thread?
> > Should I send you the information found in the perlwin32faq6.html?
> >
> 
> Windoze doesn't understand the shbang line.  You have to "associate" an
> extension with the the perl executable.

But Apache does.  Even in win32, you have to have the proper path to
the Perl executable on the shebang line, or Apache will hate you for it.

And even in Windoze, a shebang line is useful.  Particularly if you
want some command-line options, or you use Emacs, or...

David
--
David Cassell, OAO                               
cassell@mail.cor.epa.gov
Senior Computing Specialist
mathematical statistician


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

Date: Fri, 06 Aug 1999 02:59:48 GMT
From: genelong@my-deja.com
Subject: Re: Problem reading forms with perl
Message-Id: <7odj31$cdp$1@nnrp1.deja.com>

Ok, elephant, now you've got me totally lost.  Please be patient.

What is the standard perl distribution?  I learned perl out of a book,
and ftp'd it to my server with ws_ftp.  I don't have any standard
distribution.

I am trying to get onto www.cspan.org, so far without success (it is
busy) - I will keep on trying.

Where do I get the FAQ?  What is

   perldoc -q "How do I decode a CGI form"

Is this a unix command?  Everyone who writes perl seems to assume
everyone else knows unix, and I don't - I run under Windows 98/IE 5.

Sorry if these are dumb questions - I have written a few successful
perl scripts, so I am on my way, but there's a lot I don't understand.
Any pointers to documentation or other help would be wonderfully
appreciated.  Thanks for your patience.

Gene


In article <MPG.1214c56761d8d041989bea@news-server>,
  elephant@squirrelgroup.com (elephant) wrote:
> genelong@my-deja.com writes ..
> >elephant, you said:
> >> this is WHY PEOPLE
> >> ARE CONSTANTLY TOLD TO USE THE CGI MODULE !!!!
> >
> >Being a newbie, I don't know what that means.  Here is my html code:
>
> <looks skyward>
> there are these things called modules .. they are code that's been
> written and tested by a bunch of perl non-newbies .. and they're
> available for free
>
> mostly they're housed at www.cpan.org .. but some of them come with
the
> standard perl distribution
>
> the CGI.pm module is on of the ones that comes with the standard perl
> distribution
>
> for more information .. look up the documentation - first start with
the
> FAQ
>
>   perldoc -q "How do I decode a CGI form"
>
> then move on to the documentation for the CGI module
>
>   perldoc CGI
>
> then you'll know everything about CGI programming in perl that you
have
> to
>
> --
>  jason - elephant@squirrelgroup.com -
>


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 05 Aug 1999 22:44:30 -0500
From: Steve Yates <srt@xnet.com>
Subject: Re: Problem reading forms with perl
Message-Id: <37AA5A1E.1A04D85B@xnet.com>

genelong@my-deja.com wrote:
> What is the standard perl distribution?  

	A "distribution" in UNIX terms is basically a software release, or what
that software contains.  The standard should be available on every
platform that runs the software (not all UNIX machines have the same
operating system, and not all Internet servers are UNIX).  He is
referring to the version of Perl located on your web server.

> I am trying to get onto www.cspan.org, 

	Try www.cpan.org.  :)  Comprehensive Perl Archive Network.

> Where do I get the FAQ?

	The FAQ can be found on that site.

>perldoc -q "How do I decode a CGI form"

	This perldoc command searches for the question in the perl doc files. 
He is assuming you have access to a shell account on UNIX, which many
people don't.  You'll see a lot of one line posts in this group to the
effect of "man xxxx" (display the manual for xxx).  Fortuantely CPAN has
the perl documentation also.

	Now, CGI.pm is a perl module, like a unit or library in other
languages, which contains functions you can use.  In this case, CGI.pm
provides easy access to the results of a form, and also a way to write
HTML code from a perl script.  See this link for documentation for it:

http://stein.cshl.org/WWW/software/CGI

Steve


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

Date: Fri, 6 Aug 1999 13:52:05 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: Problem reading forms with perl
Message-Id: <MPG.121506ee60ceb382989bf5@news-server>

first of all .. please note the order that I've now changed the article 
to .. ie. REPLY LAST .. please conform to this standard - it makes things 
a lot simpler

genelong@my-deja.com writes ..
>What is the standard perl distribution?  I learned perl out of a book,
>and ftp'd it to my server with ws_ftp.  I don't have any standard
>distribution.

alright .. in that case - do yourself (and us *8^) a favour .. and go get 
the ActiveState port of perl from www.activestate.com/ActivePerl/ .. it 
has a whole heap of documentation .. and it does most of the Windows 
things for you during a neat installation

>Where do I get the FAQ?  What is
>
>   perldoc -q "How do I decode a CGI form"
>
>Is this a unix command?  Everyone who writes perl seems to assume
>everyone else knows unix, and I don't - I run under Windows 98/IE 5.

no .. this command will work on Windows as well .. but it relies on 
having your PATH set correctly and having the perldoc utility installed 
 .. the ActiveState port will do all this for you .. get it

>Sorry if these are dumb questions - I have written a few successful
>perl scripts, so I am on my way, but there's a lot I don't understand.
>Any pointers to documentation or other help would be wonderfully
>appreciated.  Thanks for your patience.

once you get the ActiveState (you'd think I worked for them *8^) port 
installed there will be a link in your Start menu to the HTML 
documentation .. this documentation contains other references to other 
web based documentation .. which begets more documentation

-- 
 jason - elephant@squirrelgroup.com -


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

Date: 05 Aug 1999 20:55:41 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Problem reading forms with perl
Message-Id: <yloggltveq.fsf@windlord.stanford.edu>

Steve Yates <srt@xnet.com> writes:

>> perldoc -q "How do I decode a CGI form"

> This perldoc command searches for the question in the perl doc files. 
> He is assuming you have access to a shell account on UNIX, which many
> people don't.

Does perldoc not work on Windows?  If not, why not?

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 6 Aug 1999 02:50:50 GMT
From: lt lindley <ltl@rgsun5.viasystems.com>
Subject: qr{} and quoting pattern metachars
Message-Id: <7odiia$4un$1@rguxd.viasystems.com>

I thought that I understood what was happening with qr{}.  perldoc 
perlop says that it quotes like a double quoted string (unless qr'').
I expected \Q..\E quoting of metacharacters to work within a
string passed to the qr operator.  But it is not working the way
I expect.  Bug?  Or am I missing something about how the quoting
is done and the expression is being evaluated?


#!/usr/lib/lprgs/perl -w
use strict;
my (@fields) = qw/
			   first.second
			   first.last
               /;
my $find_fields = join('|', map(quotemeta($_), @fields));
my $find_fields_re = qr{($find_fields)}o;

$find_fields = join('\E|\Q', @fields);
$find_fields = '(\Q' . $find_fields . '\E)';
my $find_fields_re2 = qr{$find_fields}o;

my (@test_strings) = (
	'xxx first.second yyy',
	'xxx first.last yyy',
	'xxx will not match yyy',
);
foreach my $test_string (@test_strings) {
	print "$1 matched for the quotemeta case\n" 
		if ($test_string =~ $find_fields_re);
	print "$1 matched for the \\Q case\n"
		if ($test_string =~ $find_fields_re2);
}
######################## END ########################
# Execution of the above on Solaris 2.7 with perl 5.00503 yields

first.second matched for the quotemeta case
first.last matched for the quotemeta case


-- 
// Lee.Lindley   /// Programmer shortage?  What programmer shortage?
// @bigfoot.com  ///  Only *cheap* programmers are in short supply.
////////////////////    50 cent beers are in short supply too.


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

Date: 5 Aug 1999 21:29:01 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: qr{} and quoting pattern metachars
Message-Id: <37aa567d@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    lee.lindley@viasystems.com writes:
:I thought that I understood what was happening with qr{}.  perldoc 
:perlop says that it quotes like a double quoted string (unless qr'').
:I expected \Q..\E quoting of metacharacters to work within a
:string passed to the qr operator.  But it is not working the way
:I expect.  Bug?  Or am I missing something about how the quoting
:is done and the expression is being evaluated?

I think Friedl's book had something about that, and here's
something Ilya put into recent incarnations of perlop:

  Gory details of parsing quoted constructs

    When presented with something that might have several different
    interpretations, Perl uses the DWIM (that's "Do What I Mean")
    principle to pick the most probable interpretation. This
    strategy is so successful that Perl programmers often do not
    suspect the ambivalence of what they write. But from time to
    time, Perl's notions differ substantially from what the author
    honestly meant.

    This section hopes to clarify how Perl handles quoted
    constructs. Although the most common reason to learn this is to
    unravel labyrinthine regular expressions, because the initial
    steps of parsing are the same for all quoting operators, they
    are all discussed together.

    The most important Perl parsing rule is the first one discussed
    below: when processing a quoted construct, Perl first finds the
    end of that construct, then interprets its contents. If you
    understand this rule, you may skip the rest of this section on
    the first reading. The other rules are likely to contradict the
    user's expectations much less frequently than this first one.

    Some passes discussed below are performed concurrently, but
    because their results are the same, we consider them
    individually. For different quoting constructs, Perl performs
    different numbers of passes, from one to five, but these passes
    are always performed in the same order.

    Finding the end
        The first pass is finding the end of the quoted construct,
        whether it be a multicharacter delimiter `"\nEOF\n"' in the
        `<<EOF' construct, a `/' that terminates a `qq//' construct,
        a `]' which terminates `qq[]' construct, or a `>' which
        terminates a fileglob started with `<'.

        When searching for single-character non-pairing delimiters,
        such as `/', combinations of `\\' and `\/' are skipped.
        However, when searching for single-character pairing
        delimiter like `[', combinations of `\\', `\]', and `\[' are
        all skipped, and nested `[', `]' are skipped as well. When
        searching for multicharacter delimiters, nothing is skipped.

        For constructs with three-part delimiters (`s///', `y///',
        and `tr///'), the search is repeated once more.

        During this search no attention is paid to the semantics of
        the construct. Thus:

            "$hash{"$foo/$bar"}"

        or:

            m/ 
              bar       # NOT a comment, this slash / terminated m//!
             /x

        do not form legal quoted expressions. The quoted part ends
        on the first `"' and `/', and the rest happens to be a
        syntax error. Because the slash that terminated `m//' was
        followed by a `SPACE', the example above is not `m//x', but
        rather `m//' with no `/x' modifier. So the embedded `#' is
        interpreted as a literal `#'.

    Removal of backslashes before delimiters
        During the second pass, text between the starting and ending
        delimiters is copied to a safe location, and the `\' is
        removed from combinations consisting of `\' and delimiter--
        or delimiters, meaning both starting and ending delimiters
        will should these differ. This removal does not happen for
        multi-character delimiters. Note that the combination `\\'
        is left intact, just as it was.

        Starting from this step no information about the delimiters
        is used in parsing.

    Interpolation
        The next step is interpolation in the text obtained, which
        is now delimiter-independent. There are four different
        cases.

    `<<'EOF'', `m''', `s'''', `tr///', `y///'
            No interpolation is performed.

    `''', `q//'
            The only interpolation is removal of `\' from pairs
            `\\'.

    `""', ```', `qq//', `qx//', `<file*glob>'
            `\Q', `\U', `\u', `\L', `\l' (possibly paired with `\E')
            are converted to corresponding Perl constructs. Thus,
            `"$foo\Qbaz$bar"' is converted to `$foo .
            (quotemeta("baz" . $bar))' internally. The other
            combinations are replaced with appropriate expansions.

            Let it be stressed that *whatever falls between `\Q' and
            `\E'* is interpolated in the usual way. Something like
            `"\Q\\E"' has no `\E' inside. instead, it has `\Q',
            `\\', and `E', so the result is the same as for
            `"\\\\E"'. As a general rule, backslashes between `\Q'
            and `\E' may lead to counterintuitive results. So,
            `"\Q\t\E"' is converted to `quotemeta("\t")', which is
            the same as `"\\\t"' (since TAB is not alphanumeric).
            Note also that:

              $str = '\t';
              return "\Q$str";

            may be closer to the conjectural *intention* of the
            writer of `"\Q\t\E"'.

            Interpolated scalars and arrays are converted internally
            to the `join' and `.' catentation operations. Thus,
            `"$foo XXX '@arr'"' becomes:

              $foo . " XXX '" . (join $", @arr) . "'";

            All operations above are performed simultaneously, left
            to right.

            Because the result of `"\Q STRING \E"' has all
            metacharacters quoted, there is no way to insert a
            literal `$' or `@' inside a `\Q\E' pair. If protected by
            `\', `$' will be quoted to became `"\\\$"'; if not, it
            is interpreted as the start of an interpolated scalar.

            Note also that the interpolation code needs to make a
            decision on where the interpolated scalar ends. For
            instance, whether `"a $b -> {c}"' really means:

              "a " . $b . " -> {c}";

            or:

              "a " . $b -> {c};

            Most of the time, the longest possible text that does
            not include spaces between components and which contains
            matching braces or brackets. because the outcome may be
            determined by voting based on heuristic estimators, the
            result is not strictly predictable. Fortunately, it's
            usually correct for ambiguous cases.

    `?RE?', `/RE/', `m/RE/', `s/RE/foo/',
            Processing of `\Q', `\U', `\u', `\L', `\l', and
            interpolation happens (almost) as with `qq//'
            constructs, but the substitution of `\' followed by RE-
            special chars (including `\') is not performed.
            Moreover, inside `(?{BLOCK})', `(?# comment )', and a
            `#'-comment in a `//x'-regular expression, no processing
            is performed whatsoever. This is the first step at which
            the presence of the `//x' modifier is relevant.

            Interpolation has several quirks: `$|', `$(', and `$)'
            are not interpolated, and constructs `$var[SOMETHING]'
            are voted (by several different estimators) to be either
            an array element or `$var' followed by an RE
            alternative. This is where the notation `${arr[$bar]}'
            comes handy: `/${arr[0-9]}/' is interpreted as array
            element `-9', not as a regular expression from the
            variable `$arr' followed by a digit, which would be the
            interpretation of `/$arr[0-9]/'. Since voting among
            different estimators may occur, the result is not
            predictable.

            It is at this step that `\1' is begrudgingly converted
            to `$1' in the replacement text of `s///' to correct the
            incorrigible *sed* hackers who haven't picked up the
            saner idiom yet. A warning is emitted if the -w command-
            line flag (that is, the `$^W' variable) was set.

            The lack of processing of `\\' creates specific
            restrictions on the post-processed text. If the
            delimiter is `/', one cannot get the combination `\/'
            into the result of this step. `/' will finish the
            regular expression, `\/' will be stripped to `/' on the
            previous step, and `\\/' will be left as is. Because `/'
            is equivalent to `\/' inside a regular expression, this
            does not matter unless the delimiter happens to be
            character special to the RE engine, such as in
            `s*foo*bar*', `m[foo]', or `?foo?'; or an alphanumeric
            char, as in:

              m m ^ a \s* b mmx;

            In the RE above, which is intentionally obfuscated for
            illustration, the delimiter is `m', the modifier is
            `mx', and after backslash-removal the RE is the same as
            for `m/ ^ a s* b /mx'). There's more than one reason
            you're encouraged to restrict your delimiters to non-
            alphanumeric, non-whitespace choices.

        This step is the last one for all constructs except regular
        expressions, which are processed further.

    Interpolation of regular expressions
        Previous steps were performed during the compilation of Perl
        code, but this one happens at run time--although it may be
        optimized to be calculated at compile time if appropriate.
        After preprocessing described above, and possibly after
        evaluation if catenation, joining, casing translation, or
        metaquoting are involved, the resulting *string* is passed
        to the RE engine for compilation.

        Whatever happens in the RE engine might be better discussed
        in the perlre manpage, but for the sake of continuity, we
        shall do so here.

        This is another step where the presence of the `//x'
        modifier is relevant. The RE engine scans the string from
        left to right and converts it to a finite automaton.

        Backslashed characters are either replaced with
        corresponding literal strings (as with `\{'), or else they
        generate special nodes in the finite automaton (as with
        `\b'). Characters special to the RE engine (such as `|')
        generate corresponding nodes or groups of nodes. `(?#...)'
        comments are ignored. All the rest is either converted to
        literal strings to match, or else is ignored (as is
        whitespace and `#'-style comments if `//x' is present).

        Parsing of the bracketed character class construct, `[...]',
        is rather different than the rule used for the rest of the
        pattern. The terminator of this construct is found using the
        same rules as for finding the terminator of a `{}'-delimited
        construct, the only exception being that `]' immediately
        following `[' is treated as though preceded by a backslash.
        Similarly, the terminator of `(?{...})' is found using the
        same rules as for finding the terminator of a `{}'-delimited
        construct.

        It is possible to inspect both the string given to RE engine
        and the resulting finite automaton. See the arguments
        `debug'/`debugcolor' in the `use the re' manpage pragma, as
        well as Perl's -Dr command-line switch documented in the
        "Switches" entry in the perlrun manpage.

    Optimization of regular expressions
        This step is listed for completeness only. Since it does not
        change semantics, details of this step are not documented
        and are subject to change without notice. This step is
        performed over the finite automaton that was generated
        during the previous pass.

        It is at this stage that `split()' silently optimizes `/^/'
        to mean `/^/m'.

--tom
-- 
"Internet is so big, so powerful and pointless that for some people it is a 
 complete substitute for life."
				- Andrew Brown, `The Independent'


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

Date: Fri, 06 Aug 1999 03:56:18 GMT
From: Xeno Campanoli <xeno@bigger.aa.net>
Subject: Re: SSH2, Need a little help
Message-Id: <933911713.350145@cacheraq001>

How do I do:

@x = qw( C D . _ # M X N M V ALL )

so that when using:

#!/usr/bin/perl -w

it doesn't yell at me about the sharp in the qw()?

I tried a \# and it gives the same error:

Possible attempt to put comments in qw() list at ./QDC.pm line 4549.

I suspect there is some correct way to do this, right?

--
Xeno Campanoli
Email:	xeno@aa.net	(Web pages:  http://www.aa.net/~xeno)


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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 99)
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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V9 Issue 395
*************************************


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