[31374] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2626 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 8 11:09:31 2009

Date: Thu, 8 Oct 2009 08:09:10 -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, 8 Oct 2009     Volume: 11 Number: 2626

Today's topics:
    Re: [regexp] Changing lines NOT containing a pattern sln@netherlands.com
    Re: Changing lines NOT containing a pattern <derykus@gmail.com>
        FAQ 4.69 How can I make the Perl equivalent of a C stru <brian@theperlreview.com>
        FAQ 8.31 Can I use perl to run a telnet or ftp session? <brian@theperlreview.com>
        Help on massaging some data <clearguy02@yahoo.com>
    Re: Help on massaging some data sln@netherlands.com
    Re: Help on massaging some data <jurgenex@hotmail.com>
    Re: Help on massaging some data <someone@example.com>
    Re: Help on massaging some data <cartercc@gmail.com>
    Re: Help on massaging some data <ben@morrow.me.uk>
    Re: Help on massaging some data <justin.0908@purestblue.com>
        Perlpod - How to add URL links with L<> <jari.aalto@cante.net>
    Re: Perlpod - How to add URL links with L<> <ben@morrow.me.uk>
    Re: Perlpod - How to add URL links with L<> <jari.aalto@cante.net>
    Re: Perlpod, pod2man: get ascii grave accent in ROFF \( <waterlan@xs4all.nl>
    Re: Perlpod, pod2man: get ascii grave accent in ROFF \( <ben@morrow.me.uk>
    Re: Perlpod, pod2man: get ascii grave accent in ROFF \( (Seymour J.)
    Re: Perlpod, pod2man: get ascii grave accent in ROFF \( <waterlan@xs4all.nl>
    Re: regex - hex class <john1949@yahoo.com>
        sorting broken string <user@example.net>
    Re: sorting broken string <benkasminbullock@gmail.com>
    Re: sorting broken string sln@netherlands.com
    Re: sorting broken string (Seymour J.)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 07 Oct 2009 15:39:45 -0700
From: sln@netherlands.com
Subject: Re: [regexp] Changing lines NOT containing a pattern
Message-Id: <cu5qc5hmurj5er7ndfviul625qogbo3kjp@4ax.com>

On 06 Oct 2009 21:51:57 GMT, azrazer <azeroiu@poupidoup.com> wrote:

>Hello,
>I recently found an interesting issue on fr.comp.lang.perl and thought it 
>would be good to share [since not answers were found until now]. So here 
>it goes.
>
>A file is slurped into a scalar variable (let say $my_text) [NOT AN 
>ARRAY].
>This $my_text now contains many lines of this form : <code>;<comments>.
>
>The question is : Using a regexp (with mg flags) How to do the following 
>for all lines at once ?
>1/ if <code> contains a fixed word [let say WORD] then do not remove 
>comments
>2/ if <code> does nots contain WORD then remove comments
>
>I have tried using look-forward and behind regexps but i guess it is not 
>the good way of doing it. Also, i wanted to try using extended regexps 
>like (?(COND)true|false) but i ended up drawing a blank...
>
>Any help appreciated !
>Thanks a lot !
>
>azra

Its moderately dificult, depending on what the overal conditions are.
Simple lookahead is all this needs. And there are many ways to do this
without extended regx's.

-sln
-------------------------

use strict;
use warnings;

my $string = "
1 this WORD here; this is ok
2 word2 is not here; delete comment  
3 word3 is not here either; should not see this WORD, ; delete comment
";

#$string =~ s/^ ( (?:(?! WORD ).)* ;) .* $ /$1/xmg;

$string =~ 
s/
  ^ # start of new line and substitution part

    (       # Capture group 1
       (?:             # group
           (?! WORD )  # lookahead, not 'WORD' ? Continue else Fail line
           .           # capture this character
       ) *             # end group, do this zero or more times
       ;               # capture  ';'
    )       # end Capture group 1

    .*   # get all from ';' to the end of line

  $ # end of new line, substitute with $1

/$1/xmg;

print $string,"\n";

__END__



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

Date: Thu, 8 Oct 2009 00:16:46 -0700 (PDT)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: Changing lines NOT containing a pattern
Message-Id: <684a847b-cf2c-454f-8b48-8378159c70b1@w37g2000prg.googlegroups.com>

On Oct 7, 3:55=A0am, "C.DeRykus" <dery...@gmail.com> wrote:
> On Oct 6, 3:28=A0pm, Ben Morrow <b...@morrow.me.uk> wrote:
>
>
>
> > Quoth azrazer <azer...@poupidoup.com>:
>
> > > Hello,
> > > I recently found an interesting issue on fr.comp.lang.perl and though=
t it
> > > would be good to share [since not answers were found until now]. So h=
ere
> > > it goes.
>
> > > A file is slurped into a scalar variable (let say $my_text) [NOT AN
> > > ARRAY].
> > > This $my_text now contains many lines of this form : <code>;<comments=
>.
>
> > > The question is : Using a regexp (with mg flags) How to do the follow=
ing
> > > for all lines at once ?
> > > 1/ if <code> contains a fixed word [let say WORD] then do not remove
> > > comments
> > > 2/ if <code> does nots contain WORD then remove comments
>
> > > I have tried using look-forward and behind regexps but i guess it is =
not
> > > the good way of doing it. Also, i wanted to try using extended regexp=
s
> > > like (?(COND)true|false) but i ended up drawing a blank...
>
> > The obvious answer (besides the one Tad suggested, or simply splitting
> > twice on newlines and then on ';') would be
>
> > =A0 =A0 s/(?<! WORD .*) ; .*//gx
>
> > but that doesn't work because perl doesn't do variable-length
> > look-behind.
> > ...
>
> Hm, late night.. =A0but this does appear to work:
>
> s/ ( (?<!WORD) ) ;. * /$1/gx;
>
> (only tried in 5.10)


This is confusing late-night nonsense since the lookaround
assertion isn't captured and $1 isn't defined. But evidently
there's a regex misfeature/bug and so it appears to work.
At least that's my guess after looking at this output:

perl -M"re debug" -wle "$_=3Dq{xxxx;comment};s/((?<!WORD));.*/$1/gx";

--
Charles DeRykus


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

Date: Thu, 08 Oct 2009 10:00:02 GMT
From: PerlFAQ Server <brian@theperlreview.com>
Subject: FAQ 4.69 How can I make the Perl equivalent of a C structure/C++ class/hash or array of hashes or arrays?
Message-Id: <CKizm.250908$0e4.114905@newsfe19.iad>

This is an excerpt from the latest version perlfaq4.pod, which
comes with the standard Perl distribution. These postings aim to 
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

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

4.69: How can I make the Perl equivalent of a C structure/C++ class/hash or array of hashes or arrays?

    Usually a hash ref, perhaps like this:

            $record = {
                    NAME   => "Jason",
                    EMPNO  => 132,
                    TITLE  => "deputy peon",
                    AGE    => 23,
                    SALARY => 37_000,
                    PALS   => [ "Norbert", "Rhys", "Phineas"],
            };

    References are documented in perlref and the upcoming perlreftut.
    Examples of complex data structures are given in perldsc and perllol.
    Examples of structures and object-oriented classes are in perltoot.



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

The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.

If you'd like to help maintain the perlfaq, see the details in 
perlfaq.pod.


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

Date: Thu, 08 Oct 2009 04:00:07 GMT
From: PerlFAQ Server <brian@theperlreview.com>
Subject: FAQ 8.31 Can I use perl to run a telnet or ftp session?
Message-Id: <btdzm.835$eJ4.530@newsfe07.iad>

This is an excerpt from the latest version perlfaq8.pod, which
comes with the standard Perl distribution. These postings aim to 
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

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

8.31: Can I use perl to run a telnet or ftp session?

    Try the Net::FTP, TCP::Client, and Net::Telnet modules (available from
    CPAN). http://www.cpan.org/scripts/netstuff/telnet.emul.shar will also
    help for emulating the telnet protocol, but Net::Telnet is quite
    probably easier to use..

    If all you want to do is pretend to be telnet but don't need the initial
    telnet handshaking, then the standard dual-process approach will
    suffice:

            use IO::Socket;             # new in 5.004
            $handle = IO::Socket::INET->new('www.perl.com:80')
                or die "can't connect to port 80 on www.perl.com: $!";
            $handle->autoflush(1);
            if (fork()) {               # XXX: undef means failure
                select($handle);
                print while <STDIN>;    # everything from stdin to socket
            } else {
                print while <$handle>;  # everything from socket to stdout
            }
            close $handle;
            exit;



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

The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.

If you'd like to help maintain the perlfaq, see the details in 
perlfaq.pod.


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

Date: Wed, 7 Oct 2009 15:39:02 -0700 (PDT)
From: Rider <clearguy02@yahoo.com>
Subject: Help on massaging some data
Message-Id: <a031b7ab-a54d-4061-8356-d750983f1913@e18g2000vbe.googlegroups.com>



Hi experts,

I need a little help on the below data massage.

In the output, I need to get only the users with the respective
multiple groups. If a user belongs to only one group, we need to
ignore that entry.

I am struggling with code here. I am trying to do it with hashes
instead of the arrays.

Can some one help me here?



The output (two columns should be seperated by two tabs) of the below
__DATA__ should be as follows (pl. note that the two columns of data
are seperated by a single tab in __DATA__ content):

1. burt		1). google_abc
		2). google_abc_def
2. mike		1). amazon_abc
		2). yahoo_xyz
		3). google_abc
