#!/usr/bin/perl use strict; use warnings; use CGI; use Data::Dumper; use Encode qw(encode decode); #use utf8; my $file='ecole.csv'; my $script=$ENV{SCRIPT_NAME} // 'index.pl'; my $cgi=CGI->new(); # decode CGI-Param my $path=decode('UTF-8',$cgi->param('path') // ''); # force UTF-8 binmode(STDOUT,':encoding(UTF-8)'); print $cgi->header(-charset => 'UTF-8'); my $html=load_level($file,$path,$script); print < Burkina Faso Internationalement École/Professeur Informations

Burkina Faso École/Professeur


Région/Province

$html EOHTML sub load_level { my $file=shift; my $path=shift; my $script=shift; my @find=split(/:/,$path); open(my $fh, '<', $file) or return ''; local $/="\x0A"; my @data=<$fh>; close($fh); # decode Windows formated Text (ISO-8859-15); @data=map{ decode('ISO-8859-15',$_) }@data; # bad way to parse CSV @data=map{$_=~tr/\x0A\x0D//d; $_=[split(/;/,$_)]}@data; return _load_level_recursive(\@data,$script,'',@find); } sub _load_level_recursive { my $data=shift; my $script=shift; my $upper=shift; my @find=@_; my %found; my $search=shift(@find); return '' unless(@$data); return '' unless (@{$data->[0]}); # last row in file if(@{$data->[0]}==1) { my $html="\n"; } my $html="\n"; return $html; }