[29233] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 477 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 1 11:10:43 2007

Date: Fri, 1 Jun 2007 08: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           Fri, 1 Jun 2007     Volume: 11 Number: 477

Today's topics:
    Re: A simple way to make a code folder available as a m <ilias@lazaridis.com>
    Re: contacting Alfred Reibenschuh, creator of (CPAN) PD <bugbear@trim_papermule.co.uk_trim>
    Re: contacting Alfred Reibenschuh, creator of (CPAN) PD <bugbear@trim_papermule.co.uk_trim>
        Ergonomic Mobile Computing  markwhite007@gmail.com
    Re: fork() and script execution afterwards <bik.mido@tiscalinet.it>
    Re: fork() and script execution afterwards <tom@snnap.net>
    Re: fork() and script execution afterwards <bik.mido@tiscalinet.it>
    Re: How do I read a GZipped UTF-8 file from Perl on Win <bik.mido@tiscalinet.it>
    Re: Issues to post reply <bik.mido@tiscalinet.it>
    Re: Multiple Line Pattern Match problem <baxter.brad@gmail.com>
        Open file in binary mode <bill@ts1000.us>
    Re: Open file in binary mode <noreply@gunnar.cc>
    Re: Open file in binary mode <bik.mido@tiscalinet.it>
    Re: Parsing: Help on ignoring quoted tokens. <m@rtij.nl.invlalid>
    Re: Parsing: Help on ignoring quoted tokens. <klaus03@gmail.com>
    Re: Parsing: Help on ignoring quoted tokens. <xicheng@gmail.com>
    Re: Perl syntax <mritty@gmail.com>
    Re: Perl syntax <tadmc@augustmail.com>
    Re: Prototypes and anonymous subroutines <baxter.brad@gmail.com>
        Senior Perl developer position in Montreal, Canada  support@sitepak.com
    Re: stumped by graphics display problem... <m@rtij.nl.invlalid>
        www.eBankGame.com (w w w .e BankGame . c o m ) <goxbuy2000@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 01 Jun 2007 11:35:08 -0000
From:  Ilias Lazaridis <ilias@lazaridis.com>
Subject: Re: A simple way to make a code folder available as a module
Message-Id: <1180697708.093375.107820@p47g2000hsd.googlegroups.com>

On May 31, 7:13 pm, xhos...@gmail.com wrote:
> Ilias Lazaridis <i...@lazaridis.com> wrote:
> > On May 24, 6:29 pm, xhos...@gmail.com wrote:
> > > Ilias Lazaridis <i...@lazaridis.com> wrote:
>
> > > > a) How can I make a svn checked out folder available as a
> > > > system-wide importable module (e.g. a command which adds the folder
> > > > to the "perl module search path").
>
> > > run:
> > > perl -le 'print "@INC"'
>
> > > And see if any of those directories look like good places to install
> > > it.
>
> > ok, but theres is a tiny problem.
>
> > if I place my folder "mycode" into
>
> > C:/Perl/site/lib
>
> > C:/Perl/site/lib/mycode
>
> > the "use" statements have to be corrected to start with "mycode::"
>
> > How can I avoid this?
>
> By moving the the code up a level, so it no longer sits in mycode
> directory, but rather directly in site/lib.

understand, but not possible.

> Or, by changing mycode to
> something better reflecting the nature of the code, for example your
> company or department name, then just using it that way with the "::"

ok, I think I understand.

e.g. instead of "mycode" I would use "Lazaridis", resulting in

use Lazaridis::CoreLib

this is the same construct like in JAVA:

com.lazaridis.corelib

Thank you!

 .

--
http://dev.lazaridis.com/lang/wiki/Perl



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

Date: Fri, 01 Jun 2007 11:16:56 +0100
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: Re: contacting Alfred Reibenschuh, creator of (CPAN) PDF-API2 ?
Message-Id: <465ff219$0$8719$ed2619ec@ptn-nntp-reader02.plus.net>

