[28859] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 103 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 9 22:01:00 2007

Date: Fri, 9 Feb 2007 19:00:25 -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           Fri, 9 Feb 2007     Volume: 11 Number: 103

Today's topics:
        Calculation with "priority" hashes <bart@nijlen.com>
    Re: Calculation with "priority" hashes <rvtol+news@isolution.nl>
        CGI why ignore "\n", no return, no new line? <robertchen117@gmail.com>
    Re: CGI why ignore "\n", no return, no new line? <spamtrap@dot-app.org>
    Re: CGI why ignore "\n", no return, no new line? <jurgenex@hotmail.com>
    Re: CGI why ignore "\n", no return, no new line? <wahab-mail@gmx.de>
    Re: CGI why ignore "\n", no return, no new line? <scobloke2@infotop.co.uk>
        CGI.pm Button Generation FeelLikeANut@gmail.com
    Re: CGI.pm Button Generation <vilain@spamcop.net>
    Re: CGI.pm Button Generation FeelLikeANut@gmail.com
    Re: CGI.pm Button Generation (NOSPAM)
    Re: CGI.pm Button Generation <stoupa@practisoft.cz>
    Re: CGI.pm Button Generation FeelLikeANut@gmail.com
    Re: CGI.pm Button Generation <attn.steven.kuo@gmail.com>
    Re: CGI.pm Button Generation <bik.mido@tiscalinet.it>
    Re: CGI.pm Button Generation anno4000@radom.zrz.tu-berlin.de
        Converting perldoc to postscript <mordecai.crystal@gmail.com>
    Re: Converting perldoc to postscript <kalyan.manchikanti@gmail.com>
    Re: Converting perldoc to postscript <mordecai.crystal@gmail.com>
    Re: Converting perldoc to postscript <john@castleamber.com>
    Re: Converting perldoc to postscript <mordecai.crystal@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 7 Feb 2007 11:11:58 -0800
From: "Bart Van der Donck" <bart@nijlen.com>
Subject: Calculation with "priority" hashes
Message-Id: <1170875517.947897.196840@s48g2000cws.googlegroups.com>

Hello,

The following data are prices for holiday houses. Say '20' represents
midweek 5feb-9feb, '21' is weekend 10feb-11feb, '22' is midweek
12feb-16feb, etc

Prices are in the following format:

    $price_midweek{20} = 38.15;
    $price_weekend{21} = 44.78;
    $price_midweek{22} = 34.84;
    $price_weekend{23} = 43.98;
    $price_midweek{24} = 39.94;
    $price_weekend{25} = 48.17;
    $price_midweek{26} = 36.04;
    $price_weekend{27} = 47.09;
    # 28 not available
    $price_weekend{29} = 44.36;
    $price_midweek{30} = 40.08;
    $price_weekend{31} = 41.33;

    $price_fullweek{20} = 57.22;
    $price_fullweek{21} = 57.22;
    $price_fullweek{22} = 61.79;
    $price_fullweek{23} = 61.79;
    $price_fullweek{24} = 58.40;
    $price_fullweek{25} = 58.40;
    $price_fullweek{26} = 58.86;
    $price_fullweek{27} = 58.86;
    $price_fullweek{28} = 59.54;
    $price_fullweek{29} = 59.54;
    # 30 and 31 not available

The prices of %price_fullweek always have priority.

$price_fullweek{20} is always the same as $price_fullweek{21},
$price_fullweek{22} is always the same as $price_fullweek{23},
$price_fullweek{24} is always the same as $price_fullweek{25}, etc.

Suppose customer wants a holiday from 22 to 26, then the price would
be 61.79 (= full week price of (midweek 22 and weekend 23)) + 58.40 (=
full week price of (midweek 24 and weekend 25)) + 36.04 (price of
midweek 26), thus total 156.23.

The price for 28 can only be booked when it's in its covering week;
because $price_weekend{28} or $price_midweek{28} don't exist.

