[29232] in Perl-Users-Digest
Perl-Users Digest, Issue: 476 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 1 03:10:09 2007
Date: Fri, 1 Jun 2007 00:09:06 -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 Fri, 1 Jun 2007 Volume: 11 Number: 476
Today's topics:
Re: Announcing: ACM SIGAPL APL2007 -- Arrays and Object <mkent@acm.org>
Re: Email::Folder->messages returns only one element <Michael.Yxf@gmail.com>
Re: fork() and script execution afterwards <joe@inwap.com>
Re: fork() and script execution afterwards <tom@snnap.net>
Re: fork() and script execution afterwards <spamtrap@dot-app.org>
Re: How do I read a GZipped UTF-8 file from Perl on Win <combustion@gmail.com>
Issues to post reply <samuelzhng@gmail.com>
Re: Issues to post reply <nobull67@gmail.com>
Market Your Business On Search Engines <DannyBoy@DannyBoyAds.com>
Re: most active perl discussion forum <kkeller-usenet@wombat.san-francisco.ca.us>
Re: Multiple Line Pattern Match problem <samuelzhng@gmail.com>
Re: Multiple Line Pattern Match problem <samuelzhng@gmail.com>
new CPAN modules on Fri Jun 1 2007 (Randal Schwartz)
Parsing: Help on ignoring quoted tokens. paktsardines@gmail.com
Re: Parsing: Help on ignoring quoted tokens. <nobull67@gmail.com>
Re: Perl syntax <eishbut@googlemail.com>
Re: Static classes, inheritance and base class funkery <nobull67@gmail.com>
Re: stumped by graphics display problem... (Alan Curry)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 01 Jun 2007 00:49:10 -0400
From: Mike Kent <mkent@acm.org>
Subject: Re: Announcing: ACM SIGAPL APL2007 -- Arrays and Objects
Message-Id: <5c9mpqF302paiU1@mid.individual.net>
Paul Mansour wrote:
> Mike,
>
> The APL2007 link does not go anywhere.
My bad; I sent the message before the page was up.
The correct link is
http://www.sigapl.org/apl2007.html
------------------------------
Date: 31 May 2007 18:48:35 -0700
From: Michael Yang <Michael.Yxf@gmail.com>
Subject: Re: Email::Folder->messages returns only one element
Message-Id: <1180623065.829569.187190@d30g2000prg.googlegroups.com>
On May 31, 7:09 pm, Christian Winter <thepoet_nos...@arcor.de> wrote:
> Michael Yang wrote:
> > I wrote another script to demonstrate my problems:
> > 1 #!/usr/bin/perl -w
> > 2 # Author: Michael Yang
> > 3 # Date: May/31/2007
> > 4 # Purpose: To test the function of Email::Folder module.
> > 5
> > 6 use strict;
> > 7 use warnings;
> > 8
> > 9 my @mail_list = @ARGV;
> > 10
> > 11 die "Usage: $0 <.msf file> \n" if not @mail_list;
> > 12
> > 13 eval { require Email::Folder; };
> > 14 die "The module Email::Folder is required for this script.\n"
> > if $!;
> > 15
> > 16 foreach my $file (@mail_list){
> > 17 if ($file =~ m/^(.*)\.msf$/i){
> > 18 $file = $1;
> > 19 print "$file MSF file detected.\n"
> > 20 }
> > 21 die "can't access import file $file" unless -r $file;
> > 22
> > 23 my $folder = Email::Folder->new($file);
> > 24
> > 25 my @msg_list = $folder->messages();
> > 26 foreach(@msg_list){
> > 27 print $_->header("Subject"), "\n";
> > 28 # print $_->as_string(), "\n";
> > 29 }
> > 30 }
>
> > To run this script, one valid *.msf file is required to pass in, which
> > contains multiple messages.
> > In this script, it will print out each message's subject data.
> > The result on my pc is that there is only one subject is printed out.
>
> A possible cause could be recognition of line endings. Does the mbox
> file stem from a different platform, was it transported via ASCII-FTP?
> To check that, you can test with different values for the "eol"
> parameter to Email::Folder's constructor:.
> # Windows-Format:
> my $folder = Email::Folder->new( $file, "eol" => "\r\n" );
> # Mac-Format:
> # my $folder = Email::Folder->new( $file, "eol" => "\r" );
> # Unix-Format:
> # my $folder = Email::Folder->new( $file, "eol" => "\n" );
>
> -Chris- Hide quoted text -
>
> - Show quoted text -
Yeah, I think that's the problem.
I need to add the OS check at the beginning for different
construction.
Thanks to all of your guys.
Really appreciated your helps!!
Cheers!
Michael
------------------------------
Date: Thu, 31 May 2007 22:47:50 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: fork() and script execution afterwards
Message-Id: <TqCdneW6sJ-XLsLbnZ2dnUVZ_qarnZ2d@comcast.com>
Tom Storey wrote:
> That was my question, whether or not the child continues to execute from
> where it forked in the parent, which seems as though it is the case.
It's not "which seems". It is documented. That is exactly how fork()
works. It is a system call that is called once and returns twice,
resuming right where it left off.
The first return is in the parent process and the value returned is
the PID of the child process. The second return is in the child
process and the returned value is 0.
The child process is created by cloning the parent's virtual memory,
variables, file descriptors, etc. Including the stack, the return
addresses on the stack, and the Program Counter for returning to
user-mode when leaving kernel-mode.
What gave you the impression that fork() would start over from the top?
-Joe
------------------------------
Date: Fri, 1 Jun 2007 15:42:43 +0930
From: "Tom Storey" <tom@snnap.net>
Subject: Re: fork() and script execution afterwards
Message-Id: <135ve6rq4070287@corp.supernews.com>
"Joe Smith" <joe@inwap.com> wrote in message
news:TqCdneW6sJ-XLsLbnZ2dnUVZ_qarnZ2d@comcast.com...
> Tom Storey wrote:
>
> > That was my question, whether or not the child continues to execute from
> > where it forked in the parent, which seems as though it is the case.
>
> It's not "which seems". It is documented. That is exactly how fork()
> works. It is a system call that is called once and returns twice,
> resuming right where it left off.
Based on my prior knowledge of the subject, it "seemed" as though it would
resume from where it forked.
>
> The first return is in the parent process and the value returned is
> the PID of the child process. The second return is in the child
> process and the returned value is 0.
Aware of that already.
>
> The child process is created by cloning the parent's virtual memory,
> variables, file descriptors, etc. Including the stack, the return
> addresses on the stack, and the Program Counter for returning to
> user-mode when leaving kernel-mode.
I had a basic idea that variables etc would be copied, but what was to
happen with the PC was unknown to me based on what I wrote below...
>
> What gave you the impression that fork() would start over from the top?
> -Joe
This is the first time Ive ever written something that uses the fork()
command, and since I hadnt found any documentation that described whether it
would start over or resume from where it forked, what what I to assume?
(I'd rather not assume anything, but after getting no where and searching
around for decent examples or documentation I figured it was time to ask
more knowledgeable persons.)
But now I know, and I can get on with my code.
Thanks,
Tom
------------------------------
Date: Fri, 01 Jun 2007 02:23:04 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: fork() and script execution afterwards
Message-Id: <m2ps4g2nxz.fsf@local.wv-www.com>
"Tom Storey" <tom@snnap.net> writes:
> This is the first time Ive ever written something that uses the fork()
> command, and since I hadnt found any documentation that described whether it
> would start over or resume from where it forked
The first line of the docs for the fork() function says "Does a fork(2) system
call to create a new process running the same program at the same point."
If you couldn't find the first sentence in the docs for the function you're
using, you weren't looking very hard.
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: Fri, 01 Jun 2007 05:47:13 -0000
From: DmitryB <combustion@gmail.com>
Subject: Re: How do I read a GZipped UTF-8 file from Perl on Windows?
Message-Id: <1180676833.912132.289230@g37g2000prf.googlegroups.com>
On May 29, 1:24 pm, DmitryB <combust...@gmail.com> wrote:
> Hi, folks,
>
> I'm looking for a way to read and write *.gz text files in UTF8
> encoding on windows (ActivePerl, gzip Perl::IO layer is not
> available). I've tried naive IO::Zlib stuff like this:
>
> tie *OUTPUTFILE, "IO::Zlib", $outputFile, "wb" or die "Could not open
> $outputFile for reading";
> binmode(OUTPUTFILE, ":utf8");
>
> Unfortunately this doesn't work, the error is:
>
> "Not a GLOB reference at c:/bin/perl/lib/IO/Zlib.pm line 566."
>
> Basically, the goal is to layer utf8 on top of zlib or achieve a
> similar result using other means. Again, keep in mind, I can't just
> say "gzip" in open() because that's not available.
>
> Does anyone have any pointers?
>
> Thanks.
I just ended up using out of process piped gzip. Works pretty good if
you don't forget to quote the filename. :-)
------------------------------
Date: Thu, 31 May 2007 22:26:32 -0700
From: samuel <samuelzhng@gmail.com>
Subject: Issues to post reply
Message-Id: <1180675592.347754.298520@d30g2000prg.googlegroups.com>
When I am trying to post some replies. The google group feedback me
with a post success message.
However, I can't find my post in the group, even minutes later.
Does anyone know why this happens?
Thanks
------------------------------
Date: Fri, 01 Jun 2007 06:12:16 -0000
From: Brian McCauley <nobull67@gmail.com>
Subject: Re: Issues to post reply
Message-Id: <1180678336.850403.197880@u30g2000hsc.googlegroups.com>
On Jun 1, 6:26 am, samuel <samuelz...@gmail.com> wrote:
> When I am trying to post some replies. The google group feedback me
> with a post success message.
> However, I can't find my post in the group, even minutes later.
>
> Does anyone know why this happens?
This is a Usenet group, it does not belong to Google. Google is just
one interface. This discussion in OT here!
That said I've experienced the same problem from time to time with
Google Groups.
------------------------------
Date: Thu, 31 May 2007 20:13:09 -0700
From: DannyBoy Advertising <DannyBoy@DannyBoyAds.com>
Subject: Market Your Business On Search Engines
Message-Id: <1180667589.961664.167860@q66g2000hsg.googlegroups.com>
Utilize the Internet's search engines to promote your specific
business website.
Yahoo, Google, MSN, Business, Ask, and many more!
If you have a website for your business, take it to the next level!
Market locally, regionally, nationally or worldwide!
*Promote Events
*Produce Leads
*Increase Sales
*Increase Registrations
*Attract specific clientele
*and more
Contact DannyBoy Advertising today for a free consultation to
determine the ideal campaign for your marketing needs.
www.DannyBoyAds.com
(407)468-9278
Webmaster@...
------------------------------
Date: Thu, 31 May 2007 11:13:21 -0700
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: most active perl discussion forum
Message-Id: <1rf3j4xarn.ln2@goaway.wombat.san-francisco.ca.us>
On 2007-05-31, Michele Dondi <bik.mido@tiscalinet.it> wrote:
>
> Oh yeah, baby! clpmisc and the decline of Perl...
Perl, like Slackware, is dead. Long live Perl!
--keith
--
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information
------------------------------
Date: Thu, 31 May 2007 22:20:03 -0700
From: samuel <samuelzhng@gmail.com>
Subject: Re: Multiple Line Pattern Match problem
Message-Id: <1180675203.540653.281760@j4g2000prf.googlegroups.com>
On 5=D4=C231=C8=D5, =CF=C2=CE=E79=CA=B131=B7=D6, Brad Baxter <baxter.b...@g=
mail.com> wrote:
> On May 31, 9:25 am, samuel <samuelz...@gmail.com> wrote:
>
> > But How to do if the block is like below :
>
> > Start
> > <content_without_keyword_dma>
> > ......
> > <content_with_keyword_dma>
> > ......
> > <content_without_keyword_dma>
> > End
>
> > And I need to print out both all the contents (both lines w and w/o
> > keyword dma) for the block where there are <content_with_keyword_dma>
> > there ?
>
> my $x =3D do { local $/; <DATA> };
> while ( $x =3D~ /^Start(.*?)^End/smg ) {
> defined and /dma/ and print for my $y =3D $1;}
>
> __DATA__
> Start
> cpu
> End
> Start
> dma
> End
> Start
> <content_without_keyword_dma>
> ......
> <content_with_keyword_dma>
> ......
> <content_without_keyword_dma>
> End
>
> --
> Brad
Thanks Brad,
The script did work for me.
But how to do if I need to remove all the blocks containing the
keyword dma from the file , but not print them out ?
Samuel
------------------------------
Date: Thu, 31 May 2007 22:23:33 -0700
From: samuel <samuelzhng@gmail.com>
Subject: Re: Multiple Line Pattern Match problem
Message-Id: <1180675413.674067.327220@r19g2000prf.googlegroups.com>
On 6=D4=C21=C8=D5, =C9=CF=CE=E712=CA=B136=B7=D6, "Skye Shaw!@#$" <skye.s...=
@gmail.com> wrote:
> On May 31, 7:26 am, Aukjan van Belkum <auk...@vanbelkum.no.spam.nl>
> wrote:
>
> > samuel wrote:
> > > On May 31, 5:40 pm, Aukjan van Belkum <auk...@vanbelkum.no.spam.nl>
> > > wrote:
> > >> samuel wrote:
> > >>> Hi All,
> > >>> Now I need to analyze a file which is composed of several blocks ,
> > >>> which is defined as below :
> > >>> Start
> > >>> <content>
> > >>> <content>
> > >>> ......
> > >>> <content>
> > >>> End
>
> Maybe try:
>
> [sshaw@localhost ~]$ cat > wakawakawaka.txt
> Start
> weeeee
> dma
> ahhhhh
> irq
> oooohhh its dma
> End
> Start
> grrr
> dma
> End
> [sshaw@localhost ~]$ perl -lne'print if !/(End|Start)/'
> wakawakawaka.txt
> weeeee
> dma
> ahhhhh
> irq
> oooohhh its dma
> grrr
> dma
>
> > > And I need to print out both all the contents (both lines w and w/o
> > > keyword dma) for the block where there are <content_with_keyword_dma>
> > > there ?
>
> For blocks with/without dma, in either case you will just print, so
> why make the distinction?
I want to print out all the contents(the lines with or w/o dma) of the
blocks containing the keyword dma. But for the blocks not including
dma at all, not print out.
So this is the distinction.
------------------------------
Date: Fri, 1 Jun 2007 04:42:09 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Fri Jun 1 2007
Message-Id: <JIxx29.1s83@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.
Acme-Note-0.4
http://search.cpan.org/~ferreira/Acme-Note-0.4/
Make a mental note for programming style
----
Algorithm-NeedlemanWunsch-0.01
http://search.cpan.org/~vbar/Algorithm-NeedlemanWunsch-0.01/
global sequence alignment with configurable scoring
----
Apache2-ASP-0.12
http://search.cpan.org/~johnd/Apache2-ASP-0.12/
ASP for a mod_perl2 environment.
----
Apache2-ASP-0.13
http://search.cpan.org/~johnd/Apache2-ASP-0.13/
ASP for a mod_perl2 environment.
----
Apache2-ASP-0.14
http://search.cpan.org/~johnd/Apache2-ASP-0.14/
ASP for a mod_perl2 environment.
----
App-Build-0.65
http://search.cpan.org/~mbarbon/App-Build-0.65/
extends Module::Build to build/install/configure entire applications (i.e. web applications), not just modules and programs
----
Audio-MPD-0.18.1
http://search.cpan.org/~jquelin/Audio-MPD-0.18.1/
class to talk to MPD (Music Player Daemon) servers
----
Audio-MPD-Common-0.1.1
http://search.cpan.org/~jquelin/Audio-MPD-Common-0.1.1/
a bunch of common helper classes for mpd
----
AutoCons-0.01_02
http://search.cpan.org/~riddle/AutoCons-0.01_02/
Write a Construct file.
----
Bundle-Font-0.01
http://search.cpan.org/~ski/Bundle-Font-0.01/
a bundle to install Font modules and dependencies
----
Business-OnlinePayment-TransFirsteLink-0.03
http://search.cpan.org/~jef/Business-OnlinePayment-TransFirsteLink-0.03/
Transfirst eLink backend for Business::OnlinePayment
----
CGI-Application-Plugin-RequireSSL-0.01
http://search.cpan.org/~dhorne/CGI-Application-Plugin-RequireSSL-0.01/
Force SSL in specified pages or modules
----
CGI-Application-Plugin-RequireSSL-0.02
http://search.cpan.org/~dhorne/CGI-Application-Plugin-RequireSSL-0.02/
Force SSL in specified pages or modules
----
Captcha-reCAPTCHA-v0.7
http://search.cpan.org/~andya/Captcha-reCAPTCHA-v0.7/
A Perl implementation of the reCAPTCHA API
----
Class-MOP-0.38
http://search.cpan.org/~stevan/Class-MOP-0.38/
A Meta Object Protocol for Perl 5
----
Gtk2-Notify-0.03
http://search.cpan.org/~flora/Gtk2-Notify-0.03/
Perl interface to libnotify
----
HTML-Copy-1.2
http://search.cpan.org/~tkurita/HTML-Copy-1.2/
copy a HTML file without breaking links.
----
HTML-Simple-v0.3
http://search.cpan.org/~andya/HTML-Simple-v0.3/
Simple HTML generation utilities
----
HTML-Simple-v0.4
http://search.cpan.org/~andya/HTML-Simple-v0.4/
Deprecated in favour of HTML::Tiny
----
HTML-Tiny-v0.4
http://search.cpan.org/~andya/HTML-Tiny-v0.4/
Tiny HTML generation utilities
----
HTML-Tiny-v0.5
http://search.cpan.org/~andya/HTML-Tiny-v0.5/
Tiny HTML generation utilities
----
IPC-PubSub-0.26
http://search.cpan.org/~audreyt/IPC-PubSub-0.26/
Interprocess Publish/Subscribe channels
----
JE-0.014
http://search.cpan.org/~sprout/JE-0.014/
Pure-Perl ECMAScript (JavaScript) Engine
----
Math-Prime-TiedArray-0.02
http://search.cpan.org/~zigdon/Math-Prime-TiedArray-0.02/
Simulate an infinite array of prime numbers
----
Moose-0.22
http://search.cpan.org/~stevan/Moose-0.22/
A complete modern object system for Perl 5
----
Moose-Autobox-0.04
http://search.cpan.org/~stevan/Moose-Autobox-0.04/
Ruby ain't got nothin on us
----
Net-Flickr-API-1.65
http://search.cpan.org/~ascope/Net-Flickr-API-1.65/
base API class for Net::Flickr::* libraries
----
POE-Component-Client-MPD-0.6.1
http://search.cpan.org/~jquelin/POE-Component-Client-MPD-0.6.1/
a full-blown mpd client library
----
POE-Component-Client-MPD-0.6.2
http://search.cpan.org/~jquelin/POE-Component-Client-MPD-0.6.2/
a full-blown mpd client library
----
POE-Component-Client-MPD-0.6.3
http://search.cpan.org/~jquelin/POE-Component-Client-MPD-0.6.3/
a full-blown mpd client library
----
POE-Component-Client-MPD-0.7.0
http://search.cpan.org/~jquelin/POE-Component-Client-MPD-0.7.0/
a full-blown mpd client library
----
POE-Component-IRC-5.31_02
http://search.cpan.org/~bingos/POE-Component-IRC-5.31_02/
a fully event-driven IRC client module.
----
Panotools-Script-0.06
http://search.cpan.org/~bpostle/Panotools-Script-0.06/
Panorama Tools scripting
----
RRDTool-Creator-0.5
http://search.cpan.org/~jacquelin/RRDTool-Creator-0.5/
Creators for round robin databases (RRD)
----
RRDTool-Creator-0.6
http://search.cpan.org/~jacquelin/RRDTool-Creator-0.6/
Creators for round robin databases (RRD)
----
Sepia-0.76_01
http://search.cpan.org/~seano/Sepia-0.76_01/
Simple Emacs-Perl Interface
----
Socialtext-Resting-Utils-0.14
http://search.cpan.org/~lukec/Socialtext-Resting-Utils-0.14/
Utilities for Socialtext REST APIs
----
Spreadsheet-Read-0.20
http://search.cpan.org/~hmbrand/Spreadsheet-Read-0.20/
Meta-Wrapper for reading spreadsheet data
----
Text-CSV_XS-0.27
http://search.cpan.org/~hmbrand/Text-CSV_XS-0.27/
comma-separated values manipulation routines
----
WWW-Facebook-API-v0.1.5
http://search.cpan.org/~unobe/WWW-Facebook-API-v0.1.5/
Facebook API implementation
----
WWW-Facebook-API-v0.1.6
http://search.cpan.org/~unobe/WWW-Facebook-API-v0.1.6/
Facebook API implementation
----
WebService-Timelog-0.04
http://search.cpan.org/~kentaro/WebService-Timelog-0.04/
A Perl interface to Timelog API
----
YAML-LibYAML-0.15
http://search.cpan.org/~ingy/YAML-LibYAML-0.15/
LibYAML bindings for Perl
----
YAML-LibYAML-0.16
http://search.cpan.org/~ingy/YAML-LibYAML-0.16/
LibYAML bindings for Perl
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/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Fri, 01 Jun 2007 05:30:10 -0000
From: paktsardines@gmail.com
Subject: Parsing: Help on ignoring quoted tokens.
Message-Id: <1180675810.299182.74310@q19g2000prn.googlegroups.com>
Hi all,
I am writing a (hopefully) simple parser to parse the contents of a
text file and turn it into some sort of html form. Here's a small
example:
forms.txt contains something like:
# Registration Form
registration {
numcols:2
[heading: Account Details] [ ]
[label:"User Name:"] [textbox:username:amcnab:mandatory]
[label:"First Name:"] [textbox:first_name:Andy]
[label:"Last Name:"] [textbox:last_name:McNab]
[label:"Password:"] [passbox:passwd::mandatory]
}
# Error form
error {
numcols:2
[heading:Explosion Error!][]
[label:"Vent Gas?:"] [select:vent:yes|no:no]
}
where:
[.*] denotes an html table cell.
Then, later in my perl code I want to be able to do:
show_form("registration"), or show_form("error") and have it render
the appropriateform layout.
Now, my question is: what is the best way to approach the parsing of
this file? Perhaps more importantly, how can i structure the file to
make the parsing as easy and practical as possible?
Also, can anyone please suggest how to ignore tokens (like ':') that
occur within quoted strings?
Bonus points if your answer makes no reference to lex or yacc. :)
Thank you for any suggestions!
pakt.
------------------------------
Date: Fri, 01 Jun 2007 06:15:10 -0000
From: Brian McCauley <nobull67@gmail.com>
Subject: Re: Parsing: Help on ignoring quoted tokens.
Message-Id: <1180678510.173693.34540@p77g2000hsh.googlegroups.com>
On Jun 1, 6:30 am, paktsardi...@gmail.com wrote:
> Also, can anyone please suggest how to ignore tokens (like ':') that
> occur within quoted strings?
This is very closely related to the FAQ "How can I split a [character]
delimited string except when inside [character]?"
------------------------------
Date: Fri, 01 Jun 2007 01:27:06 -0000
From: "eishbut@googlemail.com" <eishbut@googlemail.com>
Subject: Re: Perl syntax
Message-Id: <1180661226.167693.305040@k79g2000hse.googlegroups.com>
On Jun 1, 12:40 am, James <hslee...@yahoo.com> wrote:
> Need help to understand the following syntax.
>
> Net::SSH::Perl package, in Channel.pm, line 142,
>
> 142: $r->{code}->( $c, $c->{$buf}, @{ $r->{extra} } );
I believe a coderef is being used. $r->{code} contains a subroutine
and ( $c, $c->{$buf}, @{ $r->{extra} } ) are the parameters being
passed to the sub.
e.g.
#!/usr/bin/perl -w
use strict;
my $hash_ref;
$hash_ref->{add} = sub{
my $ten = shift;
my $twenty = shift;
my $numbers = shift;
my $sum;
$sum += $_ for @{$numbers};
print "$ten $twenty $sum\n";
};
$hash_ref->{add}->(10, 20, [1, 2, 3, 4, 18]);
>
> in sub process_buffers,
>
> sub process_buffers {
> my $c = shift;
> my($rready, $wready) = @_;
>
> my %fd = (output => $c->{wfd}, extended => $c->{efd});
> for my $buf (keys %fd) {
> if ($fd{$buf} && grep { $fd{$buf} == $_ } @$wready) {
> if (my $r = $c->{handlers}{"_${buf}_buffer"}) {
> $r->{code}->( $c, $c->{$buf}, @{ $r->{extra} } );
> }
> else {
> #warn "No handler for '$buf' buffer set up";
> }
> $c->{local_consumed} += $c->{$buf}->length
> if $buf eq "output";
> $c->{$buf}->empty;
> }
> }
>
> if ($c->{rfd} && grep { $c->{rfd} == $_ } @$rready) {
> my $buf;
> sysread $c->{rfd}, $buf, 8192;
> ($buf) = $buf =~ /(.*)/s;
> $c->send_data($buf);
> }
>
> }
>
> TIA
> James
------------------------------
Date: Fri, 01 Jun 2007 06:33:58 -0000
From: Brian McCauley <nobull67@gmail.com>
Subject: Re: Static classes, inheritance and base class funkery - or overriding module subroutines
Message-Id: <1180679638.192285.197410@k79g2000hse.googlegroups.com>
On Jun 1, 12:21 am, Tim S <t...@dionic.net> wrote:
> anno4...@radom.zrz.tu-berlin.de wrote:
>
> > sub logger {
> > central_logging_routine( shift);
> > }
>
> > sub central_logging_routine {
> > my $msg = shift;
> > print "Log Message: $msg\n";
> > }
>
> > logger( "Message one");
>
> > {
> > no warnings 'redefine';
> > *central_logging_routine = sub {
> > my $msg = shift;
> > print "Log-Meldung: $msg\n";
> > };
> > }
>
> > logger( "Meldung zwei");
> Ah yes - that is a pretty simple way to achieve overrides. I'd initially
> discounted direct redefines as I'd erroneously considered
> redefining "logger()" which I worried wouldn't affect the already exported
> verions (I tend to EXPORT_OK if doing modules). But what you are doing is,
> in effect, using logger() as a dispatcher to central_logging_routine()
> which is never exported, so there is no problem.
Hey, that's neat. I'd never thought of that in those terms. I've used
this technique in the past but I've never thought to describe it in
such succinct terms.
------------------------------
Date: Fri, 1 Jun 2007 05:47:44 +0000 (UTC)
From: pacman@TheWorld.com (Alan Curry)
Subject: Re: stumped by graphics display problem...
Message-Id: <f3obu0$7d1$1@pcls4.std.com>
In article <f3njgd$gfk$1@reader2.panix.com>,
kj <socyl@987jk.com.invalid> wrote:
>In <f3nbv4$b0g$1@pcls4.std.com> pacman@TheWorld.com (Alan Curry) writes:
>> { exec 'xli', 'stdin' } # But I do have xli
>> die "exec: $!\n";
>>}
>
>I'm curious: why the curly brackets around the exec statement?
Because there's a warning about any code after an exec, to helpfully remind
you that the code won't be reached if the exec succeeds. As if it was a bad
idea to check for the failure.
I see now that the warning doesn't show up if the statement after the exec is
a die, but in real life error handling can be more complicated than that.
Let's see...
$ perl -we 'exec "/bin/nosuchcommand"; die "oops";'
Can't exec "/bin/nosuchcommand": No such file or directory at -e line 1.
oops at -e line 1.
$ perl -we 'exec "/bin/nosuchcommand"; exit(99);'
Can't exec "/bin/nosuchcommand": No such file or directory at -e line 1.
$ echo $?
99
$ perl -MPOSIX -we 'exec "/bin/nosuchcommand"; POSIX::_exit(99);'
Statement unlikely to be reached at -e line 1.
(Maybe you meant system() when you said exec()?)
Can't exec "/bin/nosuchcommand": No such file or directory at -e line 1.
$ echo $?
99
$
So exit() has special exemption from the rule but _exit() doesn't. That's odd
since _exit() is more correct after a fork that hasn't been followed by a
successful exec. Or is there no difference at all since perl added
buffer-flushing magic to fork()?
The 'Can't exec "/bin/nosuchcommand": No such file or directory' warning is
another annoyance. When open() fails, or unlink(), or rename(), or almost any
other system call that can fail with ENOENT, you don't get a warning blasted
to stderr. Why doesn't perl trust the programmer to handle exec failures?
--
Alan Curry
pacman@world.std.com
------------------------------
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 476
**************************************