[31727] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2990 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 14 11:09:29 2010

Date: Mon, 14 Jun 2010 08:09:09 -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           Mon, 14 Jun 2010     Volume: 11 Number: 2990

Today's topics:
    Re: Convert array into list context <xhoster@gmail.com>
    Re: Convert array into list context <uri@StemSystems.com>
    Re: Convert array into list context <jurgenex@hotmail.com>
    Re: Convert array into list context <uri@StemSystems.com>
    Re: Creating pdf output file <justin.0911@purestblue.com>
        File Content reversal-Not working with foreach and pop  <divyajacobpulickal@gmail.com>
    Re: File Content reversal-Not working with foreach and  <jurgenex@hotmail.com>
    Re: File Content reversal-Not working with foreach and  <tadmc@seesig.invalid>
    Re: File Content reversal-Not working with foreach and  <ben@morrow.me.uk>
    Re: File Content reversal-Not working with foreach and  sln@netherlands.com
    Re: File Content reversal-Not working with foreach and  <justin.0911@purestblue.com>
    Re: How to grep using an array of patterns? <john@castleamber.com>
    Re: How to grep using an array of patterns? <tadmc@seesig.invalid>
    Re: Matching block of nested brace pairs <cwilbur@chromatico.net>
    Re: Matching block of nested brace pairs <ben@morrow.me.uk>
    Re: Matching block of nested brace pairs <jurgenex@hotmail.com>
    Re: Matching block of nested brace pairs <tadmc@seesig.invalid>
        www.thevoid1.net/offlame <robin1@cnsp.com>
    Re: www.thevoid1.net/offlame <uri@StemSystems.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 13 Jun 2010 19:24:50 -0700
From: Xho Jingleheimerschmidt <xhoster@gmail.com>
Subject: Re: Convert array into list context
Message-Id: <4c159381$0$3758$ed362ca5@nr5-q3a.newsreader.com>

Uri Guttman wrote:
>>>>>> "XJ" == Xho Jingleheimerschmidt <xhoster@gmail.com> writes:
> 
>   XJ> Uri Guttman wrote:
>   >>>>>>> "RC" == Ryan Chan <ryanchan404@gmail.com> writes:
>   >> 
>   RC> Consider the simple code.
>   RC> ============
>   RC> my @a = (1,2,'c');
>   >> 
>   RC> my $s = ('a' , @a);
>   >> 
>   >> regardless, that is throwing away 'a'. if you had warnings enabled, that
>   >> would be flagged. so why are you doing that? there is no benefit to that
>   >> construct.
> 
>   XJ> Of course not.  But it did what he wanted, then there would be.
> 
> me thinks you have a grammar mistake or i don't get your second sentence
> at all.

It was supposed to be "But if it did".


> and the OP's need is still silly.

Make $s be the last thing in @a, or 'a' if @a is empty.  Of course, the 
()[-1] construct handles that nicely.  I'm not sure why that need is silly.

Xho


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

Date: Sun, 13 Jun 2010 23:03:42 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: Convert array into list context
Message-Id: <87631mpb75.fsf@quad.sysarch.com>

>>>>> "XJ" == Xho Jingleheimerschmidt <xhoster@gmail.com> writes:

  XJ> Uri Guttman wrote:
  >>>>>>> "XJ" == Xho Jingleheimerschmidt <xhoster@gmail.com> writes:
  >> 
  XJ> Of course not.  But it did what he wanted, then there would be.
  >> 
  >> me thinks you have a grammar mistake or i don't get your second sentence
  >> at all.

  XJ> It was supposed to be "But if it did".


  >> and the OP's need is still silly.

  XJ> Make $s be the last thing in @a, or 'a' if @a is empty.  Of course,
  XJ> the ()[-1] construct handles that nicely.  I'm not sure why that need
  XJ> is silly.

the need for getting the last element of a list with a fixed element
that is lost is silly. yes it could be done with ()[-1] but not the way
it was coded nor did he say that was the goal (defaulting to 'a'). i
would code it this way which is clear that is the goal:

	$x = $a[0] || 'a' ;

