[31078] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2323 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 7 03:09:44 2009

Date: Tue, 7 Apr 2009 00:09:07 -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, 7 Apr 2009     Volume: 11 Number: 2323

Today's topics:
    Re: Ambiguity with lc <1usa@llenroc.ude.invalid>
    Re: Ambiguity with lc <hjp-usenet2@hjp.at>
    Re: bareword question <tzz@lifelogs.com>
    Re: bareword question <jurgenex@hotmail.com>
        Extremely long Perl debugger output in Windows <neokrish@gmail.com>
        new CPAN modules on Tue Apr  7 2009 (Randal Schwartz)
    Re: Process header record and concatenate files <smallpond@juno.com>
    Re: resolve single line with multiple items into mutlip <ben@morrow.me.uk>
    Re: resolve single line with multiple items into mutlip <uri@stemsystems.com>
    Re: resolve single line with multiple items into mutlip <cartercc@gmail.com>
    Re: resolve single line with multiple items into mutlip <uri@stemsystems.com>
    Re: Substitutions based on Posix ERE's in perl <smallpond@juno.com>
    Re: Substitutions based on Posix ERE's in perl <ben@morrow.me.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 06 Apr 2009 18:01:10 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Ambiguity with lc
Message-Id: <Xns9BE58E9B92407asu1cornelledu@127.0.0.1>

Frank Seitz <devnull4711@web.de> wrote in news:73torqFu2kl7U3
@mid.individual.net:

> sln@netherlands.com wrote:
 ...

>> The compiler gets abmigous if you don't.
> 
> I don't know what you want to tell me.

Don't worry, no one does ;-)

Sinan
-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/


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

Date: Mon, 6 Apr 2009 23:48:17 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Ambiguity with lc
Message-Id: <slrngtku51.7db.hjp-usenet2@hrunkner.hjp.at>

On 2009-04-06 13:11, A. Sinan Unur <1usa@llenroc.ude.invalid> wrote:
> Frank Seitz <devnull4711@web.de> wrote in
> news:73tonmFu2kl7U2@mid.individual.net: 
>> Glenn Jackman wrote:
>>> At 2009-04-04 10:17AM, "Frank Seitz" wrote:
>>>>  I don't believe that anybody means lc($_.'X') when she writes
>>>>  lc.'X'. I expect lc($_).'X' and nothing else.
>>> 
>>> I don't believe anyone trying to write a maintainable program would
>>> write "lc.'x'"
>> 
>> lc lowercases $_ and . concatenates the result with 'X'.
>> In my opinion this is clean code.
>
> On the other hand, mere mortals may miss the . or may have to check
> documentation. 
>
> Will $x and $y in the code below contain the same string?

No.

> I cannot instaneously answer that question.

Neither can I.

> I have to think about it. That is
> what makes this code a maintanence problem: 
>
> my $v = 'A';
>
> $_ = $v;
>
> my $x = lc . 'X';
> my $y = lc $v . 'X';

But it's the latter which is th maintenance problem.

> my $x = lc . 'X';

is perfectly clear and unambiguous. But is 

> my $y = lc $v . 'X';

supposed to mean 

  my $y = lc($v . 'X');

or

  my $y = lc($v) . 'X';

?

Well, I know the answer, but I have to think about it. If I came
across this code I would probably add the parentheses.

So perl warns about the clear and unambiguous code, but not about the
ambiguous code. Somebody got that warning backwards.

	hp


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

Date: Mon, 06 Apr 2009 11:42:42 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: bareword question
Message-Id: <86ws9x7myl.fsf@lifelogs.com>

On Sun, 05 Apr 2009 22:28:13 GMT sln@netherlands.com wrote: 

s> Why can't you quote like a normal human being?
s> Whats all the "D> asdfasdf.as.sa.sa." crap.
s> And you inject code and comments.
s> None of it has dilineation from what your quoting.

s> The most immature crap a poster can do.

s> Why do you post code with 1 space indentation???

s> Are you seriously retarded or what?

I appreciate your interest in my quoting and coding style, not to
mention my mental development.  I assure you I have no doubts about
yours.

s> Why not just make it a one-liner?