brian d foy wrote:
> In article <465ebd1f$0$8759$ed2619ec@ptn-nntp-reader02.plus.net>,
> bugbear <bugbear@trim_papermule.co.uk_trim> wrote:
> 
>> I've found (and I think fixed) a bug in this useful
>> module:
>>
>> http://search.cpan.org/~areibens/PDF-API2-0.61/
>>
>> I've tried emailing my work (test cases, documentation and code changes) to
>> the email address given here:
> 
> Have you submitted a bug to rt.cpan.org? That's a good place to put it.
> :)

Well, I did RTFM, and the perl FAQ seemed a bit ... lacking
in confidence about rt.cpan.org

QUOTE (http://www.cpan.org/misc/cpan-faq.html#Where_is_testers)

     There is also http://rt.cpan.org/ where you
     might search for a module bug already
     reported and/or report a bug.

The word "might" didn't fill me with happiness.

Still, on your recommendation, I went over to the site,
(which was excruciatingly slow)
where I was (strongly :-) invited to create a bitcard
account.

So I did.

Then I tried to go back to the main page to login.

And got a http 500 "internal server error" from Apache
(after another massive pause)

    BugBear


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

Date: Fri, 01 Jun 2007 11:20:34 +0100
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: Re: contacting Alfred Reibenschuh, creator of (CPAN) PDF-API2 ?
Message-Id: <465ff2f2$0$8732$ed2619ec@ptn-nntp-reader02.plus.net>

bugbear wrote:
>...  rt.cpan.org
> Then I tried to go back to the main page to login.
> 
> And got a http 500 "internal server error" from Apache
> (after another massive pause)

I restarted Mozilla (seamonkey) and this time
got a HTTP 500 "proxy error"

Is this bug service actually in use by anyone?

   BugBear


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

Date: Fri, 01 Jun 2007 07:49:51 -0000
From:  markwhite007@gmail.com
Subject: Ergonomic Mobile Computing
Message-Id: <1180684191.046686.90490@x35g2000prf.googlegroups.com>

Despite having worked with a laptop day in day out, I only landed up
with aching wrists, strained neck and back; with my work still
pending. I could quote several reasons for it - my laptop processor
runs too hot, my laptop keeps slipping from the pillow, plus the
aching back. I know most of you agree with me. Now let me share with
you the absolutely comfortable solution I found. It's called the
laptop desk which revolutionized the whole process of computing for me
with it's ergonomic design and heat dissipating ventilation channels.
I highly recommend it, check it for yourself - www.laptopdesk.net



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

Date: Fri, 01 Jun 2007 09:57:53 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: fork() and script execution afterwards
Message-Id: <2ljv53llcs90u5pf3130upr0mqn48grupj@4ax.com>

On Fri, 1 Jun 2007 10:14:54 +0930, "Tom Storey" <tom@snnap.net> wrote:

>> Well, only ONE "BEGIN" should be printed, since it is *before* the
>> fork(). Or am I missing something?
>
>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.

Oh sorry: yes, *this is the case*. Since you seemed confident enough
with it (as opposed to clueless n00bz,) I thought it was obvious.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Fri, 1 Jun 2007 17:36:33 +0930
From: "Tom Storey" <tom@snnap.net>
Subject: Re: fork() and script execution afterwards
Message-Id: <135vksa81jev415@corp.supernews.com>


"Sherm Pendley" <spamtrap@dot-app.org> wrote in message
news: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.

I hadnt seen that particular piece of documentation.

>
> 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 10:06:28 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: fork() and script execution afterwards
Message-Id: <pjkv53th8ei3ivkr668ute5cf5t1f8o7ik@4ax.com>

On Fri, 1 Jun 2007 15:42:43 +0930, "Tom Storey" <tom@snnap.net> wrote:

>> 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?

Well, if you're under *NIX you probably can access the fork(2) manpage
simply by issuing the

  man fork

shell command. That is the C library's fork() which maps directly to
the corresponding system call. By contrast, Perl's fork() is a wrapper
around it, with quite similar functionality. You can access the
documentation of all Perl functions with perldoc. In this case:

  perldoc -f fork


HTH,
Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Fri, 01 Jun 2007 09:44:44 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: How do I read a GZipped UTF-8 file from Perl on Windows?
Message-Id: <ncjv53damosd26n1p5epjouce0r364mmqe@4ax.com>

On Fri, 01 Jun 2007 05:47:13 -0000, DmitryB <combustion@gmail.com>
wrote:

>I just ended up using out of process piped gzip. Works pretty good if
>you don't forget to quote the filename. :-)

Hard to say without seeing any code, but I suspect you're using
something like

  open my $fh, '-|', 'gzip -d "filename.gz"' or die $!;

In that case, you can also give the arguments to gzip in LIST form as

  open my $fh, '-|', 'gzip' => '-d', 'filename.gz' or die $!;

which may be useful.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Fri, 01 Jun 2007 10:11:22 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Issues to post reply
Message-Id: <31lv53lkef9rrjer01d5h3qu3v5caqqd9m@4ax.com>

On Thu, 31 May 2007 22:26:32 -0700, samuel <samuelzhng@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?

No, I don't know. But occasionally it happens. This is one out of many
reasons why using GG as an interface sucks, personally I find it a
pita and try to avoid that like plague. Of course I don't always have
a proper newsserver and reader available, so in a few circumstances
I've had to use that.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Fri, 01 Jun 2007 14:35:15 -0000
From:  Brad Baxter <baxter.brad@gmail.com>
Subject: Re: Multiple Line Pattern Match problem
Message-Id: <1180708515.083185.126410@q66g2000hsg.googlegroups.com>

On Jun 1, 1:20 am, samuel <samuelz...@gmail.com> wrote:
> On 5=E6=9C=8831=E6=97=A5, =E4=B8=8B=E5=8D=889=E6=97=B631=E5=88=86, Brad B=
axter <baxter.b...@gmail.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

Well, if it were me, I'd print out all the other ones, and save
that.  Or maybe try using Tie::File to treat the file as an
array and splice the offending lines out.

--
Brad



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

Date: Fri, 01 Jun 2007 04:07:19 -0700
From:  Bill H <bill@ts1000.us>
Subject: Open file in binary mode
Message-Id: <1180696039.519340.251940@p77g2000hsh.googlegroups.com>

It has been so long since I used Perl to work on a binary file I have
forgotten how to do it. Basically what I need to do is open an
existing file in binary, load every byte of the file starting at the
end and work towards the begining and rewrite it to a new file. In
essense reversing the file. Any tips?


Bill H



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

Date: Fri, 01 Jun 2007 13:34:58 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Open file in binary mode
Message-Id: <5caeo1F30gn34U1@mid.individual.net>

Bill H wrote:
> It has been so long since I used Perl to work on a binary file I have
> forgotten how to do it. Basically what I need to do is open an
> existing file in binary, load every byte of the file starting at the
> end and work towards the begining and rewrite it to a new file. In
> essense reversing the file. Any tips?

     open my $f, '<', $file or die $!;
     open my $r, '>', $newfile or die $!;
     my $data;
     while ( read $f, my $buffer, 1024 ) {
         $data .= $buffer;
     }
     binmode $r;
     print $r scalar reverse $data;

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Fri, 01 Jun 2007 14:06:50 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Open file in binary mode
Message-Id: <ot2063hdakelf0q5iqqpj1vp2bjubs8tgg@4ax.com>

On Fri, 01 Jun 2007 04:07:19 -0700, Bill H <bill@ts1000.us> wrote:

>It has been so long since I used Perl to work on a binary file I have
>forgotten how to do it. Basically what I need to do is open an
>existing file in binary, load every byte of the file starting at the
>end and work towards the begining and rewrite it to a new file. In
>essense reversing the file. Any tips?

  binmode()

  open '<:raw', ...


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Fri, 1 Jun 2007 11:09:37 +0200
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: Parsing: Help on ignoring quoted tokens.
Message-Id: <pan.2007.06.01.09.10.04@rtij.nl.invlalid>

On Fri, 01 Jun 2007 05:30:10 +0000, paktsardines wrote:

> Now, my question is: what is the best way to approach the parsing of
> this file?

Use Parse::RecDecent. A bit of a learning curve, but very, very powerful.

HTH,
M4


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

Date: Fri, 01 Jun 2007 05:19:08 -0700
From:  Klaus <klaus03@gmail.com>
Subject: Re: Parsing: Help on ignoring quoted tokens.
Message-Id: <1180700348.168777.77710@p77g2000hsh.googlegroups.com>

On Jun 1, 7:30 am, paktsardi...@gmail.com wrote:
> 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.

[...snip...]

> Now, my question is: what is the best way to approach the parsing of
> this file?

If you say "parse a text file", you are usually dealing with brackets
and/or nested { ... } constructs and I can clearly see the
"registration { ... }" -  and "error { ... }" - structure in your
file.

I strongly recommend to read first perlfaq4: "How do I find matching/
nesting anything?"

However, in order to keep this simple, I would suggest to make a few
assumptions about the structure of your file, thereby effectively
eliminating the inherent nested structure.

Those assumption would be, for example:
- there are no nested { ... } constructs.
- each { ... } - contruct begins with a single line format /^\w+\s*{$/
  and it ends with a single line /^}$/
- inside a { ... } construct, each line begins with format /^\s+/
  and it is of the form /\s*\[.*?\]/g
- the first line inside a { ... } construct would be of the form
  /^\s+\[heading:.*?\]\s+\[\s*\]$/

This would allow to process the file line-by-line using only regexes,
but still producing valid html code. At first, this solution seems to
be over simplified, but as long as you can keep away from nested
structures, you can easily add/remove/modify more regexes in a trial-
and-error approach as you develop your Perl program from the bottom
up.

Here is how I would start the bottom-up approach with your test-file:

==============================
use strict;
use warnings;

my $inputfile = 'forms.txt';
open my $inp, '<', $inputfile
  or die "Error 0010: open < '$inputfile': $!";

my $comment = '';
while (<$inp>) {
    chomp;
    if (m{^\#\s*(.*)$}xms) {
        $comment = $1;
    }
    if (m{^\s+\[}xms) {
        my @td = m{\[(.*?)\]}gxms;
        if ($comment ne '') {
            if (@td != 2
            or $td[0] !~ m{^heading:(.*)$}xms) {
                die "Error 0020: unexpected '$_'";
            }
            print "<h2>$1 ($comment)</h2>\n";
            print "<table>\n";
            $comment = '';
            next;
        }
        print "  <tr>\n";
        for my $element (@td) {
            if ($element =~ m{^\s*$}xms) {
                print "    <td>&nbsp;</td>\n";
            }
            else {
                print "    <td>$element</td>\n";
            }
        }
        print "  </tr>\n";
        next;
    }
    if (/^}/xms) {
        print "</table>\n";
        $comment = '';
        next;
    }
}

close $inp;
==============================

This approach is very flexible and extremely scalable, I've already
tried it successfully by transforming a plain old schema-listing of a
mainframe database from basic Ascii format into Html.

> Bonus points if your answer makes no reference to lex or yacc.  :)

Thanks for the bonus points :-)

