Much of what you wrote in reply to my post seems to have no bearing whatsoever on my post. For instance, "there should not be a TAB in the beggining ...": none of the output I showed had a tab at the beginning of any line. I'm going to ignore all such content. Please ensure you're replying to the correct post; and, for clarity, add some indication showing to what your response refers (e.g. You wrote X; I think Y).

Where and how you get your filenames is entirely up to you. I used hard-coded filenames for demo purposes only. I often use a prefix of pm_NODE-ID_ for demo files: it provides unique names as well as a reference back to the associated PM node. If you're reading from @ARGV, you should include some sanity checking; in this instance, check that @ARGV has two elements, with the first being a valid file. Also take a look at Getopt::Long.

"I have tried print $out_fh $_ =~ y/\t/\t{3}/rs;"

That's not how transliteration works. See y/// and consider:

$ perl -E 'my $x = "A\tB\t\tC"; say $x; say $x =~ y/\tABC/\t{3}/rs;' A B C { 3 }
"I guess you forgot to close files"

No, I certainly did not forget to do that. I declared, and used, lexical filehandles in the smallest scope possible (the anonymous block). Perl automatically closes files at the end of that scope.

I also didn't forget to check for I/O exceptions. Again, Perl does this for me via the autodie pragma.

I have commented

# use 5.014; # use warnings; # use autodie;

because I have useless warnings ...

That's a very bad move and I strongly recommend that you do not do this. Parentheses missing around ... is the only warning; all the rest are errors (note the Execution of 02-00.pl aborted due to compilation errors. as the last line). Furthermore, none of those messages are "useless"!

As you're not checking for I/O exceptions, you should definitely use the autodie pragma and let Perl do it for you.

— Ken


In reply to Re^3: misalined TABs using substr,LAST_MATCH_START/END,regex by kcott
in thread misalined TABs using substr,LAST_MATCH_START/END,regex by perl_boy

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.