Hello Monks!

Finally had an occasion to use perl for something other than to complete an exercise in the llama! Still making newbish mistakes though.

The idea here is to parse some config files that reveal my database password and replace the real password with a fake password. Also does the same to hide the name of the database user. I call the program "cleaner". :)

I think I'm close to getting it to work. It does alter the username and password in the output. But when I examine the original files with cat the file is unchanged.

I think I need to select the file for output, but I am a little unsure of the usage. I'd appreciate any advice you might have.

Here's the program in question:
#!/usr/bin/perl -w use strict; foreach (@ARGV) { while (<>) { s/\s+myOldPass/ Onl33In05h15notmyreallpass/g; s/\s+myDBUser/ my-secret-db-user/g; print; } }

My ultimate goal is to be able to safely pastebin my config files to IRC so that some postfix genius can help me figure out why my postfix setup is not talking to MySQL.

Thanks guys! Very excited to be using Perl for a real world application for the first time!

In reply to Files not altered by bluethundr

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.