D
David K. Worman
So this is probably a simple thing I'm missing, but then I just started
working with perl tonight - and of course I bought the Camel book, and
conveniently left it at work on my desk where it does me no good.
What I'm trying to do is this; I have a single document (template.doc)
that I need a copy of for ~50 people currently, and rather than just
copying it 50 times and renaming them I decided to play with perl instead.
This is what I've come up with so far, going from memory of what I read in
the Camel book thus far.
#!/usr/bin/perl -w
$UNAMES = "unames.txt";
open(UNAMES) || die "Can't open $UNAMES: $!n";
while (<UNAMES>) {
$src = "template\.doc";
($dest = $_) =~ s/\w*/$_\.doc/;
system("cp $src $dest");
}
close(UNAMES);
die();
----
The file 'unames.txt' is just a \n delimited text file like so:
foo
bar
foo_bar
The result I get when running the script is three copies of template.doc
(this is good!) named foo, bar, and foo_bar (this is bad!) instead of
foo.doc, etc.
Can anyone point out what I'm sure is a simple mistake? Thanks in
advance.
working with perl tonight - and of course I bought the Camel book, and
conveniently left it at work on my desk where it does me no good.
What I'm trying to do is this; I have a single document (template.doc)
that I need a copy of for ~50 people currently, and rather than just
copying it 50 times and renaming them I decided to play with perl instead.
This is what I've come up with so far, going from memory of what I read in
the Camel book thus far.
#!/usr/bin/perl -w
$UNAMES = "unames.txt";
open(UNAMES) || die "Can't open $UNAMES: $!n";
while (<UNAMES>) {
$src = "template\.doc";
($dest = $_) =~ s/\w*/$_\.doc/;
system("cp $src $dest");
}
close(UNAMES);
die();
----
The file 'unames.txt' is just a \n delimited text file like so:
foo
bar
foo_bar
The result I get when running the script is three copies of template.doc
(this is good!) named foo, bar, and foo_bar (this is bad!) instead of
foo.doc, etc.
Can anyone point out what I'm sure is a simple mistake? Thanks in
advance.