3. zack		1). yahoo_abc
		2). ebay_abc
		3). google_abc
		4). amazon_abc


__DATA__
alissa	yahoo_xyz
burt	google_abc
burt	google_abc_def
mike	amazon_abc
mike	yahoo_xyz
mike	google_abc
will	yahoo_abc
zack	yahoo_abc
zack	ebay_abc
zack	google_abc
zack	amazon_abc



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

Date: Wed, 07 Oct 2009 16:52:55 -0700
From: sln@netherlands.com
Subject: Re: Help on massaging some data
Message-Id: <i7aqc5htt3s7qj3ecdsv1r0vmu6l4g1m5l@4ax.com>

On Wed, 7 Oct 2009 15:39:02 -0700 (PDT), Rider <clearguy02@yahoo.com> wrote:

>
>
<snip>
>In the output, I need to get only the users with the respective
>multiple groups. If a user belongs to only one group, we need to
>ignore that entry.
>
<snip>
>
>The output (two columns should be seperated by two tabs) of the below
>__DATA__ should be as follows (pl. note that the two columns of data
>are seperated by a single tab in __DATA__ content):
>
>1. burt	1). google_abc
>		2). google_abc_def
>2. mike	1). amazon_abc
>		2). yahoo_xyz
>		3). google_abc
>3. zack	1). yahoo_abc
>		2). ebay_abc
>		3). google_abc
>		4). amazon_abc
>
>
Its not so hard, why are you struggling?
I can get hard depending on how you deviate
from this simplistic example.

