CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner: Re: [rushadrena] Representing a connection matrix of graph: Edit Log


Aug 11, 2012, 8:34 PM

Views: 3868
Re: [rushadrena] Representing a connection matrix of graph

Laurent is certainly right. Your requirements are hopelessly inconsistent from one post to the next. I have answered a nearly identical post in the perl monks forum. This suggests that either this is a school assignment or you have no interest in learning perl, but want someone to do your work for you. If this is not true, I suggest that you post a complete working package, including your perl code, all referenced data files, instructions for running it, and the exact output expected. We will be able to run it, examine the output, and help you correct the code.

Your post #15 is a step in the right direction, but I am not sure what code you are using or exactly what is wrong. I do not see any need for either @array or @con. I would parse the arguments with a regular expression, and store the data directly in the hash. Note: Your sample data is used if no arguments are provided.


# Takes input in the form 'a,b|c'
# How to run : perl 'a,b|c' 'c,d|e' 'a,d|e'
# Outputs a NX3 for the above input data.
# Outputs connections in Nx2 form
use strict;
use warnings;

@ARGV = ('a,b|c', 'c,d|e', 'a,d|e') unless @ARGV;

my %HoA;
foreach ( @ARGV ) {
m/^([a-z])[,]([a-z])[|]([a-z])$/ ;
push @{$HoA{$1}}, $2;
print "\n===========\@HoA=====\n";
print "from->to\n";
while (my ($key, $values) = each %HoA) {
print $key, "=> [", join(',', @$values), "]\n";

SAMPLE_OUTPUT (default data)


c=> [d]
a=> [b,d]

Good Luck,

(This post was edited by BillKSmith on Aug 11, 2012, 8:58 PM)

Edit Log:
Post edited by BillKSmith (Veteran) on Aug 11, 2012, 8:58 PM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives