hey buddies, here i have write the perl code. actually this code has been worked in windows platfotm. but it does not run in linux platform.. main intension of code is "Read the directory and modify the content. 
use strict; use Cwd; my ($path,$dir); my @textfiles; if (@ARGV) { $path = $ARGV[0]; $dir = ( $path )?$path:getcwd(); opendir DIR,$dir or die "can't read '$dir' $!\n"; @textfiles = map{ "$dir\\$_" }grep{ /\.txt$/ }readdir( DIR ); closedir DIR; } else { opendir(DIR,'.') || die "Can't read current directory: $!\n"; @textfiles = sort grep /\.txt$/i, readdir DIR; closedir DIR; } die "\n Didn't get TEXT files to validate.\n" if (@textfiles == 0); print "\nChecking the TEXT Files...."; foreach my $textfiles (@textfiles) { unless(-f $textfiles and -e $textfiles) { print "\nInvalid. Please specify valid Input text File.\n"; } print "\n\tProcessing................. $textfiles"; open IN, $textfiles || die "Can't open the '$textfiles' for initia +l cleanup"; { local $/; $_ = <IN>; close IN; } my $tmp = $_; $tmp=~ s{\n{2}}{\n}gi; $tmp=~ s{([^-])--([^-])}{$1 – $2}gi; my $outfile = $textfiles; $outfile =~ s/\.txt/\.convtxt/g; $outfile =~ s/\.convtxt/\.txt/g; #open (OUT, ">Out-$ARGV[0]") or die "Cannot create the output file +"; open OUT, ">$outfile" || die "Can't create the output file:'$outfi +le'"; print OUT $tmp; close OUT; }

20080825 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips


In reply to i could not abl to get proper result belowed mntioned code.. by senthil_v

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.