G::Tools

H2v

Summary Included libraries Package variables Synopsis Description General documentation Methods

Summary
G::Tools::H2v - Perl extension for blah blah blah
Package variables top
Globals (from use vars definitions)
@EXPORT
$VERSION
@EXPORT_OK
Included modulestop
G::Messenger
SubOpt
strict
Inherit top
AutoLoader Exporter
Synopsistop
  use G::Tools::H2v;
blah blah blah
Descriptiontop
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.
Methodstop
DESTROYNo descriptionCode
_csv_h2vNo descriptionCode
_h2vNo descriptionCode
newNo descriptionCode

Methods description


Methods code

DESTROYdescriptiontopprevnext
sub DESTROY {
    my $self = shift;
}
_csv_h2vdescriptiontopprevnext
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;
}
_h2vdescriptiontopprevnext
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;
}
newdescriptiontopprevnext
sub new {
    my $pkg = shift;
    my $filename = shift;
    my $option = shift;
    my $this;

    return $this;
}

General documentation

AUTHOR top
A. U. Thor, a.u.thor@a.galaxy.far.far.away
SEE ALSO top
perl(1).