-sln
-------------
use strict;
use warnings;

my %users;
while (<DATA>) {
	if (/\s*(\w+)\s+(\w+)\s*/) {
		$users{$1}->{$2}++; 
	}
}
while (my ($person, $groups) = each %users) {
	delete $users{$person}, next if (keys %$groups == 1);
	print "$person -\n";
	print "\t$_\n" for (sort keys %$groups);
}
__DATA__
mike	amazon_abc
mike	yahoo_xyz
mike	google_abc
alissa	yahoo_xyz
will	yahoo_abc
zack	yahoo_abc
zack	ebay_abc
zack	google_abc
zack	amazon_abc
burt	google_abc
burt	google_abc_def




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

Date: Wed, 07 Oct 2009 17:33:33 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Help on massaging some data
Message-Id: <tmcqc518trmuvs6as7016pkvfgnhtsuqku@4ax.com>

Rider <clearguy02@yahoo.com> wrote:
>In the output, I need to get only the users with the respective
>multiple groups. If a user belongs to only one group, we need to
>ignore that entry.


Use a HoA (hash of array), where the user's name is the hash key and
each every group he belongs to is push()ed onto the array.

Then, after reading all the input data, simply print each hash entry
while skipping those entries, where there is only one element in the
array.

jue


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

Date: Thu, 08 Oct 2009 01:05:15 -0700
From: "John W. Krahn" <someone@example.com>
Subject: Re: Help on massaging some data
Message-Id: <U2hzm.22431$kC.16394@newsfe11.iad>

