Hi guys, I have a program that I am trying to write for the llama. it is question 4 of chapter 9.

It asks the student to "Write a program to add a copyright line to all of your programs, so far by placing a line such as ' ## Copyright 200x (C) by Yours Truly.

Place it in the file immediately following the shebang line. You should edit the files "in place" and keep a backup. Presume that the programs should be invoked with the filenames on the command line.

here's my answer:
#!/usr/bin/perl use strict; use warnings; $^I = ".old"; while (<>) { if (/^#!/) { $_ .= " ## Copyright (C) 2008 Yours Truly\n"; } }
But what this code does is thankfully backup the original file, but"clobber" the contents of the file it's supposed to be editing. The output is completely blank, and I don't understand why.

Any help here would be greatly appreciated!

In reply to clobbering output 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.