of course change that to -1 if you want the last element and use // if
you want it to work with 0 vs defined. this way makes it clear that 'a'
is a default and also it doesn't build up a wasteful list.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Sun, 13 Jun 2010 20:10:46 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Convert array into list context
Message-Id: <3c7b16dbspp5kcs8suc24qd8hgq6h0np4v@4ax.com>

Ryan Chan <ryanchan404@gmail.com> wrote:
>But it is ambiguous that we don't know when the array is being
>flattened,

I may very well be mistaken but I tend to believe that flattening
happens only for function arguments and return values.

jue


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

Date: Sun, 13 Jun 2010 23:50:55 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: Convert array into list context
Message-Id: <87r5kanug0.fsf@quad.sysarch.com>

>>>>> "JE" == Jürgen Exner <jurgenex@hotmail.com> writes:

  JE> Ryan Chan <ryanchan404@gmail.com> wrote:
  >> But it is ambiguous that we don't know when the array is being
  >> flattened,

  JE> I may very well be mistaken but I tend to believe that flattening
  JE> happens only for function arguments and return values.

it depends on the function (builtin or sub). some builtins have
prototypes where an array is passed whole (e.g. splice, shift) as scalar
args may follow which are kept separate and not slurped in. and you can
code subs with prototypes like that as well. i generally stay away from
sub protos but recognize they exist in builtins.

actually all list contexts will flatten an array (or multiple
arrays). most are provided by functions or return but you missed
assignment (and return's context is provided by what it is assigned
to).

also indexing provides list context:

	$x = (1, 4, @a) ;
	$x = (1, 4, @a)[$y] ;

the first line was the example the OP posted.

there are likely others but i can't think clearly now. been a long weekend.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Mon, 14 Jun 2010 12:37:35 -0000
From: Justin C <justin.0911@purestblue.com>
Subject: Re: Creating pdf output file
Message-Id: <533a.4c16228f.7a0a6@zem>

On 2010-06-12, HerbF@earthlink.net <HerbF@earthlink.net> wrote:
> I have a Perl script that generates an HTML page and sends it to a
> recipient via email. I would prefer to send the recipient a pdf document
> instead of the HTML page. Is there "an easy" method of doing this within
> the Perl script?

If there isn't a lot of data in the HTML page, and the layout is static
you could try PDF::Reuse. I had major difficulties generating the PDFs I
wanted and found this ideal. I created an empty page PDF, and that
became my template for putting everything else on/in. Damn lame I know,
but I found the documentation for the other modules impenetrable.

	Justin.

-- 
Justin C, by the sea.


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

Date: Mon, 14 Jun 2010 05:30:27 -0700 (PDT)
From: divyajacob <divyajacobpulickal@gmail.com>
Subject: File Content reversal-Not working with foreach and pop from array
Message-Id: <26627d3a-53ee-4a34-8339-3ef34892a288@t14g2000prm.googlegroups.com>

I was trying out a program
 Accept a filename as command line argument. Display the
contents of that file in the opposite order that they appear in the
file.

file content is :-

Three Rings for the Elven-kings under the sky,
Seven for the Dwarf-lords in their halls of stone,
Nine for Mortal Men doomed to die,
One for the Dark Lord on his dark throne
In the Land of Mordor where the Shadows lie.
One Ring to rule them all, One Ring to find them,
One Ring to bring them all and in the darkness bind them
In the Land of Mordor where the Shadows lie.


I want to print it like:-

In the Land of Mordor where the Shadows lie.
One Ring to bring them all and in the darkness bind them
One Ring to rule them all, One Ring to find them,
In the Land of Mordor where the Shadows lie.
One for the Dark Lord on his dark throne
Nine for Mortal Men doomed to die,
Seven for the Dwarf-lords in their halls of stone,
Three Rings for the Elven-kings under the sky,

The program I wrote is
use strict;
my $num = $#ARGV + 1;
my $str;
my @file;
if($num >= 1)
{
        $str = $ARGV[0];
}
else
{
        print "No argument provided\n";
}

open (FILE,$str);
while(<FILE>)
{
 push(@file,$_);
}
print "Reversed file content\n";
foreach(@file)
{

print pop(@file);
}
O/p
perl ex_04.pl ringfile.txt
Reversed file content
In the Land of Mordor where the Shadows lie.
One Ring to bring them all and in the darkness bind them
One Ring to rule them all, One Ring to find them,
In the Land of Mordor where the Shadows lie.

