Reference
NamingSense::TokuLog! - アートワークを Perl で設定する方法http://d.hatena.ne.jp/tokuhirom/20060218/1140279373
use Number::Phone::JP;
my $tel = Number::Phone::JP->new('012', '34567890');
print "This is valid!!\n" if $tel->is_valid_number;
$tel->set_number('098 7654 3210');
print "This is valid!!\n" if $tel->is_valid_number;
$tel->import(qw(mobile PHS));
$tel->set_number('090-0123-4567');
print "This is valid!!\n" if $tel->is_valid_number;
use Regexp::Assemble;
my $ra = Regexp::Assemble->new;
$ra->add( 'ab+c' );
$ra->add( 'ab+-' );
$ra->add( 'a\w\d+' );
$ra->add( 'a\d+' );
print $ra->re; # prints a(?:\w?\d+|b+[-c])
use CGI;
use Authen::TypeKey;
my $q = CGI->new;
my $tk = Authen::TypeKey->new;
$tk->token('typekey-token');
my $res = $tk->verify($q) or die $tk->errstr;
## In httpd.conf or .htaccess:
PerlModule Apache::AuthTypeKey
PerlSetVar TypeKeyPath /
PerlSetVar TypeKeyLoginScript /login.pl
## These documents require user to be logged in.
<Location /protected>
AuthType Apache::AuthTypeKey
AuthName TypeKey
PerlAuthenHandler Apache::AuthTypeKey->authenticate
require valid-user
PerlSetVar TypeKeyToken your_token
</Location>
## This is the _return URL that the login.pl script should point to.
<Location /login-protected>
AuthType Apache::AuthTypeKey
AuthName TypeKey
SetHandler perl-script
PerlHandler Apache::AuthTypeKey->login
PerlSetVar TypeKeyToken your_token
</Location>
#!/usr/bin/perl
use Email::Valid;
print (Email::Valid->address('user@example.com') ? 'yes' : 'no');
#!/usr/bin/perl
use Mail::CheckUser qw(check_email last_check);
my $email = 'user@example.com';
if(check_email($email)) {
print "E-mail address <$email> is OK\n";
} else {
print "E-mail address <$email> isn't valid: ", last_check()->{reason}, "\n";
}
use Data::Validate::Email qw(is_email is_email_rfc822);
if(is_email($suspect)){
print "Looks like an email address\n";
} elsif(is_email_rfc822($suspect)){
print "Doesn't much look like an email address, but passes rfc822\n";
} else {
print "Not an email address\n";
}
1. | [Perl] | XML over HTTP な API を叩く |
2. | [Perl] | XML::Simple で parse |
3. | [Perl] | そのまま objToJson でJSONに変換 |
4. | [JavaScript] | XMLHttpRequest で結果取得 |
5. | [JavaScript] | JSON を eval |
6. | [JavaScript] | 復元したデータで DHTML |
#!/usr/bin/perl
use strict;
use warnings;
use Term::ANSIColor qw(:constants);
$Term::ANSIColor::AUTORESET = 1;
print BOLD RED "RED\n";
print BOLD GREEN "GREEN\n";
print BOLD BLUE "BLUE\n";
MySQL | PHP | $sql = mysql_escape_string($sql); |
MySQL | Perl | $sql =~ s/'/''/g; $sql =~ s/\\/\\\\/g; |
PostgreSQL | PHP | $sql = pgsql_escape_string($sql); |
PostgreSQL | Perl | $sql =~ s/'/''/g; $sql =~ s/\\/\\\\/g; |
SQLite | PHP | $sql = sqlite_escape_string($sql); |
Linux | PHP | $str = escapeshellarg($str); |
Linux | Perl | $str =~ s/'/\\'/g; |
PHP | $str = htmlspecialchars($str); |
Perl | $str =~ s/</g; |
#!/usr/bin/perl
use strict;
use warnings;
use POSIX qq(strftime);
$| = 1;
while (defined(my $line = <>)) {
print strftime('%Y/%m/%d %H:%M:%S ', localtime), $line;
}
% ping localhost | puttime
2005/12/09 02:16:08 PING localhost (127.0.0.1): 56 data bytes
2005/12/09 02:16:08 64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.0 ms
2005/12/09 02:16:09 64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.0 ms
2005/12/09 02:16:10 64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.0 ms
2005/12/09 02:16:11 64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.0 ms
2005/12/09 02:16:12 64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.0 ms
- Reference
スペースモラトリアムノカミサマ - 2005-12-05 - 入力行に時刻を付けて吐き出すフィルタ
http://pmakino.jp/tdiary/20051205.html#p01