Advertisement
cd62131

SearchPhoneNumber

Jul 31st, 2014
676
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.69 KB | None | 0 0
  1. #!/usr/bin/perl
  2. # save this file utf8
  3. use strict;
  4. use warnings;
  5. use utf8;
  6. use Encode;
  7. use CGI;
  8. my $q = CGI->new;
  9. my $file = 'bel.csv';
  10. open my $csv, '<:encoding(euc-jp)', $file or die;
  11. my $search = decode_utf8 $q->param('KENSAKU');
  12. my @match = ();
  13. while (<$csv>) {
  14.   chomp;
  15.   my @d = split ',';
  16.   push @match, \@d if $d[0] eq $search;
  17. }
  18. my @td = ();
  19. for (@match) { push @td, $q->td([$_->[1], $_->[2], $_->[3]]) }
  20. print $q->header( -charset => 'UTF-8' ),
  21.   $q->start_html( -title => '番号検索' ),
  22.   $q->h3($search . ' 該当: ' . @match . '名'),
  23.   $q->table( { -border => 1 },
  24.     $q->Tr($q->th(['所属部署', '名前', '番号'])),
  25.     $q->Tr(\@td)
  26.   ),
  27.   $q->end_html;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement