[30691] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1936 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 21 03:09:42 2008

Date: Tue, 21 Oct 2008 00: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           Tue, 21 Oct 2008     Volume: 11 Number: 1936

Today's topics:
        ${$key} or similar <lehmannmapson@cnm.de>
    Re: ${$key} or similar xhoster@gmail.com
    Re: ${$key} or similar <lehmannmapson@cnm.de>
    Re: ${$key} or similar <someone@example.com>
    Re: ${$key} or similar <jimsgibson@gmail.com>
    Re: ${$key} or similar <ced@blv-sam-01.ca.boeing.com>
    Re: ${$key} or similar sln@netherlands.com
    Re: ${$key} or similar <mjcarman@mchsi.com>
    Re: ${$key} or similar <mjcarman@mchsi.com>
    Re: ${$key} or similar sln@netherlands.com
    Re: fork() & pipe() <bgydevel@gmail.com>
    Re: fork() & pipe() xhoster@gmail.com
    Re: Need help on AoH or array or any other think that m <glex_no-spam@qwest-spam-no.invalid>
        new CPAN modules on Tue Oct 21 2008 (Randal Schwartz)
    Re: Procedural interface to mysql <whynot@pozharski.name>
    Re: Scalar variable in void context before a loop <hjp-usenet2@hjp.at>
    Re: split a multiple lines text <bfzhao@gmail.com>
    Re: split a multiple lines text sln@netherlands.com
    Re: split a multiple lines text <bfzhao@gmail.com>
        String Processing Basic Stuff <v3gupta@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 20 Oct 2008 23:36:41 +0200
From: Marten Lehmann <lehmannmapson@cnm.de>
Subject: ${$key} or similar
Message-Id: <6m4bvdFesg3eU1@mid.individual.net>

Hello,

I'm using "use strict" in the beginning of every script, but for one 
certain case, I want to access variables by their names like this:

foreach $type ("billing", "admin", "tech") {
	print ${$type};
}

The value shall be the same is if I would call $billing, $admin or 
$tech. I can assure that these three variables exist in my script and 
although I could maybe rewrite parts if the script to put the values in 
a hash, I really would like to know how can I access them without a 
hash. Any ideas?

Regards
Marten


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

Date: 20 Oct 2008 21:41:23 GMT
From: xhoster@gmail.com
Subject: Re: ${$key} or similar
Message-Id: <20081020174148.008$gM@newsreader.com>

Marten Lehmann <lehmannmapson@cnm.de> wrote:
> Hello,
>
> I'm using "use strict" in the beginning of every script, but for one
> certain case, I want to access variables by their names like this:
>
> foreach $type ("billing", "admin", "tech") {
>         print ${$type};
> }

foreach $type (\$billing, \$admin, \$tech) {
        print ${$type};
}


> The value shall be the same is if I would call $billing, $admin or
> $tech. I can assure that these three variables exist in my script and
> although I could maybe rewrite parts if the script to put the values in
> a hash, I really would like to know how can I access them without a
> hash. Any ideas?

You could temporarily turn off strictures, or use fully qualified variable
names.  But you would have to use them everywhere for those variables, not
just in the foreach loop.

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


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

Date: Tue, 21 Oct 2008 00:42:28 +0200
From: Marten Lehmann <lehmannmapson@cnm.de>
Subject: Re: ${$key} or similar
Message-Id: <6m4fqpFeq96fU1@mid.individual.net>

Hello,

>> foreach $type ("billing", "admin", "tech") {
>>         print ${$type};
>> }
> 
> foreach $type (\$billing, \$admin, \$tech) {
>         print ${$type};
> }

I cannot change it, I need to work with strings because I need to print 
them also, e.g.

print "$type: ". ${$type}. "\n";

> You could temporarily turn off strictures, or use fully qualified variable
> names.  But you would have to use them everywhere for those variables, not
> just in the foreach loop.

Turning strict temporarily off omits the errors, but neither ${$type} 
nor $$type returns the expected value. How do I have to write it correctly?

Regards
Marten


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

Date: Mon, 20 Oct 2008 16:52:23 -0700
From: "John W. Krahn" <someone@example.com>
Subject: Re: ${$key} or similar
Message-Id: <SQ8Lk.12024$Ai5.7847@newsfe13.iad>

Marten Lehmann wrote:
> 
> I'm using "use strict" in the beginning of every script, but for one 
> certain case, I want to access variables by their names like this:
> 
> foreach $type ("billing", "admin", "tech") {
>     print ${$type};
> }
> 
> The value shall be the same is if I would call $billing, $admin or 
> $tech. I can assure that these three variables exist in my script and 
> although I could maybe rewrite parts if the script to put the values in 
> a hash, I really would like to know how can I access them without a 
> hash. Any ideas?

What you are attempting to do *is* access them through a hash, it's just 
not a user defined hash.  See the "Symbol Tables" section of perlmod.pod.



John
-- 
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall


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

Date: Mon, 20 Oct 2008 16:59:25 -0700
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: ${$key} or similar
Message-Id: <201020081659252553%jimsgibson@gmail.com>

In article <6m4fqpFeq96fU1@mid.individual.net>, Marten Lehmann
<lehmannmapson@cnm.de> wrote:

