Hi all,
This is my code along with the output. I'm expecting this:-
(a=>[b,d],c=>[d])
But its printing garbage addresses from memory
# Takes input in the form 'a,b|c'
# How to run : perl code.pl 'a,b|c' 'c,d|e' 'a,d|e'
# Outputs a NX3 for the above input data.
# Outputs connections in Nx2 form
use Data::Dumper;
$arg=join(' ',@ARGV);
@det=split //, $arg;
for ($i=0; $i <=8; $i++)
{$trip[$i]=$det[2*$i];}
my @array;
while (@trip) {
push(@array, [ splice(@trip, 0, 3) ]);
}
print "@$_\n" for @array;
for ($i=0; $i <=2; $i++)
{
for ($j=0; $j <=1; $j++)
{ $con[$i][$j]=$array[$i][$j];}
}
print "\n==========connections======\n";
print "from->to\n";
print " @$_\n" for @con;
my %HoA;
foreach (@con) {
($key, $value) = split;
push @{$HoA{$key}}, $value;
}
# PRINTING THE HASH
foreach (keys %HoA) {
print "$_ => $HoA{$_}\n";
}
======OUTPUT======
xguest@localhost Downloads$ perl code.pl 'a,b|c' 'c,d|e' 'a,d|e'
a b c
c d e
a d e
==========connections======
from->to
a b
c d
a d
ARRAY(0x95a5fd4) :
ARRAY(0x95a6014) :
ARRAY(0x95a6134) :
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.