s> 	sub my_function{my $p = shift @_;my @p;if (scalar @_){@p = ($p, @_);}else{@p = split ' ', $p;}

I could have, but it would have been ugly and obfuscated, as you have
aptly shown.

s> This is more readable.

I don't like it much, but feel free to use that version in your own
programs.

Ted


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

Date: Mon, 06 Apr 2009 11:36:18 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: bareword question
Message-Id: <s1ikt4lf8ul5n3786egfvt04hosg9d8gu4@4ax.com>

Ted Zlatanov <tzz@lifelogs.com> wrote:
[Replying to your post because Mr. sln is somewhere near the bottom of
my killfile]
>On Sun, 05 Apr 2009 22:28:13 GMT sln@netherlands.com wrote: 
>s> And you inject code and comments.

Which is a good thing. Sane people put their comment next to the text
they are commenting on. Then there is no confusion about what they are
commenting on.

>s> None of it has dilineation from what your quoting.

Would you mind translating this sentence into English, please?

>s> The most immature crap a poster can do.

Actually it's Usenet standard.

>s> Why do you post code with 1 space indentation???

The question mark key on your keyboard is stuck.

As to the content of the question: I personally would suggest 4 spaces
of indentation or maybe even 8 if there is plenty of room. 
1 is indeed difficult to spot, although it might be justified to keep a
max line length of 72 on deeply indentated code.

>s> Why not just make it a one-liner?
>
>s> 	sub my_function{my $p = shift @_;my @p;if (scalar @_){@p = ($p, @_);}else{@p = split ' ', $p;}

I would say because it's impossible to see the structure of that
one-liner.

sub my_function {
	my $p = shift @_;
	my @p;
	if (scalar @_) {
		@p = ($p, @_);
	} else {
		@p = split ' ', $p;
	} 

will make it immediately obvious that your great one-liner is actually
missing the closing curly bracket.

I don't always agree with Ted, but he is orders of magnitude saner than
you as your inane rantings proof beyond any shadow of a doubt.

jue


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

Date: Mon, 6 Apr 2009 21:42:10 -0700 (PDT)
From: Artemis Fowl <neokrish@gmail.com>
Subject: Extremely long Perl debugger output in Windows
Message-Id: <85b8759e-542c-4d3d-844b-6acb98ce13b3@w31g2000prd.googlegroups.com>

Hello Experts,

I am facing a minor issue while I am debugging my perl script. It
contains a lot of "PRINT" statements and when I let it run in the
debugger, in the command prompt in Windows, I lose out on a lot of
output. But I would like to capture this.
Also, when I evaluate some hash, array in my program - the output
still exceeds the command prompt window.
I tried using PERDB_OPTS environment variable. But I am not able to
get it working.
Can you please help me with this?

Many Thanks in advance,
Artemis


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

Date: Tue, 7 Apr 2009 04:42:27 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Tue Apr  7 2009
Message-Id: <KHprqr.Dwq@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.

AI-Evolve-Befunge-0.03
http://search.cpan.org/~infinoid/AI-Evolve-Befunge-0.03/
practical evolution of Befunge AI programs 
----
Algorithm-Graphs-TransitiveClosure-2009040601
http://search.cpan.org/~abigail/Algorithm-Graphs-TransitiveClosure-2009040601/
----
App-PM-Announce-0.021
http://search.cpan.org/~rkrimen/App-PM-Announce-0.021/
----
App-PM-Announce-0.022
http://search.cpan.org/~rkrimen/App-PM-Announce-0.022/
Announce your PM meeting via Meetup and LinkedIn 
----
Auth-Yubikey_WebClient-0.03
http://search.cpan.org/~massyn/Auth-Yubikey_WebClient-0.03/
Authenticating the Yubikey against the Yubico Web API 
----
Beanstalk-Client-1.05
http://search.cpan.org/~gbarr/Beanstalk-Client-1.05/
Client class to talk to beanstalkd server 
----
CGI-RSS-0.95
http://search.cpan.org/~jettero/CGI-RSS-0.95/
provides a CGI-like interface for making rss feeds 
----
CGI-ValidOp-0.51
http://search.cpan.org/~hdp/CGI-ValidOp-0.51/
Simple validation of CGI parameters and runmodes. 
----
CGI.pm-3.43
http://search.cpan.org/~lds/CGI.pm-3.43/
----
CatalystX-REPL-0.02
http://search.cpan.org/~ash/CatalystX-REPL-0.02/
read-eval-print-loop for debugging your Catalyst application 
----
Class-ByOS-0.01
http://search.cpan.org/~pevans/Class-ByOS-0.01/
write object classes that load OS-specific subclasses at runtime 
----
Class-Implant-0.01_02
http://search.cpan.org/~shelling/Class-Implant-0.01_02/
Manipulating mixin and inheritance out of packages 
----
Class-Meta-0.63
http://search.cpan.org/~dwheeler/Class-Meta-0.63/
Class automation, introspection, and data validation 
----
DBIx-Class-0.08013
http://search.cpan.org/~ash/DBIx-Class-0.08013/
Extensible and flexible object <-> relational mapper. 
----
DateTime-Format-Natural-0.75_05
http://search.cpan.org/~schubiger/DateTime-Format-Natural-0.75_05/
Create machine readable date/time with natural parsing logic 
----
DateTime-TimeZone-0.88
http://search.cpan.org/~drolsky/DateTime-TimeZone-0.88/
Time zone object base class and factory 
----
Drupal-Admin-0.03
http://search.cpan.org/~durist/Drupal-Admin-0.03/
screen scraping Perl API to some Drupal admin functions 
----
Env-Sanctify-1.00
http://search.cpan.org/~bingos/Env-Sanctify-1.00/
Lexically scoped sanctification of %ENV 
----
Games-Sudoku-SudokuTk-0.13
http://search.cpan.org/~cguine/Games-Sudoku-SudokuTk-0.13/
Sudoku Game 
----
HTML-Chunks-1.54
http://search.cpan.org/~mblythe/HTML-Chunks-1.54/
A simple nested template engine for HTML, XML and XHTML 
----
HTML-TreeBuilder-LibXML-0.04
http://search.cpan.org/~tokuhirom/HTML-TreeBuilder-LibXML-0.04/
HTML::TreeBuilder::XPath compatible interface with libxml 
----
IO-Async-Loop-linux-0.01
http://search.cpan.org/~pevans/IO-Async-Loop-linux-0.01/
pick the best Loop implementation on Linux 
----
Image-Heatmap-0.526
http://search.cpan.org/~wazzuteke/Image-Heatmap-0.526/
Build heatmap images 
----
Lexical-Attributes-2009040601
http://search.cpan.org/~abigail/Lexical-Attributes-2009040601/
Proper encapsulation 
----
Lingua-EN-Titlecase-0.13
http://search.cpan.org/~ashley/Lingua-EN-Titlecase-0.13/
Titlecase English words by traditional editorial rules. 
----
Loompa-0.51
http://search.cpan.org/~hdp/Loompa-0.51/
Lightweight object-oriented miniature Perl assistant. 
----
MOBY-1.08
http://search.cpan.org/~ekawas/MOBY-1.08/
API for hosting and/or communicating with a MOBY Central registry 
----
Mail-IMAPClient-3.16
http://search.cpan.org/~markov/Mail-IMAPClient-3.16/
An IMAP Client API 
----
Math-Random-ISAAC-1.0.1
http://search.cpan.org/~frequency/Math-Random-ISAAC-1.0.1/
Perl interface to the ISAAC PRNG Algorithm 
----
Math-Random-ISAAC-XS-1.0
http://search.cpan.org/~frequency/Math-Random-ISAAC-XS-1.0/
C implementation of the ISAAC PRNG Algorithm 
----
Module-Build-JSAN-0.05
http://search.cpan.org/~dwheeler/Module-Build-JSAN-0.05/
Build JavaScript distributions for JSAN 
----
Moose-0.73_02
http://search.cpan.org/~drolsky/Moose-0.73_02/
A postmodern object system for Perl 5 
----
MooseX-Storage-0.17
http://search.cpan.org/~bobtfish/MooseX-Storage-0.17/
An serialization framework for Moose classes 
----
MooseX-Types-DateTime-ButMaintained-0.04
http://search.cpan.org/~ecarroll/MooseX-Types-DateTime-ButMaintained-0.04/
DateTime related constraints and coercions for Moose 
----
MooseX-Types-Structured-0.11
http://search.cpan.org/~jjnapiork/MooseX-Types-Structured-0.11/
Structured Type Constraints for Moose 
----
Net-IMAP-Server-1.14
http://search.cpan.org/~alexmv/Net-IMAP-Server-1.14/
A single-threaded multiplexing IMAP server implementation, using Net::Server::Coro. 
----
Net-IMAP-Server-1.15
http://search.cpan.org/~alexmv/Net-IMAP-Server-1.15/
A single-threaded multiplexing IMAP server implementation, using Net::Server::Coro. 
----
Net-LimeLight-Purge-0.02
http://search.cpan.org/~gphat/Net-LimeLight-Purge-0.02/
LimeLight Purge Service API 
----
Net-ParSCP-0.07
http://search.cpan.org/~casiano/Net-ParSCP-0.07/
Parallel secure copy 
----
News-Pictures-0.12
http://search.cpan.org/~cguine/News-Pictures-0.12/
The great new News::Pictures! 
----
Omega-DP41-Data-Current-0.3.3
http://search.cpan.org/~kerr/Omega-DP41-Data-Current-0.3.3/
----
Omega-DP41-Data-Current-0.3.4
http://search.cpan.org/~kerr/Omega-DP41-Data-Current-0.3.4/
----
POE-Component-Client-DNS-Recursive-0.04
http://search.cpan.org/~bingos/POE-Component-Client-DNS-Recursive-0.04/
A recursive DNS client for POE 
----
POE-Component-Client-NRPE-0.14
http://search.cpan.org/~bingos/POE-Component-Client-NRPE-0.14/
a POE Component that implements check_nrpe functionality 
----
POE-Component-DHCP-Monitor-1.00
http://search.cpan.org/~bingos/POE-Component-DHCP-Monitor-1.00/
A simple POE Component for monitoring DHCP traffic. 
----
POE-Component-Server-NRPE-0.14
http://search.cpan.org/~bingos/POE-Component-Server-NRPE-0.14/
A POE Component implementation of NRPE Daemon. 
----
POE-Filter-Finger-0.04
http://search.cpan.org/~bingos/POE-Filter-Finger-0.04/
A POE Filter for creating FINGER servers. 
----
POE-Filter-XML-0.36
http://search.cpan.org/~nperez/POE-Filter-XML-0.36/
A POE Filter for parsing XML 
----
POE-Session-PlainCall-0.0100
http://search.cpan.org/~gwyn/POE-Session-PlainCall-0.0100/
POE sessions with plain perl calls 
----
RFC-RFC822-Address-2009040601
http://search.cpan.org/~abigail/RFC-RFC822-Address-2009040601/
RFC 822 style address validation. 
----
RRDTool-OO-0.24
http://search.cpan.org/~mschilli/RRDTool-OO-0.24/
Object-oriented interface to RRDTool 
----
SQL-KeywordSearch-1.12
http://search.cpan.org/~markstos/SQL-KeywordSearch-1.12/
generate SQL for simple keyword searches 
----
SQL-KeywordSearch-1.13
http://search.cpan.org/~markstos/SQL-KeywordSearch-1.13/
generate SQL for simple keyword searches 
----
SQL-Reporter-Excel-0.1
http://search.cpan.org/~dmytro/SQL-Reporter-Excel-0.1/
creating Excel reports from SQL statements 
----
SQL-Reporter-Excel-0.1.1
http://search.cpan.org/~dmytro/SQL-Reporter-Excel-0.1.1/
creating Excel reports from SQL statements 
----
Sys-Info-Driver-Unknown-0.71
http://search.cpan.org/~burak/Sys-Info-Driver-Unknown-0.71/
Compatibility layer for Sys::Info 
----
Term-Sprog-0.05
http://search.cpan.org/~keichner/Term-Sprog-0.05/
Perl extension for displaying a progress indicator on a terminal. 
----
Test-Class-Sugar-0.0200
http://search.cpan.org/~pdcawley/Test-Class-Sugar-0.0200/
Helper syntax for writing Test::Class tests 
----
Test-POE-Client-TCP-1.00
http://search.cpan.org/~bingos/Test-POE-Client-TCP-1.00/
A POE Component providing TCP client services for test cases 
----
Test-POE-Server-TCP-1.00
http://search.cpan.org/~bingos/Test-POE-Server-TCP-1.00/
A POE Component providing TCP server services for test cases 
----
Text-Darts-0.08
http://search.cpan.org/~dankogai/Text-Darts-0.08/
Perl interface to DARTS by Taku Kudoh 
----
Text-Variations-0.02
http://search.cpan.org/~evdb/Text-Variations-0.02/
create many variations of the same message 
----
Text-WordDiff-0.05
http://search.cpan.org/~dwheeler/Text-WordDiff-0.05/
Track changes between documents 
----
Tie-Counter-2009040601
http://search.cpan.org/~abigail/Tie-Counter-2009040601/
Have a counter in a scalar. 
----
Tk-MK-0.15
http://search.cpan.org/~mikra/Tk-MK-0.15/
----
Tk-MK-0.16
http://search.cpan.org/~mikra/Tk-MK-0.16/
----
Tree-Predicate-0.01
http://search.cpan.org/~marshall/Tree-Predicate-0.01/
a balanced, splittable tree for SQL predicates 
----
UUID-Generator-PurePerl-0.01
http://search.cpan.org/~banb/UUID-Generator-PurePerl-0.01/
Universally Unique IDentifier (UUID) Generator 
----
UUID-Object-0.01
http://search.cpan.org/~banb/UUID-Object-0.01/
Universally Unique IDentifier (UUID) Object Class 
----
WWW-Curl-4.06
http://search.cpan.org/~szbalint/WWW-Curl-4.06/
Perl extension interface for libcurl 
----
WWW-Mechanize-Plugin-JavaScript-0.010
http://search.cpan.org/~sprout/WWW-Mechanize-Plugin-JavaScript-0.010/
JavaScript plugin for WWW::Mechanize 
----
Win32-Process-Info-1.014
http://search.cpan.org/~wyant/Win32-Process-Info-1.014/
Provide process information for Windows 32 systems. 
----
Win32-Process-Kill-v0.1
http://search.cpan.org/~rootkwok/Win32-Process-Kill-v0.1/
Perl extension for Terminating Process in Win32 (R3) 
----
XML-FeedPP-0.40
http://search.cpan.org/~kawasaki/XML-FeedPP-0.40/
Parse/write/merge/edit RSS/RDF/Atom syndication feeds 
----
XML-Reader-0.08
http://search.cpan.org/~keichner/XML-Reader-0.08/
Reading XML and providing path information based on a pull-parser. 


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: Mon, 6 Apr 2009 09:01:15 -0700 (PDT)
From: smallpond <smallpond@juno.com>
Subject: Re: Process header record and concatenate files
Message-Id: <9e7473ad-422a-477c-9399-74db697d21c9@f19g2000yqh.googlegroups.com>

On Apr 4, 10:22 pm, Scott Bass <sas_l_...@yahoo.com.au> wrote:
> Hi,
>
> I'm not looking for a full blown solution, just architectural advice
> for the following design criteria...
>
> Input File(s): (tilde delimited)
> Line 1:
> Header Record:
> SourceSystem~EffectiveDate~ExtractDateAndTime~NumberRecords~FileFormatVersion
>
> RemainingRecords:
> 72 columns of delimited data
>
> Ouput File:
> Concatenate the input files into a single output file.  A subset of
> the header fields are prepended to the data lines as follows:
>
> SourceSystem~EffectiveDate~ExtractDateAndTime~72 columns of delimited
> data
>
> Design Criteria:
> 1) If number of records in the file does not match the number of
> records reported in the header (incomplete FTP), abort the entire
> file, print an error message, but continue processing the remaining
> files.
>
> (I'll use split and join to process the header and prepend to the
> remainder).
>
> 2) Specify the list of input files on the command line.  Specify the
> output file on the command line.  For example:
>
> concat.pl -in foo.dat bar.dat blah.dat -out concat.dat
>
> or possibly:
>
> concat.pl -in src_*.dat -out concat.dat
>
> (I'll use GetOptions to process the command line)
>
> My thoughts:
>
> 1) Slurp the file into an array (minus first record).  Count the
> elements in the array.  Abort if not equal to the number in the
> header, else concat to the output file.
>
> 2) Process the file, reading records.  At EOF, get record number from
> $. .  If correct, rewind to beginning of file handle and concat to
> output file.  (Not sure how to do the rewind bit).
>
> 3) Process the file, writing to a temp file.  At EOF, get record
> number from $. .  If correct, concat the temp file to the output file.
>
> Questions:
>
> A)  If I've globbed the files on the command line and am processing
> the file handle <>, how do I know when the file name has changed?
>
> B)  When that happens, how do I reset $. to 1?
>
> C)  Of the three approaches above, which is the "best"?  Performance
> is important but not critical.  I lean toward #3, since I need to
> cater for files too large for #1.  Or if you have a better idea please
> let me know.
>
> I hope this wasn't too cryptic...I was trying to keep it short.
>
> Thanks,
> Scott