> Hello,
> 
> >> foreach $type ("billing", "admin", "tech") {
> >>         print ${$type};
> >> }
> > 
> > foreach $type (\$billing, \$admin, \$tech) {
> >         print ${$type};
> > }
> 
> I cannot change it, I need to work with strings because I need to print 
> them also, e.g.
> 
> print "$type: ". ${$type}. "\n";
> 
> > You could temporarily turn off strictures, or use fully qualified variable
> > names.  But you would have to use them everywhere for those variables, not
> > just in the foreach loop.
> 
> Turning strict temporarily off omits the errors, but neither ${$type} 
> nor $$type returns the expected value. How do I have to write it correctly?

It does on my system:

% perl -e '$type=q(tech);$tech=q(tech value);print "$type: ${$type}\n";'
tech: tech value

Please post a short program that shows what you are getting on your
system.

To write it correctly, you need to use a hash. Why do you not wish to
use a hash?

-- 
Jim Gibson


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

Date: Mon, 20 Oct 2008 17:11:08 -0700 (PDT)
From: "C.DeRykus" <ced@blv-sam-01.ca.boeing.com>
Subject: Re: ${$key} or similar
Message-Id: <c60b09e4-2c73-4585-9139-89856158af9e@l76g2000hse.googlegroups.com>

On Oct 20, 3:42 pm, Marten Lehmann <lehmannmap...@cnm.de> wrote:
> Hello,
>
> >> foreach $type ("billing", "admin", "tech") {
> >>         print ${$type};
> >> }
>
> > foreach $type (\$billing, \$admin, \$tech) {
> >         print ${$type};
> > }
>
> I cannot change it, I need to work with strings because I need to print
> them also, e.g.
>
> print "$type: ". ${$type}. "\n";
>
> > You could temporarily turn off strictures, or use fully qualified variable
> > names.  But you would have to use them everywhere for those variables, not
> > just in the foreach loop.
>
> Turning strict temporarily off omits the errors, but neither ${$type}
> nor $$type returns the expected value. How do I have to write it correctly?
>

Not recommended for queasy stomachs but you could use string eval:

