G'day yunfei,

Welcome to the monastery.

Please provide a self-contained piece of code which reproduces your problem. (Guidelines for doing this can be found in: How do I post a question effectively?)

The following code simulates what you're describing but does not reproduce the problem.

#!/usr/bin/env perl use strict; use warnings; while (my $file = <DATA>) { print '-' x 60, "\n"; chomp $file; print "******processing <<<<${file}>>>\n\n"; if ($file =~/(zip$)|(gz$)|(tar$)|(bz$)|(bz2$)/i) { print "IF: $file\n"; } elsif ($file =~/md5$/i) { print "ELSIF: $file\n"; } print '-' x 60, "\n"; } __DATA__ /home/user/projects/database/bwa/index_bwa_human_b36_both.fasta.tar.gz /home/user/projects/database/bwa/index_bwa_human_b36_both.fasta.index. +tar.gz.md5

Output:

$ pm_weird_print.pl ------------------------------------------------------------ ******processing <<<</home/user/projects/database/bwa/index_bwa_human_ +b36_both.fasta.tar.gz>>> IF: /home/user/projects/database/bwa/index_bwa_human_b36_both.fasta.ta +r.gz ------------------------------------------------------------ ------------------------------------------------------------ ******processing <<<</home/user/projects/database/bwa/index_bwa_human_ +b36_both.fasta.index.tar.gz.md5>>> ELSIF: /home/user/projects/database/bwa/index_bwa_human_b36_both.fasta +.index.tar.gz.md5 ------------------------------------------------------------

In your while(<DBNAME>) {...} loop, it would be useful to show the raw data before and after modification as well as how that ties in with $file="$dir/$file";.

Also, please correct the typo in the title: s/wired/weird/

-- Ken


In reply to Re: weird print output by kcott
in thread weird print output by yunfei

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.