N
nj_perl_newbie
I am trying to extract the first string from a filename that is
delimitted by "."s. I want this sub routine to read the contents of a
directory and define the first field as a variable.
a directory with contents:
joe.2004039201.xl.b.csv
judy.200312123.x5.b.csv
would return joe as username and then judy as a username
this is what I have thusfar:
opendir(DIR,"<$dir") or die "Error $! opening directory.";
my(@filenames) = readdir(DIR);
my ($first,undef,undef,undef,undef) = split /\./, $_;
$username = $first;
&log_entry($logfh, "Username is: $username") if $debug;
close(DIR);
I am guessing that I need a while or something in line three to tell
it to split @filenames....but I am lost so that's why I am
posting...any help would be appreciated.
delimitted by "."s. I want this sub routine to read the contents of a
directory and define the first field as a variable.
a directory with contents:
joe.2004039201.xl.b.csv
judy.200312123.x5.b.csv
would return joe as username and then judy as a username
this is what I have thusfar:
opendir(DIR,"<$dir") or die "Error $! opening directory.";
my(@filenames) = readdir(DIR);
my ($first,undef,undef,undef,undef) = split /\./, $_;
$username = $first;
&log_entry($logfh, "Username is: $username") if $debug;
close(DIR);
I am guessing that I need a while or something in line three to tell
it to split @filenames....but I am lost so that's why I am
posting...any help would be appreciated.