Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

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

I'm settling down to work through the suggestions so far, but I think I could usefully go into a bit more detail now that I've got a better idea of formatting etc. My apologies, I've been an occasional lurker for years but haven't barked before.

What I'm trying to do is take a pattern of some sort, and then to "hiccough" some (but not all) of the lines an indeterminate number of times. So on reflection- and my apologies for not being more explicit first time round- this might be a better example of the required output:

iptables -t nat -N outbound-DMZ iptables -t nat -A outbound-DMZ -o eth1.201 -j SNAT --to-source 90.145 +.84.155 iptables -t nat -A outbound-DMZ -o eth1.200 -j SNAT --to-source 90.145 +.84.155 iptables -t nat -A outbound-DMZ -j RETURN iptables -t nat -A POSTROUTING -j outbound-DMZ

where this shows that the repeated lines are typically in the middle of the block of text rather than at the beginning or end. One idea that occured to me was something like

$commands = &reinterpolate <<"EOF"; iptables -t nat -N outbound-DMZ foreach \$iface (keys \%ipAddress) { iptables -t nat -A outbound-DMZ -o \$iface -j SNAT --to-source \$ipA +ddress{\$iface} } iptables -t nat -A outbound-DMZ -j RETURN iptables -t nat -A POSTROUTING -j outbound-DMZ EOF

where &reinterpolate picks up the lines with and between braces and (eventually) applies eval(), but I can see that some of the suggestions are approaching that.

The system this would be running on is a minimal router, so if possible I'd like to avoid anything that isn't in a typical Linux distro.

MarkMLl

In reply to Re: hiccoughing here documents by Anonymous Monk
in thread hiccoughing here documents by Anonymous Monk

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 imbibing at the Monastery: (6)
As of 2024-04-23 20:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found