my $code = 'print ';
for ( qw/billing admin tech/) {
   $code .= ('$'   . __PACKAGE__
              . '::'  . "$_,"
             );
eval $code; die $? if $?;



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

Date: Tue, 21 Oct 2008 00:19:23 GMT
From: sln@netherlands.com
Subject: Re: ${$key} or similar
Message-Id: <0o7qf4t2sspb894dpl1qt83h3i4rvflfi9@4ax.com>

On Tue, 21 Oct 2008 00:42:28 +0200, Marten Lehmann <lehmannmapson@cnm.de> wrote:

>Hello,
>
>>> foreach $type ("billing", "admin", "tech") {
>>>         print ${$type};
>>> }
>> 
>> foreach $type (\$billing, \$admin, \$tech) {
>>         print ${$type};
>> }
>
>I cannot change it, I need to work with strings because I need to print 
>them also, e.g.
>
>print "$type: ". ${$type}. "\n";
>
>> You could temporarily turn off strictures, or use fully qualified variable
>> names.  But you would have to use them everywhere for those variables, not
>> just in the foreach loop.
>
>Turning strict temporarily off omits the errors, but neither ${$type} 
>nor $$type returns the expected value. How do I have to write it correctly?
>
>Regards
>Marten

I don't know why you need to do this, or why you don't prefer a hash key
and value approach, but this does it what you want.

sln

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

my ($billing, $admin, $tech) = ('b','a','t');

foreach my $type ("billing", "admin", "tech") {
      eval "print \"$type = \$$type\n\"";
}

__END__

output:

billing = b
admin = a
tech = t




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

Date: Tue, 21 Oct 2008 00:54:37 GMT
From: Michael Carman <mjcarman@mchsi.com>
Subject: Re: ${$key} or similar
Message-Id: <hL9Lk.397589$yE1.53292@attbi_s21>

Marten Lehmann wrote:
> Turning strict temporarily off omits the errors, but neither ${$type}
> nor $$type returns the expected value. How do I have to write it
> correctly?

Symbolic references only work with global variables. You can't use them
with lexical (my) variables.

-mjc


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

Date: Tue, 21 Oct 2008 01:01:13 GMT
From: Michael Carman <mjcarman@mchsi.com>
Subject: Re: ${$key} or similar
Message-Id: <tR9Lk.342379$TT4.76299@attbi_s22>

Marten Lehmann wrote:
> I'm using "use strict" in the beginning of every script, but for one
> certain case, I want to access variables by their names like this:
> 
> foreach $type ("billing", "admin", "tech") {
>     print ${$type};
> }
> 
> The value shall be the same is if I would call $billing, $admin or
> $tech. I can assure that these three variables exist in my script and
> although I could maybe rewrite parts if the script to put the values in
> a hash, I really would like to know how can I access them without a
> hash. Any ideas?

I'm guessing that you want to avoid a hash because you want to minimize
changes to the rest of your program. How about a hash of references instead?

  my %types = (
    billing => \$billing,
    admin   => \$admin,
    tech    => \$tech,
  );

  while (my ($type, $ref) = each %types) {
    print "$type: $$ref\n";
  }

If the order is important, you could use a LoL (list of lists):

  my @types = (
    ['billing' => \$billing],
    ['admin'   => \$admin],
    ['tech'    => \$tech],
  );

  foreach my $t (@types) {
      print "$t->[0]: ${$t->[1]}\n";
  }

-mjc


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

Date: Tue, 21 Oct 2008 01:54:24 GMT
From: sln@netherlands.com
Subject: Re: ${$key} or similar
Message-Id: <fncqf417s4eua00vuo68k2g76mrda14cb7@4ax.com>

On Tue, 21 Oct 2008 00:19:23 GMT, sln@netherlands.com wrote:

>On Tue, 21 Oct 2008 00:42:28 +0200, Marten Lehmann <lehmannmapson@cnm.de> wrote:
>
>>Hello,
>>
>>>> foreach $type ("billing", "admin", "tech") {
>>>>         print ${$type};
>>>> }
>>> 
>>> foreach $type (\$billing, \$admin, \$tech) {
>>>         print ${$type};
>>> }
>>
>>I cannot change it, I need to work with strings because I need to print 
>>them also, e.g.
>>
>>print "$type: ". ${$type}. "\n";
>>
>>> You could temporarily turn off strictures, or use fully qualified variable
>>> names.  But you would have to use them everywhere for those variables, not
>>> just in the foreach loop.
>>
>>Turning strict temporarily off omits the errors, but neither ${$type} 
>>nor $$type returns the expected value. How do I have to write it correctly?
>>
>>Regards
>>Marten
>
>I don't know why you need to do this, or why you don't prefer a hash key
>and value approach, but this does it what you want.
>
>sln
>
>---------------
>use strict;
>use warnings;
>
>my ($billing, $admin, $tech) = ('b','a','t');
>
>foreach my $type ("billing", "admin", "tech") {
>      eval "print \"$type = \$$type\n\"";

     ^^^^^^^^^^^^^^^^^^^^^^^
or
       eval 'print ' . '"' . $type . ' = ' . '$' . $type . '\n' . '"';

Might be an easier way of looking at it. Look up eval and see what it does (dynamic code?).

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

(more of the same)

my @names = qw(billing admin tech);

for ( @names ) { 
	eval 'print ' . '"' . $_ . ' = ' . '$' . $_ . '\n"';
}


Good luck

sln



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

Date: Mon, 20 Oct 2008 20:57:31 +0200
From: bgy <bgydevel@gmail.com>
Subject: Re: fork() & pipe()
Message-Id: <48fcd49a$0$7858$426a34cc@news.free.fr>

> You close the pipe the first time through the loop, so it is no longer
> open the 2nd time through.
> 
> If you want all children to talk on the same pipe, then don't close it
> in the loop.  If you want different pipes for each child, then create the
> pipe inside the loop, not before it.
> 
> ...
>>  >         print TO_PARENT $$;
> 
> print TO_PARENT "$$\n";
> 
> Xho
> 

Thanks for the help !
It works now.
I did what you told me, place the pipe inside the loop !

But still one mystery, what is the utily of \n here :
> print TO_PARENT "$$\n";

bgy


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

Date: 20 Oct 2008 19:24:57 GMT
From: xhoster@gmail.com
Subject: Re: fork() & pipe()
Message-Id: <20081020152521.861$aI@newsreader.com>

bgy <bgydevel@gmail.com> wrote:
> > You close the pipe the first time through the loop, so it is no longer
> > open the 2nd time through.
> >
> > If you want all children to talk on the same pipe, then don't close it
> > in the loop.  If you want different pipes for each child, then create
> > the pipe inside the loop, not before it.
> >
> > ...
> >>  >         print TO_PARENT $$;
> >
> > print TO_PARENT "$$\n";
> >
> > Xho
> >
>
> Thanks for the help !
> It works now.
> I did what you told me, place the pipe inside the loop !
>
> But still one mystery, what is the utily of \n here :
> > print TO_PARENT "$$\n";

You read what is written to TO_PARENT using the construct <FROM_CHILD>,
which is line-oriented.  So you should write to it in lines.  Perhaps
you used -l or set $\ on order to do this, but it didn't look like it.

If the child closes the pipe after writing to it, then you might not need
the "\n", as the eof causes the <FROM_CHILD> to return.  If you have all
children write on one pipe, then there is no eof after the first child
and <FROM_CHILD> never returns, and you have a deadlock.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


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

Date: Mon, 20 Oct 2008 15:43:05 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Need help on AoH or array or any other think that might help!
Message-Id: <48fced59$0$87071$815e3792@news.qwest.net>

Tim Greer wrote:
> J. Gleixner wrote:
> 
>> Tim Greer wrote:
>>> cyrusgreats@gmail.com wrote:
>>>
>>>> On Oct 17, 2:59 pm, "J. Gleixner"
>>>> <glex_no-s...@qwest-spam-no.invalid> wrote:
>>>>> cyrusgre...@gmail.com wrote:
>>>>>> Hello good people out there. I need to write a perl script that
>>>>>> will parse the log and generate the following output:
>>>>> What have you done so far and what questions do you have?
>>>>>
>>>>>> Any help will be appreciated...million thanks in advance
>>>>> Put in some sort of effort by at least reading some
>>>>> documentation, or maybe a book, and posting your code.
>>>>>
>>>>> perldoc -f split
>>>>> perldoc -f open
>>>>> perldoc perldsc
>>>> here portion of the code:
>>>>
>>>> my %inventory;
>>>> open (FILE, $file) || die ("Could not open file. $!");
>>>> foreach my $el (<FILE)>) {
>>> ^^^ You should always copy and paste your actual code you're using. 
>>> The
>>> above is broken:  (<FILE)>)
>> Define 'broken'.  It's not good code (OP use 'while' instead
>> of foreach), but it will run.
> 
> I am aware that a for/foreach and while can work equally well.  Invalid
> syntax, as shown above -> (<FILE)>)  is what I define as "broken". 
> Better?