Rider wrote:
> 
> Hi experts,
> 
> I need a little help on the below data massage.
> 
> In the output, I need to get only the users with the respective
> multiple groups. If a user belongs to only one group, we need to
> ignore that entry.
> 
> I am struggling with code here. I am trying to do it with hashes
> instead of the arrays.
> 
> Can some one help me here?
> 
> 
> 
> The output (two columns should be seperated by two tabs) of the below
> __DATA__ should be as follows (pl. note that the two columns of data
> are seperated by a single tab in __DATA__ content):
> 
> 1. burt		1). google_abc
> 		2). google_abc_def
> 2. mike		1). amazon_abc
> 		2). yahoo_xyz
> 		3). google_abc
> 3. zack		1). yahoo_abc
> 		2). ebay_abc
> 		3). google_abc
> 		4). amazon_abc
> 
> 
> __DATA__
> alissa	yahoo_xyz
> burt	google_abc
> burt	google_abc_def
> mike	amazon_abc
> mike	yahoo_xyz
> mike	google_abc
> will	yahoo_abc
> zack	yahoo_abc
> zack	ebay_abc
> zack	google_abc
> zack	amazon_abc

$ perl -e'
my $mydata = <<MYDATA;
alissa  yahoo_xyz
burt    google_abc
burt    google_abc_def
mike    amazon_abc
mike    yahoo_xyz
mike    google_abc
will    yahoo_abc
zack    yahoo_abc
zack    ebay_abc
zack    google_abc
zack    amazon_abc
MYDATA

open my $FH, "<", \$mydata or die "open: $!";

my ( @order, %data );
while ( <$FH> ) {
     my ( $name, $addr ) = split or next;
     push @order, $name unless exists $data{ $name };
     push @{ $data{ $name } }, $addr;
     }

for my $i ( 0 .. $#order ) {
     next if @{ $data{ $order[ $i ] } } == 1;
     print $i + 1, ". $order[ $i ]";
     for my $j ( 0 .. $#{ $data{ $order[ $i ] } } ) {
         print "\t", $j + 1, "). $data{ $order[ $i ] }[ $j ]\n";
         }
     }
'
2. burt 1). google_abc
         2). google_abc_def
3. mike 1). amazon_abc
         2). yahoo_xyz
         3). google_abc
5. zack 1). yahoo_abc
         2). ebay_abc
         3). google_abc
         4). amazon_abc




John
-- 
The programmer is fighting against the two most
destructive forces in the universe: entropy and
human stupidity.               -- Damian Conway


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

Date: Thu, 8 Oct 2009 06:35:09 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: Help on massaging some data
Message-Id: <667c5ae2-ce74-4668-a164-547b641089ce@g23g2000vbr.googlegroups.com>

On Oct 7, 6:39=A0pm, Rider <cleargu...@yahoo.com> wrote:
> In the output, I need to get only the users with the respective
> multiple groups. If a user belongs to only one group, we need to
> ignore that entry.

Create two hashes, one to count to number of groups (%count) and the
other to hold a reference to an array with the groups (%users). Then,
print the %users hash if the %count hash is greater than one.


CODE:
use strict;
use warnings;

my (%users, %count);

while (<DATA>)
{
 next unless /\w/;
 chomp;
 my ($user, $group) =3D split;
 push @{$users{$user}}, $group;
 $count{$user}++;
}

foreach my $user (sort keys %users)
{
 next unless $count{$user} > 1;
 foreach my $ele (@{$users{$user}})
 {
    print "$user =3D> $ele ";
 }
 print "\n"
}

exit(0);

__DATA__
alissa  yahoo_xyz
burt    google_abc
burt    google_abc_def
mike    amazon_abc
mike    yahoo_xyz
mike    google_abc
will    yahoo_abc
zack    yahoo_abc
zack    ebay_abc
zack    google_abc
zack    amazon_abc

OUTPUT:

$ perl  user_groups.plx
burt =3D> google_abc burt =3D> google_abc_def
mike =3D> amazon_abc mike =3D> yahoo_xyz mike =3D> google_abc
zack =3D> yahoo_abc zack =3D> ebay_abc zack =3D> google_abc zack =3D>
amazon_abc



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

Date: Thu, 8 Oct 2009 14:57:14 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Help on massaging some data
Message-Id: <qm71q6-kkb2.ln1@osiris.mauzo.dyndns.org>


Quoth ccc31807 <cartercc@gmail.com>:
> On Oct 7, 6:39 pm, Rider <cleargu...@yahoo.com> wrote:
> > In the output, I need to get only the users with the respective
> > multiple groups. If a user belongs to only one group, we need to
> > ignore that entry.
> 
> Create two hashes, one to count to number of groups (%count) and the
> other to hold a reference to an array with the groups (%users). Then,
> print the %users hash if the %count hash is greater than one.

This will give you

    $count{$usr} == @{$users{$usr}}

so there's no need for %count. Also, I would call a hash mapping from
user to groups %groups, not %users.

