[30602] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1845 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 9 03:09:46 2008

Date: Tue, 9 Sep 2008 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, 9 Sep 2008     Volume: 11 Number: 1845

Today's topics:
    Re: Cartesian to lat and lon <zed@resonant.org>
    Re: Cartesian to lat and lon <jimsgibson@gmail.com>
    Re: Complex (for me) reference deconstruction <tadmc@seesig.invalid>
        new CPAN modules on Tue Sep  9 2008 (Randal Schwartz)
    Re: Perl equivalent of unix time command xhoster@gmail.com
    Re: Perl equivalent of unix time command xhoster@gmail.com
    Re: Perl equivalent of unix time command <melroysoares@hotmail.com>
    Re: Perl equivalent of unix time command <tomislav.novak@gmail.com>
    Re: submit  to FormMail.pl throwing some error. <jimsgibson@gmail.com>
    Re: using 2-arg open to open to a scalar <ced@blv-sam-01.ca.boeing.com>
    Re: What is wrong in the following script <rvtol+news@isolution.nl>
    Re: What is wrong in the following script <whynot@pozharski.name>
    Re: XML::Twig doctype and entity handling <zed@resonant.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 08 Sep 2008 16:17:06 GMT
From: Zed Pobre <zed@resonant.org>
Subject: Re: Cartesian to lat and lon
Message-Id: <slrngcajh3.4pp.zed@resonant.org>

Andrew Rich <vk4tec@people.net.au> wrote:
>
> I have had success going from lat and lon to bearing and distance from a 
> known point.
>
> Now I have a need to go the other way.
>
> Given a known point, and given the bearing and distance, calculate the lat 
> and lon.
>
> Ideas ?
>
> Maybe there is a module that does this ?

I suspect that what you want is Geo::Direction::Distance.

If it isn't, searching CPAN for "Geo Distance" should bring up quite a
few other tools.

-- 
Zed Pobre <zed@resonant.org> a.k.a. Zed Pobre <zed@debian.org>
PGP key and fingerprint available on finger; encrypted mail welcomed.


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

Date: Mon, 08 Sep 2008 12:54:46 -0700
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: Cartesian to lat and lon
Message-Id: <080920081254465935%jimsgibson@gmail.com>

In article <48c34c6a$1_1@news.peopletelecom.com.au>, Andrew Rich
<vk4tec@people.net.au> wrote:

> Hello
> 
> I have had success going from lat and lon to bearing and distance from a 
> known point.
> 
> Now I have a need to go the other way.
> 
> Given a known point, and given the bearing and distance, calculate the lat 
> and lon.
> 
> Ideas ?
> 
> Maybe there is a module that does this ?

There are several. I wrote one called Geo::Ellipsoid and submitted it
to CPAN. I have been using it for several years. I would be glad to
help you with it if you have any problems using it. 

Other modules that do the same thing are Geo::Forward and
Geo::Direction::Distance. They all give comparable results, according
to my admittedly short tests.

-- 
Jim Gibson


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

Date: Mon, 8 Sep 2008 22:23:00 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Complex (for me) reference deconstruction
Message-Id: <slrngcbr0k.219.tadmc@tadmc30.sbcglobal.net>