Sorry.. Yep. For some reason I totally missed that it wasn't (<FILE>). 
Never mind.. :-)


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

Date: Tue, 21 Oct 2008 04:42:22 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Tue Oct 21 2008
Message-Id: <K92nqM.1sqH@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

App-ZofCMS-Plugin-FormChecker-0.0101
http://search.cpan.org/~zoffix/App-ZofCMS-Plugin-FormChecker-0.0101/
plugin to check HTML form data. 
----
B-Hooks-EndOfScope-0.03
http://search.cpan.org/~flora/B-Hooks-EndOfScope-0.03/
Execute code after a scope finished compilation 
----
B-Hooks-EndOfScope-0.04
http://search.cpan.org/~flora/B-Hooks-EndOfScope-0.04/
Execute code after a scope finished compilation 
----
BDB-Wrapper-0.21
http://search.cpan.org/~hikarine/BDB-Wrapper-0.21/
Wrapper module for BerkeleyDB.pm 
----
Business-Address-POBox-0.08
http://search.cpan.org/~marcel/Business-Address-POBox-0.08/
Check whether an address looks like a P.O.Box 
----
Business-ISBN-Data-20081020
http://search.cpan.org/~bdfoy/Business-ISBN-Data-20081020/
data pack for Business::ISBN 
----
Catalyst-Plugin-InflateMore-0.1.30
http://search.cpan.org/~pjfl/Catalyst-Plugin-InflateMore-0.1.30/
Inflates symbols in application config 
----
Class-Scaffold-0.06
http://search.cpan.org/~marcel/Class-Scaffold-0.06/
large-scale OOP application support 
----
Class-Value-0.06
http://search.cpan.org/~marcel/Class-Value-0.06/
the Value Object design pattern 
----
Data-Comparable-0.04
http://search.cpan.org/~marcel/Data-Comparable-0.04/
present your object for comparison purposes 
----
Data-Container-0.06
http://search.cpan.org/~marcel/Data-Container-0.06/
base class for objects containing a list of items 
----
Data-Conveyor-0.05
http://search.cpan.org/~marcel/Data-Conveyor-0.05/
stage-based conveyor-belt-like ticket handling system 
----
Data-Feed-0.00007
http://search.cpan.org/~dmaki/Data-Feed-0.00007/
Extensible Feed Parsing Tool 
----
Data-Inherited-1.06
http://search.cpan.org/~marcel/Data-Inherited-1.06/
hierarchy-wide accumulation of list and hash results 
----
Data-Storage-0.08
http://search.cpan.org/~marcel/Data-Storage-0.08/
generic abstract storage mechanism 
----
Data-Storage-0.09
http://search.cpan.org/~marcel/Data-Storage-0.09/
generic abstract storage mechanism 
----
Dist-Joseki-0.15
http://search.cpan.org/~marcel/Dist-Joseki-0.15/
tools for the prolific module author 
----
Don-Mendo-0.0.4
http://search.cpan.org/~jmerelo/Don-Mendo-0.0.4/
Modules for "La venganza de Don Mendo", Sir Mendo's revenge. 
----
Don-Mendo-0.0.5
http://search.cpan.org/~jmerelo/Don-Mendo-0.0.5/
Modules for "La venganza de Don Mendo", Sir Mendo's revenge. 
----
ExtUtils-MakeMaker-6.48
http://search.cpan.org/~mschwern/ExtUtils-MakeMaker-6.48/
Create a module Makefile 
----
Games-Risk-2.0.1
http://search.cpan.org/~jquelin/Games-Risk-2.0.1/
classical 'risk' board game 
----
Gitosis-Config-0.0.4
http://search.cpan.org/~perigrin/Gitosis-Config-0.0.4/
Parse and Write gitosis config files 
----
Lingua-EN-Titlecase-0.10
http://search.cpan.org/~ashley/Lingua-EN-Titlecase-0.10/
Titlecase English words by traditional editorial rules. 
----
Lingua-JA-Regular-Unicode-0.02
http://search.cpan.org/~tokuhirom/Lingua-JA-Regular-Unicode-0.02/
convert japanese chars. 
----
Log-Dispatch-FileRotate-1.19
http://search.cpan.org/~markpf/Log-Dispatch-FileRotate-1.19/
Log to files that archive/rotate themselves 
----
Mail-SpamFilter-0.06
http://search.cpan.org/~mward/Mail-SpamFilter-0.06/
Provides a convenient interface for several spam filters. 
----
Mojo-0.7
http://search.cpan.org/~sri/Mojo-0.7/
The Web In A Box! 
----
MooseX-Meta-Attribute-Index-0.01
http://search.cpan.org/~ctbrown/MooseX-Meta-Attribute-Index-0.01/
----
Net-Gnip-0.2
http://search.cpan.org/~simonw/Net-Gnip-0.2/
interact with Gnip 
----
Net-Gnip-0.3
http://search.cpan.org/~simonw/Net-Gnip-0.3/
interact with Gnip 
----
Net-IMAP-Server-1.05
http://search.cpan.org/~alexmv/Net-IMAP-Server-1.05/
A single-threaded multiplexing IMAP server implementation, using Net::Server::Coro. 
----
Net-RawIP-0.24
http://search.cpan.org/~saper/Net-RawIP-0.24/
Perl extension for manipulate raw ip packets with interface to libpcap 
----
Net-Stitcho-0.03
http://search.cpan.org/~melo/Net-Stitcho-0.03/
Client module for the Stitcho.com API 
----
OODoc-Template-0.14
http://search.cpan.org/~markov/OODoc-Template-0.14/
Simple template system 
----
PAR-Repository-Client-0.21
http://search.cpan.org/~smueller/PAR-Repository-Client-0.21/
Access PAR repositories 
----
POE-Component-Data-SimplePassword-0.0101
http://search.cpan.org/~zoffix/POE-Component-Data-SimplePassword-0.0101/
POE wrapper around Data::SimplePassword 
----
POE-Component-IRC-Plugin-AntiSpamMailTo-0.0101
http://search.cpan.org/~zoffix/POE-Component-IRC-Plugin-AntiSpamMailTo-0.0101/
little IRC plugin to generate mailto: links that avoid dumb spam bots 
----
POE-Component-SmokeBox-0.01_09
http://search.cpan.org/~bingos/POE-Component-SmokeBox-0.01_09/
POE enabled CPAN smoke testing with added value. 
----
Path-Dispatcher-0.02
http://search.cpan.org/~sartak/Path-Dispatcher-0.02/
flexible dispatch 
----
Perl-Dist-Strawberry-1.07
http://search.cpan.org/~adamk/Perl-Dist-Strawberry-1.07/
Strawberry Perl for win32 
----
Pg-Loader-0.10
http://search.cpan.org/~ioannis/Pg-Loader-0.10/
Perl extension for loading Postgres tables 
----
PostScript-MailLabels-2.27
http://search.cpan.org/~ajackson/PostScript-MailLabels-2.27/
Modules for creating PostScript(tm) files of mailing address labels. 
----
String-BlackWhiteList-0.07
http://search.cpan.org/~marcel/String-BlackWhiteList-0.07/
match a string against a blacklist and a whitelist 
----
Test-Formats-0.10
http://search.cpan.org/~rjray/Test-Formats-0.10/
An umbrella class for test classes that target formatted data 
----
Test-TestCoverage-0.08
http://search.cpan.org/~reneeb/Test-TestCoverage-0.08/
Test if your test covers all 'public' subroutines of the package 
----
Test-Without-Module-0.16
http://search.cpan.org/~corion/Test-Without-Module-0.16/
Test fallback behaviour in absence of modules 
----
Text-Phonetic-1.07
http://search.cpan.org/~maros/Text-Phonetic-1.07/
A module implementing various phonetic algorithms 
----
Time-y2038-20081020
http://search.cpan.org/~mschwern/Time-y2038-20081020/
Versions of Perl's time functions which work beyond 2038 
----
WWW-MeGa-0.09_1
http://search.cpan.org/~fish/WWW-MeGa-0.09_1/
A MediaGallery 
----
XML-Hash-0.93
http://search.cpan.org/~braceta/XML-Hash-0.93/
Converts from a XML into a Hash. 
----
XML-Hash-0.94
http://search.cpan.org/~braceta/XML-Hash-0.94/
Converts from a XML into a Hash. 
----
YAML-Active-1.08
http://search.cpan.org/~marcel/YAML-Active-1.08/
Combine data and logic in YAML 
----
genpass-0.06
http://search.cpan.org/~xsawyerx/genpass-0.06/
Quickly create secure passwords 
----
libwww-perl-5.819
http://search.cpan.org/~gaas/libwww-perl-5.819/


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion


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

