[29936] in Perl-Users-Digest
Perl-Users Digest, Issue: 1179 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 8 21:09:45 2008
Date: Tue, 8 Jan 2008 18:09:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 8 Jan 2008 Volume: 11 Number: 1179
Today's topics:
Active State perl for windows not working. <kcom@fusemail.com>
Re: Active State perl for windows not working. <jurgenex@hotmail.com>
Re: Active State perl for windows not working. <tzz@lifelogs.com>
every($key, $interval) function <tzz@lifelogs.com>
Re: every($key, $interval) function <rvtol+news@isolution.nl>
Re: every($key, $interval) function <tzz@lifelogs.com>
Re: every($key, $interval) function <rvtol+news@isolution.nl>
Re: FAQ 5.5 How can I copy a file? <karinwalike@comcast.net>
Re: FAQ 5.5 How can I copy a file? <jimsgibson@gmail.com>
HELP! File Copy, Move and Rename will not work in my s <karinwalike@comcast.net>
Re: HELP! File Copy, Move and Rename will not work in <someone@example.com>
Re: HELP! File Copy, Move and Rename will not work in <glex_no-spam@qwest-spam-no.invalid>
Re: HELP! File Copy, Move and Rename will not work in m <karinwalike@comcast.net>
Re: remove special characters in front of the file name <jurgenex@hotmail.com>
Using CPAN "lightweight" <bernie@fantasyfarm.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 08 Jan 2008 16:34:38 -0400
From: Caduceus <kcom@fusemail.com>
Subject: Active State perl for windows not working.
Message-Id: <dhn7o3hannpg0ugh7okc1t5k466m4gdogb@4ax.com>
When I try to type in perl -v, perl -h,perl -w, or perl -procinv.pl
nothing happens. Is there something I can do for this? TIA Steve
------------------------------
Date: Tue, 08 Jan 2008 23:02:10 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Active State perl for windows not working.
Message-Id: <5508o35basvlj6ug2qkp6uqph1svqisu3e@4ax.com>
Caduceus <kcom@fusemail.com> wrote:
>When I try to type in perl -v, perl -h,perl -w, or perl -procinv.pl
>nothing happens. Is there something I can do for this?
Nothing? You really get nothing? Not even an error message?
Then someone must have created a perl.bat or perl.com or perl.exe that
immediately terminates and replaced perl's perl.exe with that program.
jue
------------------------------
Date: Tue, 08 Jan 2008 18:01:54 -0600
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Active State perl for windows not working.
Message-Id: <86ejcrkgst.fsf@lifelogs.com>
On Tue, 08 Jan 2008 16:34:38 -0400 Caduceus <kcom@fusemail.com> wrote:
C> When I try to type in perl -v, perl -h,perl -w, or perl -procinv.pl
C> nothing happens. Is there something I can do for this? TIA Steve
Your keyboard is unplugged, or at least the following keys are not
working:
p
e
r
l
SPACE
-
v
h
w
o
c
i
n
.
Hope this helps...
Ted
------------------------------
Date: Tue, 08 Jan 2008 16:18:35 -0600
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: every($key, $interval) function
Message-Id: <86ve64j70k.fsf@lifelogs.com>
I find this function very useful:
{
my %counters = ();
sub every
{
my $id = shift @_;
my $when = shift @_;
return (0 == ++$counters{$id} % $when);
}
}
I call it like this:
print "debug info: ..."
if every("debug spot", 50);
print "extra info: ..."
if every("extra spot", 100);
So the debug info will be printed on every 50th call to every(). It's
small and convenient, but I have to make up a new ID every time.
I'd like to preserve the functional interface, so no OOP cheating. How
can I avoid the $id parameter, creating an automatically localized
every() call each time? I thought of __FILE__ and __LINE__ but those
are not unique enough, since you could potentially have
if (every(50)||every(33)) {}
on a line... I also thought of every(\&action_sub, 50) but that avoids
the problem sideways (it doesn't create a unique key, but makes the
action the key, which is not the same thing).
Ted
------------------------------
Date: Wed, 9 Jan 2008 01:21:47 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: every($key, $interval) function
Message-Id: <fm17jn.ro.1@news.isolution.nl>
Ted Zlatanov schreef:
> {
> my %counters = ();
> sub every
> {
> my $id = shift @_;
> my $when = shift @_;
>
> return (0 == ++$counters{$id} % $when);
> }
> }
>
> I call it like this:
>
> print "debug info: ..."
> if every("debug spot", 50);
>
> print "extra info: ..."
> if every("extra spot", 100);
>
> So the debug info will be printed on every 50th call to every(). It's
> small and convenient, but I have to make up a new ID every time.
>
> I'd like to preserve the functional interface, so no OOP cheating.
> How can I avoid the $id parameter, creating an automatically localized
> every() call each time? I thought of __FILE__ and __LINE__ but those
> are not unique enough, since you could potentially have
>
> if (every(50)||every(33)) {}
>
> on a line... I also thought of every(\&action_sub, 50) but that
> avoids the problem sideways (it doesn't create a unique key, but
> makes the action the key, which is not the same thing).
#!/usr/bin/perl
use strict;
use warnings;
sub every_factory {
my $d = shift;
my $n;
return sub { !(++$n % $d) }
}
my ($everyX, $everyY) = (every_factory(3), every_factory(5));
for my $i (1..50) {
print "$i:X\n" if $everyX->();
print "$i:Y\n" if $everyY->();
}
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Tue, 08 Jan 2008 18:59:00 -0600
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: every($key, $interval) function
Message-Id: <863at7ke5n.fsf@lifelogs.com>
On Wed, 9 Jan 2008 01:21:47 +0100 "Dr.Ruud" <rvtol+news@isolution.nl> wrote:
R> #!/usr/bin/perl
R> use strict;
R> use warnings;
R> sub every_factory {
R> my $d = shift;
R> my $n;
R> return sub { !(++$n % $d) }
R> }
R> my ($everyX, $everyY) = (every_factory(3), every_factory(5));
R> for my $i (1..50) {
R> print "$i:X\n" if $everyX->();
R> print "$i:Y\n" if $everyY->();
R> }
That's neat, creating $n and returning a subroutine that has it in
scope. I don't like it as much as every(50) because it separates the
number of cycles from the usage of the function, so you'd have to look
back up to remember how many cycles $everyX will use.
I was hoping to create something truly unique and use it as the key
automatically, like __FILE__:__LINE__ but allowing more than one per
line. I tried `caller 0' in list context but it is not enough.
__COLUMN__ would be perfect, if it existed (I don't know of such a
thing).
Ted
------------------------------
Date: Wed, 9 Jan 2008 02:36:58 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: every($key, $interval) function
Message-Id: <fm1c1v.104.1@news.isolution.nl>
Ted Zlatanov schreef:
> Dr.Ruud:
>> #!/usr/bin/perl
>> use strict;
>> use warnings;
>
>> sub every_factory {
>> my $d = shift;
>> my $n;
>> return sub { !(++$n % $d) }
>> }
>
>> my ($everyX, $everyY) = (every_factory(3), every_factory(5));
>
>> for my $i (1..50) {
>> print "$i:X\n" if $everyX->();
>> print "$i:Y\n" if $everyY->();
>> }
>
> That's neat, creating $n and returning a subroutine that has it in
> scope.
"closure"
> I don't like it as much as every(50) because it separates the
> number of cycles from the usage of the function, so you'd have to look
> back up to remember how many cycles $everyX will use.
Then just call it $every50.
Or compromise:
#!/usr/bin/perl
use strict;
use warnings;
sub every{
my %counters if 0;
my ($div, @id) = @_;
return !(++$counters{ caller(), $div, @id } % $div);
}
for my $i (1..13) {
print "A:$i\n" if every(3); print "B:$i\n" if every(3,"B");
print "C:$i\n" if every(5);
}
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Tue, 8 Jan 2008 15:19:09 -0800 (PST)
From: kwalike57 <karinwalike@comcast.net>
Subject: Re: FAQ 5.5 How can I copy a file?
Message-Id: <2a946010-5182-4f17-8ceb-50b9160fb8e7@j78g2000hsd.googlegroups.com>
On Dec 22 2007, 8:53=A0am, mer...@stonehenge.com (Randal L. Schwartz)
wrote:
> >>>>> "Michele" =3D=3D Michele Dondi <bik.m...@tiscalinet.it> writes:
> >> could also do a quick system command
>
> >> `cp $orig $new`;
>
> Michele> Just like with quite about anything else one may want to do. But =
if
> Michele> every faq entry did contain a remark of this kind for all of them=
,
> Michele> then they would amount pretty much to a shell manual as a whole. =
And
> Michele> you know, the times Perl was posted to comp.sources.unix are long=
> Michele> gone. Your suggestions suffers from the well known, usual portabi=
lity
> Michele> issues. Since copying a file is a portable concept, this may matt=
er.
>
> Additionally, you've got the broken idiom of using backquotes in a
> void context, and not properly accounting for shell metacharacters.
> I mean, even if you *wanted* to use cp, you should do this:
>
> =A0 system "cp", $orig, $new;
>
> *Sigh*. =A0Kids these days. :)
>
> print "Just another Perl hacker,"; # the original
>
> --
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 009=
5
> <mer...@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
> See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl traini=
ng!
Hello.
I have a question along these lines. I have a perl script that in a
nutshell, reads a directory and then looks for a specific file naming
convention which is matched up by using a regExp that loads a variable
$FILE. Once it finds this it Connect:Directs (copies file) the file
to a remote node. After this is done I send an email notification
that the file transfer completes. My problem is that when this whole
process completes, I want to rename the $FILE to a file.done format.
I do this with the rename function normally but saying rename ($FILE,
$FILEDONE). This is not working. I can tell the script to print out
the value of $FILE and $FILEDONE and both values are correctly
indicated. For example if $FILE is FILEa.txt then $FILEDONE would be
FILEa.txt.done.
So my question is, why won't my file rename properly. My script exits
with an error indicating cannot rename $FILE.
In light of this I decided to try to copy $FILE and then also tried to
move $FILE. Neither work. This script runs on a Windows box and so I
tried to manually execute the copy and move commands from the command
line and both work fine. I can rename, copy and move the file with no
problem. I am using File::Copy in my script. I have tried using the
system command to execute the copy and moves and I have tried to
manually type in the copy and moves as well in the script. I have
only tried to do this with the variable values and have not tried
executing these commands with a qualified path to the file name.
Any ideas? This seems like it should be the easiest part of the whole
process and it has taken up a bunch of time trying to get this last
element to work.
Thanks for your help!!
Karin Walike
------------------------------
Date: Tue, 08 Jan 2008 16:30:33 -0800
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: FAQ 5.5 How can I copy a file?
Message-Id: <080120081630330463%jimsgibson@gmail.com>
In article
<2a946010-5182-4f17-8ceb-50b9160fb8e7@j78g2000hsd.googlegroups.com>,
kwalike57 <karinwalike@comcast.net> wrote:
> Hello.
>
> I have a question along these lines.
Note that it is best to start a new thread if you have a new problem
(which I now notice you have already done. Grr!).
[problem renaming file in Perl under Windows snipped]
Write a small test script that renames a single test file. Check the
return value from rename and, if it fails, print the special variable
$!. Something like this (untested):
use strict;
my $file = 'test.txt';
my $newfile = "$file.done";
rename($file,$newfile) or die($!);
If that works, incorporate it into your full program. If it doesn't
work, and you can't figure out why not, post the program and the actual
results here.
--
Jim Gibson
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
------------------------------
Date: Tue, 8 Jan 2008 15:20:49 -0800 (PST)
From: kwalike57 <karinwalike@comcast.net>
Subject: HELP! File Copy, Move and Rename will not work in my script!
Message-Id: <4646b30d-f3df-4192-aa05-5940cd31d7de@d21g2000prf.googlegroups.com>
Hello.
I have a perplexing question that seems like it should be very
simple. I have a perl script that in a nutshell, reads a directory
and then looks for a specific file naming convention which is matched
up by using a regExp that loads a variable $FILE. Once it finds this
it Connect:Directs (copies file) the file to a remote node. After
this is done I send an email notification that the file transfer
completes. My problem is that when this whole process completes, I
want to rename the $FILE to a file.done format. I do this with the
rename function normally but saying rename ($FILE, $FILEDONE). This
is not working. I can tell the script to print out the value of $FILE
and $FILEDONE and both values are correctly indicated. For example if
$FILE is FILEa.txt then $FILEDONE would be FILEa.txt.done.
So my question is, why won't my file rename properly. My script exits
with an error indicating cannot rename $FILE.
In light of this I decided to try to copy $FILE and then also tried to
move $FILE. Neither work. This script runs on a Windows box and so I
tried to manually execute the copy and move commands from the command
line and both work fine. I can rename, copy and move the file with no
problem. I am using File::Copy in my script. I have tried using the
system command to execute the copy and moves and I have tried to
manually type in the copy and moves as well in the script. I have
only tried to do this with the variable values and have not tried
executing these commands with a qualified path to the file name.
Any ideas? This seems like it should be the easiest part of the whole
process and it has taken up a bunch of time trying to get this last
element to work.
Thanks for your help!!
Karin Walike
------------------------------
Date: Tue, 08 Jan 2008 23:33:14 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: HELP! File Copy, Move and Rename will not work in my script!
Message-Id: <_KTgj.346$yQ1.6@edtnps89>
kwalike57 wrote:
> Hello.
Your second posting of the same problem and you still have not posted
any code.
My crystal ball seems to think that you may have a problem with
directories, either incorrect names or missing completely? Possibly on
line 42?
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
------------------------------
Date: Tue, 08 Jan 2008 17:44:31 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: HELP! File Copy, Move and Rename will not work in my script!
Message-Id: <47840ae0$0$495$815e3792@news.qwest.net>
kwalike57 wrote:
> Hello.
>
> I have a perplexing question that seems like it should be very
> simple. I have a perl script that in a nutshell, reads a directory
Care to post a short example? How the heck do you expect
anyone to be able to help, if we can't see what you're doing?
[...]
> So my question is, why won't my file rename properly. My script exits
> with an error indicating cannot rename $FILE.
[...]
Fix your error to include why it failed and the values of the filenames
it's trying to copy/move, maybe that'll help you figure out the problem.
It's likely either you're not in the directory you think you're in or
it's a permission problem.
perldoc File::Copy
All functions return 1 on success, 0 on failure. $! will be set if an
error was encountered.
------------------------------
Date: Tue, 8 Jan 2008 16:17:41 -0800 (PST)
From: kwalike57 <karinwalike@comcast.net>
Subject: Re: HELP! File Copy, Move and Rename will not work in my script!
Message-Id: <054035d4-66e9-4b3d-b73d-293a2a8e604d@j78g2000hsd.googlegroups.com>
On Jan 8, 3:33=A0pm, "John W. Krahn" <some...@example.com> wrote:
> kwalike57 wrote:
> > Hello.
>
> Your second posting of the same problem and you still have not posted
> any code.
>
> My crystal ball seems to think that you may have a problem with
> directories, either incorrect names or missing completely? =A0Possibly on
> line 42?
>
> John
> --
> Perl isn't a toolbox, but a small machine shop where you
> can special-order certain sorts of tools at low cost and
> in short order. =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-- =
Larry Wall
Here is the code...
#!/perl/bin/perl
#
#NewAutoConDir.pl
#Karin Walike
#12.01.07
#
#Connect:Direct process automation for server PKSW1714
#The script sleeps and wakes up to check and see if there is a file
#has been loaded to the server for Connect:Direct to customer.
#
#
#We currently have XX customers sending/receiving data to this node.
#
#Product list: xx, xx, xx, xx, xx,
use MIME::Lite;
use Cwd;
use File::Copy;
my $date=3Dlocaltime();
my $dirVM=3D"D:\\Prod_D\\BOP\\Data\\SMSDATA\\PCSWHSLE\\CD\\VM\\";
my $doneDir=3D"D:\\Prod_D\\BOP\\Data\\SMSDATA\\PCSWHSLE\\CD\\VM\\DONE\
\";
my $FILE;
my @FILES;
my $doneExt =3D ".done";
my $ConDir1=3D"D:\\tools\\'Sterling Commerce'\\'CONNECT Direct v4.1'\
\'Common Utilities'";
my $ConDir2=3D"D:\\Prod_D\\BOP\\Scripts\\temp";
my $ConDir3=3D"D:\\Prod_D\\BOP\\scripts\\triggerDir";
my $LOG=3D"D:\\Prod_D\\BOP\\Logs\\ConDirLogVM_1.txt";
my $LOG2=3D"D:\\Prod_D\\BOP\\Logs\\ConDirLogVM_2.txt";
my $LOG3=3D"D:\\Prod_D\\BOP\\Logs\\ConDirLogVM_3.txt";
my $LOG4=3D"D:\\Prod_D\\BOP\\Logs\\ConDirLogVM_4.txt";
my $EXCONDIR=3D"D:\\Prod_D\\BOP\\Scripts\\temp\\ConDirVM.cmd";
open (OUT,">>$LOG");
while(1) {
# Open the directory VM
if( -d $dirVM ) {
opendir( VMDIR, $dirVM ) || die "Cannot open directory $dirVM $!";
}else{
print "Directory $dirVM does not exist. Exiting...\n";
exit;
}
# Iterate through the directory VM
opendir(VMDIR, $dirVM) || die "Cannot open directory $dirVM $!";
#open(VMDIR,"D:\\Prod_D\\BOP\\Data\\SMSDATA\\PCSWHSLE\\VM") || die
"Cannot open directory $dirVM $!";
#open(VMDIR,'dir "D:\Prod_D\BOP\Data\SMSDATA\PCSWHSLE\VM" |') || die;
@FILES =3D readdir(VMDIR);
#closedir(VMDIR);
chomp (@FILES);
print "\n@FILES\n";
foreach $FILE ( @FILES ) {
if ($FILE !~ /^RU_VIRGIN_MOBILE_[0-9]_[0-9][0-9][0-9][0-9][0-9][0-9]
[0-9][0-9].*\.gz$/) {
#print "$FILE is not an EMBARQ product...\n";
goto sleeplabel;
}else{
chomp($FILE);
print "\nFile is $FILE\n";
print "\nBeginning Connect:Direct processing for VIRGIN MOBILE
customer file...\n";
print OUT "\n$date $FILE\n";
goto sleeplabel if (!$FILE);
if (file_transfer_complete($FILE)) {
print "\nFound file $FILE\n";
open(IN, "$ConDir3\\send_triggerVM.pl");
open(OUT, ">$ConDir2\\tmp_sendVM.cdp");
while (<IN>) {
if (/ConDirFile/) {
s/ConDirFile/$dirVM$FILE/;
}
print OUT $_;
}
close(OUT);
close(IN);
print "First Connect:Direct pre-processing step passed...\n";
"$ConDir2\\tmp_sendVM.cdp > D:\\Prod_D\\BOP\\scripts\\temp\\file";
sleep 10;
print "Second Connect:Direct pre-processing step passed...\n";
system $EXCONDIR || errorexit(2, "\nConnect:Direct process failed");
print "\nConnect:Direct processing for VIRGIN MOBILE customer file
completed...\n";
print OUT "\nConnect:Direct Processed for $date $FILE\n";
# Send email to notify file has been C:D to mainframe
my $machine =3D "PKSW1714";
my $email =3D 'IOP-ITSupport@sprint.com';
my $email2 =3D 'CD.Rom@sprint.com';
my $subject =3D "Connect:Direct Processing VIRGIN MOBILE: $FILE has
been sent to VIRGIN MOBILE node VSCPFTP01";
my $body =3D " Hello, \n\n $FILE has been moved from $machine to
VSCPFTP01. \n\n Please contact $email2 with questions. \n\n Thanks, \n
\n IOP Connect:Direct Team\n\n";
my $server =3D "10.214.13.55";
my $msg =3D MIME::Lite->new(
From =3D> 'CD.Rom@sprint.com',
To =3D> 'IOP-ITSupport@sprint.com',
Subject =3D> $subject,
Type =3D> 'TEXT',
Data =3D> $body
);
#Use SMTP to send
MIME::Lite->send('smtp', $server, Timeout=3D>60);
sleep 30;
$msg->send;
open(OUT, ">>$LOG"); #reopen closed LOG
print "\nEmail notification of Connect:Direct transfer sent...\n";
#sleeplabel2:
print"\n\n*******Waiting for VIRGIN MOBILE file processing to
complete*******\n\n";
sleep 50;
# Rename the current process to done
chomp($FILE);
print "File is writable\n" if -w $FILE;
$FILEDONE =3D $FILE . $doneExt;
chomp($FILEDONE);
print "filedone=3D$FILEDONE\n";
#rename ("D:\\Prod_D\\BOP\\Data\\SMSDATA\\PCSWHSLE\\CD\\VM\
\RU_VIRGIN_MOBILE_1_20071130.007.gz", "D:\\Prod_D\\BOP\\Data\\SMSDATA\
\PCSWHSLE\\CD\\VM\\RU_VIRGIN_MOBILE_1_20071130.007.gz.done");
rename ($FILE, $FILEDONE);
#if (renamefiles($FILE)) {
print "\nFile successfully renamed: $FILEDONE\n" || errorexit(14,
"Could not rename $FILE");
#}
#move ($FILE,$FILEDONE) || errorexit(9, "Unable to move $FILE");
#copy ($FILE,$FILEDONE) || errorexit(12, "Unable to copy $FILE to
$FILEDONE");
sleeplabel:
print"\n\n*******Waiting for VIRGIN MOBILE Connect:Direct file*******
\n\n";
sleep 10;
#
# Begin Subroutines
#
#
# Sub file_transfer_complete
#
# monitor a file for size changes over a brief period
#
# parm1 - file name
# parm2 - delay in seconds (optional)
#
sub file_transfer_complete {
my $filename =3D shift;
my $waitTime =3D shift || 20;
my $sizefirst =3D -s $filename; # initial file size
sleep $waitTime; # wait a while
my $sizeDelta =3D -s $filename; #file size after wait
if( $sizeDelta =3D=3D $sizefirst ) {
print "transfer complete $filename 1: $sizefirst\t2: $sizeDelta" ;
return 1;
} else {
print "transfer incomplete $filename 1: $sizefirst\t2: $sizeDelta" ;
return 0;
}
}
# Sub errorexit print error message to the log and return an error
code
#
sub errorexit {
my $returncode =3D shift;
my $message =3D shift;
open (OUT, ">>$LOG");
print OUT "\n### ERROR $returncode ### $message";
exit ($returncode);
}
# Sub Rename files to .done extension
#
sub renamefiles {
my $file1 =3D shift;
my $done =3D ".done";
my $file2 =3D $file1 . $done;
rename ($file1, $file2) || die "Cannot rename $file1\n";
}
}
}
}
}
------------------------------
Date: Tue, 08 Jan 2008 22:20:13 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: remove special characters in front of the file names
Message-Id: <qbt7o31ood79v2um3j3pcjj8630eau4prb@4ax.com>
wong_powah@yahoo.ca wrote:
>e.g. for this output:
>$ find . -type f -print
>./VERSION
>./RELEASE
>
>My desired output will be:
>VERSION
>RELEASE
>
>This does not work:
>$ find . -type f -print | perl -pe 's/([?|*.\047"])/$1/g'
>./VERSION
>./RELEASE
I have a _very_ strong suspicion that we are looking at an x-y-problem.
You want to achieve something and you believe, removing "special" characters
from the beginning of the string is the best way to do it. Therefore you are
asking how to remove special characters. That would be the Y.
From you sample data I gather you are dealing with file names and I'm
guessing you want to get the basename of the file. That would be the X.
The right tool to do that would be File::Basename.
As for blindly removing those characters that you mentioned earlier
[?|*.\'"] are you aware, that in most file system many if not all of them
can be part of a regular file name? Do you really want to change the file
name if it starts with one of your "special" characters?
jue
------------------------------
Date: Tue, 08 Jan 2008 17:01:03 -0500
From: Bernie Cosell <bernie@fantasyfarm.com>
Subject: Using CPAN "lightweight"
Message-Id: <96s7o312i1lcro9a1aar7a9aih3avu5oer@library.airnews.net>
Is there a way to use the CPAN module *without* its creating a directory
and doing all sorts of fancy initialization and such? I want to set up a
program that I'd intended to "use CPAN" and do some mucking about with
modules and such, but when I try to run it I get barraged with dialogs and
it stashes away config stuff and who knows what... I'd like to run it
"self contained", no readline, no ".cpan" directories... just run?
I just tried and when it can't find a $HOME/.cpan dir with its config info
it launches into config-mode again... not so nice for a background task.
Can I somehow predefine all of the vbls that CPAN is looking for so it'll
just find 'em and be happy and not go poking around in the filesystem?
[also, is there a 'quiet' mode -- even when it finds what it wants I get
"Loading LWP...OK.. Fetching <something> with LWP" and all of that stuff].
Thanks!
/Bernie\
--
Bernie Cosell Fantasy Farm Fibers
bernie@fantasyfarm.com Pearisburg, VA
--> Too many people, too few sheep <--
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 1179
***************************************