hi I have a problem with the following script:-
#!/usr/bin/perl -w
use strict;
use warnings;
use File::Copy;
my $file = 'm:serverlist1.txt';
open (INFO, $file);
while ($file = )
{
#chomp $file;
#print $file;
copy("m:\robcop\screenshots1.doc","$file")or die "Copy failed: $!";
#print "copied to $file
";
}
it fails on path not found,
yet the list of paths
\\server1\userinfo\sfm\fact sheets\
\\server2\userinfo\sfm\fact sheets\
\\server3\userinfo\sfm\fact sheets\
is correct, and if I type one of these lines in in place of $file it works no problem.
Can anyone help
Comments
:
: #!/usr/bin/perl -w
: use strict;
: use warnings;
: use File::Copy;
: my $file = 'm:serverlist1.txt';
: open (INFO, $file);
: while ($file = )
: {
:
: #chomp $file;
Keep the chomp. It's your friend.
: #print $file;
: copy("m:\robcop\screenshots1.doc","$file")or die "Copy failed: $!";
: #print "copied to $file
";
: }
:
: it fails on path not found,
: yet the list of paths
: \\server1\userinfo\sfm\fact sheets\
: \\server2\userinfo\sfm\fact sheets\
: \\server3\userinfo\sfm\fact sheets\
:
: is correct, and if I type one of these lines in in place of $file it works no problem.
: Can anyone help
:
Is that list of paths stored in the file? If so, you don't need to escapse 's in files.
\server1userinfosfmfact sheets
\server2userinfosfmfact sheets
\server3userinfosfmfact sheets
You only need to do that in literals in your Perl script that are in interpolative context. By that I mean:-
print "Escpae \ in double quotes";
print 'No need to escape in single quotes';
If you hava a variable inbetween double quotes it doesn't have to have the escaped data etc - it's only for data you have directly in your program. Hope that makes sense.
Also, minor style point - you did "$file". For just one variable you can do away with the quotes, just write $file.
Hope this helps,
Jonathan
###
for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
(tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
/(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");