why does this not work

L

Lowell Kirsh

I'm trying to write a simple file-copy script on Windows and I can't
figure out why it's not working. Here's part of what I have:

my $fromDir = "C:\\Documents and Settings\\user\\Application
Data\\Mozilla\\Profiles\\default\\iw2wx3e0.slt\\";

my $fromFile = "\"${fromDir}bookmarks.html\"";

Now, at this point, '-r $fromFile' returns false, but I know the file is
there because in the same script I put in 'system "cat $fromFile"' and
this print the contents to screen, proving the file is really there.
What am I doing wrong?

Lowell
 
J

John J. Trammell

I'm trying to write a simple file-copy script on Windows and I can't
figure out why it's not working. Here's part of what I have:

my $fromDir = "C:\\Documents and Settings\\user\\Application
Data\\Mozilla\\Profiles\\default\\iw2wx3e0.slt\\";

my $fromFile = "\"${fromDir}bookmarks.html\"";
^^ ^^

Too many "s.

How about:

my $from_dir = "C:/Documents and Settings/user/whatever/.../";
my $from_file = $from_dir . "bookmarks.html";
 
A

A. Sinan Unur

I'm trying to write a simple file-copy script on Windows and I can't
figure out why it's not working. Here's part of what I have:

my $fromDir = "C:\\Documents and Settings\\user\\Application
Data\\Mozilla\\Profiles\\default\\iw2wx3e0.slt\\";

use strict;
use warnings;

use File::Spec;

my $full_path = File::Spec->catfile(
$ENV{USERPROFILE}, 'Application Data', 'Mozilla',
'Profiles', 'default', 'iw2wx3e0.slt', 'bookmarks.html'
);

print qq{"$full_path"};

Reduces time spent escaping quotes, slashes etc.
 
L

Lowell Kirsh

It seems a bit verbose to be using in my throw-away scripts. Perhaps
it'd be useful for longer programs. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,147
Messages
2,570,835
Members
47,382
Latest member
MichaleStr

Latest Threads

Top