If you want to process your input in one pass, use tell to save the
position of the output at the start of each input file.  If you get
to the end of input and the number of records is wrong, use seek
to discard it.


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

Date: Mon, 6 Apr 2009 18:06:07 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: resolve single line with multiple items into mutliple lines,  single items
Message-Id: <vcppa6-ndv.ln1@osiris.mauzo.dyndns.org>


Quoth ccc31807 <cartercc@gmail.com>:
> Some will say this is a simple minded solution, and maybe it is, but
> FWIW here's my contribution. This decomposes your data into a data
> structure in memory. It's dynamic in the sense that it doesn't matter
> how many records you have or where the @'s are, as long as you have
> only two levels. All you have to do then is print it out. I have used
> Dumper simply because I'm to lazy to finish it.
> 
> CODE:
> use strict;
> use warnings;
> use Data::Dumper;
> 
> while (<DATA>)
> {
> 	my @rest = split /\t/;
> 	my $num = @rest;
> 	for (my $i = 0; $i < $num; $i++)
> 	{
> 		if ($rest[$i] =~ /@/)
> 		{
> 			$rest[$i] = [split /@/, $rest[$i]];
> 		}
> 		print qq(\t$rest[$i]\n);
> 	}

It would be cleaner to build a new array:

    my @twolevel;
    for (@rest) {
        push @twolevel, [split /\@/, $_];
        print qq(\t$_\n);
    }

or more idiomatically

    print "\t" . join("\n\t", @rest) . "\n";
    my @twolevel = map { [split /\@/] } @rest;

> 	print "\nData Structure via Dumper is:\n";
> 	print Dumper(@rest);
> }
> 
> exit(0);