Mark Clements <mark.clementsREMOVETHIS@wanadoo.fr> wrote:
> John W. Krahn wrote:
>> Mark Clements wrote:
>>> Tad J McClellan wrote:
>>>> sjcampbl@gmail.com<sjcampbl@gmail.com> wrote:
>>>>> Ok, I think I understand. Thanks for the help.
>>>>>
>>>>> So...
>>>>>
>>>>> for $r (@{$t->{rows}}) {
>>>>>
>>>>> {rows} is a hash key within a hash referenced by $t
>>>>> $t->{rows} contains an array reference
>>>>> @{$t->{rows}} de-references this array reference, returning an actual
>>>>> array
>>>>
>>>> Almost.
>>>>
>>>> It does not return an actual array. It returns a list.
>>>>
>>>> See:
>>>>
>>>> perldoc -q difference
>>>>
>>>> What is the difference between a list and an array?
>>>>
>>> Hmmm... OK - I've read the faq above and it says:
>>>
>>> "
>>> An array has a changeable length. A list does not. An array is
>>> something you can push or pop, while a list is a set of values.
>>> "
>>>
>>> But you *can* pop etc a dereferenced arrayref.


But you cannot, in general, pop etc the list that a foreach iterates over.


>>> mark@hermes:~$ perl -Mstrict -Mwarnings -le 'my $c=[qw(a b c)];print
>>> pop @{$c}; print "@{$c}"'
>>> c
>>> a b
>>> mark@hermes:~$
>>>
>>> So - the snippet of code above initializes an arrayref, and then pops
>>> its dereferenced value. According to the faq this would make the
>>> deferenced value an array since I can pop it.
>>>
>>> Am I missing something?
>>
>> In the example @{$t->{rows}} *is* an array, which in list context
>> *returns* a list.
> OK - got it. That's pretty subtle :)


Which is why I thought it deserved a mention.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Tue, 9 Sep 2008 04:42:22 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Tue Sep  9 2008
Message-Id: <K6wvqM.1LKF@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.

AUBBC-1.30
http://search.cpan.org/~sflex/AUBBC-1.30/
----
Acme-Curse-0.0.1
http://search.cpan.org/~moritz/Acme-Curse-0.0.1/
Remove the blessing that lay on references 
----
Alien-wxWidgets-0.39
http://search.cpan.org/~mbarbon/Alien-wxWidgets-0.39/
building, finding and using wxWidgets binaries 
----
Archive-Tar-1.39_04
http://search.cpan.org/~kane/Archive-Tar-1.39_04/
module for manipulations of tar archives 
----
Business-KontoCheck-2.93
http://search.cpan.org/~michel/Business-KontoCheck-2.93/
Perl extension for checking German and Austrian Bank Account Numbers 
----
CGI-Application-Plugin-Config-Any-0.11
http://search.cpan.org/~mab/CGI-Application-Plugin-Config-Any-0.11/
Add Config::Any Support to CGI::Application 
----
CGI-Carp-Throw-0.02
http://search.cpan.org/~ronaldws/CGI-Carp-Throw-0.02/
CGI::Carp exceptions that don't look like errors. 
----
CGI-Lazy-0.09
http://search.cpan.org/~vayde/CGI-Lazy-0.09/
----
CGI.pm-3.42
http://search.cpan.org/~lds/CGI.pm-3.42/
----
CPAN-Indexer-Mirror-0.03
http://search.cpan.org/~adamk/CPAN-Indexer-Mirror-0.03/
Creates the mirror.yml and mirror.json files 
----
CPAN-Indexer-Mirror-0.04
http://search.cpan.org/~adamk/CPAN-Indexer-Mirror-0.04/
Creates the mirror.yml and mirror.json files 
----
CPANPLUS-0.85_04
http://search.cpan.org/~kane/CPANPLUS-0.85_04/
API & CLI access to the CPAN mirrors 
----
Calendar-Schedule-1.01
http://search.cpan.org/~vlado/Calendar-Schedule-1.01/
for managing calendar schedules 
----
Catalyst-View-Graphics-Primitive-0.02
http://search.cpan.org/~gphat/Catalyst-View-Graphics-Primitive-0.02/
A Catalyst View for Graphics::Primitive 
----
Chart-Clicker-2.08
http://search.cpan.org/~gphat/Chart-Clicker-2.08/
Powerful, extensible charting. 
----
DBD-ODBC-1.16_3
http://search.cpan.org/~mjevans/DBD-ODBC-1.16_3/
ODBC Driver for DBI 
----
DBIx-Perlish-0.44
http://search.cpan.org/~gruber/DBIx-Perlish-0.44/
a perlish interface to SQL databases 
----
Data-Feed-0.00006
http://search.cpan.org/~dmaki/Data-Feed-0.00006/
Extensible Feed Parsing Tool 
----
Data-Valve-0.00008
http://search.cpan.org/~dmaki/Data-Valve-0.00008/
Throttle Your Data 
----
Document-Writer-0.08
http://search.cpan.org/~gphat/Document-Writer-0.08/
Library agnostic document creation 
----
Email-MIME-1.861_01
http://search.cpan.org/~rjbs/Email-MIME-1.861_01/
Easy MIME message parsing. 
----
Error-Exception-1.1
http://search.cpan.org/~srvance/Error-Exception-1.1/
Combines Error and Exception::Class with correct stringication 
----
File-Corresponding-0.002
http://search.cpan.org/~johanl/File-Corresponding-0.002/
Find corresponding files in the directory tree 
----
Geometry-AffineTransform-1.1
http://search.cpan.org/~liyanage/Geometry-AffineTransform-1.1/
Affine Transformation to map 2D coordinates to other 2D coordinates 
----
Google-Chart-0.05004
http://search.cpan.org/~dmaki/Google-Chart-0.05004/
Interface to Google Charts API 
----
Graphics-Primitive-0.29
http://search.cpan.org/~gphat/Graphics-Primitive-0.29/
Device and library agnostic graphic primitives 
----
Graphics-Primitive-0.30
http://search.cpan.org/~gphat/Graphics-Primitive-0.30/
Device and library agnostic graphic primitives 
----
Graphics-Primitive-Driver-Cairo-0.24
http://search.cpan.org/~gphat/Graphics-Primitive-Driver-Cairo-0.24/
Cairo backend for Graphics::Primitive 
----
HTML-FormFu-0.03005
http://search.cpan.org/~cfranks/HTML-FormFu-0.03005/
HTML Form Creation, Rendering and Validation Framework 
----
HTTP-Engine-0.0.17
http://search.cpan.org/~yappo/HTTP-Engine-0.0.17/
Web Server Gateway Interface and HTTP Server Engine Drivers (Yet Another Catalyst::Engine) 
----
IPC-Message-Minivan-0.01_04
http://search.cpan.org/~gruber/IPC-Message-Minivan-0.01_04/
a minimalistic message bus 
----
IPC-Message-Minivan-0.01_05
http://search.cpan.org/~gruber/IPC-Message-Minivan-0.01_05/
a minimalistic message bus 
----
IPC-Messaging-0.01_11
http://search.cpan.org/~gruber/IPC-Messaging-0.01_11/
process handling and message passing, Erlang style 
----
JiftyX-ModelHelpers-0.01
http://search.cpan.org/~gugod/JiftyX-ModelHelpers-0.01/
Use Jifty model easily. 
----
Kephra-0.3.10.4
http://search.cpan.org/~lichtkind/Kephra-0.3.10.4/
crossplatform, GUI-Texteditor along perllike Paradigms 
----
LEOCHARRE-Dir-1.03
http://search.cpan.org/~leocharre/LEOCHARRE-Dir-1.03/
subs for dirs 
----
Mirror-YAML-0.04_01
http://search.cpan.org/~adamk/Mirror-YAML-0.04_01/
Mirror Configuration and Auto-Discovery 
----
MooseX-KeyedMutex-0.00002
http://search.cpan.org/~dmaki/MooseX-KeyedMutex-0.00002/
Role To Add KeyedMutex 
----
Mvalve-0.00014
http://search.cpan.org/~dmaki/Mvalve-0.00014/
Generic Q4M Powered Message Pipe 
----
Net-IMAP-Client-0.2.1
http://search.cpan.org/~mishoo/Net-IMAP-Client-0.2.1/
Not so simple IMAP client library 
----
Net-IMAP-Client-0.3
http://search.cpan.org/~mishoo/Net-IMAP-Client-0.3/
Not so simple IMAP client library 
----
Net-PingFM-0.3
http://search.cpan.org/~draxil/Net-PingFM-0.3/
Interact with ping.fm from perl 
----
Net-SFTP-Foreign-1.43
http://search.cpan.org/~salva/Net-SFTP-Foreign-1.43/
SSH File Transfer Protocol client 
----
PBS-0.03
http://search.cpan.org/~tmerritt/PBS-0.03/
Perl extension for PBS 
----
POE-Component-SmokeBox-0.01_01
http://search.cpan.org/~bingos/POE-Component-SmokeBox-0.01_01/
POE enabled CPAN smoke testing with added value. 
----
Panotools-Script-0.17
http://search.cpan.org/~bpostle/Panotools-Script-0.17/
Panorama Tools scripting 
----
Pod-POM-View-Confluence-0.01
http://search.cpan.org/~book/Pod-POM-View-Confluence-0.01/
Confluence view of a Pod Object Model 
----
Proc-ProcessTable-0.45
http://search.cpan.org/~durist/Proc-ProcessTable-0.45/
Perl extension to access the unix process table 
----
Queue-Q4M-0.00013
http://search.cpan.org/~dmaki/Queue-Q4M-0.00013/
Simple Interface To q4m 
----
RWDE-504
http://search.cpan.org/~kamelkev/RWDE-504/
Rapid Web Development Framework 
----
RWDE-510
http://search.cpan.org/~kamelkev/RWDE-510/
Rapid Web Development Framework 
----
Schedule-At-1.07
http://search.cpan.org/~joserodr/Schedule-At-1.07/
OS independent interface to the Unix 'at' command 
----
Search-QueryParser-SQL-0.002
http://search.cpan.org/~karman/Search-QueryParser-SQL-0.002/
turn free-text queries into SQL WHERE clauses 
----
Sjis-0.28
http://search.cpan.org/~ina/Sjis-0.28/
Source code filter for ShiftJIS script 
----
Spreadsheet-WriteExcel-2.25
http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel-2.25/
Write to a cross-platform Excel binary file. 
----
Test-Differences-Color-v0.03
http://search.cpan.org/~alec/Test-Differences-Color-v0.03/
colorize the result of Test::Differences 
----
Test-HTTP-0.12
http://search.cpan.org/~mml/Test-HTTP-0.12/
Test HTTP interactions. 
----
Test-Reporter-1.51_02
http://search.cpan.org/~dagolden/Test-Reporter-1.51_02/
sends test results to cpan-testers@perl.org 
----
Test-Reporter-1.52
http://search.cpan.org/~dagolden/Test-Reporter-1.52/
sends test results to cpan-testers@perl.org 
----
VisualDreams-Yubikey_online-0.03
http://search.cpan.org/~wildchild/VisualDreams-Yubikey_online-0.03/
----
WWW-Mechanize-Plugin-JavaScript-0.005a
http://search.cpan.org/~sprout/WWW-Mechanize-Plugin-JavaScript-0.005a/
JavaScript plugin for WWW::Mechanize 
----
WWW-Mixi-Scraper-0.18
http://search.cpan.org/~ishigaki/WWW-Mixi-Scraper-0.18/
yet another mixi scraper 
----
WWW-Mixi-Scraper-0.19
http://search.cpan.org/~ishigaki/WWW-Mixi-Scraper-0.19/
yet another mixi scraper 
----
WebService-LastFM-0.06
http://search.cpan.org/~cbrink/WebService-LastFM-0.06/
Simple interface to Last.FM Web service API 
----
XML-Encoding-2.04
http://search.cpan.org/~shay/XML-Encoding-2.04/
A perl module for parsing XML encoding maps. 
----
YAML-DBH-1.03
http://search.cpan.org/~leocharre/YAML-DBH-1.03/
----
okbiff-20080907
http://search.cpan.org/~mschwern/okbiff-20080907/
check if you have mail on OkCupid.com 
----
warnings-method-0.02
http://search.cpan.org/~gfuji/warnings-method-0.02/
Produces warnings if methods are called as functions 


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: 08 Sep 2008 16:28:53 GMT
From: xhoster@gmail.com
Subject: Re: Perl equivalent of unix time command
Message-Id: <20080908122855.532$XW@newsreader.com>

Melroy <melroysoares@hotmail.com> wrote:
> Hi all,
> I want to benchmark a bunch of running processes using Perl ,

Why?

> but I
> could not find any equivalent for the unix time coammnd in perl?

system "time $process @args" ....;


 Can
> someone point to me
> if such a function exists in perl? The only command I found was
> "times",
> but I don't know how to use it.

Capture the value before the external program is run, capture again
after, and subtract.


> doing a websearch did not help. If the
> function
> "times" does teh job, can someone show me an example of how to use it?

$ perl -l
my @x= times;
system q{perl -le '1 foreach (1..1e7)'};
my $i;
foreach( times) {
  print $_ - $x[$i++]
}
__END__
0
0
0.57
0

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: 08 Sep 2008 16:42:54 GMT
From: xhoster@gmail.com
Subject: Re: Perl equivalent of unix time command
Message-Id: <20080908124255.604$vo@newsreader.com>

Melroy <melroysoares@hotmail.com> wrote:
> More speccifically here is what I tried following
> http://bytes.com/forum/thread678672.html
> but no use :-(
>
> my $v = `time -p gzip  energylossmc.dat 1>/dev/null 2>&1` ;
> print $v ;
> Nothing seems to get captured in the variable v?

You sent the gzip output to /dev/null, so there is nothing on stdout to
capture.

On my machine, the redirection only applies to gzip, not to time, so
time's output goes where it otherwise would, which is stderr, which is
not captured by backticks.  So it just goes to my console.


> What am I doing wrong?
> I also replaced time with /usr/bin/time
> but no use.
>
> Any help is greatly appreciated

my $x = `time -p (gzip  energylossmc.dat 1>/dev/null 2>&1) 2>&1 `

The parenthesis forces the last 2>&1 to apply to time, sending its stderr
to stdout, where it is captured.

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, 8 Sep 2008 10:40:09 -0700 (PDT)
From: Melroy <melroysoares@hotmail.com>
Subject: Re: Perl equivalent of unix time command
Message-Id: <60140f7a-97a3-475b-a4f1-0d8442e8d2ac@a1g2000hsb.googlegroups.com>

Hi,
Thanks a lot for all the replies. One more question I have is whether
there is a module
written in perl to track the max. memory usage of a launched job(such
as the one in this
thread). The unix "time" command does not seem to help.
Thanks




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

Date: Tue, 09 Sep 2008 07:16:53 +0200
From: Tomislav Novak <tomislav.novak@gmail.com>
Subject: Re: Perl equivalent of unix time command
Message-Id: <87fxo9zynu.fsf@gmail.com>

Melroy <melroysoares@hotmail.com> writes:

> Hi,
> Thanks a lot for all the replies. One more question I have is whether
> there is a module
> written in perl to track the max. memory usage of a launched job(such
> as the one in this
> thread). The unix "time" command does not seem to help.
> Thanks

Try Unix::Getrusage. However, on some Unices (eg. Linux when I last
tried) the memory fields aren't set, so you'll have to do it some other
way -- for example, examining /proc/<pid>/status periodically, or
enabling BSD process accounting and parsing data from `sa'...

-- 
T.


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

Date: Mon, 08 Sep 2008 12:40:26 -0700
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: submit  to FormMail.pl throwing some error.
Message-Id: <080920081240264287%jimsgibson@gmail.com>

In article <48c1da87$0$182$e4fe514c@news.xs4all.nl>, Leon Timmermans
<fawaka@gmail.com> wrote:

> On Fri, 05 Sep 2008 16:57:45 -0700, Jim Gibson wrote:
> 
> > In article <48c192b4$0$199$e4fe514c@news.xs4all.nl>, Leon Timmermans
> > <fawaka@gmail.com> wrote:
> > 
> > 
> > In what way is that script a "mess"? The NMS scripts are touted for
> > robustness and security. Yours is the first criticism I have
> > encountered. The script source file is certainly neat enough.
> 
> It's a 3306 lines, 75 kilobyte script. That says enough in my opinion.

The length of the code may be due to the complexity of the task.
Shorter is not always better. Shorter versions may leave out steps
required for safety, reliability, handling special cases, or error
checking and reporting.

> 
> > I have not used any NMS scripts or studied them in any detail, but they
> > are frequently recommended by others.
> 
> Given the fact that it is a drop-in replacement for that awful script 
> from "Matt's script archive" this architecture is unavoidable, but that 
> doesn't make it pretty to look at.

I found the code nicely indented and easy on the eyes.

> 
> > What do you recommend as being better? And why?
> 
> There is a version of it that is split out, that is already infinitely 
> better.

There is a tradeoff in having all of the code in one file (easy to
edit, copy, install) and splitting the same code into multiple source
files (easier to maintain). Neither approach is necessarily better than
the other.

Can you provide a link to the "split out" version so we can evaluate it?

Thanks.

-- 
Jim Gibson


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

Date: Mon, 8 Sep 2008 15:04:29 -0700 (PDT)
From: "C.DeRykus" <ced@blv-sam-01.ca.boeing.com>
Subject: Re: using 2-arg open to open to a scalar
Message-Id: <bc0a3188-51b2-4dcc-a7a8-50d3205fc50e@a3g2000prm.googlegroups.com>

On Sep 2, 3:46 pm, "John W. Krahn" <some...@example.com> wrote:
> xhos...@gmail.com wrote:
> > I'm looking for a value to put in $some_string so that the
> > below code will have $y read from $scalar.  I can't use the "<&4" syntax,
> > since $x doesn't have a real fileno to be duped.
>
> > open my $x, "<", \$scalar or die $!;
> > open my $y, $some_string or die $!;
>
> > The context of this is that I have an external (i.e. not my code) module
> > which won't take a file-handle, it will only take a "filename" which gets
> > passed to the 2-argument form of open.  So I want to craft a magical
> > "filename" that when given to 2-arg open, does what I want.
>
> It will work with a package filehandle:
>
> $ perl -e'
> $scalar = <<TEXT;
> one two
> three four
> TEXT
>
> open IN, "<", \$scalar or die $!;
> open my $y, "<&=IN" or die $!;
> print while <IN>;
> print while <$y>;
> '
> one two

Or, if Alias isn't handy and you want a lexical filehandle instead:

open my $fh, "+<",  undef
   or die $!;
print $fh $scalar;
seek $fh, 0, 0 or die $!;

open( my $y, "<&=@{[fileno $fh]}" )
   or die $!;

--
Charles DeRykus






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

Date: Mon, 8 Sep 2008 20:43:23 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: What is wrong in the following script
Message-Id: <ga42ri.1a4.1@news.isolution.nl>

Arun schreef:

> #!\usr\bin\perl -w
> [...]
> use strict;

It won't solve your real problem, but it sure looks better: 

#!/usr/bin/perl
use strict;
use warnings;

-- 
Affijn, Ruud

"Gewoon is een tijger."


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

Date: Tue, 09 Sep 2008 00:03:41 +0300
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: What is wrong in the following script
Message-Id: <diggp5xaar.ln2@carpet.zombinet>

Arun <sajapuram.arun.prakash@gmail.com> wrote:
> problem: excecutes only DATA string but nor IO1 and IO0.

I would like to hear any answert to Josef Moellers's question too.

Meanwhile:

> #!\usr\bin\perl -w

Use C<use warnings;> instead.

> use IO::Socket;
> use diagnostics;

Use C<perldoc perldiag> instead.

> use strict;
> use POSIX qw(strftime);

> my $remote_host = "";
> my $remote_port = "";
> my ($handle, $send_data,$send_i1,$send_i0,$count);

> $count=0;
> $handle= IO::Socket::INET->new(   PeerAddr   =>   $remote_host,
>                                   PeerPort   =>   $remote_port,

I'm not an B<IO::Socket::INET> expert, but I suppose you are going to
connect to empty port at empty address.

>                                   Proto      =>   "tcp",
>                                   Type       =>   SOCK_STREAM
>                               )
> || die "Couldn't connect to $remote_host:$remote_port: \n";

> print STDERR "[Connected to $remote_host:$remote_port]\n";

> DATA: while(<$handle=1>)
*SKIP*
>        $send_data = self define string;

BTW, copy-paste your code.  Don't retype.

*SKIP*
> IO1: while(<$handle=1>)
*SKIP*
> IO0: while(<$handle=1>)
*SKIP*

I would like to know your intentions too.  What you really achieved is:

23:38:09 69 [0:0]$ perl -mIO::Handle -wle '
$x = new IO::Handle; print <$x=1>'
IO::Handle=GLOB(0x814ed90)=1

I believe, that since filehandles aren't supposed to be assigned while
reading from them, Perl treats your construct as globbing (instead of
reading).  Surprise?  C<perldoc -f glob> has more.

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



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

Date: Mon, 08 Sep 2008 19:17:07 GMT
From: Zed Pobre <zed@resonant.org>
Subject: Re: XML::Twig doctype and entity handling
Message-Id: <slrngcau78.th9.zed@resonant.org>

John Bokma <john@castleamber.com> wrote:
>
> Zed Pobre <zed@resonant.org> wrote:
>
>> I've been contemplating bludgeoning out a low-memory solution with
>> sysread, since the metadata will always be at the top of the file and
>> has never so far been larger than about 8kb, but was hoping to see if
>> someone knew how to get Twig working first.
>
> If you want to reduce memory to a minimum you can't avoid using a 
> streaming solution. I probably would use XML::Parser or SAX.
>
> It's not clear if by HTML you actually mean XHTML (I guess yes, otherwise 
> you'll might bump into problems with XML parsing)

Unfortunately, I really do mean HTML, and very badly formed HTML at
that.  The only part that can be relied upon to be well-formed is the
<metadata>...</metadata> clump that I was trying to extract with
twig_roots without actually parsing the rest of the file.

It turns out that this isn't possible even with XML::Twig.

One of the kind monks over at perlmonks.org pointed out that there's
nothing stopping me from passing parsefile() a pipe, so I got past the
doctype problem by passing it 'cat oeb12doctype.xml input.html|', at
which point the parse() cheerfully got so far as splitting off the
HTML with all of the metadata elements removed before die-ing horribly
on a mismatched tag.  According to the Twig documentation, there is no
way to proceed and get the extracted elements anyway, so this entire
technique has been a dead end, though amusingly this technique does
work to split out the HTML without the <metadata> elements, since
twig_print_outside_roots will finish up before the parser dies from
mismatched tags.  That probably isn't reliable, though.

I'll have to constrain the memory use by doing the initial split in
10k chunks, I guess.

Thanks for the help.

-- 
Zed Pobre <zed@resonant.org> a.k.a. Zed Pobre <zed@debian.org>
PGP key and fingerprint available on finger; encrypted mail welcomed.


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

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


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