#!/usr/bin/perl -w use strict; # 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; print "Input args are: @ARGV\n"; my %hash; foreach my $input (@ARGV) { my($key, $value ) = ($input =~ m/\w/g)[0,1]; #not sure what role if any the |c or |e plays in this? push @{$hash{$key}}, $value; } print Dumper \%hash; __END__ C:\TEMP>perl hasharray2.pl "a,b|c" "c,d|e" "a,d|e" Input args are: a,b|c c,d|e a,d|e $VAR1 = { 'c' => [ 'd' ], 'a' => [ 'b', 'd' ] };