in reply to Compress me

You could write the if statement like:

if ($_ =~ /replaceme/) { print $out qq{$_ <FORM METHOD="post" ACTION="$script_url" name="login"> <table ...> ... }; }

Using qq{} (see perlop - Quote and Quote-like Operators) you can dispense with escaping the embedded quotes, you won't need the terminal newline and there's only one print statement. You could also use a here document which is described in the same documentation.

-- Ken

Replies are listed 'Best First'.
Re^2: Compress me
by choroba (Cardinal) on Nov 07, 2010 at 23:11 UTC
    Using <<EOF (aka here-doc) for the form is another option.
Re^2: Compress me
by toniax (Scribe) on Nov 07, 2010 at 18:36 UTC
    Hi Ken,
    Your code change worked great . I did notice something odd though .
    The closing bracket on the qq can not have any spaces between it or the last character or the space is translated to the next line. I do not quite understand why?
    Thanks again Ken

      That's sort of what my "... you won't need the terminal newline ..." was referring to.

      When you have a quoted string that extends over more than one line, you have embedded newlines - these are the ones you typed at the keyboard (not explicit \n characters).

      Your original last two lines:

      <td> <table><tr><td><br>\n";

      are actually:

      <td>{embedded newline} <table><tr><td><br>\n";

      You could have achieved the same output with:

      <td> <table><tr><td><br> ";

      which is actually:

      <td>{embedded newline} <table><tr><td><br>{embedded newline} ";

      Although I used ellipses, what you see on the screen:

      <table ...> ... };

      is actually:

      <table ...>{embedded newline} ...{embedded newline} };

      I hope that explains it. If not, please show an example of exact output.

      -- Ken

        Hello Ken,
        I understand what you are saying now. my mistake was
        print $out qq{ <FORM METHOD = post ACTION = $script_url name=login> <table border=0 cellpadding=4 cellspacing=4 width=470> <tr> <td> <table><tr><td>Category<br> } <----My mistake should of been print $out qq{ <FORM METHOD = post ACTION = $script_url name=login> <table border=0 cellpadding=4 cellspacing=4 width=470> <tr> <td> <table><tr><td>Category<br> } <----The fix it forced a new line so the line below it was not on the same line as <table><tr><td>Category<br>