If 30 and 31 would be in the booking, then the prices of weekend
+midweek are taken (40.08+41.33) because %price_fullweek holds no
entry for 30 and 31.

It's only possible to stay in period ranges that follow each other
(like 20-21-22-23 or 25-26-27 etc).

Is it possible to calculate the total price under such circumstances ?

Thanks very much,

--
 Bart



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

Date: Wed, 7 Feb 2007 21:56:26 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Calculation with "priority" hashes
Message-Id: <eqdi19.11g.1@news.isolution.nl>

Bart Van der Donck schreef:

> The following data are prices for holiday houses. Say '20' represents
> midweek 5feb-9feb, '21' is weekend 10feb-11feb, '22' is midweek
> 12feb-16feb, etc
>
> Prices are in the following format:
>
>     $price_midweek{20} = 38.15;
>     $price_weekend{21} = 44.78;
>     $price_midweek{22} = 34.84;
>     $price_weekend{23} = 43.98;
>     $price_midweek{24} = 39.94;
>     $price_weekend{25} = 48.17;
>     $price_midweek{26} = 36.04;
>     $price_weekend{27} = 47.09;
>     # 28 not available
>     $price_weekend{29} = 44.36;
>     $price_midweek{30} = 40.08;
>     $price_weekend{31} = 41.33;
>
>     $price_fullweek{20} = 57.22;
>     $price_fullweek{21} = 57.22;
>     $price_fullweek{22} = 61.79;
>     $price_fullweek{23} = 61.79;
>     $price_fullweek{24} = 58.40;
>     $price_fullweek{25} = 58.40;
>     $price_fullweek{26} = 58.86;
>     $price_fullweek{27} = 58.86;
>     $price_fullweek{28} = 59.54;
>     $price_fullweek{29} = 59.54;
>     # 30 and 31 not available
>
> The prices of %price_fullweek always have priority.
>
> $price_fullweek{20} is always the same as $price_fullweek{21},
> $price_fullweek{22} is always the same as $price_fullweek{23},
> $price_fullweek{24} is always the same as $price_fullweek{25}, etc.
>
> Suppose customer wants a holiday from 22 to 26, then the price would
> be 61.79 (= full week price of (midweek 22 and weekend 23)) + 58.40 (=
> full week price of (midweek 24 and weekend 25)) + 36.04 (price of
> midweek 26), thus total 156.23.
>
> The price for 28 can only be booked when it's in its covering week;
> because $price_weekend{28} or $price_midweek{28} don't exist.
>
> If 30 and 31 would be in the booking, then the prices of weekend
> +midweek are taken (40.08+41.33) because %price_fullweek holds no
> entry for 30 and 31.
>
> It's only possible to stay in period ranges that follow each other
> (like 20-21-22-23 or 25-26-27 etc).
>
> Is it possible to calculate the total price under such circumstances ?

Step 1: use an AoA.

$ perl -Mstrict -MData::Dumper -wle'
  my @price;
  push @price, [undef, undef, undef] for 1..10;
  push @price,
      [38.15, 44.78, 57.22],
      [34.84, 43.98, 61.79],
      [39.94, 48.17, 58.40],
      [36.04, 47.09, 58.86],
      [undef, 44.36, 59.54],
      [40.08, 41.33, undef],
  ;
  print Dumper \@price;
'

Variant-1:

$ perl -Mstrict -MData::Dump
  push my @price,
      (undef) x 10,
      [38.15, 44.78, 57.22],
      [34.84, 43.98, 61.79],
      [39.94, 48.17, 58.40],
      [36.04, 47.09, 58.86],
      [undef, 44.36, 59.54],
      [40.08, 41.33, undef],
  ;
  print Dumper \@price;
'

The fullweek-price could of course also go into the initial element of
each subarray.

Variant-2:

