in reply to tabular format of data

my @data = map {chomp; [split /:/]} <DATA>; my $width = length $data[0][0]; # Assume they're all the same length +. my $Width = @{$data[0]}; my $divider = "-" x (($width + 1) * $Width); my $topline = $divider x 2; chop $topline; say $topline; foreach my $line (@data) { print "$_|" for @$line; say "\n$divider"; } __DATA__ A:B C:D
This prints:
------- A|B| ---- C|D| ----

Replies are listed 'Best First'.
Re^2: tabular format of data
by deepak_4682us (Initiate) on Feb 18, 2012 at 00:54 UTC
    Actually, I have stored column1 values in Arr1 and column two values in Arr2. Is it possible to represetn them in tabular format?
      Sure. Replace my first line with:
      my @data; foreach (my $i = 0; $i < @Arr1 && $i < @Arr2; $i++) { $data[$i] = [$Arr1[$i], $Arr2[$i]]; }
      A reply falls below the community's threshold of quality. You may see it by logging in.
      A reply falls below the community's threshold of quality. You may see it by logging in.
      Sure, show your code
        A.txt:- A:B C:D code: # it has column1 values of txt file @a1=`cut -d":" -f1 < A.txt; # it has column2 values of txt file @a2=`cut -d":" -f2 < A.txt; I wanted to reprent the values in tabular form
      A reply falls below the community's threshold of quality. You may see it by logging in.
      A reply falls below the community's threshold of quality. You may see it by logging in.
      A reply falls below the community's threshold of quality. You may see it by logging in.
Re^2: tabular format of data
by deepak_4682us (Initiate) on Feb 18, 2012 at 04:16 UTC
    also i have tried the above code.. its printing like A |B |C |D
A reply falls below the community's threshold of quality. You may see it by logging in.