S
shumaker
I am writing a DTS package task in perl but am having trouble with the
glob statment. Basically I want to take all *.dat files in a certain
directory, read them in line by line and output them to a single output
file. I have to use full path names because I don't run the perl
script from a specific directory, it's run by the sql server. (Unless
someone knows how to set the working directory from the perl script?)
I set mydirectory to the value of a global DTS package variable, which
is a user supplied string
$mydirectory == "M:/Database Files/Import/"
open(OUT,"> ".$mydirectory."outputfilename.txt") or
die "Can't open output file: $!";
The output file is created in $mydirectory with no problem, but the
data isn't getting read in.
The script worked fine with:
while (glob "*.dat")#for each .dat file
{
open(IN,$_); #open the .dat file
.. . .
when it was a regular script being run from the directory, but when I
try to tell it to search a specific directory:
while (glob $mydirectory."*.dat")
{
open(IN,$_); #open the .dat file
.. . .
Nothing is getting written to me output file, and I'm pretty sure it's
something to do with my syntax for the glob or how I'm specifying the
path string.
PS. If my string variable contains single backslash characters instead
of forward slash characters, do the backslashes get treated as escape
sequences, or are escape sequences only interpreted in string literals?
glob statment. Basically I want to take all *.dat files in a certain
directory, read them in line by line and output them to a single output
file. I have to use full path names because I don't run the perl
script from a specific directory, it's run by the sql server. (Unless
someone knows how to set the working directory from the perl script?)
I set mydirectory to the value of a global DTS package variable, which
is a user supplied string
$mydirectory == "M:/Database Files/Import/"
open(OUT,"> ".$mydirectory."outputfilename.txt") or
die "Can't open output file: $!";
The output file is created in $mydirectory with no problem, but the
data isn't getting read in.
The script worked fine with:
while (glob "*.dat")#for each .dat file
{
open(IN,$_); #open the .dat file
.. . .
when it was a regular script being run from the directory, but when I
try to tell it to search a specific directory:
while (glob $mydirectory."*.dat")
{
open(IN,$_); #open the .dat file
.. . .
Nothing is getting written to me output file, and I'm pretty sure it's
something to do with my syntax for the glob or how I'm specifying the
path string.
PS. If my string variable contains single backslash characters instead
of forward slash characters, do the backslashes get treated as escape
sequences, or are escape sequences only interpreted in string literals?