[24792] in Perl-Users-Digest
Perl-Users Digest, Issue: 6945 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 2 11:06:16 2004
Date: Thu, 2 Sep 2004 08:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 2 Sep 2004 Volume: 10 Number: 6945
Today's topics:
Re: A question about Perl: using perl command line to r (Anno Siegel)
ActivePerl and @INC on Win2k (Horst Walter)
Re: How to emit signals in Glib::Object derived modules (Anno Siegel)
Re: how to use Perl to rename the filenames and directo (Anno Siegel)
Re: how to use Perl to rename the filenames and directo <bik.mido@tiscalinet.it>
Re: how to use Perl to rename the filenames and directo <jurgenex@hotmail.com>
Re: missing 0s (Anno Siegel)
Re: missing 0s (Min Wang)
Re: missing 0s <noreply@gunnar.cc>
Re: missing 0s <sholden@flexal.cs.usyd.edu.au>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 2 Sep 2004 10:33:42 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: A question about Perl: using perl command line to replace strings...
Message-Id: <ch6su6$29v$1@mamenchi.zrz.TU-Berlin.DE>
lucy <losemind@yahoo.com> wrote in comp.lang.perl.misc:
>
> "lucy" <losemind@yahoo.com> wrote in message
> news:ch5bgv$rs3$1@news.Stanford.EDU...
> >
> > "Scott W Gifford" <gifford@umich.edu> wrote in message
> > news:qszwtzdsu4b.fsf@tetris.gpcc.itd.umich.edu...
> >>[ Why was this crossposted to comp.soft-sys.matlab? ]
> >>
> >> "lucy" <losemind@yahoo.com> writes:
> >>
> >>> I have a quick question, how to change a string "abcd" to another string
> >>> "xyabcd" in all the *.m (text) files under current directory?
> >>
> >> perl -pi.bak -e's/abcd/xyabcd/g' *.m
> >>
> >> See the docs for the -i flag in perlrun(1) for more information.
> >>
> >> ----ScottG.
> >
> > That's great! That's exactly I want. But how can I make this work for all
> > subdirectories recursively?
> >
> > thanks a lot
> >
>
> And how to make it work even for filenames and directory names...?
Want it to milk the cows in the morning too?
Anno
------------------------------
Date: 2 Sep 2004 05:49:18 -0700
From: unkwb@web.de (Horst Walter)
Subject: ActivePerl and @INC on Win2k
Message-Id: <53867fbe.0409020449.763156e3@posting.google.com>
I have just installed ActivePerl and want to start the ppm. There I
get the following error
Can't locate Win32/TieRegistry.pm in @INC (@INC contains:
C:/ActivePerl/5.8.4/lib .) at C:\ActivePerl\5.8.4\bin\ppm.bat line 15.
When I run it from C:\ActivePerl\5.8.4\site\lib it works, makes sense
because the "." is in @INC.
Question: How can I somehow add C:\ActivePerl\5.8.4\site\lib to @INC.
I browsed thru the groups, but did not find something applicable to my
problem. Nor did I find any registry keys.
Thanks for any help
Env: Win2k
This is perl, v5.8.4 built for MSWin32-x86-multi-thread
(with 3 registered patches, see perl -V for more detail)
------------------------------
Date: 2 Sep 2004 09:13:47 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to emit signals in Glib::Object derived modules?
Message-Id: <ch6o8b$smk$1@mamenchi.zrz.TU-Berlin.DE>
Samuel Abels <newsgroups@debain.org> wrote in comp.lang.perl.misc:
> Hello,
>
> I am trying to implement a module derived from Glib::Object. This
> works fine, except for when I want my module to emit a self-defined
> signal.
>
> I know from the Gtk-Perl documentation that the signal has to be
> registered first.
> So this is what I figured should be right according to the docs:
>
> ------------------------------------------------
> #!/usr/bin/env perl
> package TestClass;
> use strict;
> use Gtk2 '-init';
> use vars qw(@ISA $VERSION);
> @ISA = qw(Glib::Object);
I don't know any specifics, but this will come to late for "use" to
see it. Put a BEGIN block around the @ISA assignment and try again.
Anno
------------------------------
Date: 2 Sep 2004 10:08:15 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: how to use Perl to rename the filenames and directory names under current and subdirectories recursively?
Message-Id: <ch6ref$67$2@mamenchi.zrz.TU-Berlin.DE>
lucy <losemind@yahoo.com> wrote in comp.lang.perl.misc:
> Is there a way to use Perl command line
>
> to rename all the filenames and directory names
>
> from '*abcd*.*' to '*xyz*.*'
>
> and do this recursively for all files and all subdirectories?
See the _Perl Cookbook_, a section titled "Renaming Files".
Anno
------------------------------
Date: Thu, 02 Sep 2004 14:18:29 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: how to use Perl to rename the filenames and directory names under current and subdirectories recursively?
Message-Id: <0l3ej09cab59ckcfsqt19f46f1qeh1ej6l@4ax.com>
On 1 Sep 2004 21:24:05 GMT, "A. Sinan Unur" <1usa@llenroc.ude.invalid>
wrote:
>"lucy" <losemind@yahoo.com> wrote in news:ch5bu2$s4b$1@news.Stanford.EDU:
>
>> Is there a way to use Perl command line
>>
>> to rename all the filenames and directory names
^^^^^^^^^^^^^^^
>> from '*abcd*.*' to '*xyz*.*'
>>
>> and do this recursively for all files and all subdirectories?
>
>
>use File::Find;
With some caution because of the above detail, i.e. if she really
wants to also rename directory names (and there are some to be
renamed), then something along the lines of
find sub {
rename $_, do {
(my $n=$_) =~ s/abc/xyz/ or return;
$n;
}
}, '.';
which is the kind of solution one may naively think about, simply
won't work. IMHO the best workaround would be to do the renaming in
'preprocess', returning the updated list, and actually doing nothing
in 'wanted'. All this is left as an exercise to the OP... ;-)
Michele
--
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
"perl bug File::Basename and Perl's nature"
------------------------------
Date: Thu, 02 Sep 2004 14:37:53 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: how to use Perl to rename the filenames and directory names under current and subdirectories recursively?
Message-Id: <5fGZc.3202$A63.72@trnddc09>
Michele Dondi wrote:
> On 1 Sep 2004 21:24:05 GMT, "A. Sinan Unur" <1usa@llenroc.ude.invalid>
> wrote:
>
>> "lucy" <losemind@yahoo.com> wrote in
>> news:ch5bu2$s4b$1@news.Stanford.EDU:
>>
>>> Is there a way to use Perl command line
>>>
>>> to rename all the filenames and directory names
> ^^^^^^^^^^^^^^^
>
>>> from '*abcd*.*' to '*xyz*.*'
>>>
>>> and do this recursively for all files and all subdirectories?
>>
>>
>> use File::Find;
>
> With some caution because of the above detail, i.e. if she really
> wants to also rename directory names (and there are some to be
> renamed), [...]
> which is the kind of solution one may naively think about, simply
> won't work. IMHO the best workaround would be to do the renaming in
> 'preprocess', returning the updated list, and actually doing nothing
> in 'wanted'. All this is left as an exercise to the OP... ;-)
Way to complicated. Just to a depth-first parsing and you will be fine.
jue
------------------------------
Date: 2 Sep 2004 09:52:17 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: missing 0s
Message-Id: <ch6qgh$67$1@mamenchi.zrz.TU-Berlin.DE>
Min Wang <dbymw@yahoo.com> wrote in comp.lang.perl.misc:
> I have line in a file
> 001-02-0003
>
> I do
> ($a,$b,$c) = split('-',$_) after read.
> Now I print them I get 1,2,3 instead of 001,02,0003.
How do you print them? Explaining in English what you (think you) did
is insufficient. Show your code!
If you print them in a normal print-statement immediately after the
split, the zeroes will show up. Gunnar has demonstrated that in
his reply. So what else are you doing? Are you using printf for
printing? With what format? Is there intervening code between the
split() and print()?
Anno
------------------------------
Date: 2 Sep 2004 04:41:01 -0700
From: dbymw@yahoo.com (Min Wang)
Subject: Re: missing 0s
Message-Id: <8da89ef8.0409020341.176a16c8@posting.google.com>
Gunnar,
Thank you very much.
Furthermore,
I tried
$x = substr($b, 0, 1);
$y = substr($b, 1);
I expect to have $x=0 and $y=2.
In stead, I got $x = 2 and $y is null.
Thanks.
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in message news:<2pn32uFmcsn0U1@uni-berlin.de>...
> Min Wang wrote:
> > I have line in a file
> > 001-02-0003
> >
> > I do
> > ($a,$b,$c) = split('-',$_) after read.
> > Now I print them I get 1,2,3 instead of 001,02,0003.
>
> $_ = '001-02-0003';
> my ($x,$y,$z) = split /-/;
> print "$x,$y,$z\n";
>
> Outputs:
> 001,02,0003
------------------------------
Date: Thu, 02 Sep 2004 15:05:41 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: missing 0s
Message-Id: <2pokpuFnh0maU1@uni-berlin.de>
Min Wang wrote:
> Gunnar Hjalmarsson wrote:
>> Min Wang wrote:
>>> I have line in a file
>>> 001-02-0003
>>>
>>> I do
>>> ($a,$b,$c) = split('-',$_) after read.
>>> Now I print them I get 1,2,3 instead of 001,02,0003.
>>
>> $_ = '001-02-0003';
>> my ($x,$y,$z) = split /-/;
>> print "$x,$y,$z\n";
>>
>> Outputs:
>> 001,02,0003
>
> Thank you very much.
>
> Furthermore,
>
> I tried
>
> $x = substr($b, 0, 1);
> $y = substr($b, 1);
>
> I expect to have $x=0 and $y=2.
> In stead, I got $x = 2 and $y is null.
my $first = substr $y, 0, 1;
my $second = substr $y, 1;
print "First: $first, second: $second\n";
Outputs:
First: 0, second: 2
Funny computer you have. :)
How about following Anno's advice and post the exact code that
produces the results you say it does?
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 2 Sep 2004 13:57:17 GMT
From: Sam Holden <sholden@flexal.cs.usyd.edu.au>
Subject: Re: missing 0s
Message-Id: <slrncje9lt.h12.sholden@flexal.cs.usyd.edu.au>
On 2 Sep 2004 04:41:01 -0700, Min Wang <dbymw@yahoo.com> wrote:
> Gunnar,
>
> Thank you very much.
>
> Furthermore,
>
> I tried
>
> $x = substr($b, 0, 1);
> $y = substr($b, 1);
>
> I expect to have $x=0 and $y=2.
> In stead, I got $x = 2 and $y is null.
No you don't:
$_ = '001-02-0003';
($a,$b,$c) = split('-',$_);
$x = substr($b, 0, 1);
$y = substr($b, 1);
print "*$x* *$y*\n";
Stop posting snippets of code and instead post a small self contained
script that demonstrates the problem. It'll only be a few lines long...
[snip a full quote, from which I retrieved the $_ = and split bits]
--
Sam Holden
------------------------------
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 V10 Issue 6945
***************************************