For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > February 2007 > problem cp









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author problem cp
john.swilting

2007-02-23, 8:04 am

how to make a function cp
who would go like
I read the name of the old file I it copis in a variable $variable I
re-elect the new file and I copy it towards the old file while keeping the
same name of the file
john.swilting

2007-02-23, 8:04 am

john.swilting wrote:

> how to make a function cp
> who would go like
> I read the name of the old file I it copis in a variable $variable I
> re-elect the new file and I copy it towards the old file while keeping the
> same name of the file

en français
je lis le nom de l'ancien fichier je le copis dans une variable $variable je
renomme le nouveau fichier et je le copie vers l'ancien fichier tout en
gardant le meme nom du fichier
john.swilting

2007-02-23, 8:04 am

john.swilting wrote:

> how to make a function cp
> who would go like
> I read the name of the old file I it copis in a variable $variable I
> re-elect the new file and I copy it towards the old file while keeping the
> same name of the file

why not

open (FH , $old_fichier);
select(FH);
rename $new_fichier, $old_fichier;
`cp $new_ficier /image1`

its nice that
Michele Dondi

2007-02-23, 8:04 am

On Fri, 23 Feb 2007 12:54:05 +0100, "john.swilting"
<john.swilting@wanadoo.fr> wrote:

>open (FH , $old_fichier);
>select(FH);
>rename $new_fichier, $old_fichier;
>`cp $new_ficier /image1`
>
>its nice that