--
Klaus



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

Date: Fri, 01 Jun 2007 15:07:53 -0000
From:  Xicheng Jia <xicheng@gmail.com>
Subject: Re: Parsing: Help on ignoring quoted tokens.
Message-Id: <1180710473.219300.9240@h2g2000hsg.googlegroups.com>

On Jun 1, 1:30 am, paktsardi...@gmail.com wrote:
> 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?

I think your input data format is just fine, so:

1) use paragraph-mode to separate between tables, make sure no empty
line within a single table block.
  * specify number of columns and optional table caption, make each of
them in the same line(no embedded newline). (you could make caption in
multiple lines though:))
  * each table row is in the same line, and each column enclosed by
square brackets.
  * if you have embedded square brackets, make a rule and leave that
to Perl regex:-).

I guess you've done all these above. :-)

2) then you need a data structure or probably database. For a data
structure, I would use a hash to organize tables and then use array of
array to define each table.

Here is a sample:

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

my %tables = ();
local $/ = "\n\n";

# build the data structure
while(my $tbl = <DATA>)
{
    # find table name
    next if not $tbl =~ /^(\w+)\s*\{\s*$/m;
    my $table = $1;
    # get the number of columns
    my $numCol = $1 if $tbl =~ /^\s*numcols:(\d+)/m;
    # find caption if there is any (note: it parses only the first
#line)
    my $caption = $1 if $tbl =~ /^#(.*)/m;
    push @{$tables{$table}}, $caption if defined $caption;
    # check each line and find table rows
    foreach my $row (split "\n", $tbl) {
        # adjust the following regex if you have embedded square
bracket
        my @cols = ($row =~ /\[([^][]*)\]/g);
        push @{$tables{$table}}, [ @cols ] if scalar @cols == $numCol;
    }
}

print "Check registration form\n";
show_form('registration');

print "\n\nCheck error form\n";
show_form('error');

##### subroutines #####
sub show_form {
    my $tbl = shift;
    my @form = @{$tables{$tbl}};
    print "<table>\n";
    if (not ref $form[0]) {
        print "  <caption>$form[0]</caption>\n";
        shift @form;
    }
    foreach my $row (@form) {
        print "  <tr>\n";
        foreach my $col (@{$row}) {
            $col = '&nbsp;' if $col =~ /^\s*$/;
            my $var = mkCol($col);
            print "    <th>$var</th>\n" if $row->[0] =~ /^heading:/;
            print "    <td>$var</td>\n" if $row->[0] =~ /^label:/;
        }
        print "  </tr>\n";
    }
    print "</table>\n";
}

##### subroutine to parse table cell #####
sub mkCol {
    my $col = shift;
    return $1 if $col =~ /^label:"([^"]*?):?"$/;
    return $1 if $col =~ /^heading:\s*(.*)/;
    return $col;
}