I am getting only 4 lines in the output,Why I am not getting full 8
lines in the output?
Please help..am I doing anything wrong.

Thanks in advance
Divya



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

Date: Mon, 14 Jun 2010 06:14:33 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: File Content reversal-Not working with foreach and pop from array
Message-Id: <m99c16p4cd7mo6iaqlbu5785g26cr3mv58@4ax.com>

divyajacob <divyajacobpulickal@gmail.com> wrote:
>I was trying out a program
> Accept a filename as command line argument. Display the
>contents of that file in the opposite order that they appear in the
>file.
>
>file content is :-
>
>Three Rings for the Elven-kings under the sky,
>Seven for the Dwarf-lords in their halls of stone,
>Nine for Mortal Men doomed to die,
>One for the Dark Lord on his dark throne
>In the Land of Mordor where the Shadows lie.
>One Ring to rule them all, One Ring to find them,
>One Ring to bring them all and in the darkness bind them
>In the Land of Mordor where the Shadows lie.
>
>
>I want to print it like:-
>
>In the Land of Mordor where the Shadows lie.
>One Ring to bring them all and in the darkness bind them
>One Ring to rule them all, One Ring to find them,
>In the Land of Mordor where the Shadows lie.
>One for the Dark Lord on his dark throne
>Nine for Mortal Men doomed to die,
>Seven for the Dwarf-lords in their halls of stone,
>Three Rings for the Elven-kings under the sky,
>
>The program I wrote is
>use strict;
>my $num = $#ARGV + 1;

