HTML创建列表的快捷写法,perl 用HTML格式列表和表的快捷方式

[perl]代码库#-----------------------------

print ol ( li ( [ qw ( red blue green ) ] ) );

#

  1. red
  2. blue
  3. green

@names = qw ( Larry Moe Curly );

print ul ( li ( { -TYPE => "disc" }, \@names ) );

#

  • Larry
  • Moe

#

#

Curly

#-----------------------------

print li ( "alpha" );

#

alpha

print li ( [ "alpha", "omega"] );

#

alpha omega

#-----------------------------

use CGI qw ( :standard :html3 );

%hash = (

"Wisconsin" => [ "Superior", "Lake Geneva", "Madison" ],

"Colorado" => [ "Denver", "Fort Collins", "Boulder" ],

"Texas" => [ "Plano", "Austin", "Fort Stockton" ],

"California" => [ "Sebastopol", "Santa Rosa", "Berkeley" ],

);

$\ = "\n";

print "

print Tr ( th [qw ( State Cities ) ] );

for $k ( sort keys %hash )

{

print Tr ( th ( $k ), td ( [ sort @ {$hash{$k}} ] ) );

}

print "

";

#-----------------------------

#

#

#

State Cities

#

#

California Berkeley Santa Rosa

#

#

Sebastopol

#

#

Colorado Boulder Denver

#

#

Fort Collins

#

#

Texas Austin Fort Stockton

#

#

Plano

#

#

Wisconsin Lake Geneva Madison

#

#

Superior

#

#

#-----------------------------

print table

caption ( 'Cities I have Known' ),

Tr ( th [qw ( State Cities ) ] ),

map { Tr ( th ( $_ ), td ( [ sort @{$hash{$_}} ] ) ) } sort keys %hash;

#-----------------------------

# download the following standalone program

#!/usr/bin/perl

# salcheck - check for salaries

use DBI;

use CGI qw ( :standard :html3 );

$limit = param ( "LIMIT" );

print header(), start_html ( "Salary Query" ),

h1 ( "Search" ),

start_form(),

p ( "Enter minimum salary", textfield ( "LIMIT" ) ),

submit(),

end_form();

if ( defined $limit )

{

$dbh = DBI->connect ( "dbi:mysql:somedb:server.host.dom:3306",

"username", "password" )

or die "Connecting: $DBI::errstr";

$sth = $dbh->prepare ( "SELECT name,salary FROM employees

WHERE salary > $limit" )

or die "Preparing: ", $dbh->errstr;

$sth->execute

or die "Executing: ", $sth->errstr;

print h1 ( "Results" ), "

while ( @row = $sth->fetchrow() )

{

print Tr ( td ( \@row ) );

}

print "

\n";

$sth->finish;

$dbh->disconnect;

}

print end_html();

#-----------------------------

694748ed64b9390909c0d88230893790.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值