There is no need to exit() from a Perl program under normal
circumstances. Falling off the end will exit successfully.

Ben



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

Date: Mon, 06 Apr 2009 13:49:05 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: resolve single line with multiple items into mutliple lines,  single items
Message-Id: <x7myatr7u6.fsf@mail.sysarch.com>

>>>>> "BM" == Ben Morrow <ben@morrow.me.uk> writes:

  >> exit(0);

  BM> There is no need to exit() from a Perl program under normal
  BM> circumstances. Falling off the end will exit successfully.

i like to have explicit exits in my main program. i usually keep the top
level inline code very short with a few key lexicals and top sub calls
and then exit(). then come the subs in some semblance of order. arg
parsing and help/usage subs always go to the bottom out of the way. this
is how i teach to write scripts so they are easy to develop AND
read. and the explicit exit tells you the top level code is done and you
don't have to scan for it (or fall to the bottom) to see any more main
level code.

uri

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


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

Date: Mon, 6 Apr 2009 11:27:10 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: resolve single line with multiple items into mutliple lines,  single items
Message-Id: <41cfc8ec-b76c-4b6d-9840-91fa9cffc684@s20g2000yqh.googlegroups.com>

On Apr 6, 1:49=A0pm, Uri Guttman <u...@stemsystems.com> wrote:
> i like to have explicit exits in my main program. i usually keep the top
> level inline code very short with a few key lexicals and top sub calls
> and then exit(). then come the subs in some semblance of order. arg
> parsing and help/usage subs always go to the bottom out of the way. this
> is how i teach to write scripts so they are easy to develop AND
> read. and the explicit exit tells you the top level code is done and you
> don't have to scan for it (or fall to the bottom) to see any more main
> level code.

