Allison Ogle wrote:
>
> Hi,
Hello,
> I am trying to figure out how to open a datafile without knowing the name of
> the datafile. For example, using the below code, I can open the datafile
> LogFile.dat from the folder where the script is located. Both the script
> and LogFile.dat are saved in the same folder therefore the below code works.
>
> $inputFile="LogFile.dat";
>
> # Opening LogFile.dat
> open (DATA,$inputFile)||die("Can't open datafile: $!");
>
> However, if I didn't know the name of the datafile how would I open it? I
> tried $inputFile="(*).dat"; and $inputFile="*.dat"; but neither works. Does
> anyone have any ideas? Thanks,
TIMTOWTDI :-)
@inputFiles = glob '*.dat';
@inputFiles = <*.dat>;
@inputFiles = `ls *.dat`;
open D, '.' or die $!;
@inputFiles = grep /\.dat$/, readdir D;
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]