Date: Tue, 21 Oct 2008 00:36:42 +0300
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: Procedural interface to mysql
Message-Id: <slrngfpufa.6u6.whynot@orphan.zombinet>

On 2008-10-20, John Bokma <john@castleamber.com> wrote:
> Eric Pozharski <whynot@pozharski.name> wrote:
>> Would you like to point at any class that actually inherits from
>> B<DBI>
> *points at a class I've written for a customer* Oh, and I found one
> for you that's on CPAN:
><http://search.cpan.org/src/TIMB/DBI-1.607/lib/DBI/ProxyServer.pm> ->
>@ISA = qw(RPC::PlServer DBI);

Oh, that hurts.  No-one is more lazy than me.

-- 
Torvalds' goal for Linux is very simple: World Domination


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

Date: Mon, 20 Oct 2008 22:03:45 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Scalar variable in void context before a loop
Message-Id: <slrngfpp11.46c.hjp-usenet2@hrunkner.hjp.at>

On 2008-10-20 13:03, Jürgen Exner <jurgenex@hotmail.com> wrote:
> markhobley@hotpop.donottypethisbit.com (Mark Hobley) wrote:
>>In my professional perl programming guide, some of the examples put the 
>>variable to be used as an iterator in void context before the loop. For 
>>example:
>>
>>$l;
>>for ($l = 0; $l < 10; $l++) {
>>  print $l;
>>}
>>
>>I am curious as to what reasons there are for doing this, because there 
>>does not appear to be any mention of it anywhere within the book.
>
> Of ocurse I don't know what the author was thinking. But _I_ would write
> this as
> 	for my $| (0..9) {
> 		print $|;
> 	}

I hope not.


> Another question is why he would possibly want to assign 0 to 9 to the
> autoflush variable.

A third question is why you use a font which apparently uses the same
glyph for the pipe symbol and the lower case ell.

	hp


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