I agree fully.

As a matter of style, you can write functions that only receive
arguments and return values with no side effects or assignments
withing the functions, or you can write functions that make
assignments and have side effects.

Philosophically, I'm inclined to the first style, and attempt to write
in that style.

In practice, I normally write in the second style, so that my 'main'
program is very short and consists on of a sequence of function calls
(followed by exit(0)). The bulk of the work, including variable
assignments, are done by my user defined functions.

I'm tending now to use a lot of modules, so that my 'main' program
still consists of sequences of function calls, my user defined
functions still avoid side effects and assignments as much as
possible, and the dirty work is done in the modules. I don't
particularly like this, and my style will probably continue to change.

Your thoughts?

CC


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

Date: Mon, 06 Apr 2009 14:47:07 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: resolve single line with multiple items into mutliple lines,  single items
Message-Id: <x763hhr55g.fsf@mail.sysarch.com>

>>>>> "c" == ccc31807  <cartercc@gmail.com> writes:

  c> As a matter of style, you can write functions that only receive
  c> arguments and return values with no side effects or assignments
  c> withing the functions, or you can write functions that make
  c> assignments and have side effects.

it varies. in some cases a few top level lexicals are ok by me.

  c> I'm tending now to use a lot of modules, so that my 'main' program
  c> still consists of sequences of function calls, my user defined
  c> functions still avoid side effects and assignments as much as
  c> possible, and the dirty work is done in the modules. I don't
  c> particularly like this, and my style will probably continue to change.

