[13646] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1056 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 15 14:06:31 1999

Date: Fri, 15 Oct 1999 11:06:16 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <940010775-v9-i1056@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 15 Oct 1999     Volume: 9 Number: 1056

Today's topics:
        Comment out multiple lines <ilya@speakeasy.org>
    Re: Comment out multiple lines <laurensmith@sprynet.com>
    Re: Comment out multiple lines <flavell@mail.cern.ch>
    Re: Comment out multiple lines (Brett W. McCoy)
    Re: Comment out multiple lines (Abigail)
    Re: Comment out multiple lines <ilya@speakeasy.org>
    Re: Comment out multiple lines <ilya@speakeasy.org>
    Re: Comment out multiple lines (Abigail)
    Re: Comment out multiple lines <laurensmith@sprynet.com>
    Re: Comment out multiple lines <sariq@texas.net>
        Compilation errors on my(... msumsion@my-deja.com
    Re: Compilation errors on my(... (Martien Verbruggen)
    Re: Compilation errors on my(... <aqumsieh@matrox.com>
        Complex Regexpr (sorta) <john.komp@uscorp.net>
    Re: Complex Regexpr (sorta) (Abigail)
    Re: Complex Regexpr (sorta) <laurensmith@sprynet.com>
    Re: Complex Regexpr (sorta) <ltl@rgsun40.viasystems.com>
    Re: Complex Regexpr (sorta) (Tad McClellan)
    Re: Complex Regexpr (sorta) <john.komp@uscorp.net>
    Re: Complex Regexpr (sorta) (Randal L. Schwartz)
    Re: Complex Regexpr (sorta) <ltl@rgsun5.viasystems.com>
        Confused about reference vs. value... (Python Addict)
    Re: Confused about reference vs. value... (Bill Moseley)
    Re: Confused about reference vs. value... (Michel Dalle)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 13 Oct 1999 18:06:49 GMT
From: Ilya <ilya@speakeasy.org>
Subject: Comment out multiple lines
Message-Id: <s09ihps3bhk86@corp.supernews.com>


Is there any way to comment out whole sections at a time, like in C and other
high level languages, instead of using "#" a bunch of times? If I have to
comment 20-30 lines at a time, this gets annoying.



  ===========================================================================
  Money, when  considered as the fruit of many years' industry, as the reward
  of labor, sweat and toil, is not to be sported with, or trusted to the airy
  bubble of paper currency.  -- Thomas Paine
  ===========================================================================


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

Date: Wed, 13 Oct 1999 11:25:28 -0700
From: "Lauren Smith" <laurensmith@sprynet.com>
Subject: Re: Comment out multiple lines
Message-Id: <7u2iqu$nf7$1@brokaw.wa.com>

Ilya wrote in message ...
>
>Is there any way to comment out whole sections at a time, like in C and
other
>high level languages, instead of using "#" a bunch of times? If I have
to
>comment 20-30 lines at a time, this gets annoying.
I realize that your opinion of the FAQ and docs that come with Perl is
not exactly the highest, but your question is answered there.

perlfaq7:"How can I comment out a large block of perl code?"

Lauren
--
Yep, it's in there.  - Prego (IIRC)




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

Date: Wed, 13 Oct 1999 20:57:36 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Comment out multiple lines
Message-Id: <Pine.HPP.3.95a.991013205523.14204F-100000@hpplus01.cern.ch>

On Wed, 13 Oct 1999, Ilya wrote:

> Is there any way to comment out whole sections at a time, 

perldoc -q comment

 =head1 Found in /usr/local/lib/perl5/5.00503/pod/perlfaq7.pod

 =head2 How can I comment out a large block of perl code?

 Use embedded POD to discard it:


Great stuff, this perldoc -q



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

Date: Wed, 13 Oct 1999 19:11:28 GMT
From: bmccoy@foiservices.com (Brett W. McCoy)
Subject: Re: Comment out multiple lines
Message-Id: <slrn809miu.su9.bmccoy@moebius.foiservices.com>

Also Sprach Ilya <ilya@speakeasy.org>:
>
>Is there any way to comment out whole sections at a time, like in C and other
>high level languages, instead of using "#" a bunch of times? If I have to
>comment 20-30 lines at a time, this gets annoying.

start the block with =comment
and end it with =cut

Everything in between will be ignored.

This is how POD is embedded into Perl code.


-- 
Brett W. McCoy                             bmccoy@foiservices.com
Computer Operations Manager (Alpha Geek)   http://www.foiservices.com
FOI Services, Inc./DIOGENES                301-975-0110
---------------------------------------------------------------------------


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

Date: 13 Oct 1999 14:34:17 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Comment out multiple lines
Message-Id: <slrn809nla.nk2.abigail@alexandra.delanet.com>

Ilya (ilya@speakeasy.org) wrote on MMCCXXXIV September MCMXCIII in
<URL:news:s09ihps3bhk86@corp.supernews.com>:
,, 
,, Is there any way to comment out whole sections at a time, like in C and other
,, high level languages, instead of using "#" a bunch of times? If I have to
,, comment 20-30 lines at a time, this gets annoying.


RTFFAQ


Abigail
-- 
sub f{sprintf$_[0],$_[1],$_[2]}print f('%c%s',74,f('%c%s',117,f('%c%s',115,f(
'%c%s',116,f('%c%s',32,f('%c%s',97,f('%c%s',0x6e,f('%c%s',111,f('%c%s',116,f(
'%c%s',104,f('%c%s',0x65,f('%c%s',114,f('%c%s',32,f('%c%s',80,f('%c%s',101,f(
'%c%s',114,f('%c%s',0x6c,f('%c%s',32,f('%c%s',0x48,f('%c%s',97,f('%c%s',99,f(
'%c%s',107,f('%c%s',101,f('%c%s',114,f('%c%s',10,)))))))))))))))))))))))))


  -----------== 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: Wed, 13 Oct 1999 20:17:55 GMT
From: Ilya <ilya@speakeasy.org>
Subject: Re: Comment out multiple lines
Message-Id: <s09q7jnfbhk6@corp.supernews.com>

Lauren Smith <laurensmith@sprynet.com> wrote:
> Ilya wrote in message ...
>>
>>Is there any way to comment out whole sections at a time, like in C and
> other
>>high level languages, instead of using "#" a bunch of times? If I have
> to
>>comment 20-30 lines at a time, this gets annoying.
> I realize that your opinion of the FAQ and docs that come with Perl is
> not exactly the highest, but your question is answered there.

> perlfaq7:"How can I comment out a large block of perl code?"


So you are saying I should search *all* of FAQs for this?

On www.perl.com in the FAQ section, I did a search on "comments", which didn't
get it. Then I searched on "comment out" which produced a huge list.
Now, after knowing the answer, it is obvious to me.
But if you don't know the answer, it could likely be in any one of those.

               General Questions About Perl (it is a general question, I think)

               Programming Tools (you could see it that way too)

               General Perl Language Issues (maybe here?)

perldoc -q comment out

was more successful, however.

And even now looking at this, it is not entirely clear. What the "=cut"
statement at the end for? 

     =begin comment text

     all of this stuff

     here will be ignored
     by everyone

     =end comment text

     =cut

  ===========================================================================
  Money, when  considered as the fruit of many years' industry, as the reward
  of labor, sweat and toil, is not to be sported with, or trusted to the airy
  bubble of paper currency.  -- Thomas Paine
  ===========================================================================


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

Date: Wed, 13 Oct 1999 20:23:50 GMT
From: Ilya <ilya@speakeasy.org>
Subject: Re: Comment out multiple lines
Message-Id: <s09qimjhbhk32@corp.supernews.com>

Brett W. McCoy <bmccoy@foiservices.com> wrote:
> Also Sprach Ilya <ilya@speakeasy.org>:

>>Is there  any way to  comment out whole  sections at a  time, like in  C and
>>other high level languages, instead of using "#" a bunch of times? If I have
>>to comment 20-30 lines at a time, this gets annoying.

> start the block with =comment
> and end it with =cut


Oh, that's not at all obvious from the FAQ entry. To me, it reads like you
have to use "=begin comment text" to begin a comment and "=end comment text"
to end a comment, but then was wondering what "=cut" was for. But I guess you
are right. Thanks.


   # program is here

    =for nobody
    This paragraph is commented out

    # program continues

    =begin comment text

    all of this stuff

    here will be ignored
    by everyone

    =end comment text

    =cut




  ===========================================================================
  Money, when  considered as the fruit of many years' industry, as the reward
  of labor, sweat and toil, is not to be sported with, or trusted to the airy
  bubble of paper currency.  -- Thomas Paine
  ===========================================================================


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

Date: 13 Oct 1999 16:38:36 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Comment out multiple lines
Message-Id: <slrn809uuc.nk2.abigail@alexandra.delanet.com>

Ilya (ilya@speakeasy.org) wrote on MMCCXXXIV September MCMXCIII in
<URL:news:s09q7jnfbhk6@corp.supernews.com>:
$$ 
$$ So you are saying I should search *all* of FAQs for this?

It really would not hurt to take the time and read the entire faq.
Then you know what's in there, and next time, you won't have to
wonder whether something is in the FAQ or not.

However, you don't need to search all the FAQs to see which questions
are answered. 'man perlfaq' (or perldoc perlfaq for the man challenged)
lists *all* the questions. A simple search on 'comment' finds it in
seconds.

$$ And even now looking at this, it is not entirely clear. What the "=cut"
$$ statement at the end for? 

man perlpod



Abigail
-- 
$" = "/"; split // => eval join "+" => 1 .. 7;
*{"@_"} = sub {foreach (sort keys %_) {print "$_ $_{$_} "}};
%_ = (Just => another => Perl => Hacker); &{%_};


  -----------== 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: Wed, 13 Oct 1999 14:27:53 -0700
From: "Lauren Smith" <laurensmith@sprynet.com>
Subject: Re: Comment out multiple lines
Message-Id: <7u2th0$4qn$1@brokaw.wa.com>


Ilya wrote in message ...
>Lauren Smith <laurensmith@sprynet.com> wrote:
>> perlfaq7:"How can I comment out a large block of perl code?"
>
>So you are saying I should search *all* of FAQs for this?

What I am definitely *not* saying is that you should READ every single
FAQ every time you want to find the answer to a problem.  OTOH, if you
run into a problem, you should *search* all of the FAQs.  Seeing as how
the search utility comes with Perl in the form of perldoc, it should be
relatively easy to construct a search phrase that would find what you're
looking for.

If you are unfamiliar with perldoc, then try typing 'perldoc perldoc' at
your command line.  It will give you a list of flags that you can use
with it to find anything from functions to FAQs.

>On www.perl.com in the FAQ section, I did a search on "comments", which
didn't
>get it. Then I searched on "comment out" which produced a huge list.

Yeah, that's probably not the most efficient way of searching the docs.

If you have trouble understanding the FAQs, come on back and ask for
clarification.

:-)
Lauren





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

Date: Wed, 13 Oct 1999 16:43:13 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Comment out multiple lines
Message-Id: <3804FCF1.E807E617@texas.net>

Ilya wrote:
> 
> Lauren Smith <laurensmith@sprynet.com> wrote:
> > Ilya wrote in message ...
> >>
> >>Is there any way to comment out whole sections at a time, like in C and
> > other
> >>high level languages, instead of using "#" a bunch of times? If I have
> > to
> >>comment 20-30 lines at a time, this gets annoying.
> > I realize that your opinion of the FAQ and docs that come with Perl is
> > not exactly the highest, but your question is answered there.
> 
> > perlfaq7:"How can I comment out a large block of perl code?"
> 
> So you are saying I should search *all* of FAQs for this?

Oh no, of course not.  You're time is *much* more valuable than that of
any other participant in this group.  We should look it up for you!

> perldoc -q comment out
> 
> was more successful, however.

Then why didn't you use 'perldoc -q' to answer your next question, which
is also in the docs?!

Enough is enough.

*plonk*

- Tom


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

Date: Thu, 14 Oct 1999 06:05:38 GMT
From: msumsion@my-deja.com
Subject: Compilation errors on my(...
Message-Id: <7u3rrc$11h$1@nnrp1.deja.com>

Ok.  I admit that I have no clue what I'm doing.  My programmer is
*missing* and I need to get this thing to work:

-----------
$_ = $totalcost;

if (/\./) {
	my($left, $right) = split(/\./,$totalcost);
	if (length($right) == 0) {
		$totalcost = $totalcost . "00";
		}
		elsif (length($right) == 1) { $totalcost =
$totalcost . "0"; }
	}
	else { $totalcost = $totalcost . ".00"; }
------------

syntax error in file ***.cgi at line 52, next 2 tokens "my("

Please throw a hint my way....


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 14 Oct 1999 06:54:13 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Compilation errors on my(...
Message-Id: <p6fN3.16$16.1233@nsw.nnrp.telstra.net>

On Thu, 14 Oct 1999 06:05:38 GMT,
	msumsion@my-deja.com <msumsion@my-deja.com> wrote:
> Ok.  I admit that I have no clue what I'm doing.  My programmer is
> *missing* and I need to get this thing to work:

Be glad they're missing. Don't let them back in.

[snip very elaborate way of saying]:

$totalcost = sprintf "%.2f", $totalcost;

(Actually, it doesn't say that, because the original code would leave
more than two decimals alone, but I bet the _intent_ was to always end
up with two decimals. Even if not, the code you showed was
unreasonably bulky and clunky, and even if the intent was to keep more
than two decimals it could have been done much more elegant)

> syntax error in file ***.cgi at line 52, next 2 tokens "my("

Errrr.. are you sure you are using perl 5? This worked before? on the
same box? Or did you move this to a different machine?

That sort of information is very important.

From a command line, type

# perl -v

If that says anything less than 5.004_04 you should upgrade, The code
you showed will not run on anything below perl 5. If it says anything
less than 5.005_03 you should consider upgrading.

I suspect that it will say something that starts with a 4.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | +++ Out of Cheese Error +++ Reinstall
Commercial Dynamics Pty. Ltd.   | Universe and Reboot +++
NSW, Australia                  | 


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

Date: Thu, 14 Oct 1999 08:56:58 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Compilation errors on my(...
Message-Id: <x3yd7ui6qxy.fsf@tigre.matrox.com>


msumsion@my-deja.com writes:

> Ok.  I admit that I have no clue what I'm doing.  My programmer is
> *missing* and I need to get this thing to work:

Did you try to look in the documentation for help? That should be your
first option (and it would've been much faster for you).

> -----------
> $_ = $totalcost;
> 
> if (/\./) {
> 	my($left, $right) = split(/\./,$totalcost);
> 	if (length($right) == 0) {
> 		$totalcost = $totalcost . "00";
> 		}
> 		elsif (length($right) == 1) { $totalcost =
> $totalcost . "0"; }
> 	}
> 	else { $totalcost = $totalcost . ".00"; }
> ------------
> 
> syntax error in file ***.cgi at line 52, next 2 tokens "my("

I don't see the reason of your error. It's probably in part of the
code that you don't show us, so we can't help you much.

> Please throw a hint my way....

Ok. Here you go. Apparently you (or your programmer) are trying to
round $totalcost to two decimal places. There is a very easy way to
accomplish this, and it is described well in the FAQs. Checkout what
perlfaq4 says:

       Why am I getting long decimals (eg, 19.9499999999999) instead
       of the numbers I should be getting (eg, 19.95)?

HTH,
--Ala



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

Date: Thu, 14 Oct 1999 17:34:20 -0500
From: "John W. Komp" <john.komp@uscorp.net>
Subject: Complex Regexpr (sorta)
Message-Id: <38065A6C.CFADEAC3@uscorp.net>


Hi,

I'm trying to parse a c file (a structure actually)...

item1, /* a comment */
item2, /* a comment */ more stuff
/* a comment */
item3
};

I want to end up with $1 holding everything infront of the comment or
the whole line if there is no comment, $2 holding the comment or the
whole line if there is only a comment and $3 to hold the remainder of
the line after the comment.

My regexpression I'm using is:

/(.*((?=\/\*)|\n)))
 (\/\*.*\*\/)
 (.*)/

For what ever reason if the line has no comment then $1 is always empty.
I assume thats from the ?= but I thought the |\n would match the end of
the line and leave everything in $1. 

Suggestions?

Is there a way to debug something like this?

Thanks,

-John

-- 
****************************************************
    This morning I shot six holes in my freezer
    I think I've got cabin fever
    Somebody sound the alarm
                   -  J. Buffett
****************************************************


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

Date: 14 Oct 1999 20:39:01 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Complex Regexpr (sorta)
Message-Id: <slrn80d1d4.q8s.abigail@alexandra.delanet.com>

John W. Komp (john.komp@uscorp.net) wrote on MMCCXXXV September MCMXCIII
in <URL:news:38065A6C.CFADEAC3@uscorp.net>:
## 
## Hi,
## 
## I'm trying to parse a c file (a structure actually)...
## 
## item1, /* a comment */
## item2, /* a comment */ more stuff
## /* a comment */
## item3
## };
## 
## I want to end up with $1 holding everything infront of the comment or
## the whole line if there is no comment, $2 holding the comment or the
## whole line if there is only a comment and $3 to hold the remainder of
## the line after the comment.
## 
## My regexpression I'm using is:
## 
## /(.*((?=\/\*)|\n)))
##  (\/\*.*\*\/)
##  (.*)/

Is there a reason you don't use the regex from the faq? What if comments
span multiple lines? What if there are strings having /* in them? What
if there are two comments on a line? What about escaped characters?

## For what ever reason if the line has no comment then $1 is always empty.
## I assume thats from the ?= but I thought the |\n would match the end of
## the line and leave everything in $1. 

Wrong. If there are no comments in a line, there isn't a '/*' token.
However, the third set of captioning parens *require* a '/*'. If there's
no '/*' in the line, the entire regex will fail.

Furthermore, you probably want a /x as well.

## Suggestions?

Yes. Get yourself Mastering Regular Expression and study it.



Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'


  -----------== 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, 14 Oct 1999 19:01:57 -0700
From: "Lauren Smith" <laurensmith@sprynet.com>
Subject: Re: Complex Regexpr (sorta)
Message-Id: <7u61v0$5ck$1@brokaw.wa.com>


John W. Komp wrote in message <38065A6C.CFADEAC3@uscorp.net>...
>I'm trying to parse a c file (a structure actually)...
>
>item1, /* a comment */
>item2, /* a comment */ more stuff
>/* a comment */
>item3
>};
>
>I want to end up with $1 holding everything infront of the comment or
>the whole line if there is no comment, $2 holding the comment or the
>whole line if there is only a comment and $3 to hold the remainder of
>the line after the comment.
I have thought about what possible reason you would want to keep
comments, and the only one that I can reasonably consider is that you
are trying to automate the documentation of the program.  Why don't you
just use a regex similar to the one in perlfaq6:"How do I use a regular
expression to strip C style comments from a file?" to capture the
comments?  Then you could slice and dice the struct however you wanted.

Lauren




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

Date: 15 Oct 1999 02:37:55 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: Re: Complex Regexpr (sorta)
Message-Id: <7u6423$8a5$1@rguxd.viasystems.com>

John W. Komp <john.komp@uscorp.net> wrote:

:>item1, /* a comment */
:>item2, /* a comment */ more stuff
:>/* a comment */
:>item3
:>};

:>I want to end up with $1 holding everything infront of the comment or
:>the whole line if there is no comment, $2 holding the comment or the
:>whole line if there is only a comment and $3 to hold the remainder of
:>the line after the comment.

I just used your specification and whipped out something that works
while watching the football game on ESPN.  There is almost certainly
a better way to do what you are trying to do, but this regexp seems
to work as long as you have 0 or 1 comments.

m{(.*?)(/\*.*\*/|$)(.*|$)};

I am ignoring the newline.  If you want to include the newline,
see `perldoc perlre` for the /m and /s modifiers and you would
probably use the \n where I use $.

Try

use re 'debugcolor'; # at the beginning of your program. It will
help you see what is going on.

-- 
// Lee.Lindley   /// I used to think that being right was everything.
// @bigfoot.com  ///  Then I matured into the realization that getting
////////////////////   along was more important.  Except on usenet.


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

Date: Thu, 14 Oct 1999 20:21:32 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Complex Regexpr (sorta)
Message-Id: <c2s5u7.e54.ln@magna.metronet.com>

John W. Komp (john.komp@uscorp.net) wrote:

: I'm trying to parse a c file (a structure actually)...


   So you have already seen the Perl FAQ about finding C comments then.


: My regexpression I'm using is:

: /(.*((?=\/\*)|\n)))
:  (\/\*.*\*\/)
:  (.*)/


   I doubt that, as it has both compilation and logic errors.

   Your parenthesis are unbalanced.

   Your pattern requires some spaces and newlines that I don't
   think you meant to require.

   Did you mean to use ///x instead?

   Or did you mean for it to be all on one line?


: Suggestions?


   Post pseudo-code if you desire a pseudo-answer.

   Post real code if you want a real answer.


: Is there a way to debug something like this?


   perldoc perldebug


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Fri, 15 Oct 1999 08:02:44 -0500
From: "John W. Komp" <john.komp@uscorp.net>
To: lee.lindley@bigfoot.com
Subject: Re: Complex Regexpr (sorta)
Message-Id: <380725F3.D86AF6DE@uscorp.net>


Lee,

Your Regexp worked like a champ. I'll get a handle on hungry and
eagerness yet. It was definately the first term that had tripped me up
and the '?' works much better than the '?=' I was trying to use.

Unfortunately debugcolor won't work for me as the IS people here didn't
install part of the re package apparently. It crashes out looking for
re.pm.

-John

lt lindley wrote:
> 
> m{(.*?)(/\*.*\*/|$)(.*|$)};
> 
> 
> use re 'debugcolor'; # at the beginning of your program. It will
> help you see what is going on.
> 
> --
> // Lee.Lindley   /// I used to think that being right was everything.
> // @bigfoot.com  ///  Then I matured into the realization that getting
> ////////////////////   along was more important.  Except on usenet.

-- 
****************************************************
    This morning I shot six holes in my freezer
    I think I've got cabin fever
    Somebody sound the alarm
                   -  J. Buffett
****************************************************


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

Date: 15 Oct 1999 07:07:08 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Complex Regexpr (sorta)
Message-Id: <m1puyghg4z.fsf@halfdome.holdit.com>

>>>>> "John" == John W Komp <john.komp@uscorp.net> writes:

John> I want to end up with $1 holding everything infront of the comment or
John> the whole line if there is no comment, $2 holding the comment or the
John> whole line if there is only a comment and $3 to hold the remainder of
John> the line after the comment.

Besides abigail's dead-on comments, what do you want when there
are two comments on a line?

Half the battle on stuff like this is getting a specification that
makes sense.

print "Just another Perl hacker,"

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 15 Oct 1999 15:55:08 GMT
From: lt lindley <ltl@rgsun5.viasystems.com>
Subject: Re: Complex Regexpr (sorta)
Message-Id: <7u7ios$kfu$2@rguxd.viasystems.com>

John W. Komp <john.komp@uscorp.net> wrote:
:>Lee,

:>Your Regexp worked like a champ. I'll get a handle on hungry and
:>eagerness yet. It was definately the first term that had tripped me up
:>and the '?' works much better than the '?=' I was trying to use.

John, 
You left out a very important part of my post in your attribution.
What I offered works "only for 0 or 1 complete comments on a line."
Lots of others are chiming in that you should look at the faq
entry about stripping C comments.  It is good advice.  It will
save you trouble in the long run.

:>Unfortunately debugcolor won't work for me as the IS people here didn't
:>install part of the re package apparently. It crashes out looking for
:>re.pm.

Upgrade. 

-- 
// Lee.Lindley   /// I used to think that being right was everything.
// @bigfoot.com  ///  Then I matured into the realization that getting
////////////////////   along was more important.  Except on usenet.


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

Date: Fri, 15 Oct 1999 11:39:33 GMT
From: init__self@my-deja.com (Python Addict)
Subject: Confused about reference vs. value...
Message-Id: <slrn80e4jm.1joh.init__self@jules.com>

Hello. I've inherited a bunch of scripts that were cobbled together in
the mid 14th century and as I'm not keen on having my box rooted, I
thought it might be a good idea to bring them into modern times.

I'm having a slight problem understanding passing values. Consider this
sub:

- - - - -
sub trim {
	# Trim spaces
	my $tempParam = shift;
	my $temp = param($tempParam);
	$temp =~ s/^\s+//; # trim first space(s)
	$temp =~ s/\s+$//; # trim last space(s)
	param($tempParam,$temp);
}
- - - - -

When I call this sub via something like

- - - - -
	if ( trim(param('whatever')) eq "" ) {
		...
- - - - -

not a great deal happens. 

If I understand things correctly, passing by reference requires a
leading '\'. But I'm not actually sure what kind of thingie (thanks
Camel book!) I'm passing. Is it an array? Hmmm.

param(), by the way, has been conjoured up by way of saying 'use CGI;' at
the top of my script. It's a fresh CGI.pm as I grabbed it via CPAN last
night.

Any beatings with the clue stick gleefully received.

-- 
If you threw Microsoft and the truth in a room, would you get a 
matter-antimatter explosion?


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

Date: Fri, 15 Oct 1999 06:37:26 -0700
From: moseley@best.com (Bill Moseley)
Subject: Re: Confused about reference vs. value...
Message-Id: <MPG.1270cdf2ae68b51398980a@nntp1.ba.best.com>

Python Addict (init__self@my-deja.com) seems to say...
> I'm having a slight problem understanding passing values. Consider this
> sub:

This is not a question about references.

> 
> sub trim {
> 	# Trim spaces
> 	my $tempParam = shift;
> 	my $temp = param($tempParam);
> 	$temp =~ s/^\s+//; # trim first space(s)
> 	$temp =~ s/\s+$//; # trim last space(s)
> 	param($tempParam,$temp);
> }
> 
> When I call this sub via something like
> 	if ( trim(param('whatever')) eq "" ) {
> not a great deal happens. 

Look at that sub routine.  You pass it the NAME of the parameter, not 
the value.  It extracts out the value:
 	my $temp = param($tempParam);

 	if ( trim( 'whatever' ) eq "" ) {

> If I understand things correctly, passing by reference requires a
> leading '\'. But I'm not actually sure what kind of thingie (thanks
> Camel book!) I'm passing. Is it an array? Hmmm.

> Any beatings with the clue stick gleefully received.

If you are updating scripts for security you should read a bit.

perldoc perlsec is one place to start.

-- 
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.


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

Date: Fri, 15 Oct 1999 13:44:47 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: Confused about reference vs. value...
Message-Id: <7u7bcu$4u9$1@news.mch.sbs.de>

In article <slrn80e4jm.1joh.init__self@jules.com>, init__self@my-deja.com (Python Addict) wrote:
<snip>
>I'm having a slight problem understanding passing values. Consider this
>sub:
>
>- - - - -
>sub trim {
>        # Trim spaces
>        my $tempParam = shift;
>        my $temp = param($tempParam);
>        $temp =~ s/^\s+//; # trim first space(s)
>        $temp =~ s/\s+$//; # trim last space(s)
>        param($tempParam,$temp);
>}
>- - - - -
>
>When I call this sub via something like
>
>- - - - -
>        if ( trim(param('whatever')) eq "" ) {
>                ...
>- - - - -
>
>not a great deal happens. 

Suppose param('whatever') is equal to 'myvalue'. If you call trim()
like this, $tempParam becomes 'myvalue', and $temp becomes ???
(undef, most likely). So at the end of trim, you set param('myvalue')
to undef, which is probably not what you want :-)

Just drop the param when calling trim(), and you'll be OK (for non-array
values, that is).

Michel.


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

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

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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


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