G::Tools
H2v
G::Tools::H2v - Perl extension for blah blah blah
|
Globals (from use vars definitions) |
@EXPORT |
$VERSION |
@EXPORT_OK |
use G::Tools::H2v; blah blah blah
|
Stub documentation for G::Tools::H2v was created by h2xs. It looks like the author of the extension was negligent enough to leave the stub unedited.
Blah blah blah.
|
DESTROY | No description | Code |
_csv_h2v | No description | Code |
_h2v | No description | Code |
new | No description | Code |
Methods description
Methods code
sub DESTROY
{ my $self = shift;
}
sub _csv_h2v
{ my $infile = shift;
my $outfile = shift;
my @array = ();
my $i = 0;
my $j = 0;
open(INFILE, $infile) || die ("$!");
while(<INFILE>){
chomp;
$array[$i] = [split(/,/)];
$i ++;
}
close(INFILE);
&h2v(\@array);
open(OUTFILE, '>' . $outfile) || die ("$!");
foreach my $ref (@array){
foreach my $cell (@$ref){
print OUTFILE $cell . ',';
}
print OUTFILE "\n";
}
close(OUTFILE);
return 1;
}
sub _h2v
{ my $ref_array = shift;
my $i = 0;
my $j = 0;
my @array = ();
my $maxcol = 0;
my $maxrow = 0;
for ($i = 0; defined($ref_array->[$i][$j]); $i ++){
for ($j = 0; defined($ref_array->[$i][$j]); $j ++){
$array[$j][$i] = $ref_array->[$i][$j];
}
$maxcol = $j if ($maxcol < $j);
$j = 0;
}
$maxrow = $i;
for ($i = 0; $i <= $maxrow; $i ++){
@$ref_array->[$i] = ();
for ($j = 0; $j <= $maxcol; $j ++){
$ref_array->[$i][$j] = $array[$i][$j] if (defined($array[$i][$j]));
}
$j = 0;
}
return 1;
}
sub new
{ my $pkg = shift;
my $filename = shift;
my $option = shift;
my $this;
return $this;
}
General documentation