Date: Mon, 20 Oct 2008 20:59:35 -0700 (PDT)
From: bingfeng <bfzhao@gmail.com>
Subject: Re: split a multiple lines text
Message-Id: <e567b5ba-c5b5-4c3a-8015-6efa497377c1@64g2000hsu.googlegroups.com>

On Oct 21, 1:27=A0am, s...@netherlands.com wrote:
> On Mon, 20 Oct 2008 02:42:03 -0700 (PDT), bingfeng <bfz...@gmail.com> wro=
te:
> >Hello,
> >Assume I have following string:
> >my $cmds =3D <<DOC
> > =A0__begin {
> > =A0 =A0 abc;
> > =A0 =A0 def;
> > =A0 =A0 {foo;bar}
> > =A0} __end;
> > =A0__begin {
> > =A0 =A0 cde;
> > =A0} __end;
> > =A0abc;
> > =A0bad;
> >DOC
> >;
>
> >I want to split it into an array, the first item is "__begin {
> > =A0 =A0 abc;
> > =A0 =A0 def;
> > =A0 =A0 {foo;bar}
> > =A0} __end", the second item =A0is =A0"__begin {
> > =A0 =A0 cde;
> > =A0} __end", and the third is "abc" and the fourth is "bad".
>
> >split obviously cannot be used here, so I use following regex:
> >my @lines =3D ($cmds =3D~ /__begin.*?__end|[^;]+/sg);
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0^^
> my @lines =3D ($cmds =3D~ /__begin.*?__end|[^\s;]+/sg);
>
> You were on the right track. [^;] however is first to match all before ';=
',
> which means it grabs the' =A0 __begin { .. abc;' then the next, then next=
 .
> '__begin.*?__end' is never matched. By including not whitespace, [^\s;] i=
n
> the character class, begin and end have a chance.
>
You are right. Thanks for your explanation. My sample is some
oversimple. the standalone sentence may contain other word and space,
with following test message:
my $cmds =3D <<DOC
  __begin {
     abc sss;
     def;
     {foo;bar}
  } __end;
  __begin {
     cde;
  } __end;
  abc kkk;
  bad fde;
DOC
;

you solution gives following Dumper result:
$VAR1 =3D '__begin {
     abc sss;
     def;
     {foo;bar}
  } __end';
$VAR2 =3D '__begin {
     cde;
  } __end';
$VAR3 =3D 'abc';
$VAR4 =3D 'kkk';
$VAR5 =3D 'bad';
$VAR6 =3D 'fde';

that's not what I want. Apart from John's solution, I have no other
solution. Thank you

> sln
>
> --------------------
>
> use strict;
> use warnings;
>
> my $cmds =3D <<DOC
> =A0 __begin {
> =A0 =A0 =A0abc;
> =A0 =A0 =A0def;
> =A0 =A0 =A0{foo;bar}
> =A0 } __end;
> =A0 __begin {
> =A0 =A0 =A0cde;
> =A0 } __end;
> =A0 abc;
> =A0 bad;
> DOC
> ;
>
> my @lines =3D ($cmds =3D~ /__begin.*?__end|[^\s;]+/sg);
>
> for (my $i =3D 0; $i < @lines; $i++) {
> =A0 =A0 =A0 =A0 print "\n\$lines[$i] =3D \n\n\"$lines[$i]\"\n";
>
> }
>
> __END__
>
> output:
>
> $lines[0] =3D
>
> "__begin {
> =A0 =A0 =A0abc;
> =A0 =A0 =A0def;
> =A0 =A0 =A0{foo;bar}
> =A0 } __end"
>
> $lines[1] =3D
>
> "__begin {
> =A0 =A0 =A0cde;
> =A0 } __end"
>
> $lines[2] =3D
>
> "abc"
>
> $lines[3] =3D
>
> "bad"



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

Date: Tue, 21 Oct 2008 05:46:09 GMT
From: sln@netherlands.com
Subject: Re: split a multiple lines text
Message-Id: <24pqf41mnl48orc4kde3b5jk1tter0i06i@4ax.com>

On Mon, 20 Oct 2008 20:59:35 -0700 (PDT), bingfeng <bfzhao@gmail.com> wrote:

>On Oct 21, 1:27 am, s...@netherlands.com wrote:
>> On Mon, 20 Oct 2008 02:42:03 -0700 (PDT), bingfeng <bfz...@gmail.com> wrote:
>> >Hello,
>> >Assume I have following string:
>> >my $cmds = <<DOC
>> >  __begin {
>> >     abc;
>> >     def;
>> >     {foo;bar}
>> >  } __end;
>> >  __begin {
>> >     cde;
>> >  } __end;
>> >  abc;
>> >  bad;
>> >DOC
>> >;
>>
>> >I want to split it into an array, the first item is "__begin {
>> >     abc;
>> >     def;
>> >     {foo;bar}
>> >  } __end", the second item  is  "__begin {
>> >     cde;
>> >  } __end", and the third is "abc" and the fourth is "bad".
>>
>> >split obviously cannot be used here, so I use following regex:
>> >my @lines = ($cmds =~ /__begin.*?__end|[^;]+/sg);
>>
>>                                          ^^
>> my @lines = ($cmds =~ /__begin.*?__end|[^\s;]+/sg);
>>
>> You were on the right track. [^;] however is first to match all before ';',
>> which means it grabs the'   __begin { .. abc;' then the next, then next.
>> '__begin.*?__end' is never matched. By including not whitespace, [^\s;] in
>> the character class, begin and end have a chance.
>>
>You are right. Thanks for your explanation. My sample is some
>oversimple. the standalone sentence may contain other word and space,
>with following test message:
>my $cmds = <<DOC
>  __begin {
>     abc sss;
>     def;
>     {foo;bar}
>  } __end;
>  __begin {
>     cde;
>  } __end;
>  abc kkk;
>  bad fde;
>DOC
>;
>
>you solution gives following Dumper result:
>$VAR1 = '__begin {
>     abc sss;
>     def;
>     {foo;bar}
>  } __end';
>$VAR2 = '__begin {
>     cde;
>  } __end';
>$VAR3 = 'abc';
>$VAR4 = 'kkk';
>$VAR5 = 'bad';
>$VAR6 = 'fde';
>