Ben



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

Date: Thu, 08 Oct 2009 14:47:54 -0000
From: Justin C <justin.0908@purestblue.com>
Subject: Re: Help on massaging some data
Message-Id: <2b61.4acdfb9a.ee69d@zem>

On 2009-10-07, Rider <clearguy02@yahoo.com> wrote:
>
> Hi experts,

You aren't addressing me, obviously.


> I need a little help on the below data massage.
>
> I am struggling with code here. I am trying to do it with hashes
> instead of the arrays.
>
> Can some one help me here?
>
> The output (two columns should be seperated by two tabs) of the below
> __DATA__ should be as follows (pl. note that the two columns of data
> are seperated by a single tab in __DATA__ content):
>
> 1. burt		1). google_abc
> 		2). google_abc_def
> 2. mike		1). amazon_abc
> 		2). yahoo_xyz
> 		3). google_abc
> 3. zack		1). yahoo_abc
> 		2). ebay_abc
> 		3). google_abc
> 		4). amazon_abc
>
> __DATA__
> alissa	yahoo_xyz
> burt	google_abc
> burt	google_abc_def
> mike	amazon_abc
> mike	yahoo_xyz
> mike	google_abc
> will	yahoo_abc
> zack	yahoo_abc
> zack	ebay_abc
> zack	google_abc
> zack	amazon_abc

I'd use a hash of arrays. 

push @{$names{$name}}, $group;
 .
 .