$ perl -Mstrict -MData::Dumper -wle'
  push my @price,
      (undef) x 10,
      [57.22, [38.15, 44.78] ],
      [61.79, [34.84, 43.98] ],
      [58.40, [39.94, 48.17] ],
      [58.86, [36.04, 47.09] ],
      [59.54, [undef, 44.36] ],
      [undef, [40.08, 41.33] ],
  ;
  print Dumper \@price;
'

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

Date: 5 Feb 2007 23:39:24 -0800
From: "robertchen117@gmail.com" <robertchen117@gmail.com>
Subject: CGI why ignore "\n", no return, no new line?
Message-Id: <1170747564.180633.32980@m58g2000cwm.googlegroups.com>

#!/usr/bin/perl
use CGI;
print "Content-type: text/html\n\n";


$no_connected = 0;
$no_unkown = 0;
$no_unreachable = 0;
$no_disconnected= 0;
$no_unavailable= 0;
$total = 0;
$others = 0;

printf("-----------------------------------------------------------------------
\n");
printf("%s total hosts\n", $total);
printf("%6s hosts connected\n", $no_connected);
printf("%6s hosts unreachable\n", $no_unreachable);
printf("%6s hosts unkown\n", $no_unkown);
printf("%6s hosts disconnected\n", $no_disconnected);
printf("%6s hosts unavailable\n", $no_unavailable);
printf("%6s hosts others status\n", $others);
printf("-----------------------------------------------------------------------
\n");


put in my apache, and access the cgi, the result is:
-----------------------------------------------------------------------
0 total hosts 0 hosts connected 0 hosts unreachable 0 hosts unkown 0
hosts disconnected 0 hosts unavailable 0 hosts others status
--------------------------------------------------------------
---------

my question is: why no new return? no new line?



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

Date: Tue, 06 Feb 2007 02:43:50 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: CGI why ignore "\n", no return, no new line?
Message-Id: <m2lkjb91e1.fsf@Sherm-Pendleys-Computer.local>

"robertchen117@gmail.com" <robertchen117@gmail.com> writes:

> #!/usr/bin/perl
> use CGI;
> print "Content-type: text/html\n\n";

 ...

> my question is: why no new return? no new line?

For the same reason newlines are ignored in HTML that's served from a .html
file instead of a CGI. Did you have a Perl question?

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


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

Date: Tue, 06 Feb 2007 08:07:12 GMT
From: "J¨¹rgen Exner" <jurgenex@hotmail.com>
Subject: Re: CGI why ignore "\n", no return, no new line?
Message-Id: <QGWxh.1332$da1.513@trndny03>

robertchen117@gmail.com wrote:
> #!/usr/bin/perl
> use CGI;
> print "Content-type: text/html\n\n";
[...]
> printf("-----------------------------------------------------------------------
> \n");
> printf("%s total hosts\n", $total);

This output doesn't look like HTML to me. Why are you lying about the 
content type?

> put in my apache, and access the cgi, the result is:
> my question is: why no new return? no new line?

Because HTML is a free format markup language.

Of course this has nothing to do with Perl in the first place anyway.

jue 




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

Date: Tue, 06 Feb 2007 09:45:53 +0100
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: CGI why ignore "\n", no return, no new line?
Message-Id: <eq9fhs$gs$1@mlucom4.urz.uni-halle.de>

robertchen117@gmail.com wrote:

> use CGI;
> print "Content-type: text/html\n\n";

(!)

> printf("%s total hosts\n", $total);
> printf("%6s hosts connected\n", $no_connected);

(!)

> my question is: why no new return? no new line?

As Sherm & Juergen said, there's nothing
like a "\n" in HTML that modifies the
layout.

BTW you aren't using any part of
the module included by 'use CGI',

this module provides some functionality
that translates the program flow into
structural markup and markup-bound layout
instructions compatible with older HTML
concepts.

Your example would have looked in the
good old times of pre-XHTML like this ...


#!/usr/bin/perl
use CGI qw':standard';

$no_connected = 0;
$no_unkown = 0;
$no_unreachable = 0;
$no_disconnected = 0;
$no_unavailable = 0;
$total = 0;
$others = 0;

print
   header, start_html('chens site'),
   hr,
   table( {-border=>"0"},
         Tr(
            [
             td([ $total,          'total hosts'        ]),
             td([ $no_connected ,  'hosts connected'    ]),
             td([ $no_connected ,  'hosts connected'    ]),
             td([ $no_unreachable, 'hosts unreachable'  ]),
             td([ $no_unkown,      'hosts unkown'       ]),
             td([ $no_disconnected,'hosts disconnected' ]),
             td([ $no_unavailable, 'hosts unavailable'  ]),
             td([ $others,         'hosts others status'])
            ]
           )
        ),
   hr,
   end_html;


 ... which would result in a somehow proper table-markup
(which matches your intention more or less).

Regards

M.


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

Date: Tue, 06 Feb 2007 11:41:23 +0000
From: Ian Wilson <scobloke2@infotop.co.uk>
Subject: Re: CGI why ignore "\n", no return, no new line?
Message-Id: <45c86964$0$2439$db0fefd9@news.zen.co.uk>

robertchen117@gmail.com wrote:
> #!/usr/bin/perl
> use CGI;
> print "Content-type: text/html\n\n";

print "Content-type: text/plain\n\n";

Set the content-type correctly for the type of content!
What you print below is plain text, not HTML.

> 
> 
> $no_connected = 0;
> $no_unkown = 0;
> $no_unreachable = 0;
> $no_disconnected= 0;
> $no_unavailable= 0;
> $total = 0;
> $others = 0;
> 
> printf("-----------------------------------------------------------------------
> \n");
> printf("%s total hosts\n", $total);
> printf("%6s hosts connected\n", $no_connected);
> printf("%6s hosts unreachable\n", $no_unreachable);
> printf("%6s hosts unkown\n", $no_unkown);
> printf("%6s hosts disconnected\n", $no_disconnected);
> printf("%6s hosts unavailable\n", $no_unavailable);
> printf("%6s hosts others status\n", $others);
> printf("-----------------------------------------------------------------------
> \n");

There is no HTML markup in your print statements.

If desired, you could retain the "Content-type: text/html" and add some HTML
preamble and postamble such as

print "<html><head><title>Host info</title></head><body><pre>";
 ... your printf statements
print "</pre></body></html>";

But you'd probably be better off using a module that simplifies writing the
correct Doctype etc. For example CGI.pm - read `perldoc CGI`.


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

Date: 6 Feb 2007 17:21:30 -0800
From: FeelLikeANut@gmail.com
Subject: CGI.pm Button Generation
Message-Id: <1170811290.280533.240430@v45g2000cwv.googlegroups.com>

I need the CGI module to be able to generate the following HTML:

	<button name="overwrite" value="yes" type="submit">Overwrite</button>
	<button name="overwrite" value="no" type="submit">Cancel</button>

I can't figure out how to get CGI.pm to do this. Can someone help me
find what I'm missing?



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

Date: Tue, 06 Feb 2007 18:58:05 -0800
From: Michael Vilain <vilain@spamcop.net>
Subject: Re: CGI.pm Button Generation
Message-Id: <vilain-1999E9.18580506022007@comcast.dca.giganews.com>

In article <1170811290.280533.240430@v45g2000cwv.googlegroups.com>,
 FeelLikeANut@gmail.com wrote:

> I need the CGI module to be able to generate the following HTML:
> 
> 	<button name="overwrite" value="yes" type="submit">Overwrite</button>
> 	<button name="overwrite" value="no" type="submit">Cancel</button>
> 
> I can't figure out how to get CGI.pm to do this. Can someone help me
> find what I'm missing?

AFAIK, <button> isn't widely used HTML and not recommended.  What DTD 
are you using and what version of CGI.pm are you running?  I'm running 
1.33, which is ancient, but only because that's what my web hosting 
company is running.  

In any case, when I use CGI to generate the button code:

use CGI;
$q = new CGI;
print $q->button(-name=>"overwrite",
                  -value=>"yes",
                  -type=>"submit");

This generates the following HTML:

<INPUT TYPE="button" NAME="overwrite" VALUE="yes" TYPE="submit">

The W3C spec for <button> says

"The BUTTON element defines a submit button, reset button, or push 
button. Authors can also use INPUT to specify these buttons, but the 
BUTTON element allows richer labels, including images and emphasis. 
However, BUTTON is new in HTML 4.0 and not as widely supported as INPUT. 
For compatibility with old browsers, INPUT should generally be used 
instead of BUTTON."

http://www.htmlhelp.com/reference/html40/forms/button.html

If you look at the code in CGI.pm, it may not support <button> and use 
<input> instead.  The only way around this is to code the HTML by hand 
and not use CGI.pm.

-- 
DeeDee, don't press that button!  DeeDee!  NO!  Dee...





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

Date: 6 Feb 2007 20:26:27 -0800
From: FeelLikeANut@gmail.com
Subject: Re: CGI.pm Button Generation
Message-Id: <1170822387.237464.269100@v33g2000cwv.googlegroups.com>

On Feb 6, 9:58 pm, Michael Vilain <vil...@spamcop.net> wrote:
> In article <1170811290.280533.240...@v45g2000cwv.googlegroups.com>,
>
>  FeelLikeA...@gmail.com wrote:
> > I need the CGI module to be able to generate the following HTML:
>
> >    <button name="overwrite" value="yes" type="submit">Overwrite</button>
> >    <button name="overwrite" value="no" type="submit">Cancel</button>
>
> > I can't figure out how to get CGI.pm to do this. Can someone help me
> > find what I'm missing?
>
> AFAIK, <button> isn't widely used HTML and not recommended. What DTD
> are you using and what version of CGI.pm are you running?

HTML 4.01 Strict and CGI.pm 3.25.

> I'm running
> 1.33, which is ancient, but only because that's what my web hosting
> company is running.
>
> In any case, when I use CGI to generate the button code:
>
> use CGI;
> $q = new CGI;
> print $q->button(-name=>"overwrite",
>                   -value=>"yes",
>                   -type=>"submit");
>
> This generates the following HTML:
>
> <INPUT TYPE="button" NAME="overwrite" VALUE="yes" TYPE="submit">
>
> The W3C spec for <button> says
>
> "The BUTTON element defines a submit button, reset button, or push
> button. Authors can also use INPUT to specify these buttons, but the
> BUTTON element allows richer labels, including images and emphasis.
> However, BUTTON is new in HTML 4.0 and not as widely supported as INPUT.
> For compatibility with old browsers, INPUT should generally be used
> instead of BUTTON."
>
> http://www.htmlhelp.com/reference/html40/forms/button.html

Well, to be fair, citing htmlhelp.com is not the same as citing the
W3C spec. The spec itself does not make the recommendation to use
IINPUT instead of BUTTON. Also, HTML 4 and BUTTON have been around for
more than nine years now -- more than enough time, I would think, for
browsers to support it, and in fact they have. It seems to be only
CGI.pm that is lacking in this regard.

> If you look at the code in CGI.pm, it may not support <button> and use
> <input> instead.  The only way around this is to code the HTML by hand
> and not use CGI.pm.

Yes, that is the conclusion I've come to as well, unfortunately. I
wanted to make sure I wasn't missing something. I'd have thought that
CGI.pm would have added support for BUTTON a long time ago.



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

Date: Tue, 06 Feb 2007 22:50:23 -0600
From: "Mumia W. (NOSPAM)" <paduille.4060.mumia.w+nospam@earthlink.net>
Subject: Re: CGI.pm Button Generation
Message-Id: <eqbna2$a5b$1@aioe.org>

On 02/06/2007 07:21 PM, FeelLikeANut@gmail.com wrote:
> I need the CGI module to be able to generate the following HTML:
> 
> 	<button name="overwrite" value="yes" type="submit">Overwrite</button>
> 	<button name="overwrite" value="no" type="submit">Cancel</button>
> 
> I can't figure out how to get CGI.pm to do this. Can someone help me
> find what I'm missing?
> 

Michael Vilain's comments apply. However, if you are willing to risk 
using the "-any" option to CGI.pm, you can do this:

     use CGI qw(-any);

     print CGI::Button({
         name => 'overwrite',
         value => 'yes',
         type => 'submit',
         },
         'Overwrite'), "\n";

     print CGI::Button({
         name => 'overwrite',
         value => 'no',
         type => 'submit'},
         'Cancel'), "\n";

I don't advise this however. The "-any" option will automatically create 
any weird function name you can imagine, and that could create some hard 
to find bugs.


-- 
Windows Vista and your freedom in conflict:
http://www.badvista.org/


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

Date: Wed, 7 Feb 2007 03:20:46 +0100
From: "Petr Vileta" <stoupa@practisoft.cz>
Subject: Re: CGI.pm Button Generation
Message-Id: <eqbmmp$2ial$2@ns.felk.cvut.cz>

<FeelLikeANut@gmail.com> píse v diskusním príspevku 
news:1170811290.280533.240430@v45g2000cwv.googlegroups.com...
>I need the CGI module to be able to generate the following HTML:
>
> <button name="overwrite" value="yes" type="submit">Overwrite</button>
> <button name="overwrite" value="no" type="submit">Cancel</button>
>
> I can't figure out how to get CGI.pm to do this. Can someone help me
> find what I'm missing?
>
To use the same name in the same form for other inputs then "radio" is not a 
good idea at all ;-)
Second ... why you want to use CGI module for this non standard html code? 
Simple write this

print "<button name=\"overwrite\" value=\"yes\" 
type=\"submit\">Overwrite</button>\n",
        "<button name=\"overwrite\" value=\"no\" 
type=\"submit\">Cancel</button>\n";


-- 

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail 
from another non-spammer site please.)





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

Date: 7 Feb 2007 03:32:43 -0800
From: FeelLikeANut@gmail.com
Subject: Re: CGI.pm Button Generation
Message-Id: <1170847963.649417.205010@m58g2000cwm.googlegroups.com>

On Feb 6, 9:20 pm, "Petr Vileta" <sto...@practisoft.cz> wrote:
> <FeelLikeA...@gmail.com> p=EDse v diskusn=EDm pr=EDspevkunews:1170811290.=
280533.240430@v45g2000cwv.googlegroups.com...>I need the CGI module to be a=
ble to generate the following HTML:
>
> > <button name=3D"overwrite" value=3D"yes" type=3D"submit">Overwrite</but=
ton>
> > <button name=3D"overwrite" value=3D"no" type=3D"submit">Cancel</button>
>
> > I can't figure out how to get CGI.pm to do this. Can someone help me
> > find what I'm missing?
>
> To use the same name in the same form for other inputs then "radio" is no=
t a
> good idea at all ;-)

Um ... why not? It's legit and works very conveniently.

> Second ... why you want to use CGI module for this non standard html code?

Non standard code? It's been standardized for more than nine years.
In any case, I'd prefer to use CGI.pm because I'm writing a module
that returns HTML code from some of its functions. Those functions
take a CGI object reference as an argument and use that object to
generate HTML. This lets the module adapt -- without lots of extra
code -- to the different requirements of each user, such as whether to
output HTML or XHTML, and the character encoding being used.

> Simple write this
>
> print "<button name=3D\"overwrite\" value=3D\"yes\"
> type=3D\"submit\">Overwrite</button>\n",
>         "<button name=3D\"overwrite\" value=3D\"no\"
> type=3D\"submit\">Cancel</button>\n";
>
> --
>
> Petr Vileta, Czech republic
> (My server rejects all messages from Yahoo and Hotmail. Send me your mail
> from another non-spammer site please.)




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

Date: 7 Feb 2007 13:15:03 -0800
From: "attn.steven.kuo@gmail.com" <attn.steven.kuo@gmail.com>
Subject: Re: CGI.pm Button Generation
Message-Id: <1170882903.141837.47000@m58g2000cwm.googlegroups.com>

On Feb 7, 3:32 am, FeelLikeA...@gmail.com wrote:


(snipped)

> In any case, I'd prefer to use CGI.pm because I'm writing a module
> that returns HTML code from some of its functions. Those functions
> take a CGI object reference as an argument and use that object to
> generate HTML. This lets the module adapt -- without lots of extra
> code -- to the different requirements of each user, such as whether to
> output HTML or XHTML, and the character encoding being used.
>


What about extending CGI?

Something like:

package CGI::Extend;
use base qw/CGI/;

require Exporter;
push @ISA, qw/Exporter/;
@EXPORT_OK = qw/my_button/;

use HTML::Element;

sub my_button {
    my ($self, $content, @p) = CGI::self_or_CGI(@_);
    my ($name, $value, $type) = CGI::Util::rearrange([['NAME'],
['VALUE'], ['TYPE']], @p);

    my $h = HTML::Element->new('button');
    $h->attr('name', $name) if defined($name);
    $h->attr('value', $value) if defined($value);
    $h->attr('type', $type) if defined($type);
    $h->push_content( $content );
    return $h->as_HTML;
}

1;


# === then in your application:

#!/usr/bin/perl
use strict;
use warnings;
use CGI::Extend qw/my_button/;

print my_button(
    "Overwrite",
    -value => 'yes',
    -type => 'submit',
    -name => 'overwrite'
);

# Test OO style:
my $q2 = CGI::Extend->new();
print $q2->my_button(
    "Cancel",
    -value => 'no',
    -type => 'submit',
    -name => 'overwrite'
);


I'm sure the above is insufficiently tested but
it's a start.

--
Hope this helps,
Steven



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

Date: Thu, 08 Feb 2007 15:59:32 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: CGI.pm Button Generation
Message-Id: <n5rjs25ah0ghalebtm6elruf2ocmfrrk0p@4ax.com>

On Wed, 7 Feb 2007 03:20:46 +0100, "Petr Vileta"
<stoupa@practisoft.cz> wrote:

>print "<button name=\"overwrite\" value=\"yes\" 
>type=\"submit\">Overwrite</button>\n",
>        "<button name=\"overwrite\" value=\"no\" 
>type=\"submit\">Cancel</button>\n";

Ever heard 'bout alternative delimiters?!? ;-)


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: 8 Feb 2007 19:19:39 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: CGI.pm Button Generation
Message-Id: <531bebF1qk54iU2@mid.dfncis.de>

attn.steven.kuo@gmail.com <attn.steven.kuo@gmail.com> wrote in comp.lang.perl.misc:
> On Feb 7, 3:32 am, FeelLikeA...@gmail.com wrote:
> 
> 
> (snipped)
> 
> > In any case, I'd prefer to use CGI.pm because I'm writing a module
> > that returns HTML code from some of its functions. Those functions
> > take a CGI object reference as an argument and use that object to
> > generate HTML. This lets the module adapt -- without lots of extra
> > code -- to the different requirements of each user, such as whether to
> > output HTML or XHTML, and the character encoding being used.
> >
> 
> 
> What about extending CGI?

Right.  That's the spirit!

> Something like:

[good-looking code snipped]

> I'm sure the above is insufficiently tested but
> it's a start.

Once it *is* sufficiently tested, submit it as a patch to CGI.pm.
That's how open-source software grows.

Anno


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

Date: 9 Feb 2007 09:24:01 -0800
From: "Mordecai" <mordecai.crystal@gmail.com>
Subject: Converting perldoc to postscript
Message-Id: <1171041840.983669.100500@p10g2000cwp.googlegroups.com>

What's the best way to do so?  I hope to get the default man page
formatting, not the plain text formatting as specified by "-t".
Thanks!



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

Date: 9 Feb 2007 09:37:20 -0800
From: "Kalyan Manchikanti" <kalyan.manchikanti@gmail.com>
Subject: Re: Converting perldoc to postscript
Message-Id: <1171042640.161997.281490@h3g2000cwc.googlegroups.com>

On Feb 9, 11:24 am, "Mordecai" <mordecai.crys...@gmail.com> wrote:
> What's the best way to do so?  I hope to get the default man page
> formatting, not the plain text formatting as specified by "-t".
> Thanks!

Did you try perldoc -oman  ?

Kalyan




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

Date: 9 Feb 2007 09:51:39 -0800
From: "Mordecai" <mordecai.crystal@gmail.com>
Subject: Re: Converting perldoc to postscript
Message-Id: <1171043499.220570.183640@j27g2000cwj.googlegroups.com>

On Feb 9, 12:37 pm, "Kalyan Manchikanti"
<kalyan.manchika...@gmail.com> wrote:
> On Feb 9, 11:24 am, "Mordecai" <mordecai.crys...@gmail.com> wrote:
>
> > What's the best way to do so?  I hope to get the default man page
> > formatting, not the plain text formatting as specified by "-t".
> > Thanks!
>
> Did you try perldoc -oman  ?
>
> Kalyan

But that just gives the default man page formatting (as if without the
option, right?) while what I am trying to get is the postscript
version of that format.  Perldoc doesn't seem to provide a simple
option to do so.  Any further suggestions?



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

Date: 9 Feb 2007 19:10:29 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Converting perldoc to postscript
Message-Id: <Xns98D286051791Fcastleamber@130.133.1.4>

"Mordecai" <mordecai.crystal@gmail.com> wrote:

> What's the best way to do so?  I hope to get the default man page
> formatting, not the plain text formatting as specified by "-t".
> Thanks!

http://search.cpan.org/~ni-s/PodToHTML-0.05/podtohtml 

-p

    Generate PostScript rather than HTML. This is done using 
HTML::FormatPS and font sizes etc. are not yet specifiable.


and

http://search.cpan.org/~stas/Pod-HtmlPsPdf-0.04/lib/Pod/HtmlPsPdf.pm

-- 
John

A house gecko, and a scorpion drinking
http://johnbokma.com/mexit/2006/05/21/


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

Date: 9 Feb 2007 14:15:57 -0800
From: "Mordecai" <mordecai.crystal@gmail.com>
Subject: Re: Converting perldoc to postscript
Message-Id: <1171059357.682430.26030@h3g2000cwc.googlegroups.com>

On Feb 9, 2:10 pm, John Bokma <j...@castleamber.com> wrote:
> "Mordecai" <mordecai.crys...@gmail.com> wrote:
> > What's the best way to do so?  I hope to get the default man page
> > formatting, not the plain text formatting as specified by "-t".
> > Thanks!
>
> http://search.cpan.org/~ni-s/PodToHTML-0.05/podtohtml
>
> -p
>
>     Generate PostScript rather than HTML. This is done using
> HTML::FormatPS and font sizes etc. are not yet specifiable.
>
> and
>
> http://search.cpan.org/~stas/Pod-HtmlPsPdf-0.04/lib/Pod/HtmlPsPdf.pm
>
> --
> John
>
> A house gecko, and a scorpion drinkinghttp://johnbokma.com/mexit/2006/05/21/

Thanks for the solution but I have neither packages installed at
work...  Also it seems to be an overkill to convert pod to html first
then to ps.  I was hoping to find something that can directly convert
the man page output of "perldoc" to ps, similar to what "man" allows
you to do via the "-t" or "-Tps" option...



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

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


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