Thats too bad. You made a good attempt and I gave
you credit by saying you almost had it right the first time.
And the regex was altered slightly from why you yourself tried.

I didn't write a regex for you. Because if I did that, you could
always come back and say for example:

  #>You are right. Thanks for your explanation. My sample is some
  #>oversimple. the standalone sentence may contain other word and space,
  #>with following test message ...

But you didn't say that in the first place.

>that's not what I want. Apart from John's solution, I have no other
>solution.
>
    ^^^^^^^^^^^^^
Think again ... you just invalidated his regex.

my @lines = $str =~ /^\s*__begin(?s:.*?)__end;$|^\s*\S+;$/mg;

$lines[0] =
"  __begin {
     abc sss;
     def;
     {foo;bar}
  } __end;"

$lines[1] =
"  __begin {
     cde;
  } __end;"

What are you going to do now?
We're still in the extremely simple stage.
In fact, the more you add, the simpler it gets.

sln

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

Version 2 

#################
# Misc Parse 2
#################

use strict;
use warnings;

# the old
my $cmd1 = <<DOC1
  __begin {
     abc;
     def;
     {foo;bar}
  } __end;
  __begin {
     cde;
  } __end;
  abc;
  bad;
DOC1
;

# the new
my $cmds2 = <<DOC2
  __begin {
     abc sss;
     def;
     {foo;bar}
  } __end;
  __begin {
     cde;
  } __end;
  abc kkk;
  bad fde;
DOC2
;

my $str = $cmds2;

my @lines = ($str =~ /\s*(__begin.*?__end|.*?);/sg);

for (my $i = 0; $i < @lines; $i++) {
	print "\n\$lines[$i] = \n\n\"$lines[$i]\"\n";
}

__END__

output:

$lines[0] =

"__begin {
     abc sss;
     def;
     {foo;bar}
  } __end"

$lines[1] =

"__begin {
     cde;
  } __end"

$lines[2] =

"abc kkk"

$lines[3] =

"bad fde"




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

Date: Mon, 20 Oct 2008 23:18:02 -0700 (PDT)
From: bingfeng <bfzhao@gmail.com>
Subject: Re: split a multiple lines text
Message-Id: <fc538bd7-cfb6-41cf-8cb0-193542d563d1@l42g2000hsc.googlegroups.com>

On Oct 21, 1:46=A0pm, s...@netherlands.com wrote:
> On Mon, 20 Oct 2008 20:59:35 -0700 (PDT), bingfeng <bfz...@gmail.com> wro=
te:
> >On Oct 21, 1:27=A0am, s...@netherlands.com wrote:
> >> On Mon, 20 Oct 2008 02:42:03 -0700 (PDT), bingfeng <bfz...@gmail.com> =
wrote:
> >> >Hello,
> >> >Assume I have following string:
> >> >my $cmds =3D <<DOC
> >> > =A0__begin {
> >> > =A0 =A0 abc;
> >> > =A0 =A0 def;
> >> > =A0 =A0 {foo;bar}
> >> > =A0} __end;
> >> > =A0__begin {
> >> > =A0 =A0 cde;
> >> > =A0} __end;
> >> > =A0abc;
> >> > =A0bad;
> >> >DOC
> >> >;
>
> >> >I want to split it into an array, the first item is "__begin {
> >> > =A0 =A0 abc;
> >> > =A0 =A0 def;
> >> > =A0 =A0 {foo;bar}
> >> > =A0} __end", the second item =A0is =A0"__begin {
> >> > =A0 =A0 cde;
> >> > =A0} __end", and the third is "abc" and the fourth is "bad".
>
> >> >split obviously cannot be used here, so I use following regex:
> >> >my @lines =3D ($cmds =3D~ /__begin.*?__end|[^;]+/sg);
>
> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0^^
> >> my @lines =3D ($cmds =3D~ /__begin.*?__end|[^\s;]+/sg);
>
> >> You were on the right track. [^;] however is first to match all before=
 ';',