__DATA__
# 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]
}

(you need to do more test by yourself though)

> Also, can anyone please suggest how to ignore tokens (like ':') that
> occur within quoted strings?

Don't know your final goal, but you probably can leave that to
handling each cell (i.e. subroutine mkCol() in my test code).

Good luck,
Xicheng




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

Date: Fri, 01 Jun 2007 04:03:24 -0700
From:  Paul Lalli <mritty@gmail.com>
Subject: Re: Perl syntax
Message-Id: <1180695804.182053.245100@p77g2000hsh.googlegroups.com>

On May 31, 7:40 pm, James <hslee...@yahoo.com> wrote:
> Need help to understand the following syntax.
>
> Net::SSH::Perl package, in Channel.pm, line 142,
>
>     $r->{code}->( $c, $c->{$buf}, @{ $r->{extra} } );

$r is a reference to a hash.  The hash that $r references contains (at
least) two keys: 'code' and 'extra'.

$r->{code} is the value of the hash that $references, at the key
'code'.  This value is a reference to a subroutine.  You can call a
subroutine via its reference by using the arrow-parentheses notation.
So $r->{code}->(...) says to call the subroutine referenced by $r-
>{code}.

Arguments are being passed to this subroutine.  The first, $c, is a
reference to a hash.  The second $c->{$buf}, is the value of this hash
at the key $buf.  Finally, $r->{extra} is a reference to an array, and
@{$r->{extra}} is the array that $r->{extra} references.  All of the
elements of this array (which could be 0 or more) are being passed as
the final arguments to the subroutine that $r->{code} references.

