There seems to be a problem and I can`t figure it out.. This is the code:
use strict; use warnings; system('/usr/bin/clear'); print "\n\n"; open(IN1,"/root/work/htb/banner"); open(HTB,">/root/work/htb/full"); my @head_htb=<IN1>; close(IN1); print HTB "@head_htb"; my $DEV = 'dev eth1'; my $count = 500; my %special_subnets = ( 6 => [ 0, 1, 2], 17 => [ 0, 1], 19 => [ 0, 1, 2], ); foreach my $oct1 ( 10 ) { foreach my $oct2 ( 1 .. 22 ) { my $third_octets_aref = $special_subnets{$oct2} || [ 0 ]; foreach my $oct3 ( @{ $third_octets_aref } ) { foreach my $oct4 ( 1 .. 254 ) { # 253 ?? print HTB generate_rule( $DEV, $count, $oct1, $oct2, $oct +3, $oct4 ); $count++; } } } } sub generate_rule { my ( $dev, $count, @octets ) = @_; my $ip = join '.', @octets; #my $countx = '0x' . $count; my $countx = sprintf '0x%04x', $count; return <<"RULE"; class add $dev parent 1:7 classid 1:$count rate 4kbit ceil 512 +Kbit burst 4kbit prio 1 quantum 2000 filter add $dev protocol ip parent 1:0 prio 1 u32 match ip dst + $ip/32 match ip src 0.0.0.0/0 flowid 1:$count qdisc add $dev parent 1:$count handle $countx: pfifo limit 5 RULE } close (HTB);
And the error is :
Can't find string terminator "RULE" anywhere before EOF at genhtb.pl l +ine 44.
As far as I know a ENTER must be pressed after RULE so perl can reconize it as a string terminator..

In reply to Re^2: IP generation algorithm (tc) by giany
in thread IP generation algorithm (tc) by giany

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



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.