Here i am having " .tmideg0
"hidden file .
I have made programm but it doesnot work
#!/usr/bin/perl
$runDir = $ENV{"REGR_RUN_DIR"};
@files = (<*.tmideg0> <*.tmideg1>);
foreach $FILE (@files)
{
open (IN, $FILE) || die "Couldn't open $FILE for reading";
open (OUT, ">$runDir/$FILE.dat") || die "Couldn't open $FILE for reading";
while(<IN>) {
print OUT $_;
}
}
close(IN);
close(OUT);
---------- Post updated at 02:43 PM ---------- Previous update was at 11:09 AM ----------
here i am having code
in which it convert all ".txt" file to ".txt.dat" file but i want ".dat file" how to do it.
#!/usr/bin/perl
$runDir = $ENV{"REGR_RUN_DIR"};
@files = (<*.txt>);
foreach $FILE (@files)
{
open (IN, $FILE) || die "Couldn't open $FILE for reading";
open (OUT, ">$runDir/$FILE.dat") || die "Couldn't open $FILE for reading";
while(<IN>) {
print OUT $_;
}
}
close(IN);
close(OUT);
First off, "doesn't work" is not an error description becoming to a professional programmer. How did it "not work"? Core dump? File not found? Syntax error? Interpreter having a bad day? Other?
You might as well start with developing good habits and this includes: analysis of an error includes to describe everything related to it: the error messages, other diagnostic messages, description of what happened, etc., etc..
In your case most probably this:
@files = (<*.tmideg0> <*.tmideg1>);
is the culprit: file(name)s starting with a "." are not expanded by usual file globs. Try:
@files = (<.*tmideg0> <.*tmideg1>);
to include files starting with a "." and ending in "tmideg0", i.e. ".tmideg0", ".bla-footmideg0", etc. into your glob.
I hope this helps.
bakunin
I am certainly not an expert using perl
, but for your original problem, please try changing:
@files = (<*.tmideg0> <*.tmideg1>);
to:
@files = (<.tmideg0>, <.tmideg1>);
or:
@files = (<.tmideg[01]>);