Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

OK so I tried as many examples as I could. The one worked but i couldnt' quite do what i needed with it.

Looks like I am right back to square 1. So here is the test scenario that I made. I just need to know what I am doing wrong with my code.(i don't need a "better" way of doing it, unless a good justification can be justified)

this is the file "ip accounting file":

Source Destination Packets Bytes 15.254.32.120 10.2.9.2 5 504 63.97.127.34 10.2.9.2 4 471 17.149.36.162 10.2.9.3 14 3416 79.31.21.75 10.2.9.2 11 3993 209.68.19.130 10.2.9.2 33 15941 72.247.242.235 10.2.9.2 7 3750 17.149.36.15 10.2.9.3 14 3404 65.54.81.34 10.2.9.2 42 23068 67.148.147.64 10.2.9.2 553 274036 67.148.147.65 10.2.9.3 57 39207 8.8.8.8 10.2.9.6 84 8006 Accounting data age is 0w1d Box#

here is the file "include ip file" :

10.2.9.2 10.2.9.3 10.2.9.4 10.2.9.5 10.2.9.6

my code is this:

#!/usr/bin/perl -w open TMPINCLUDEIPFILE, "<", "$tmpincludeipfile"; open TMPIPACCOUNTINGFILE, "<", "$tmpipaccountingfile"; foreach $Line (<TMPINCLUDEIPFILE>) { print "Line = $Line\n"; foreach $Line1 (<TMPIPACCOUNTINGFILE>) { print "Line1 = $Line1\n"; } } exit;

and this code gives me the following output:

./testfile.pl Line = 10.2.9.2 Line1 = Source Destination Packets By +tes Line1 = 15.254.32.120 10.2.9.2 5 +504 Line1 = 63.97.127.34 10.2.9.2 4 + 471 Line1 = 17.149.36.162 10.2.9.3 14 + 3416 Line1 = 79.31.21.75 10.2.9.2 11 +3993 Line1 = 209.68.19.130 10.2.9.2 33 + 15941 Line1 = 72.247.242.235 10.2.9.2 7 + 3750 Line1 = 17.149.36.15 10.2.9.3 14 + 3404 Line1 = 65.54.81.34 10.2.9.2 42 230 +68 Line1 = 67.148.147.64 10.2.9.2 553 + 274036 Line1 = 67.148.147.65 10.2.9.3 57 + 39207 Line1 = 8.8.8.8 10.2.9.6 84 80 +06 Line1 = Line1 = Accounting data age is 0w1d Line1 = Box# Line = 10.2.9.3 Line = 10.2.9.4 Line = 10.2.9.5 Line = 10.2.9.6

The output I expected to see (looking for) is:

Line = 10.2.9.2 Line1 = Source Destination Packets By +tes Line1 = 15.254.32.120 10.2.9.2 5 +504 Line1 = 63.97.127.34 10.2.9.2 4 + 471 Line1 = 17.149.36.162 10.2.9.3 14 + 3416 Line1 = 79.31.21.75 10.2.9.2 11 +3993 Line1 = 209.68.19.130 10.2.9.2 33 + 15941 Line1 = 72.247.242.235 10.2.9.2 7 + 3750 Line1 = 17.149.36.15 10.2.9.3 14 + 3404 Line1 = 65.54.81.34 10.2.9.2 42 230 +68 Line1 = 67.148.147.64 10.2.9.2 553 + 274036 Line1 = 67.148.147.65 10.2.9.3 57 + 39207 Line1 = 8.8.8.8 10.2.9.6 84 80 +06 Line1 = Line1 = Accounting data age is 0w1d Line1 = Box# Line = 10.2.9.3 Line1 = Source Destination Packets By +tes Line1 = 15.254.32.120 10.2.9.2 5 +504 Line1 = 63.97.127.34 10.2.9.2 4 + 471 Line1 = 17.149.36.162 10.2.9.3 14 + 3416 Line1 = 79.31.21.75 10.2.9.2 11 +3993 Line1 = 209.68.19.130 10.2.9.2 33 + 15941 Line1 = 72.247.242.235 10.2.9.2 7 + 3750 Line1 = 17.149.36.15 10.2.9.3 14 + 3404 Line1 = 65.54.81.34 10.2.9.2 42 230 +68 Line1 = 67.148.147.64 10.2.9.2 553 + 274036 Line1 = 67.148.147.65 10.2.9.3 57 + 39207 Line1 = 8.8.8.8 10.2.9.6 84 80 +06 Line1 = Line1 = Accounting data age is 0w1d Line1 = Box# Line = 10.2.9.4 Line1 = Source Destination Packets By +tes Line1 = 15.254.32.120 10.2.9.2 5 +504 Line1 = 63.97.127.34 10.2.9.2 4 + 471 Line1 = 17.149.36.162 10.2.9.3 14 + 3416 Line1 = 79.31.21.75 10.2.9.2 11 +3993 Line1 = 209.68.19.130 10.2.9.2 33 + 15941 Line1 = 72.247.242.235 10.2.9.2 7 + 3750 Line1 = 17.149.36.15 10.2.9.3 14 + 3404 Line1 = 65.54.81.34 10.2.9.2 42 230 +68 Line1 = 67.148.147.64 10.2.9.2 553 + 274036 Line1 = 67.148.147.65 10.2.9.3 57 + 39207 Line1 = 8.8.8.8 10.2.9.6 84 80 +06 Line1 = Line1 = Accounting data age is 0w1d Line1 = Box# Line = 10.2.9.5 Line1 = Source Destination Packets By +tes Line1 = 15.254.32.120 10.2.9.2 5 +504 Line1 = 63.97.127.34 10.2.9.2 4 + 471 Line1 = 17.149.36.162 10.2.9.3 14 + 3416 Line1 = 79.31.21.75 10.2.9.2 11 +3993 Line1 = 209.68.19.130 10.2.9.2 33 + 15941 Line1 = 72.247.242.235 10.2.9.2 7 + 3750 Line1 = 17.149.36.15 10.2.9.3 14 + 3404 Line1 = 65.54.81.34 10.2.9.2 42 230 +68 Line1 = 67.148.147.64 10.2.9.2 553 + 274036 Line1 = 67.148.147.65 10.2.9.3 57 + 39207 Line1 = 8.8.8.8 10.2.9.6 84 80 +06 Line1 = Line1 = Accounting data age is 0w1d Line1 = Box# Line = 10.2.9.6 Line1 = Source Destination Packets By +tes Line1 = 15.254.32.120 10.2.9.2 5 +504 Line1 = 63.97.127.34 10.2.9.2 4 + 471 Line1 = 17.149.36.162 10.2.9.3 14 + 3416 Line1 = 79.31.21.75 10.2.9.2 11 +3993 Line1 = 209.68.19.130 10.2.9.2 33 + 15941 Line1 = 72.247.242.235 10.2.9.2 7 + 3750 Line1 = 17.149.36.15 10.2.9.3 14 + 3404 Line1 = 65.54.81.34 10.2.9.2 42 230 +68 Line1 = 67.148.147.64 10.2.9.2 553 + 274036 Line1 = 67.148.147.65 10.2.9.3 57 + 39207 Line1 = 8.8.8.8 10.2.9.6 84 80 +06 Line1 = Line1 = Accounting data age is 0w1d Line1 = Box#
Is there something wrong with my code? if so, what? thanks in advance! Marc

In reply to Re: Generating a List of numbers by mlebel
in thread Generating a List of numbers by mlebel

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (5)
As of 2024-04-24 08:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found