copying a file without using module File::Copy

copying a file without using module File::Copy

Post by Michael Pasto » Sun, 16 Feb 2003 00:13:06



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

 
 
 

copying a file without using module File::Copy

Post by wigg.. » Sun, 16 Feb 2003 00:23:47


------------------------------------------------


> 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...

Well you could shell out to the local copy program, but that would be less portable:

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

 
 
 

copying a file without using module File::Copy

Post by James Ki » Sun, 16 Feb 2003 00:26:56


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...

Have you checked the docs for File::Copy ?

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:}

 
 
 

copying a file without using module File::Copy

Post by Jensen Kenneth B Sra Afpc/Dpdm » Sun, 16 Feb 2003 00:28:11


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.

-----Original Message-----

Sent: Friday, February 14, 2003 9: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

--



 
 
 

copying a file without using module File::Copy

Post by James Ki » Sun, 16 Feb 2003 00:34:10


Quote:

> > Is the only way to copy a file from one directory to another
> > by using the
> > copy module...?

Sorry. I misread your question. You could shell out to the system copy as
Wiggins mentioned. But why not use the 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";
> }

 
 
 

copying a file without using module File::Copy

Post by Rob Dix » Sun, 16 Feb 2003 01:20:42



>>> Is the only way to copy a file from one directory to another
>>> by using the
>>> copy module...?

> Sorry. I misread your question.

Yeah, so did I :)

Quote:> You could shell out to the system
> copy as Wiggins mentioned. But why not use the module ?

/R
 
 
 

copying a file without using module File::Copy

Post by Michael Pasto » Sun, 16 Feb 2003 03:14:20


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

--



 
 
 

copying a file without using module File::Copy

Post by Timothy Johns » Sun, 16 Feb 2003 03:44:00


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?

-----Original Message-----

Sent: Friday, February 14, 2003 10:14 AM

Subject: RE: copying a file without using module 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

--


--



 
 
 

copying a file without using module File::Copy

Post by Rob Dix » Sun, 16 Feb 2003 03:52:17



> 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?

Hear hear!

/R

 
 
 

copying a file without using module File::Copy

Post by Michael Pasto » Sun, 16 Feb 2003 03:56:57


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...

Thank you to all who responded...

Regards,
Mike

-----Original Message-----

Sent: Friday, February 14, 2003 1:52 PM

Subject: Re: copying a file without using module File::Copy


> 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?

Hear hear!

/R

--


 
 
 

copying a file without using module File::Copy

Post by wigg.. » Sun, 16 Feb 2003 04:27:22


------------------------------------------------


> 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...

For your future reference File::Copy comes as a base module on Perl starting at least as early as 5.6.1 so you shouldn't have to worry about installing it. If I remember correctly you are running an older version?  Any of the gurus know when it was introduced as a base install, I don't have an old enough Perl around to look myself, and not sure where to check this...wasn't in my 5.6.1 docs...

http://danconia.org

 
 
 

copying a file without using module File::Copy

Post by Jenda Krynic » Sun, 16 Feb 2003 04:50:18



Quote:> 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...

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.

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

 
 
 

copying a file without using module File::Copy

Post by Rob Dix » Sun, 16 Feb 2003 05:16:07




>> 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...

> 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.

This is why we were asking, Mike. Its extremely common for
people to decide on a solution to their problem and ask
questions here about how that solution can be implemented.
Solving a problem in a given language requires the ability to
think in that language's idioms. Especially if you are new to
Perl it's appropriate to give a rundown of the problem
you're trying to solve as well as your chosen solution.

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

 
 
 

copying a file without using module File::Copy

Post by Pau » Sun, 16 Feb 2003 05:50:09



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.

Unless your version is too old.

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

 
 
 

copying a file without using module File::Copy

Post by Pau » Sun, 16 Feb 2003 05:56:13


Quote:> system ('copy d:\server\vsiwork\*.tag d:\server\vsiout');

btw, for security reasons, you might want to consider converting that
to

 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......

6. Copy files in PB

7. copy data without opening file

8. Newsletter exchange

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