you can always pass in a main hash ref to keep all the top level
stuff. as i said, it varies based on my mood and the complexity of the
program's top level.

uri

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


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

Date: Mon, 6 Apr 2009 08:47:08 -0700 (PDT)
From: smallpond <smallpond@juno.com>
Subject: Re: Substitutions based on Posix ERE's in perl
Message-Id: <37600483-0305-4dbe-a894-7f7477672159@k2g2000yql.googlegroups.com>

On Apr 5, 11:57 am, Peter Makholm <pe...@makholm.net> wrote:
> For a project I have to implement lookup using NAPTR records from
> DNS. Basicaly the consist of an substitution using POSIX ERE
> syntax. (See RFC 3403).
>
> Parsing the regexp to perl with minor corrections would probably solve
> my problem in maost of the well behaved cases. But what about the not
> so well behaved cases?
>
> Is there an easy way to sanitize a regular expression such that it
> is safe to run? Or should I write a full translation from ERE to perl?
>
> Searhing CPAN doesn't ive me anything usefull.
>
> Any other ideas?
>
> //Makholm


Easy way?  I doubt it.  Perl regexp has too many special constructs
and
multiple uses of characters to be very easy.  I would treat it like a
taint check on a web form: only allow what you know to be safe and
deny
anything else.  Then do a non-interpolating substitution to prevent
leaking any information.  So maybe convert /LHS/RHS/ to s'LHS'RHS'
where you have checked for legal characters and sequences in LHS and
RHS
and translated any differing POSIX-ish into Perl-ish.

Somebody must have made a comprehensive set of test cases for this
spec
as part of reviewing it.  Find that.


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

Date: Mon, 6 Apr 2009 18:13:00 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Substitutions based on Posix ERE's in perl
Message-Id: <spppa6-ndv.ln1@osiris.mauzo.dyndns.org>


Quoth Peter Makholm <peter@makholm.net>:
> For a project I have to implement lookup using NAPTR records from
> DNS. Basicaly the consist of an substitution using POSIX ERE
> syntax. (See RFC 3403).
> 
> Parsing the regexp to perl with minor corrections would probably solve
> my problem in maost of the well behaved cases. But what about the not
> so well behaved cases?
> 
> Is there an easy way to sanitize a regular expression such that it
> is safe to run? Or should I write a full translation from ERE to perl?
> 
> Searhing CPAN doesn't ive me anything usefull.

I take it Regex::POSIX isn't good enough? It doesn't appear to support
returning the match positions, which would be required to do a
substitution.

If you have 5.10 re::engine::POSIX would be the obvious thing to use.

Ben



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

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


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