Better (unless you fooled around with $[ )
	my $num = @ARGV; 
# using an array in scalar context yields the number of array elements

>my $str;
>my @file;
>if($num >= 1)

More perlishly written as
	if (@ARGV) {
# yields false if and only if array length is 0

>{
>        $str = $ARGV[0];
>}
>else
>{
>        print "No argument provided\n";

Logical error. Probably missing:
	exit -1;
Otherwise you continue your program and try to open a file even if there
was no filename supplied.
>}

>open (FILE,$str);

You should use lexical file handles, the 3-argument form of open(), and
always, yes always, check for failure:
	open ($FILE, '<', $str) or die "Cannot open $str: $!";

>while(<FILE>)
>{
> push(@file,$_);
>}

The whole while loop can be replaced by 
	@file = <$FILE>;

>print "Reversed file content\n";
>foreach(@file) {
>	print pop(@file);
>}

This is bad bad bad style. While looping through the array using foreach
you are altering the array itself, i.e. you are deleting elements from
the array. Don't do that because results are unpredictable.

In this case by the time the loop has been executed 4 fimes the array
contains only 4 remaining elements and the foreach loop has reached the
end of the array.

Instead use a while loop:
	while (@file) {
This will repeat the loop until all elements have been pop'ed out of the
array and only the empty array is left.

And of course the most obvious approach is to use reverse().

	print reverse (@file);

jue


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

Date: Mon, 14 Jun 2010 08:28:43 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: File Content reversal-Not working with foreach and pop from array
Message-Id: <slrni1cb9p.dt4.tadmc@tadbox.sbcglobal.net>

divyajacob <divyajacobpulickal@gmail.com> wrote:
> I was trying out a program
>  Accept a filename as command line argument. Display the
> contents of that file in the opposite order that they appear in the
> file.

> The program I wrote is
> use strict;
> my $num = $#ARGV + 1;


    my $num = @ARGV;


> open (FILE,$str);


You should always, yes *always*, check the return value from open():

    open(FILE, $str) or die "could not open '$str' $!";


> foreach(@file)
> {
>
> print pop(@file);

> I am getting only 4 lines in the output,Why I am not getting full 8
> lines in the output?
> Please help..am I doing anything wrong.


Yes, what you are doing wrong is not reading the docs for
the language features that you are using.

The "Foreach Loops" section in

    perldoc perlsyn

says

    If any part of LIST is an array, foreach will get very confused if
    you add or remove elements within the loop body, for example with
    splice.   So don't do that.

so then,

   while (@file) {
       print pop(@file);
   }

or, probably better

   foreach (reverse @file) {
       print;
   }

or, probably better still, simply

   print reverse <FILE>;


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.


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

Date: Mon, 14 Jun 2010 14:19:47 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: File Content reversal-Not working with foreach and pop from array
Message-Id: <jsmhe7-jvr1.ln1@osiris.mauzo.dyndns.org>


Quoth divyajacob <divyajacobpulickal@gmail.com>:
> I was trying out a program
>  Accept a filename as command line argument. Display the
> contents of that file in the opposite order that they appear in the
> file.
> 
> file content is :-
> 
> Three Rings for the Elven-kings under the sky,
> Seven for the Dwarf-lords in their halls of stone,
> Nine for Mortal Men doomed to die,
> One for the Dark Lord on his dark throne
> In the Land of Mordor where the Shadows lie.
> One Ring to rule them all, One Ring to find them,
> One Ring to bring them all and in the darkness bind them
> In the Land of Mordor where the Shadows lie.
> 
> 
> I want to print it like:-
> 
> In the Land of Mordor where the Shadows lie.
> One Ring to bring them all and in the darkness bind them
> One Ring to rule them all, One Ring to find them,
> In the Land of Mordor where the Shadows lie.
> One for the Dark Lord on his dark throne
> Nine for Mortal Men doomed to die,
> Seven for the Dwarf-lords in their halls of stone,
> Three Rings for the Elven-kings under the sky,
> 
> The program I wrote is
> use strict;

Good. You also want

    use warnings;

> my $num = $#ARGV + 1;

If you want the number of elements in an array, evaluate the array in
scalar context. That is:

    my $num = @ARGV;

(You don't actually need $num at all: if (@ARGV >= 1) will work
perfectly well.)

> my $str;
> my @file;
> if($num >= 1)
> {
>         $str = $ARGV[0];
> }
> else
> {
>         print "No argument provided\n";
> }

If there is no argument provided, this will print a message and then
carry on regardless. You probably want to replace 'print' with 'die',
which will print the message to STDERR (as appropriate for errors) and
then exit.

> 
> open (FILE,$str);

*Always* check the return value of open, or use 'autodie' which will do
it for you.
Use 3-arg open (it's safer, especially when you don't know what the
filename will be).
Use lexical filehandles.

    open(my $FILE, "<", $str)
        or die "can't open '$str': $!";

> while(<FILE>)
> {
>  push(@file,$_);
> }

<FILE> will return the whole file, divided into lines, if you use it in
list context, so this whole loop can be replaced with

    my @file = <$FILE>;

> print "Reversed file content\n";
> foreach(@file)
> {
> 
> print pop(@file);
> }

If you have just a single array as the argument to foreach, perl will
iterate over the array itself rather than expanding it to a list first.
This means that if you modify the array in the loop you will see
unexpected side-effects. You want either

    foreach (reverse @file) {
        print $_;
    }

or

    while (@file) {
        print pop @file;
    }

Ben



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

Date: Mon, 14 Jun 2010 07:44:15 -0700
From: sln@netherlands.com
Subject: Re: File Content reversal-Not working with foreach and pop from array
Message-Id: <abfc165sss4v40813m5jnbsmjqrd29fhje@4ax.com>

On Mon, 14 Jun 2010 05:30:27 -0700 (PDT), divyajacob <divyajacobpulickal@gmail.com> wrote:

>I was trying out a program
> Accept a filename as command line argument. Display the
>contents of that file in the opposite order that they appear in the
>file.
>
[snip]
>foreach(@file)
>{
>
>print pop(@file);
>}
[snip]

>I am getting only 4 lines in the output,Why I am not getting full 8
>lines in the output?
>Please help..am I doing anything wrong.
>
>Thanks in advance
>Divya

The only question is why the bogus pretense of programming.
Are you trying to actually print out a reverse of the file
or are you whining that this:

  print pop(@array) foreach(@array)

never works?

How do you know what pop, push, foreach is ??
What does print pop(@array) do?
You have to go to the root of the problem.

-sln


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

Date: Mon, 14 Jun 2010 14:28:19 -0000
From: Justin C <justin.0911@purestblue.com>
Subject: Re: File Content reversal-Not working with foreach and pop from array
Message-Id: <60db.4c163c83.3c8d7@zem>

On 2010-06-14, divyajacob <divyajacobpulickal@gmail.com> wrote:
> I was trying out a program
>  Accept a filename as command line argument. Display the
> contents of that file in the opposite order that they appear in the
> file.
>
> file content is :-
>
> Three Rings for the Elven-kings under the sky,
> Seven for the Dwarf-lords in their halls of stone,
> Nine for Mortal Men doomed to die,
> One for the Dark Lord on his dark throne
> In the Land of Mordor where the Shadows lie.
> One Ring to rule them all, One Ring to find them,
> One Ring to bring them all and in the darkness bind them
> In the Land of Mordor where the Shadows lie.
>
>
> I want to print it like:-
>
> In the Land of Mordor where the Shadows lie.
> One Ring to bring them all and in the darkness bind them
> One Ring to rule them all, One Ring to find them,
> In the Land of Mordor where the Shadows lie.
> One for the Dark Lord on his dark throne
> Nine for Mortal Men doomed to die,
> Seven for the Dwarf-lords in their halls of stone,
> Three Rings for the Elven-kings under the sky,
>
> The program I wrote is
> use strict;
> my $num = $#ARGV + 1;
> my $str;
> my @file;
> if($num >= 1)
> {
>         $str = $ARGV[0];
> }
> else
> {
>         print "No argument provided\n";
> }
>
> open (FILE,$str);
> while(<FILE>)
> {
>  push(@file,$_);
> }
> print "Reversed file content\n";
> foreach(@file)
> {
>
> print pop(@file);
> }

You're removing from the stack that your reading from. The 'foreach'
works with each line, you then go and confuse it by taking a line away
with 'pop'. In this instance I'd be inclined to 'while (@file)' instead.
Your pop will then be OK.

As well as 'use strict' add 'use warnings', they're very helpful.

	Justin.

-- 
Justin C, by the sea.


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

Date: Sun, 13 Jun 2010 21:52:03 -0500
From: John Bokma <john@castleamber.com>
Subject: Re: How to grep using an array of patterns?
Message-Id: <87r5ka2ung.fsf@castleamber.com>

"Uri Guttman" <uri@StemSystems.com> writes:

>>>>>> "JB" == John Bokma <john@castleamber.com> writes:
>
>   JB> [1] I hate it when regulars can get away with stuff they wouldn't let
>   JB>     any newbie get away with.
>
> that is why they are called regulars. they have (usually) earned some
> reputation points or have external (like cpan and other perl community)
> experience worth listening too.

I am not talking about reputation etc. I am glad that you replied, to be
honest. Why do you think it's OK to write file::slurp when you mean 
File::Slurp?

> good thing. how that is done may be your issue but i like tad's way as
> it hits hard 

Yes, it's fucking annoying (since you like hard, there it is). As a
regular one should, IMO, learn to stand above it, and don't get pissed
off at every single newbie that shows up. It's not that much harder to
ask/reprimand nicely. I mean I can ask you nicely to press the shift now
and then as to make your postings a bit easier on the eye, and also not
to confuse newbies with non-existing pragmatic (!) modules like
file::slurp. Or I can slap you around every day. I prefer the first
because it has hopefully an effect.

I do like to keep reading posts by you, Tad and several others. But it
gets harder and harder to pick the fruit, since too many posts are just
bashing newbies. While I agree that this is not a help desk for people
who can't be bothered to scratch their own asses, I think there is a
better way to handle it. Like I wrote in an earlier post: have the
faq-bot post daily: "Why doesn't anyone answer my question?" with the
pointers to the FAQ, posting guidelines, etc. No more need to bash
newbies, and more time for fun discussions. And trust me, while they
will ignore stuff like "posting guidelines" they will read "Why doesn't"
because that's the question they have ;-).

If you have a better idea, I am all in for it. But personally I really
start to dislike the negative energy a lot of posts here have. While it
might feel good to set someone straight, it might scare off others (like
me, and I am not easily scared away).

I also read comp.lang.python and the climate is very, very different
from comp.lang.perl.misc. And no: "move over there, and stay away
from here" is not a good answer. I hope you agree.

Thanks for reading,

-- 
John Bokma                                                               j3b

Hacking & Hiking in Mexico -  http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development


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

Date: Mon, 14 Jun 2010 00:04:27 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: How to grep using an array of patterns?
Message-Id: <slrni1bdo7.c1e.tadmc@tadbox.sbcglobal.net>

John Bokma <john@castleamber.com> wrote:
> "Uri Guttman" <uri@StemSystems.com> writes:
>
>>>>>>> "JB" == John Bokma <john@castleamber.com> writes:
>>
>>   JB> [1] I hate it when regulars can get away with stuff they wouldn't let
>>   JB>     any newbie get away with.


What "stuff" do you mean there?

Are you suggesting that _I_ got away with something that wouldn't be
accepted from a newbie?

What would that be?


>> that is why they are called regulars. they have (usually) earned some
>> reputation points or have external (like cpan and other perl community)
>> experience worth listening too.
>
> I am not talking about reputation etc. I am glad that you replied, to be
> honest. Why do you think it's OK to write file::slurp when you mean 
> File::Slurp?


Hey! I agree with you about something!


>> good thing. how that is done may be your issue but i like tad's way as
>> it hits hard 
>
> Yes, it's fucking annoying (since you like hard, there it is). 


<cue the violins>


> As a
> regular one should, IMO, learn to stand above it, and don't get pissed
> off at every single newbie that shows up. 


I don't get pissed at every single newbie that shows up.

(ridiculous exaggeration hurts your arguments rather than
 helping to make your point. I discount pretty much everything
 that is said following such ridiculousness.
)

I get pissed at every single newbie that expects us to read
the docs to them.

And even then I don't get snarky for a single offense.

A quick count of my followups to this OP shows 17 replies.

13 where I just answered the question, because the answer was not
obvious from the docs.

4 where I answered the question and injected some snark, because
the answer was obvious from the docs.

You reap what you sow.

If you don't want to be taken to task, then don't post without
attempting to find the answer yourself first.

Usenet is a last-resort resource, not the first resort.


> It's not that much harder to
> ask/reprimand nicely. 


Right, but it is easier to ignore when delivered nicely.

Ignoring accepted netiquette is certainly bad for our newsgroup.

I don't want bad for this newsgroup.


> I mean I can ask you nicely to press the shift now
> and then as to make your postings a bit easier on the eye, 


Uri's "style" annoys the hell out of me too.


> and also not
> to confuse newbies with non-existing pragmatic (!) modules like
> file::slurp. Or I can slap you around every day. I prefer the first
> because it has hopefully an effect.
>
> I do like to keep reading posts by you, Tad and several others. But it
> gets harder and harder to pick the fruit, since too many posts are just
> bashing newbies. 


None, none!, of my followups to this thread's OP were "just" bashing.

(there's that exaggeration thing yet again, your credibility with me
 approaches zero)

Each and every one of my followups included help (along with the bashing).


> While I agree that this is not a help desk for people
> who can't be bothered to scratch their own asses, I think there is a
> better way to handle it. 


Just as you are free to think that nice is better, others are free
to think that in-your-face is better.

It is a waste of your time to try and convince me otherwise, as I've
been here far too long to believe that your approach is better, and
I find it hard to believe what you say anyway.


> Like I wrote in an earlier post: have the
> faq-bot post daily: "Why doesn't anyone answer my question?" with the
> pointers to the FAQ, posting guidelines, etc. 


Are you waiting for someone else to implement your idea for you?


> No more need to bash
> newbies, and more time for fun discussions. And trust me, while they
> will ignore stuff like "posting guidelines" they will read "Why doesn't"
> because that's the question they have ;-).


I doubt that, but go ahead and try it and we'll find out.


> If you have a better idea, I am all in for it. But personally I really
> start to dislike the negative energy a lot of posts here have. While it
> might feel good to set someone straight, it might scare off others (like
> me, and I am not easily scared away).


Wa wa wa.

If you are unwilling to spend 10 minutes grepping the std docs
before asking your question on Usenet, then Usenet is better off
if you _are_ scared away.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.


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

Date: Sun, 13 Jun 2010 21:53:18 -0400
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: Matching block of nested brace pairs
Message-Id: <86y6eiqt0x.fsf@mithril.chromatico.net>

>>>>> "PY" == Peng Yu <pengyu.ut@gmail.com> writes:

    PY> The example on this link is daunting to me. I have read perlre.

    PY> I still don't understand it how it works. What doesn't "Recurse
    PY> to start of paren group 2"?

Do you understand what "recurse" means? Do you understand what "paren
group 2" means?

    PY> For my specific problem (C++ namespace), would you please show
    PY> me how to do it and explain it to me how it works? Thank you!

Frankly, no, because if I do, you'll ignore the explanation and ask
comp.lang.perl.misc the next time you have a problem to solve, and I'm
already tired of seeing you ask FAQs.  You really have two options: you
can put in the work to understand what you're doing, or you can hire
someone, for money, who will write code to your specification.

Charlton


-- 
Charlton Wilbur
cwilbur@chromatico.net


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

Date: Mon, 14 Jun 2010 01:01:30 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Matching block of nested brace pairs
Message-Id: <q38ge7-0g91.ln1@osiris.mauzo.dyndns.org>


Quoth Peng Yu <pengyu.ut@gmail.com>:
> Suppose I have some C++ code like the following, I want to match the
> whole namespace x block.
> 
> namespace x
> {
>   namespace y
>   {
>    ....
>   }
> 
> }
> 
> The following webpage shows brace-matching for perl regex. But I don't
> find the matchpairs module. (I'm using perl 5.10.1). Would you please
> let me know if there is a way to match block of nested braces in perl?
> 
> http://dev.perl.org/perl6/rfc/145.html
                      ^^^^^ ^^^
This was a speculative design document during the early part of the
development of Perl 6. None of these RFCs apply to Perl 5.

As far as balanced matching goes, check the FAQ. (Please do so *before*
posting in future.)

Ben



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

Date: Sun, 13 Jun 2010 20:16:39 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Matching block of nested brace pairs
Message-Id: <4k7b16te3s3a51mulb06c3574h2r8b9m5s@4ax.com>

Peng Yu <pengyu.ut@gmail.com> wrote:
>The following webpage shows brace-matching for perl regex. But I don't
>find the matchpairs module. (I'm using perl 5.10.1). Would you please
>let me know if there is a way to match block of nested braces in perl?

You keep asking very basic questions and questions that are answered in
the FAQ. I _VERY_STRONGLY_ suggest you familiarize yourself with the
FAQ.

Here is the last fish for you: "perldoc -q nest":
	"How do I find matching/nesting anything?"

jue


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

Date: Mon, 14 Jun 2010 00:18:57 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Matching block of nested brace pairs
Message-Id: <slrni1bejd.c1e.tadmc@tadbox.sbcglobal.net>

Peng Yu <pengyu.ut@gmail.com> wrote:
> Suppose I have some C++ code like the following, I want to match the
> whole namespace x block.

[ snip string to match ]

> Would you please
> let me know if there is a way to match block of nested braces in perl?


Would you please scan the Perl FAQ before posting to the Perl newsgroup?

    How do I find matching/nesting anything?

-------------------------
#!/usr/bin/perl
use warnings;
use strict;
use Regexp::Common;
;

$_ = '
namespace x
{
  namespace y
  {
   ....
  }

}
';

if ( /(.*\n$RE{balanced}{-parens=>'{}'})/ ) {
    print "$1\n\n";
}
-------------------------


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.


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

Date: Mon, 14 Jun 2010 00:56:05 -0700 (PDT)
From: Robin <robin1@cnsp.com>
Subject: www.thevoid1.net/offlame
Message-Id: <f40eaa22-9691-49c4-9174-63f41a3119c6@q12g2000yqj.googlegroups.com>


great sites...perl source code here

www.thevoid1.net/offlame

it has some really unique health walkthrough stuff I've never seen
before.
-R


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

Date: Mon, 14 Jun 2010 04:59:42 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: www.thevoid1.net/offlame
Message-Id: <8739wqkn0h.fsf@quad.sysarch.com>

>>>>> "R" == Robin  <robin1@cnsp.com> writes:

  R> great sites...perl source code here

and why would we look there? better than cpan? 

  R> www.thevoid1.net/offlame

must mean officially lame.

  R> it has some really unique health walkthrough stuff I've never seen
  R> before.

wow.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

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:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 V11 Issue 2990
***************************************


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