Hello All,
Is the only way to copy a file from one directory to another by using the
copy module...?
Would anyone have a snipet of code copying a file from one dir to another...
Any assistance would be appreciated...
Thank you,
Mike
Hello All,
Is the only way to copy a file from one directory to another by using the
copy module...?
Would anyone have a snipet of code copying a file from one dir to another...
Any assistance would be appreciated...
Thank you,
Mike
------------------------------------------------
> Hello All,
> Is the only way to copy a file from one directory to another by using the
> copy module...?
> Would anyone have a snipet of code copying a file from one dir to another...
> Any assistance would be appreciated...
my $result = `cp $file $newfile`;
Or you could do the really tedious, open the file for reading, open the new file for writing, read the contents of the read file and print to the write file, close both files. But why would you want to do that? Is there a particular reason for avoiding File::Copy?
http://danconia.org
Have you checked the docs for File::Copy ?Quote:> Is the only way to copy a file from one directory to another
> by using the
> copy module...?
> Would anyone have a snipet of code copying a file from one
> dir to another...
> Any assistance would be appreciated...
one example:
--------
use strict;
use File::Copy;
# a bunch of file with foo*
foreach (glob '/home/foo*')
{
next if ! -f $_; # copy files only, not directories
print "Copying $_ ...\n";
copy ($_, '/where/to') or warn "Failed to copy $_ : $!\n";
Quote:}
link (sourcefile, destination);
Creates a hard link to an existing file. A hard link is a new inode that
points to an existing data stream; that is, it's a duplicate directory entry
for an existing file. The duplicate has a different name and different
permissions and access times. Only the inode field (from the stat function)
is identical to the original.
Hello All,
Is the only way to copy a file from one directory to another by using the
copy module...?
Would anyone have a snipet of code copying a file from one dir to another...
Any assistance would be appreciated...
Thank you,
Mike
--
Sorry. I misread your question. You could shell out to the system copy asQuote:> > Is the only way to copy a file from one directory to another
> > by using the
> > copy module...?
Quote:> one example:
> --------
> use strict;
> use File::Copy;
> # a bunch of file with foo*
> foreach (glob '/home/foo*')
> {
> next if ! -f $_; # copy files only, not directories
> print "Copying $_ ...\n";
> copy ($_, '/where/to') or warn "Failed to copy $_ : $!\n";
> }
> Sorry. I misread your question.
/RQuote:> You could shell out to the system
> copy as Wiggins mentioned. But why not use the module ?
Works great...
Have a wonderful weekend..
Mike
Hello All,
Is the only way to copy a file from one directory to another by using the
copy module...?
Would anyone have a snipet of code copying a file from one dir to another...
Any assistance would be appreciated...
Thank you,
Mike
--
If you don't mind, I think there are still some of us that are wondering;
why don't you want to use File::Copy?
Thank you to all who responded...used several folks advice shelling out to
OS using the system function to copy the file...
Works great...
Have a wonderful weekend..
Mike
-----Original Message-----
From: Michael Pastore
Sent: Friday, February 14, 2003 10:13 AM
Subject: copying a file without using module File::Copy
Hello All,
Is the only way to copy a file from one directory to another by using the
copy module...?
Would anyone have a snipet of code copying a file from one dir to another...
Any assistance would be appreciated...
Thank you,
Mike
--
--
/R
Being a Perl nubie....and not having alot of experience in installing and
using Perl modules...I decided to go the route of using the system
function..
I took a look at CPAN and what was involved in installing the module and
using it (was confused)...looked pretty involved..at least for me, rather
than just putting:
system ('copy d:\server\vsiwork\*.tag d:\server\vsiout');
in the code...
Thank you to all who responded...
Regards,
Mike
> If you don't mind, I think there are still some of us that are
> wondering; why don't you want to use File::Copy?
/R
--
------------------------------------------------
> Being a Perl nubie....and not having alot of experience in installing and
> using Perl modules...I decided to go the route of using the system
> function..
> I took a look at CPAN and what was involved in installing the module and
> using it (was confused)...looked pretty involved..at least for me, rather
> than just putting:
> system ('copy d:\server\vsiwork\*.tag d:\server\vsiout');
> in the code...
http://danconia.org
While this may be a valid reason not to use a module it's notQuote:> Tim/Rob/All,
> Being a Perl nubie....and not having alot of experience in installing
> and using Perl modules...I decided to go the route of using the system
> function..
> I took a look at CPAN and what was involved in installing the module
> and using it (was confused)...looked pretty involved..at least for me,
> rather than just putting:
> system ('copy d:\server\vsiwork\*.tag d:\server\vsiout');
> in the code...
Jenda
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery
>> Being a Perl nubie....and not having alot of experience in installing
>> and using Perl modules...I decided to go the route of using the
>> system function..
>> I took a look at CPAN and what was involved in installing the module
>> and using it (was confused)...looked pretty involved..at least for
>> me, rather than just putting:
>> system ('copy d:\server\vsiwork\*.tag d:\server\vsiout');
>> in the code...
> While this may be a valid reason not to use a module it's not
> applicable to File::Copy.
> The module is part of the core, you already have it! Just like
> anybody else.
By the way, if you're using ActivePerl (perl -V will tell you)
it's very easy to install pre-built modules with the ppm
utility. Just
ppm install File::Copy
would have done it if it wasn't already installed.
It might be a good idea, now that you have a working
program, to re-implement it using the module. That way
it won't be so scary next time.
Cheers, and well done,
Rob
Unless your version is too old.Quote:> > Being a Perl nubie....and not having alot of experience in
> > installing and using Perl modules...
> While this may be a valid reason not to use a module it's not
> applicable to File::Copy.
> The module is part of the core, you already have it! Just like
> anybody else.
Try this to check:
perl -MFile::Copy -e 'print "found\n"'
It will print "found" if it's available, or self-destruct if it's not.
:)
Installs aren't that bad, though.
Start with something simple and nonvital like The Damian's amusing
Acme::Bleach (but don't use it on important code! lol!) and you can't
hurt much. ;o]
__________________________________________________
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com
btw, for security reasons, you might want to consider converting thatQuote:> system ('copy d:\server\vsiwork\*.tag d:\server\vsiout');
system qw/ copy d:\server\vsiwork\*.tag d:\server\vsiout /;
or to be more visually explicit for nuB's,
system ('copy','d:\server\vsiwork\*.tag','d:\server\vsiout');
To be honest, however, on our system the security isn't such an issue,
so I occasionally use the originally given single-string syntax as
well. :)
Since you're obviously on a WinDOZE system, though, make sure you don't
use doublequotes around file paths; "d:\server\vsiwork\*.tag"
interpolates the backslashes, so you end up with a string that looks
like d:servervsiwork*.tag
Luck and fun, bud.
Paul
__________________________________________________
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com
1. FTP or COPY - To copy WOrd file from my PC no NT Server?
I folks;
I need to copy text file, Word DOcument and exel file from my pc into the NT
server called "ServerNT123".
if the file was fond on "C:\Doc1\Wollo.DOC"
How do I move it using SAS into the SeverNT123? I user SAS Intrnet
Dispacher, but if I get some hint on how to use it using the Base SAS, that
is Good enough for me.
Thanks;
Wollo
_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx
2. veritas database edition advanced cluster
3. eegads! File::Copy not copying
4. SBS Group Policy for Outlook 2003
5. how to copy a formula without copy the formula......
7. copy data without opening file
9. Copy and object from a pdf file into another pdf file
10. How to copy several pdf-files in one pdf-file?
11. Copy links from file to file
12. Copy of excel files to 1 excel file -need vba code
13. Macro to Copy the sheets from One file to Multiple Files