IMHO you want either to do it all in Perl or use OS native commands
altogether. Personally, I would perfer the former.


Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{po
p^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
john.swilting

2007-02-23, 8:04 am

john.swilting wrote:

> john.swilting wrote:
>
> why not
>
> open (FH , $old_fichier);
> select(FH);
> rename $new_fichier, $old_fichier;
> `cp $new_ficier /image1`
>
> its nice that

not
open (FH , $old_file);
select(FH);
rename $old_file ,$new_file;
`cp $new_file /image1`;


I had to reverse the files in the rename
Michele Dondi

2007-02-23, 8:04 am

On Fri, 23 Feb 2007 12:25:10 +0100, "john.swilting"
<john.swilting@wanadoo.fr> wrote:

>how to make a function cp

[snip]

IIUC, which I find increasingly hard to believe, you may be interested
in File::Copy.


Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{po
p^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
john.swilting

2007-02-23, 8:04 am

Michele Dondi wrote:

> On Fri, 23 Feb 2007 12:54:05 +0100, "john.swilting"
> <john.swilting@wanadoo.fr> wrote:
>
>
> IMHO you want either to do it all in Perl or use OS native commands
> altogether. Personally, I would perfer the former.
>
>
> Michele

ok

File::*

all
its nice
Abigail

2007-02-23, 8:04 am

Michele Dondi (bik.mido@tiscalinet.it) wrote on MMMMCMXXIV September
MCMXCIII in < URL:news:vtntt2ptjjljafukbpp1bsiqse57i1v
bg0@4ax.com>:
&& On Fri, 23 Feb 2007 12:54:05 +0100, "john.swilting"
&& <john.swilting@wanadoo.fr> wrote:
&&
&& >open (FH , $old_fichier);
&& >select(FH);
&& >rename $new_fichier, $old_fichier;
&& >`cp $new_ficier /image1`
&& >
&& >its nice that
&&
&& IMHO you want either to do it all in Perl or use OS native commands
&& altogether. Personally, I would perfer the former.


I very much prefer the latter.



Abigail
--
$"=$,;*{;qq{@{[(A..Z)[qq[0020191411140003]=~m[..]g]]}}}=*_;
sub _ {push @_ => /::(.*)/s and goto &{ shift}}
sub shift {print shift; @_ and goto &{+shift}}
Hack ("Just", "Perl ", " ano", "er\n", "ther "); # 20070223
Michele Dondi

2007-02-23, 7:07 pm

On Fri, 23 Feb 2007 13:39:12 +0100, "john.swilting"
<john.swilting@wanadoo.fr> wrote:

>open (FH , $old_file);


unchecked open();

>select(FH);
>rename $old_file ,$new_file;


unchecked rename();

>`cp $new_file /image1`;


backticks in void context;


Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{po
p^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
john.swilting

2007-02-23, 7:07 pm

Abigail wrote:

> Michele Dondi (bik.mido@tiscalinet.it) wrote on MMMMCMXXIV September
> MCMXCIII in < URL:news:vtntt2ptjjljafukbpp1bsiqse57i1v
bg0@4ax.com>:
> && On Fri, 23 Feb 2007 12:54:05 +0100, "john.swilting"
> && <john.swilting@wanadoo.fr> wrote:
> &&
> && >open (FH , $old_fichier);
> && >select(FH);
> && >rename $new_fichier, $old_fichier;
> && >`cp $new_ficier /image1`
> && >
> && >its nice that
> &&
> && IMHO you want either to do it all in Perl or use OS native commands
> && altogether. Personally, I would perfer the former.
>
>
> I very much prefer the latter.
>
>
>
> Abigail

why
john.swilting

2007-02-23, 7:07 pm

john.swilting wrote:

> Abigail wrote:
>
> why

I do not know how I will program the change image to order. on sale
Abigail

2007-02-23, 7:07 pm

john.swilting (john.swilting@wanadoo.fr) wrote on MMMMCMXXIV September
MCMXCIII in <URL:news:45defae4$0$27411$ba4acef3@news.orange.fr>:
,, Abigail wrote:
,,
,, > Michele Dondi (bik.mido@tiscalinet.it) wrote on MMMMCMXXIV September
,, > MCMXCIII in < URL:news:vtntt2ptjjljafukbpp1bsiqse57i1v
bg0@4ax.com>:
,, > && On Fri, 23 Feb 2007 12:54:05 +0100, "john.swilting"
,, > && <john.swilting@wanadoo.fr> wrote:
,, > &&
,, > && >open (FH , $old_fichier);
,, > && >select(FH);
,, > && >rename $new_fichier, $old_fichier;
,, > && >`cp $new_ficier /image1`
,, > && >
,, > && >its nice that
,, > &&
,, > && IMHO you want either to do it all in Perl or use OS native commands
,, > && altogether. Personally, I would perfer the former.
,, >
,, >
,, > I very much prefer the latter.
,, >
,, > Abigail
,, why


Easy. 'system cp => @files, $destination' is just one line (regardless of
the number of files), works flawlessly, and is flexible.

use File::Copy;
copy $file => $destination;

needs two lines just to copy one file, is broken, is hopelessly inflexible,
and will delete your files if you think 'copy' might mimic the 'cp' command.

If you value your time, and your files, you wouldn't be using File::Copy.


Abigail
--
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'
Joe Smith

2007-02-27, 4:13 am

Abigail wrote:

> use File::Copy;
> copy $file => $destination;
>
> needs two lines just to copy one file, is broken, is hopelessly inflexible,
> and will delete your files if you think 'copy' might mimic the 'cp' command.


Huh? Just how can copy() cause the input file to be deleted?

-Joe
Abigail

2007-02-27, 8:04 am

Joe Smith (joe@inwap.com) wrote on MMMMCMXXVIII September MCMXCIII in
< URL:news:e86dnTAA8vt5fn7YnZ2dnUVZ_t6qnZ2
d@comcast.com>:
?? Abigail wrote:
??
?? > use File::Copy;
?? > copy $file => $destination;
?? >
?? > needs two lines just to copy one file, is broken, is hopelessly inflexible,
?? > and will delete your files if you think 'copy' might mimic the 'cp' command.
??
?? Huh? Just how can copy() cause the input file to be deleted?


If you get the impression that 'copy' mimics the 'cp' command,
you might get the idea you can savely replace

copy "/etc/passwd", "/backup";
copy "/etc/shadow", "/backup";

with

copy "/etc/passwd", "/etc/shadow", "/backup";


The effect of that is that "/etc/shadow" will get truncated.



Abigail
--
perl -wle 'eval {die [[qq [Just another Perl Hacker]]]};; print
${${${@}}[$#{@{${@}}}]}[$#{${@{${@}}}[$#
{@{${@}}}]}]'
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com