if (@{$names{$name}} > 1 ) {
  .
  .

 .. and I'd be interested to hear what the real experts think of that,
for my own, slow, perl educational purposes! 

	Justin.

-- 
Justin C, by the sea.


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

Date: Thu, 08 Oct 2009 02:00:35 +0300
From: Jari Aalto <jari.aalto@cante.net>
Subject: Perlpod - How to add URL links with L<>
Message-Id: <87skdudd2k.fsf@jondo.cante.net>


[Please keep CC]  According to http://perldoc.perl.org/perlpod.html the
L<> is used like:

    =pod

    L<<a href="http://www.perl.org/">http://www.perl.org/</a>>

    =cut

But this appears to signal errors:

    $ podchecker test.pod

    ** WARNING: node '<a href="http://www.perl.org/"' contains non-escaped | or / at line ...
    *** ERROR: unresolved internal link '<a href="http://www.perl.org/"' at line ...

How it is used?

Jari

-- 
Use Licenses!  http://www.linuxjournal.com/article.php?sid=6225
Which Licence? http://www.linuxjournal.com/article.php?sid=4825
http://www.opensource.org/docs/definition.php
OSI Licences   http://www.opensource.org/licenses/


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

Date: Thu, 8 Oct 2009 00:19:35 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Perlpod - How to add URL links with L<>
Message-Id: <79kvp6-g752.ln1@osiris.mauzo.dyndns.org>


Quoth Jari Aalto <jari.aalto@cante.net>:
> 
> [Please keep CC]  According to http://perldoc.perl.org/perlpod.html the
> L<> is used like:
> 
>     =pod
> 
>     L<<a href="http://www.perl.org/">http://www.perl.org/</a>>

 ...no. L<> for arbitrary URLs is used like

    L<http://www.perl.org/>

and there is no way to alter the text displayed (you always get the full
URL).

There appears to be a bug in the renderer used for perldoc.perl.org
which is causing the example to come out incorrectly. If you check the
pod source at
http://perl5.git.perl.org/perl.git/blob/HEAD:/pod/perlpod.pod or the
correctly-rendered version at
http://search.cpan.org/~dapm/perl-5.10.1/pod/perlpod.pod you will
see that the <a> stuff isn't supposed to be there. You could report a
bug to whoever maintins perldoc.perl.org.

Ben



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

Date: Thu, 08 Oct 2009 03:03:42 +0300
From: Jari Aalto <jari.aalto@cante.net>
Subject: Re: Perlpod - How to add URL links with L<>
Message-Id: <87iqeqda5d.fsf@jondo.cante.net>

Ben Morrow <ben@morrow.me.uk> writes:
>> According to http://perldoc.perl.org/perlpod.html
>> 
>>     L<<a href="http://www.perl.org/">http://www.perl.org/</a>>
>
> ...no. L<> for arbitrary URLs is used like
>
>     L<http://www.perl.org/>
>
> and there is no way to alter the text displayed (you always get the full
> URL).
>
> There appears to be a bug in the renderer used for perldoc.perl.org
> which is causing the example to come out incorrectly. If you check the
> pod source at
> http://perl5.git.perl.org/perl.git/blob/HEAD:/pod/perlpod.pod or the
> correctly-rendered version at
> http://search.cpan.org/~dapm/perl-5.10.1/pod/perlpod.pod you will
> see that the <a> stuff isn't supposed to be there. You could report a
> bug to whoever maintins perldoc.perl.org.

Reported.
http://github.com/jonallen/perldoc.perl.org/issues#issue/3

Thanks,
Jari

-- 
Use Licenses!  http://www.linuxjournal.com/article.php?sid=6225
Which Licence? http://www.linuxjournal.com/article.php?sid=4825
http://www.opensource.org/docs/definition.php
OSI Licences   http://www.opensource.org/licenses/


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

Date: Thu, 08 Oct 2009 10:57:36 +0200
From: Erwin Waterlander <waterlan@xs4all.nl>
Subject: Re: Perlpod, pod2man: get ascii grave accent in ROFF \(ga.
Message-Id: <4acda981$0$83241$e4fe514c@news.xs4all.nl>

Op 10/07/2009 10:32 PM, Ben Morrow schreef:

> 
> 'Wrong' according to whom? Pod is not supposed to be a highly-specific
> document creation system, it is supposed to be a quick and easy way of
> documenting Perl with lots of DWIM in the formatters.
> 
> I know you said 'don't ask', but I have to ask why you think you need
> this. It sounds like you may be better served by some other markup
> language.

It is not indented for normal text but for unix shell script examples. 
There a backqoute replaced by a qoute results in a wrong script.

In normal text there is no issue. I don't care that quotes in normal 
text are translated to the current locale.


> 
> One more thought: have you tried using E<96> and E<39>?
> 

That would not help.


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

Date: Thu, 8 Oct 2009 14:00:32 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Perlpod, pod2man: get ascii grave accent in ROFF \(ga.
Message-Id: <gc41q6-e5b2.ln1@osiris.mauzo.dyndns.org>


Quoth Erwin Waterlander <waterlan@xs4all.nl>:
> Op 10/07/2009 10:32 PM, Ben Morrow schreef:
> > 
> > 'Wrong' according to whom? Pod is not supposed to be a highly-specific
> > document creation system, it is supposed to be a quick and easy way of
> > documenting Perl with lots of DWIM in the formatters.
> > 
> > I know you said 'don't ask', but I have to ask why you think you need
> > this. It sounds like you may be better served by some other markup
> > language.
> 
> It is not indented for normal text but for unix shell script examples. 
> There a backqoute replaced by a qoute results in a wrong script.

Have you indented your examples, to make them into a 'verbatim
paragraph'? If you have, the pod formatters should be leaving backquote
alone (after all, it's just as special a character in Perl as in shell).
If they are not, you have a buggy version of whatever pod tool you are
using; upgrade to the latest version, and report a bug if it's still
there.

Ben



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

Date: Wed, 07 Oct 2009 18:52:11 -0500
From: Shmuel (Seymour J.) Metz <spamtrap@library.lspace.org.invalid>
Subject: Re: Perlpod, pod2man: get ascii grave accent in ROFF \(ga.
Message-Id: <4acd29ab$8$fuzhry+tra$mr2ice@news.patriot.net>

In <ogavp6-tm12.ln1@osiris.mauzo.dyndns.org>, on 10/07/2009
   at 09:32 PM, Ben Morrow <ben@morrow.me.uk> said:

>In running text those two characters are semantically equivalent,

No, only in a specific narrow context. In a generic context one is an
opening delimiter and the other a closing delimiter.

>(or rather, quoting `like this' is incorrect,

Actually it's correct but there are various venues[1] where a different
quoting style is used.

[1] It's also different in, e.g., Bourne shell, Perl, but that's not
    running text.

-- 
Shmuel (Seymour J.) Metz, SysProg and JOAT  <http://patriot.net/~shmuel>

Unsolicited bulk E-mail subject to legal action.  I reserve the
right to publicly post or ridicule any abusive E-mail.  Reply to
domain Patriot dot net user shmuel+news to contact me.  Do not
reply to spamtrap@library.lspace.org



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

Date: Thu, 08 Oct 2009 16:50:10 +0200
From: Erwin Waterlander <waterlan@xs4all.nl>
Subject: Re: Perlpod, pod2man: get ascii grave accent in ROFF \(ga.
Message-Id: <4acdfc22$0$83240$e4fe514c@news.xs4all.nl>

Op 10/08/2009 03:00 PM, Ben Morrow schreef:
> Quoth Erwin Waterlander <waterlan@xs4all.nl>:
>> Op 10/07/2009 10:32 PM, Ben Morrow schreef:
>>> 'Wrong' according to whom? Pod is not supposed to be a highly-specific
>>> document creation system, it is supposed to be a quick and easy way of
>>> documenting Perl with lots of DWIM in the formatters.
>>>
>>> I know you said 'don't ask', but I have to ask why you think you need
>>> this. It sounds like you may be better served by some other markup
>>> language.
>> It is not indented for normal text but for unix shell script examples. 
>> There a backqoute replaced by a qoute results in a wrong script.
> 
> Have you indented your examples, to make them into a 'verbatim
> paragraph'? If you have, the pod formatters should be leaving backquote
> alone (after all, it's just as special a character in Perl as in shell).
> If they are not, you have a buggy version of whatever pod tool you are
> using; upgrade to the latest version, and report a bug if it's still
> there.
> 
> Ben
> 

This is the solution (also thanks to Jari Aalto):

POD:
   code=`cmd`   # example

pod2man produces this ROFF:
\&  code=\`cmd\`   # example


An escaped backquote in ROFF, has the same output as \(ga.

man 7 groff:
\`     The grave accent `; same as \(ga.  Unescaped: left quote, 
backquote (ASCII 0x60).


So now everybody who uses the man page will see an ASCII backquote.

regards,

Erwin


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

Date: Thu, 8 Oct 2009 09:07:10 +0100
From: "John" <john1949@yahoo.com>
Subject: Re: regex - hex class
Message-Id: <hak6j9$rgg$1@news.albasani.net>


"John W. Krahn" <someone@example.com> wrote in message 
news:iE7zm.225471$sC1.64449@newsfe17.iad...
> John wrote:
>>
>> I may have an error elsewhere in my program,
>> but , for the moment, will the following removed all hex chars 00 to 40?
>>
>> $x =~ s|[\x00-\x40]||g;
>
> $ perl -le'
> use Data::Dumper;
> $Data::Dumper::Useqq = 1;
> my $string = join q//, map chr, 0 .. 127;
> print Dumper $string;
> $string =~ s|[\x00-\x40]||g;
> print Dumper $string;
> '
> $VAR1 = 
> "\0\1\2\3\4\5\6\a\b\t\n\13\f\r\16\17\20\21\22\23\24\25\26\27\30\31\32\e\34\35\36\37 
> !\"#\$%&'()*+,-./0123456789:;<=>?\@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177";
>
> $VAR1 = 
> "ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177";
>
>
> Yes, that works.
>
>
>
> John
> -- 
> The programmer is fighting against the two most
> destructive forces in the universe: entropy and
> human stupidity.               -- Damian Conway


OK.  Thanks.  It should removed '0A' and I guess it does but it re-appears 
later on.
My guess is somewhere later in the propram it is added back.

Regards
John





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

Date: Thu, 08 Oct 2009 01:16:19 -0400
From: monkeys paw <user@example.net>
Subject: sorting broken string
Message-Id: <KN6dnefJp-gE6FDXnZ2dnUVZ_qqdnZ2d@insightbb.com>

If a string is broken into pieces and sorted, with four components after 
the string break, how would it be done.

Example:

@list = qw(CA2009000H1 AK2009000H2 FL2009000H1 FL2009000H13 FL2009000H111);

I would like the string to be broken like so:

$a =~ /^(\w{2})(\d+)([A-Za-z]+)(\d+)$/;

So we get  CA, 2009000, H, 1    etc.

The final sort should look like:

AK2009000H2
CA2009000H1
FL2009000H1
FL2009000H13
FL2009000H111

I was trying this for a sort block:
my @list = qw(AK2009000H2 CA2009000H1 FL2009000H1 FL2009000H13 
FL2009000H111);

@list = sort state_billnum @list;


sub state_billnum {
     $a =~ /^(\w{2})(\d+)([A-Za-z]+)(\d+)$/;
     my ($astt, $asession, $atype, $anum) = ($1, $2, $3, $4);
     $b =~ /^(\w{2})(\d+)(\w+)(\d+)$/;
     my ($bstt, $bsession, $btype, $bnum) = ($1, $2, $3, $4);
     return
     $astt cmp $bstt ||
     $asession <=> $bsession ||
     $atype cmp $btype ||
     $anum <=> $bnum;
}

But this sorts as:

           'AK2009000H2',
           'CA2009000H1',
           'FL2009000H1',
           'FL2009000H111',
           'FL2009000H13'


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

Date: Wed, 7 Oct 2009 23:52:19 -0700 (PDT)
From: Ben Bullock <benkasminbullock@gmail.com>
Subject: Re: sorting broken string
Message-Id: <df5083dd-9c5f-4038-987f-a5e841a36991@m33g2000pri.googlegroups.com>

On Oct 8, 2:16=A0pm, monkeys paw <u...@example.net> wrote:

> =A0 =A0 =A0$b =3D~ /^(\w{2})(\d+)(\w+)(\d+)$/;
                             ^^


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

Date: Thu, 08 Oct 2009 02:00:51 -0700
From: sln@netherlands.com
Subject: Re: sorting broken string
Message-Id: <i5arc51e4u5c3i9rret1dmudue2ns16gm2@4ax.com>

On Thu, 08 Oct 2009 01:16:19 -0400, monkeys paw <user@example.net> wrote:

>If a string is broken into pieces and sorted, with four components after 
>the string break, how would it be done.
>
>Example:
>
>@list = qw(CA2009000H1 AK2009000H2 FL2009000H1 FL2009000H13 FL2009000H111);
>
>I would like the string to be broken like so:
>
>$a =~ /^(\w{2})(\d+)([A-Za-z]+)(\d+)$/;
>
>So we get  CA, 2009000, H, 1    etc.
>
>The final sort should look like:
>
>AK2009000H2
>CA2009000H1
>FL2009000H1
>FL2009000H13
>FL2009000H111
>
>I was trying this for a sort block:
>my @list = qw(AK2009000H2 CA2009000H1 FL2009000H1 FL2009000H13 
>FL2009000H111);
>
>@list = sort state_billnum @list;
>
>
>sub state_billnum {
>     $a =~ /^(\w{2})(\d+)([A-Za-z]+)(\d+)$/;
>     my ($astt, $asession, $atype, $anum) = ($1, $2, $3, $4);
>     $b =~ /^(\w{2})(\d+)(\w+)(\d+)$/;
>     my ($bstt, $bsession, $btype, $bnum) = ($1, $2, $3, $4);
>     return
>     $astt cmp $bstt ||
>     $asession <=> $bsession ||
>     $atype cmp $btype ||
>     $anum <=> $bnum;
>}
>
>But this sorts as:
>
>           'AK2009000H2',
>           'CA2009000H1',
>           'FL2009000H1',
>           'FL2009000H111',
>           'FL2009000H13'

Ben Bullock solved it. But the explanation is..

\w includes numeric. Btype was grabbing all but
the last digit when $b is parsed (assuming just alpha
is needed).
Likewise, if you expect the state abbrv to
be all alpha, it should change as well.
Something like this.

  my ($astt, $asession, $atype, $anum) = 
        $a =~ /^([a-z]{2})(\d+)([a-z]+)(\d+)$/i;

  my ($bstt, $bsession, $btype, $bnum) = 
        $b =~ /^([a-z]{2})(\d+)([a-z]+)(\d+)$/i;

-sln


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

Date: Thu, 08 Oct 2009 05:37:47 -0500
From: Shmuel (Seymour J.) Metz <spamtrap@library.lspace.org.invalid>
Subject: Re: sorting broken string
Message-Id: <4acdc0fb$10$fuzhry+tra$mr2ice@news.patriot.net>

In <KN6dnefJp-gE6FDXnZ2dnUVZ_qqdnZ2d@insightbb.com>, on 10/08/2009
   at 01:16 AM, monkeys paw <user@example.net> said:

>If a string is broken into pieces and sorted, with four components after 
>the string break, how would it be done.

The real question is how should it be tested? Before using your parse for
sorting, first ensure that it is breaking up the string the way that you
expect.

-- 
Shmuel (Seymour J.) Metz, SysProg and JOAT  <http://patriot.net/~shmuel>

Unsolicited bulk E-mail subject to legal action.  I reserve the
right to publicly post or ridicule any abusive E-mail.  Reply to
domain Patriot dot net user shmuel+news to contact me.  Do not
reply to spamtrap@library.lspace.org



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

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


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