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

Veteran / Moderator

Aug 11, 2012, 9:09 AM

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

I for sure understand that you don't want to process static data appended at the end of your program. That wouldn't be very useful, this was just an example for you. If you were reading from a file lines looking like the sample data at the end of my program, you could use exactly the same syntax.

Your slightly different syntax is correct to visit all the @con array elements.

But for your program as you showed it to work correctly, each of the @con array elements needs to contain a pair of words separated by a white space. For example, you could possibly have:

$con[0] may contain "a b" 
$con[1] may contain "foo bar"
$con[2] may contain "Jan 01"
$con[3] may contain "Feb 02"

The main point is that for the syntax:

foreach (@con) { 
($one, $two) = split ;
# ...

to work correctly, the @con array element being visited must contain two words separated by a white space (or, at least two words, but if there are more than two words, only the first two words would be taken into account).

In other words, each array element must contain something looking more or less like anyone of the lines I used in my input example (except that the words may contain more than one letter).

The alternative is that you tell me what you currently have in the @con array, so that I can change my sample syntax to fit it to your data format, if possible.

Currently, it looks like @con might just be empty. Possibily you chould try to print it contents. Or maybe I could help you if you told me how you are currently trying to populate this array.

(This post was edited by Laurent_R on Aug 11, 2012, 9:17 AM)

Edit Log:
Post edited by Laurent_R (Veteran) on Aug 11, 2012, 9:16 AM
Post edited by Laurent_R (Veteran) on Aug 11, 2012, 9:17 AM

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

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