For more information:
perldoc perlreftut
perldoc perlref

Hope this helps,
Paul Lalli



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

Date: Fri, 1 Jun 2007 06:15:31 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Perl syntax
Message-Id: <slrnf5vvuj.7gc.tadmc@tadmc30.august.net>

James <hslee911@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} } );


$r is a reference to a hash.

$r->{code} is a reference to a subroutine.

$c is a reference to a hash.

$r->{extra} is a reference to an array.

See:

    perldoc perlreftut

$c->{$buf} is an example of "Use Rule 2".

@{ $r->{extra} } is an example of "Use Rule 1".


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Fri, 01 Jun 2007 14:54:58 -0000
From:  Brad Baxter <baxter.brad@gmail.com>
Subject: Re: Prototypes and anonymous subroutines
Message-Id: <1180709698.457110.183560@k79g2000hse.googlegroups.com>

On May 31, 5:47 pm, Brian McCauley <nobul...@gmail.com> wrote:
> On May 31, 5:27 pm, gba...@hiwaay.net (Greg Bacon) wrote:
>
>
>
> > In article <1180626699.280974.311...@w5g2000hsg.googlegroups.com>,
> >     Brad Baxter  <baxter.b...@gmail.com> wrote:
>
> > : So a couple of questions:
> > :
> > : 1. If prototypes are ignored for anonymous subroutines,
> > : why be able to define them?
>
> > You can make them work (see below), but maybe it was a speculative
> > development path that deadended.
>
> > : 2. Am I missing a calling convention that does not ignore
> > : them?
>
> > It's ugly, but consider
>
> >     $ perl -le 'BEGIN { *n = sub ($) { print @_ } } n(1,2)'
> >     Too many arguments for main::n at -e line 1, at end of line
> >     Execution of -e aborted due to compilation errors.
>
> Have encountered obscure edge cases where I've used this sort of
> thing. But they are rare.
>
> I've also abused prototypes (in a similar way to the way sort() does)
> as a poor-man's metadata by using the explicit prototype() function.
> For an example see String::Interpolate.

Fair enough.  Thanks.

--
Brad



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

Date: Fri, 01 Jun 2007 07:32:43 -0700
From:  support@sitepak.com
Subject: Senior Perl developer position in Montreal, Canada
Message-Id: <1180708363.770817.119840@q66g2000hsg.googlegroups.com>

Hi,

Sitepak (http://www.sitepak.com) is looking for a senior level Perl
developer.

The job description can be found there:

http://www.sitepak.com/tiki-index.php?page=Jobs

Please send your resumes to jobs@sitepak.com

Regards



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

Date: Fri, 1 Jun 2007 11:24:04 +0200
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: stumped by graphics display problem...
Message-Id: <pan.2007.06.01.09.24.30@rtij.nl.invlalid>

On Thu, 31 May 2007 20:42:12 +0000, Alan Curry wrote:

> (You can't quit the "display" program using the keyboard?)

'q'

HTH,
M4


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

Date: Fri, 01 Jun 2007 01:32:12 -0700
From:  "ebankgame.com" <goxbuy2000@gmail.com>
Subject: www.eBankGame.com (w w w .e BankGame . c o m )
Message-Id: <1180686732.731661.156170@i38g2000prf.googlegroups.com>

www.eBankGame.com (w w w .e BankGame . c o m )
As you might or might not known that Taiwan earthquake has caused
most
of supplier are experiencing the serve problem to process the gold.
However, eBankGame is always stay line with all the game players to
help you guys to enjoy the game at any time. We provide Gold Farmer
service for you to own the gold with little bit expense. Your expense
will be more valuable by take one action and gain multiple purposes.
The service is focus on gold farming for your character in the game
by
using professional human player to taking tasks and gain reputation
in
the game in order to gain the gold for you (We do not apply any plug-
in or Bots on your character). Meanwhile your character will be
improved 1-15 power leveling which depends on your original level
(this aspect is not available for Level 60). www.eBankGame.com (w w
w .e BankGame . c o m)


1.The Fastest Delivery Speed on all Servers in 1-8 hours since your
payment arrives.If the deliver is delayed over 8 hours, you will get
5% extra gold for the late.Or you can request a refund.


2.Special Discount Servers.Sometimes, there will be some servers,
with
special discounts, with extremely NICE PRice on some certain servers.


3.Perfect Service.24 hours service with various contact methods: MSN,
ICQ, Online Chat on Web homepage,Welcome to www.eBankGame.com
If any problem, please contact us asap!


Happy shopping!
Sincerely,


www.eBankGame.com


E-mail:ebankgame2...@gmail.com
MSN:ebagame2...@msn.com
ICQ:468873592


Choose your game
World of Warcraft EU
World of Warcraft US
Lord of The Rings EU
Lord of The Rings US
Lineage II
EverQuest2
Guild Wars
Final Fantacy XI
Runescape 2
RFO Online
Dungeons & Dragons Online
Eve Online
Star Wars Galaxies


go to  www.eBankGame.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 477
**************************************


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