[27095] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8980 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 21 21:05:39 2006

Date: Tue, 21 Feb 2006 18:05:05 -0800 (PST)
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 Feb 2006     Volume: 10 Number: 8980

Today's topics:
    Re: Combining three arrays of hashes into one? robic0
    Re: Implementing a "pull" (?) interface in perl xhoster@gmail.com
    Re: Reading Mac / Unix / DOS text files <nospam@comcast.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 21 Feb 2006 16:53:48 -0800
From: robic0
Subject: Re: Combining three arrays of hashes into one?
Message-Id: <urcnv1ddbfamlbviuo27rckhijthtd30dk@4ax.com>

On Fri, 17 Feb 2006 23:37:15 GMT, "Frank J. Russo" <FJRussonc@earthlink.net> wrote:
On Thu, 16 Feb 2006 17:45:45 -0800, Keith Lee <cmarvel@nethere.com> wrote:

>>>All:
>>>	Is there a way of copying three arrays of hashes into one array for
>>>	future sorting?  Thanks!
>>>
>>>Keith

>>Lookout, I'm asking you post an example to coincode with your what
>>ever bullshit question/without example you are posting!

>That was unnecessary.  Your choice of words /  limited vocabular, would make 
>one not even want to pay attention to you no matter what you have to say. 
>Words have meaning.  Use them properly. 
>

Its hard not to be rude to the Christian God people like you.
You didn't quote, so I did it for you.

This is Usenet, this isin't your local church gathering. If my limited vocabulary
bothers you, perhaps you should filter out my posts and not trouble yourself so much.

If this is a relative of yours, I had no intentions to offend him as not anyone else
(except for a select few that I know).

However, you on the otherhand. You can kiss my goddamed fucnkin ass !!!!



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

Date: 22 Feb 2006 01:42:12 GMT
From: xhoster@gmail.com
Subject: Re: Implementing a "pull" (?) interface in perl
Message-Id: <20060221204432.012$7d@newsreader.com>

Arvin Portlock <nomail@sorry.com> wrote:
> I'm writing a module to parse an XML file of records. It
> will be used by a variety of different applications, e.g.,
> loading into a relational database, etc. I'll be using
> a SAX based approach, ExpatXS, as the XML files can be
> very large.
>
> In the past I've written such modules by assembling a huge
> data structure in memory then returning it to the calling
> application as, say, a reference to an array of hashes.
> This was tremendously convenient yet very very slow.

Something like?:

$parser->init($foo);
my $alldata=$parser->get_all();
foreach my $i (@$alldata) {
  process($i);
};


Was it slow only because you exhausted memory and were swapping?
Or was it just slow in providing feedback/progress messages?

> Some
> applications would take hours to execute. This time around
> I'd like to learn something new and approach it differently.
>
> Is there some way to design this, module plus application,
> so that as a record is read the application can process it
> immediately?

There are several ways to do this, but it is quite likely that it will not
be any faster from beginning to end than the original way.  If you can have
the parsing and the processing in separate threads or processes, or if you
are exhausting memory, then "parse process parse process" could be faster,
but if both operations happen synchronously anyway and memory is not an
issue, then "parse parse parse process process process" would probably not
be much if any slower.

> Is this what is know as a pull-based architecture?
> How does the application "know" when a new record is available?

The easiest way is to have the application block until a new record is
ready. That is just what readline aka <> does:

$parser->init($foo);
while (defined (my $i=$parser->get_one()) {
  process($i);
};


> Does it listen for something that the module emits? I'm
> thinking maybe it can be done with a callback. The callback
> subroutine is written in the calling application and when
> the end of the record is parsed, that subroutine is called.


my $sub= sub { process($_[0]) };
$parser->init($foo);
$parser->put_all_through_callback($sub);


> I'm sure this is a basic question but it's new to me. Is my
> callback idea worth exploring?

The callback method is more flexible, but it isn't clear to me that you
need that flexibility.  If not, I'd go with the simpler (or at least more
familiar) readline like method.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Tue, 21 Feb 2006 19:16:21 -0500
From: "thrill5" <nospam@comcast.net>
Subject: Re: Reading Mac / Unix / DOS text files
Message-Id: <orudnfyiAvVSMmbeRVn-rQ@comcast.com>

I don't know why you had to stare at "while (<IF>)" for anything longer than 
about a tenth of second.  Pretty obvious what the code does to me. 
Whitespace  and using barewords for file handles is a matter of programming 
style.  Just because that's not the way you do it does not mean that it is 
incorrect or wrong.

Scott

"A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in message 
news:Xns97718FB4BB1ECasu1cornelledu@132.236.56.8...
> January Weiner <january.weiner@gmail.com> wrote in news:dtfd12$m4k$1
> @sagnix.uni-muenster.de:
>
>> I'd like my script to treat text files coming from various systems
> alike.
>> More specifically, I'd like to recognize ends of line as one of: \r,
> \l,
>> \r\l.  Is there a more elegant way than doing the obvious?:
>
> You should use the codes for those characters rather than the escapes.
>
>>   while(<IF>) {
>
> I stared at this for a long time trying to figure out what
>
> while(<IF>) {
>
> meant. I guess IF is short for Input File?
>
> Here, an appropriate amount of whitespace, not using bareword
> filehandles, and using an appropriate variable name would have helped
> immensely with readability.
>
> while ( <$input> ) {
>
>>     s/\r?\l?$// ; # is this correct anyway? will an end of line be
>>                   # recognized with a Mac file?
>
>
> This information is readily available by doing a cursory Google search.
> Are you that lazy?
>
> s{ \012 | (?: \015\012? ) }{\n}x
>
> should convert any line ending convention to the one supported by your
> platform.
>
>> I would expect that there is some weird variable out there
>> (like the $/)
>
>
> $/ is not a weird variable. It is documented in perldoc perlvar.
>
> Sinan 




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

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 V10 Issue 8980
***************************************


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