> >> which means it grabs the' =A0 __begin { .. abc;' then the next, then n=
ext.
> >> '__begin.*?__end' is never matched. By including not whitespace, [^\s;=
] in
> >> the character class, begin and end have a chance.
>
> >You are right. Thanks for your explanation. My sample is some
> >oversimple. the standalone sentence may contain other word and space,
> >with following test message:
> >my $cmds =3D <<DOC
> > =A0__begin {
> > =A0 =A0 abc sss;
> > =A0 =A0 def;
> > =A0 =A0 {foo;bar}
> > =A0} __end;
> > =A0__begin {
> > =A0 =A0 cde;
> > =A0} __end;
> > =A0abc kkk;
> > =A0bad fde;
> >DOC
> >;
>
> >you solution gives following Dumper result:
> >$VAR1 =3D '__begin {
> > =A0 =A0 abc sss;
> > =A0 =A0 def;
> > =A0 =A0 {foo;bar}
> > =A0} __end';
> >$VAR2 =3D '__begin {
> > =A0 =A0 cde;
> > =A0} __end';
> >$VAR3 =3D 'abc';
> >$VAR4 =3D 'kkk';
> >$VAR5 =3D 'bad';
> >$VAR6 =3D 'fde';
>
> Thats too bad. You made a good attempt and I gave
> you credit by saying you almost had it right the first time.
> And the regex was altered slightly from why you yourself tried.
>
> I didn't write a regex for you. Because if I did that, you could
> always come back and say for example:
>
> =A0 #>You are right. Thanks for your explanation. My sample is some
> =A0 #>oversimple. the standalone sentence may contain other word and spac=
e,
> =A0 #>with following test message ...
>
> But you didn't say that in the first place.
>
> >that's not what I want. Apart from John's solution, I have no other
> >solution.
>
> =A0 =A0 ^^^^^^^^^^^^^
> Think again ... you just invalidated his regex.
>
> my @lines =3D $str =3D~ /^\s*__begin(?s:.*?)__end;$|^\s*\S+;$/mg;
>
> $lines[0] =3D
> " =A0__begin {
> =A0 =A0 =A0abc sss;
> =A0 =A0 =A0def;
> =A0 =A0 =A0{foo;bar}
> =A0 } __end;"
>
> $lines[1] =3D
> " =A0__begin {
> =A0 =A0 =A0cde;
> =A0 } __end;"
>
> What are you going to do now?
> We're still in the extremely simple stage.
> In fact, the more you add, the simpler it gets.
>
> sln
>
> -------------------------------
>
> Version 2
>
> #################
> # Misc Parse 2
> #################
>
> use strict;
> use warnings;
>
> # the old
> my $cmd1 =3D <<DOC1
> =A0 __begin {
> =A0 =A0 =A0abc;
> =A0 =A0 =A0def;
> =A0 =A0 =A0{foo;bar}
> =A0 } __end;
> =A0 __begin {
> =A0 =A0 =A0cde;
> =A0 } __end;
> =A0 abc;
> =A0 bad;
> DOC1
> ;
>
> # the new
> my $cmds2 =3D <<DOC2
> =A0 __begin {
> =A0 =A0 =A0abc sss;
> =A0 =A0 =A0def;
> =A0 =A0 =A0{foo;bar}
> =A0 } __end;
> =A0 __begin {
> =A0 =A0 =A0cde;
> =A0 } __end;
> =A0 abc kkk;
> =A0 bad fde;
> DOC2
> ;
>
> my $str =3D $cmds2;
>
> my @lines =3D ($str =3D~ /\s*(__begin.*?__end|.*?);/sg);
>
> for (my $i =3D 0; $i < @lines; $i++) {
> =A0 =A0 =A0 =A0 print "\n\$lines[$i] =3D \n\n\"$lines[$i]\"\n";
>
> }
>
> __END__
>
> output:
>
> $lines[0] =3D
>
> "__begin {
> =A0 =A0 =A0abc sss;
> =A0 =A0 =A0def;
> =A0 =A0 =A0{foo;bar}
> =A0 } __end"
>
> $lines[1] =3D
>
> "__begin {
> =A0 =A0 =A0cde;
> =A0 } __end"
>
> $lines[2] =3D
>
> "abc kkk"
>
> $lines[3] =3D
>
> "bad fde"

Wow, I had to admit your regex is simpler, easy to understand and
elegant. I'll study what you said carefully. Anyway, thank you very
much.


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

Date: Mon, 20 Oct 2008 23:27:24 -0700 (PDT)
From: Vishal G <v3gupta@gmail.com>
Subject: String Processing Basic Stuff
Message-Id: <4c58d9d7-5374-4c06-adfd-5a30d13fbb4d@v39g2000pro.googlegroups.com>

 Hi Guys,

Very basic question....

Please dont suggest to use other programing language or other data
structure cause I can't...

I read data from file and yes I have to slurp the whole thing to
memory cause I can use upto 4GB...

data in file is in this format

30 56 78 34 2 39 87 (50 values per line, total of 120 million
entries)

reading file in paragraph mode

Now I have to remove multiple spaces without using much memory

This is what I have wrote (might be very low standard code for Gurus
out there)

It works but takes 5 mins consuming 600-700 MB, if I use substitution
to achieve this it takes 4-5 GB and around 2-3 mins...

Could you pls suggest way to process it faster using less memory
possible...

                # Process the string $_ to remove leading whitespaces,
multiple whitespaces
                # and to padd each value to same size
                my $chr = '';
                my $str = '';
                my $value = '';
                my $unitlength = $Alignment::BASEQUALITY_BYTES;
                while (length($_) > 0) {
                    if (($chr = substr($_, 0, 1, "")) ne " ") {
                        $value = $value . $chr;
                    } else {
                        $str = $str . sprintf("%${unitlength}d",
$value) if ($value);
                        undef $value;
                    }
                }

                # BQ field
                $ace->{'BQ'}->{$name} = $str;

                undef $str;
                undef $chr;

Thanks in advance

Vishal


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 1936
***************************************


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