[24790] in Perl-Users-Digest
Perl-Users Digest, Issue: 6943 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 1 18:06:21 2004
Date: Wed, 1 Sep 2004 15:05:10 -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 Wed, 1 Sep 2004 Volume: 10 Number: 6943
Today's topics:
A question about Perl: using perl command line to repla <losemind@yahoo.com>
Re: A question about Perl: using perl command line to r <namdiesttocs@mindspring.com>
Re: A question about Perl: using perl command line to r <noreply@gunnar.cc>
Re: A question about Perl: using perl command line to r <losemind@yahoo.com>
Re: A question about Perl: using perl command line to r <losemind@yahoo.com>
Re: A question about Perl: using perl command line to r <gifford@umich.edu>
Re: Assistance parsing text file using Text::CSV_XS (Anno Siegel)
C<sub'a>? <bik.mido@tiscalinet.it>
Re: Can a path to a dir contain '.'? <1usa@llenroc.ude.invalid>
Re: Can a path to a dir contain '.'? (Michael Petersen)
Re: Can't locate object method ... utf8_heavy.pl <usenet@morrow.me.uk>
Re: Custom web design and web site development (krakle)
Re: Custom web design and web site development <lfylling@online.no>
Re: Fastest versions of perl? <Juha.Laiho@iki.fi>
Re: Fastest versions of perl? (Pablo S)
Re: Fastest versions of perl? <tore@aursand.no>
Re: Fastest versions of perl? <abigail@abigail.nl>
Re: Help: Open an URL an keep reading from it, non-bloc <mr@sandman.net>
how to use Perl to rename the filenames and directory n <losemind@yahoo.com>
Re: how to use Perl to rename the filenames and directo <1usa@llenroc.ude.invalid>
Re: N00b to PERL... help!! (krakle)
Re: N00b to PERL... help!! <tadmc@augustmail.com>
Re: Newbie: Win32:Sound:WaveOut problem <invalid@invalid.invalid>
Re: no re 'eval' not secure enough nobull@mail.com
Re: Parsing FileName for upload <usenet@morrow.me.uk>
q about MIME:Lite and using Bcc (dan baker)
Re: Reading Unicode File and Saving Contents to Access <usenet@morrow.me.uk>
Re: Regex matching a string that DOESN'T contain a give <miknrene@drizzle.com>
Re: Regex matching a string that DOESN'T contain a give <secret@secret.com>
Re: using the result of a variable regular expression <usenet@morrow.me.uk>
Re: What do the &= and &&= operators do? <usenet@morrow.me.uk>
Re: When using system() to invoke lynx; connect_timeout <tadmc@augustmail.com>
Re: Xah Lee's Unixism <wyrmwif@tango-sierra-oscar-foxtrot-tango.fake.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 1 Sep 2004 11:39:15 -0700
From: "lucy" <losemind@yahoo.com>
Subject: A question about Perl: using perl command line to replace strings...
Message-Id: <ch550l$j1t$1@news.Stanford.EDU>
I have a quick question, how to change a string "abcd" to another string
"xyabcd" in all the *.m (text) files under current directory?
I defintely can write a perl script to do this. But I remember there is a
most simple way of doing this using Perl.
It is just "Perl xxxxxxxxxxxxxxxx" a command line with some options...
It just escaped my memory, anybody knows how to do that please give me a
hand!
Thanks a lot.
------------------------------
Date: 1 Sep 2004 18:46:16 GMT
From: Scott Seidman <namdiesttocs@mindspring.com>
Subject: Re: A question about Perl: using perl command line to replace strings...
Message-Id: <Xns955796424D49scottseidmanmindspri@130.133.1.4>
"lucy" <losemind@yahoo.com> wrote in
news:ch550l$j1t$1@news.Stanford.EDU:
> I have a quick question, how to change a string "abcd" to another
> string "xyabcd" in all the *.m (text) files under current directory?
>
> I defintely can write a perl script to do this. But I remember there
> is a most simple way of doing this using Perl.
>
> It is just "Perl xxxxxxxxxxxxxxxx" a command line with some options...
>
> It just escaped my memory, anybody knows how to do that please give me
> a hand!
>
> Thanks a lot.
>
>
>
You still need to figure out what xxxxxxxxxxx is-- why not just put it in a
file and be done with it? It's going to be the same loop through the
directories in your file, the same search and replace statement, and the
same output commands.
Scott
------------------------------
Date: Wed, 01 Sep 2004 22:29:45 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: A question about Perl: using perl command line to replace strings...
Message-Id: <2pmq06Fmjvj0U1@uni-berlin.de>
lucy wrote:
> I have a quick question,
> ...
> I defintely can write a perl script to do this. But I remember
> there is a most simple way of doing this using Perl.
>
> It is just "Perl xxxxxxxxxxxxxxxx" a command line with some
> options...
>
> It just escaped my memory,
And the first thing you came to think of was asking lots of people (in
two!! newsgroups) for help.
> anybody knows how to do that please give me a hand!
Give you a hand with what? Looking it up in and reading the docs for
you??
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Wed, 1 Sep 2004 13:30:22 -0700
From: "lucy" <losemind@yahoo.com>
Subject: Re: A question about Perl: using perl command line to replace strings...
Message-Id: <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
------------------------------
Date: Wed, 1 Sep 2004 13:30:58 -0700
From: "lucy" <losemind@yahoo.com>
Subject: Re: A question about Perl: using perl command line to replace strings...
Message-Id: <ch5bi3$rtj$1@news.Stanford.EDU>
"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...?
------------------------------
Date: Wed, 01 Sep 2004 14:48:36 -0400
From: Scott W Gifford <gifford@umich.edu>
Subject: Re: A question about Perl: using perl command line to replace strings...
Message-Id: <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.
------------------------------
Date: 1 Sep 2004 18:20:23 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Assistance parsing text file using Text::CSV_XS
Message-Id: <ch53t7$t55$1@mamenchi.zrz.TU-Berlin.DE>
Scott W Gifford <gifford@umich.edu> wrote in comp.lang.perl.misc:
> "Domenico Discepola" <domenico_discepola@quadrachemicals.com> writes:
>
> > Hello. I'm trying to parse a text file into a 2-d array using Text::CSV_XS.
> > The input file is structured as follows. "Fields" are separated with a
> > "\x0d\x0a" (CRLF) and are enclosed in double-quotes. "Records" are
> > separated with a "\x0c" (FF). My fields can contain embedded CRLF's hence
> > the need for double-quoting. How can I use Text::CSV_XS to solve my
> > problem? My code below only outputs the first line in the input file.
> > Thanks in advance.
>
> Text::CSV_XS assumes that it's handed a full record at a time, and
> expects you to independently figure out where one record ends and the
> next one begins.
Well, *record* separation is easily done in this case. Just set
local $/ = "x0c";
and use <>, chomp() and whatever as usual to get one record each time.
If CSV_XS isn't upset by embedded linefeeds as such it can do the hard
part.
OP only mentions embedded record separators, not field separators, so
this should work.
Anno
------------------------------
Date: Wed, 01 Sep 2004 21:14:44 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: C<sub'a>?
Message-Id: <au6cj05iui659tt9fv0s7i0tj1lq9jsher@4ax.com>
A friend of mine has just written his first japh. A thing that I
couldn't understand at first[*], and that continued puzzling for quite
a while is a small fragment of code along the lines of
sub'a{that does something}
At first I was surprised that such a beast did even parse, but now I'm
highly confident I've understood why it does, although not
*completely* sure...
Well, here it comes: in earlier versions of perl you used e.g.
C<<$pkg'var>> instead of C<<$pkg::var>>, and that syntax is still
supported for backwards compatibility, so
sub'a
should be equivalent to
sub ::a # a.k.a. main::a
right?
Still assuming that my interpretation is correct, there remains one
subtle difference:
# perl -le "sub'a{9} print a"
9
# perl -le "sub::a{9} print a"
Can't call method "sub::a" without a package or object reference at
-e line 1.
# perl -le "sub ::a{9} print a"
9
So that it seems that perl disambiguates in different ways the two
constructs...
[*] And he doesn't, either, for he just copied that bit from some
other japh.
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: 1 Sep 2004 18:53:24 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Can a path to a dir contain '.'?
Message-Id: <Xns9557977993A0Dasu1cornelledu@132.236.56.8>
"David K. Wall" <dwall@fastmail.fm> wrote in
news:Xns95578A98B7A79dkwwashere@216.168.3.30:
> A. Sinan Unur <1usa@llenroc.ude.invalid> wrote in message
> <news:Xns95577E4D13159asu1cornelledu@132.236.56.8>:
>
>> micFJERN@reflector.dk (Michael Petersen) wrote in
>> news:1gjg3pb.1z0qu4twwzy9eN%micFJERN@reflector.dk:
>>
>>> a path in a perlscript
>>
>> No such thing called perlscript. ITYM Perl script.
>
> Well, there's the PerlScript that comes with Activestate Perl:
>
> "PerlScript is an ActiveX scripting engine that allows you to
> use Perl with any ActiveX scripting host."
I stand corrected. Thanks. On the other hand, the OP mentioned Unix, so
that is my excuse for jumping to conclusions.
Sinan.
------------------------------
Date: Wed, 1 Sep 2004 20:59:43 +0200
From: micFJERN@reflector.dk (Michael Petersen)
Subject: Re: Can a path to a dir contain '.'?
Message-Id: <1gjgcy4.h856au1vlgt95N%micFJERN@reflector.dk>
Scott W Gifford <gifford@umich.edu> wrote:
> micFJERN@reflector.dk (Michael Petersen) writes:
>
> > I really don't no much about perl or unix stuff so can anyone tell me if
> > a path in a perlscript to a directory can look like this
> > /www.domain.com/dir1/dir2 ??
>
> That's a perfectly acceptable path.
>
> ----ScottG.
Thanks - Mic
------------------------------
Date: Wed, 1 Sep 2004 00:35:05 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Can't locate object method ... utf8_heavy.pl
Message-Id: <9ief02-ps6.ln1@osiris.mauzo.dyndns.org>
Quoth Brad Baxter <bmb@ginger.libs.uga.edu>:
> Hello,
>
> This is perl, v5.6.1 built for sun4-solaris.
>
> I'm getting the following error:
>
> Can't locate object method "ToLower" via package "main" (perhaps you
> forgot to load "main"?) at /usr/local/lib/perl5/5.6.1/utf8_heavy.pl line
> 30.
>
> I've narrowed it down to this line (in a much longer program):
>
> lc $term;
>
> where $term eq 'id aarl001-003 ' (as far as I've been able to determine).
My guess would be that this string actually has some utf8 characters in
it, or has had at some point in the past. If you need to do Unicode
work, you would be *much* better off with 5.8; alternatively, if you are
acquiring unicode strings by accident you may be able to help things
with a 'use bytes' in various strategic places.
Not having 5.6 installed, can you post line 30 (with a decent amount of
context) of /.../utf8_heavy.pl?
Ben
--
perl -e'print map {/.(.)/s} sort unpack "a2"x26, pack "N"x13,
qw/1632265075 1651865445 1685354798 1696626283 1752131169 1769237618
1801808488 1830841936 1886550130 1914728293 1936225377 1969451372
2047502190/' # ben@morrow.me.uk
------------------------------
Date: 1 Sep 2004 11:35:50 -0700
From: krakle@visto.com (krakle)
Subject: Re: Custom web design and web site development
Message-Id: <237aaff8.0409011035.23e71ec6@posting.google.com>
cna_pgroup@yahoo.com (CNA Programming Group) wrote in message news:<a03287ab.0408310501.529d7472@posting.google.com>...
> I'm experienced PHP/Coldfusion developer from Russia with more than 5
> years of experience in the field.
>
> Also i have a good web designer here. So we can create the whole site
> from the very beginning.
>
> If you want to make a hi-quality website fast and for a reasonable
> price - than this offer is for you.
>
> I usually charge USD 7 per hour, but would rather like flat-rate
> per-project prices.
>
> Portfolio can be seen at http://www.actionwebstudio.com/portfolio.php
>
> Please contact us at http://www.actionwebstudio.com/contacts.php or
> via email at alex_c@list.ru if you are interested.
>
> Thanks
huh? what? $7 an hour?
Your work can't be "hi-quality".. Do yourself a favor and 1. stop
spamming and 2. get a job at mcdonalds they will pay you more :)
------------------------------
Date: Wed, 1 Sep 2004 21:23:24 +0200
From: "Lennart Fylling" <lfylling@online.no>
Subject: Re: Custom web design and web site development
Message-Id: <NkpZc.4482$WW4.62894@news4.e.nsc.no>
krakle wrote:
> huh? what? $7 an hour?
> Your work can't be "hi-quality".. Do yourself a favor and 1. stop
> spamming and 2. get a job at mcdonalds they will pay you more :)
3. read some articles on how you really design webpages. Here's a nice page
for beginners:
http://www.dezwozhere.com/links.html
--
Lennart Fylling
<testurl> http://lennart-fylling.com/ </testurl>
------------------------------
Date: Wed, 01 Sep 2004 18:07:02 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: Fastest versions of perl?
Message-Id: <ch531r$uk1$1@ichaos.ichaos-int>
pablo_tweek@yahoo.com (Pablo S) said:
>Run from bash on 2 redhat systems with the same hardware:
>
>#!/usr/bin/perl
>$start=time;
>my $i=20000000;
>
>while ($i) {
> $i--;
>}
>print "Finished!". (time - $start);
>
>
>Stock redhat 7.3: 3 seconds (5.6.1)
>Stock FC2: 37 seconds (5.8.3)
I may be completely beating the bushes here, but could you be seeing
something related to use of locales? Also, it might be a good idea to
install current patches to the FC2 system (if not done already).
Old RedHats (pre-9.0) used to run using some locale with 8-bit charset.
Later releases default to using UTF-8 character set. What was visible
at least with RH9 was a huge slowdown of 'grep' (roughly half the speed),
and the speed was easily restored by changing LC_CTYPE to a 8-bit
character set.
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)
------------------------------
Date: 1 Sep 2004 13:19:45 -0700
From: pablo_tweek@yahoo.com (Pablo S)
Subject: Re: Fastest versions of perl?
Message-Id: <76d9ca90.0409011219.5de4dbc0@posting.google.com>
Stephen Quinney <stephen@jadevine.org.uk> wrote in message news:<87r7pm4eo2.fsf@mizar.oucs.ox.ac.uk>...
> AlV <skweek@no.spam> writes:
>
> > Pablo S wrote:
> >> Hi, Check this paradox -
> >> Run from bash on 2 redhat systems with the same hardware:
> >> #!/usr/bin/perl $start=time;
> >> my $i=20000000;
> >> while ($i) {
> >> $i--;
> >> }
> >> print "Finished!". (time - $start);
> >> Stock redhat 7.3: 3 seconds (5.6.1)
> >> Stock FC2: 37 seconds (5.8.3)
> >
> > Well, I tested your program with my different perl installations
> > (compiled by myself for different purposes):
> > Perl 5.6.1 : 4 seconds
> > Perl 5.8.0 : 4 seconds
> > Perl 5.8.4 : 4 seconds
> >
> > My guess is either 5.8.3 was severely broken in case you should
> > upgrade or the soooo clever people at Fedora/Red Hat screwed something
> > ;o)
>
> Does that FC2 have SELinux turned on, in either mode? If so, that
> might slow things down a bit. It'd be interesting to see the breakdown
> of the total time into compile time and run time that might tell you
> where the real problem lies. Do other things on the FC2 box run slowly
> compared to the RH7.3 box? If so, I'd expect you've got a hardware
> problem somewhere.
>
> Stephen
Hardware indeed. =/ After recompiling a no-frills perl and having
basically exactly the same result, I compiled a quick C program and
ran that on the 2 systems. Same performance disparity. Tracked it to
the motherboard. I will now benchmark every system I buy.
So looks like the new perl, even multithreaded, still has comparable
performance, at least for me, on a variety of platforms. It's great
news!
Thanks all for the input!
Pablo
------------------------------
Date: Wed, 01 Sep 2004 22:21:56 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: Fastest versions of perl?
Message-Id: <pan.2004.09.01.20.21.56.308267@aursand.no>
On Wed, 01 Sep 2004 13:19:45 -0700, Pablo S wrote:
> After recompiling a no-frills perl and having basically exactly the same
> result, I compiled a quick C program and ran that on the 2 systems.
> Same performance disparity. Tracked it to the motherboard.
What motherboard is it?
--
Tore Aursand <tore@aursand.no>
"What we anticipate seldom occurs. What we least expected generally
happens." (Benjamin Disraeli)
------------------------------
Date: 01 Sep 2004 22:01:42 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Fastest versions of perl?
Message-Id: <slrncjchm6.fm.abigail@alexandra.abigail.nl>
Pablo S (pablo_tweek@yahoo.com) wrote on MMMMXIX September MCMXCIII in
<URL:news:76d9ca90.0408312216.384fda53@posting.google.com>:
:: Hi,
::
:: Check this paradox -
::
:: Run from bash on 2 redhat systems with the same hardware:
The *same* hardware? As in, you first installed the one OS, ran the
test, then you installed the other OS and ran the test again? Or
"same" as "my vendor gave me two sets of hardware with matching
type numbers on the components"?
Anyway, here are my results, running on the same OS on the same hardware:
4.16usr 0.00sys [5.000]
5.04usr 0.01sys [5.004_04]
5.03usr 0.01sys [5.004_05]
5.07usr 0.01sys [5.005]
5.07usr 0.03sys [5.005_01]
5.05usr 0.01sys [5.005_02]
5.13usr 0.00sys [5.005_03]
5.04usr 0.01sys [5.005_04]
5.33usr 0.00sys [5.6.0]
5.09usr 0.02sys [5.6.1]
5.07usr 0.01sys [5.6.2]
5.23usr 0.02sys [5.8.0]
4.71usr 0.00sys [5.8.1]
4.70usr 0.00sys [5.8.2]
4.72usr 0.02sys [5.8.3]
4.72usr 0.00sys [5.8.4]
4.68usr 0.02sys [5.8.5]
4.72usr 0.01sys [5.9.0]
4.72usr 0.00sys [5.9.1]
And this is the program to create the results:
#!/usr/bin/perl
use strict;
use warnings;
no warnings qw /syntax/;
my @versions = qw /5.000 5.004_04 5.004_05 5.005 5.005_01 5.005_02
5.005_03 5.005_04 5.6.0 5.6.1 5.6.2 5.8.0
5.8.1 5.8.2 5.8.3 5.8.4 5.8.5 5.9.0
5.9.1/;
my $program = 'my $i = 20_000_000; while ($i) {$i --}';
foreach my $version (@versions) {
system time => -f => "%Uusr %Ssys [$version]",
"/opt/perl/$version/bin/perl", -we => $program;
die "time died with ", $? >> 8, "\n" if $?;
}
__END__
Abigail
--
#!/opt/perl/bin/perl -w
$\ = $"; $; = $$; END {$: and print $:} $SIG {TERM} = sub {$ := $_}; kill 15 =>
fork and ($; == getppid and exit or wait) foreach qw /Just another Perl Hacker/
------------------------------
Date: Wed, 01 Sep 2004 20:16:21 +0200
From: Sandman <mr@sandman.net>
Subject: Re: Help: Open an URL an keep reading from it, non-blocking
Message-Id: <mr-C80D67.20162101092004@individual.net>
In article <Xns9556A97A6215castleamber@130.133.1.4>,
John Bokma <postmaster@castleamber.com> wrote:
> A web based chat uses a method I call infinite loading. Basically the
> browser opens the url, but it never stops, like it is downloading an
> infinite long page. The chat system just keeps adding new lines.
>
> Is there a way to do this in Perl. I mean, is there a module that let's me
> see if there is data available, and read it, and move on in a loop?
>
> I can write it, but I don't like reinventing wheels.
I once wrote a IRC bot using only IO::Socket, that connected to an IRC server,
logged on and executed command when specific strings were sent from the server.
Sounds like all you want to do is connect to a web server on port 80, request a
specific URI and then just read the data the server sends you.
It should be noted that I was a -complete- novice when I wrote that script (as
if THAT has changed significantly), so using IO::Socket might have been a
really bad idea, but it worked.
It looked something like this (bits and parts of the app, with what I remember
to be the things that made it work, this won't work since I snipped it heavily):
------------------------
#!/usr/bin/perl
# no strict or warnings here, suppress them all! Screw the Real Way! :)
# lots of setup stuff snipped, like $server declarations and such.
$|++; # Don't buffer output
use IO::Socket;
$host = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr => "$server",
PeerPort => "$port",
) or { error("Cannot connect to host: $server \n$!") };
$host->autoflush(1);
# This, uh.. flushes every line to output...? I don't remmeber
$SIG{ALRM}='timeout'; # When alarm triggers, run sub 'timeout'.
# If we didn't die, the connection is made
print $host "NICK $nickname\n";
print $host "USER sandman sandman.net $server\n";
alarm 30; # trigger the alarm in 30 seconds.
while (<$host>) {
last if / 376 /; # We recieved what we wanted to recieve at this point
}
alarm 0; # reset the alarm if we completed within 30 seconds
# Then next block of commands, working pretty much the same way
sub timeout {
error("No response in 30 seconds, timeout.");
}
------------------------
So, I had a series of while loops to wait for the correct answer from the irc
server and so on. There are probably a bunch of oldies that will twist in agony
over the above code, but what the hell - maybe it helps you in some way? Oh,
the error sub just printed the error and then quit the program, nothing fancy.
If you want I could probably code a working example of talking to an IRC
server, and use strict and warnings.
--
Sandman[.net]
------------------------------
Date: Wed, 1 Sep 2004 13:37:21 -0700
From: "lucy" <losemind@yahoo.com>
Subject: how to use Perl to rename the filenames and directory names under current and subdirectories recursively?
Message-Id: <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?
Thanks a lot
------------------------------
Date: 1 Sep 2004 21:24:05 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: how to use Perl to rename the filenames and directory names under current and subdirectories recursively?
Message-Id: <Xns9557B104AB2E0asu1cornelledu@132.236.56.8>
"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;
------------------------------
Date: 1 Sep 2004 11:33:19 -0700
From: krakle@visto.com (krakle)
Subject: Re: N00b to PERL... help!!
Message-Id: <237aaff8.0409011033.4cec78ff@posting.google.com>
"Jürgen Exner" <jurgenex@hotmail.com> wrote in message news:<ibIYc.3233$bD5.2269@trnddc03>...
> ft4bredn wrote:
> > I have recently become interested in PERL, after trying to figure
>
> Please note, the programming language you are probably talking about is
> called Perl, the interpreter for Perl is called perl.
> If you really want to discuss PERL (whatever that may be), then you came to
> the wrong place.
> Some people are very particular about the proper spelling.
I think it's ridiculous you even bring that up. What are you 13?
------------------------------
Date: Wed, 1 Sep 2004 13:40:20 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: N00b to PERL... help!!
Message-Id: <slrncjc5sk.68q.tadmc@magna.augustmail.com>
ft4bredn <none@anytime.net> wrote:
> Subject: N00b to PERL... help!!
Please put the subject of your article in the Subject of your article.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 01 Sep 2004 21:47:00 GMT
From: "DG" <invalid@invalid.invalid>
Subject: Re: Newbie: Win32:Sound:WaveOut problem
Message-Id: <orrZc.220240$8_6.76208@attbi_s04>
I found a solution at:
http://aspn.activestate.com/ASPN/Mail/Message/activeperl/1520559
The "Win32:Sound:WaveOut" module seems to have a bug when opening files.
The link above shows how to fix this module.
Also, there seems to be a documentation error. "Play([FROM, TO])" should be
"Play([FROM, DURATION])". For example, if you want to play from sample
#1200 to sample #1800 (duration of 600 samples) the documentation says that
you would use "$WAV->Play(1200,1800)". But my tests show that you should
use "$WAV->Play(1200,600)". So the second term is NOT the "TO" location, it
is the "DURATION" or number of samples to play starting after "FROM".
Hope this info helps someone else.
DG
"DG" <invalid@invalid.invalid> wrote in message
news:z1iZc.96511$Fg5.43900@attbi_s53...
> Hello and thanks for the help,
>
> I would like to play a *portion* of a wav file (say from sample 400 to
> sample 9000) on a Windows machine.
> Unfortunately, I'm unable to get my code to work. Below are my tests.
>
> I tried the following code:
>
> use Win32::Sound;
> $WAV = new Win32::Sound::WaveOut("klaxton.wav"); #open "klaxton.wav"
> located in the current directory
> $WAV->Play(400,9000); #play from sample 400
to
> sample 9000
>
>
> When I run it, I get the following error messages:
> Use of uninitialized value at C:/Perl/site/lib/Win32/Sound.pm line 109.
> Argument "klaxton.wav" isn't numeric in entersub at
> C:/Perl/site/lib/Win32/Sound.pm line 109.
>
>
> So I tried the modified code below:
>
> use Win32::Sound;
> $WAV = new Win32::Sound::WaveOut(); #use defaults
> $WAV->Open("klaxton.wav"); #open "klaxton.wav" located in the
> current directory
> $WAV->Play(400,9000); #play from sample 400 to sample
9000
>
> When I run it, I get the following error messages:
> Use of uninitialized value at C:/Perl/site/lib/Win32/Sound.pm line 109.
> Use of uninitialized value at C:/Perl/site/lib/Win32/Sound.pm line 109.
> Use of uninitialized value at C:/Perl/site/lib/Win32/Sound.pm line 109.
> Use of uninitialized value at x.bat line 28.
> Argument "klaxton.wav" isn't numeric in entersub at x.bat line 28.
>
>
> To test the Sound package, I ran the following code (it worked fine):
> use Win32::Sound;
> Win32::Sound::Play("klaxton.wav");
>
>
> To test the WaveOut package, I ran the example code given in the
> documentation (shown below). It worked fine.
>
>
> use Win32::Sound;
>
> # Create the object
> $WAV = new Win32::Sound::WaveOut(44100, 8, 2);
>
> $data = "";
> $counter = 0;
> $increment = 440/44100;
>
> # Generate 44100 samples ( = 1 second)
> for $i (1..44100) {
>
> # Calculate the pitch
> # (range 0..255 for 8 bits)
> $v = sin($counter/2*3.14) * 128 + 128;
>
> # "pack" it twice for left and right
> $data .= pack("cc", $v, $v);
>
> $counter += $increment;
> }
>
> $WAV->Load($data); # get it
> $WAV->Write(); # hear it
> 1 until $WAV->Status(); # wait for completion
> $WAV->Save("sinus.wav"); # write to disk
> $WAV->Unload(); # drop it
>
>
> So the packages are working. The wav file is present. Yet I can't get
my
> original code to work. What am I doing wrong?
>
> thanks for the help,
> DG
>
>
------------------------------
Date: 1 Sep 2004 11:11:34 -0700
From: nobull@mail.com
Subject: Re: no re 'eval' not secure enough
Message-Id: <4dafc536.0409011011.6cea3550@posting.google.com>
Matthew Braid <mb@uq.net.au.invalid> wrote in message news:<cgmacc$82$1@bunyip.cc.uq.edu.au>...
> Matthew Braid wrote:
>
> In this case I was looking for holes in the idea of 'securing' an object's data
> through a my'd hash inside the package keyed on an instance's stringification
> (eg Object::Child=SCALAR(0x813221c)) and I thought that maybe an eval inside an
> RE might be able to access that. After testing I found they can't. That's when I
> was supposed to hit cancel instead of send :)
But your threat model is still bogus. Your module cannot 'secure' its
data against the determined programmer[1]. The programmer can simply
edit the source of your module and change the hash from lexically
scoped to package scoped or they could use B and PadWalker.
[1] Or anyone able to execute arbitrary Perl code on the system due to
a security hole elsewhere.
------------------------------
Date: Tue, 31 Aug 2004 19:45:41 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Parsing FileName for upload
Message-Id: <ljte02-fc5.ln1@osiris.mauzo.dyndns.org>
Quoth Tore Aursand <tore@aursand.no>:
> On Thu, 26 Aug 2004 12:07:27 +0100, Brian McCauley wrote:
> >> Use the File::Basename module, for God's sake!
>
> > Bzzzt! That doesn't help. File::Basename parses (by default) acording
> > to the local OS's syntax. Since we're talking here about filnames
> > comming from a remote computer running a potentially different OS this
> > is worse than useless.
>
> Damn! You're so right. My fault not thinking of that, of course. But
> there must be (a) module(s) which is safer than the approached solution?
File::Spec::*
I don't know why these haven't been amalgamated with File::Basename:
they have completely independant path-parsing logic...
Ben
--
I must not fear. Fear is the mind-killer. I will face my fear and
I will let it pass through me. When the fear is gone there will be
nothing. Only I will remain.
ben@morrow.me.uk Frank Herbert, 'Dune'
------------------------------
Date: 1 Sep 2004 11:48:13 -0700
From: botfood@yahoo.com (dan baker)
Subject: q about MIME:Lite and using Bcc
Message-Id: <13685ef8.0409011048.7e9e9824@posting.google.com>
I have been trying all kinds of ways to add Bcc recipients to email
generated with MIME:Lite on a windows 98 pre-compiled install from
ActiveState and sent via SMTP. The version says it is $Id: Lite.pm,v
2.102 2000/08/15 01:32:50 eryq Exp $
does anyone have an example, or can you verify that bcc does indeed
work with this version on this platform?
this should work: ???
$msg = MIME::Lite->new(
From => $Sender ,
To => $Recipient ,
Bcc =>
'test1@mydomain.com,test2@mydomain.com' ,
Subject => $Subject ,
Type => $Type ,
Data => $Body
);
thanks
------------------------------
Date: Wed, 1 Sep 2004 01:33:02 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Reading Unicode File and Saving Contents to Access
Message-Id: <uuhf02-ps6.ln1@osiris.mauzo.dyndns.org>
Quoth qjason@starhub.net.sg:
> Hi
>
> I have a Unicode (utf8) file containing Unicode characters. I need to
> open this file, read each line, then save it to an Access database
> table via SQL.
>
> This is my script:
>
> #--------------------------------------------------
> $file = 'unicode.txt';
> open (FILE, "$file") || print "cannot open $file: $!";
> while (<FILE>)
> {
> $name = $_;
>
> $sql = "INSERT INTO `sql_table` VALUES ('$name')";
> &execute_sql;
> }
Use DBI instead. My guess would be that the ODBC driver (or whatever)
can cope with these issues. If that doesn't work...
> #--------------------------------------------------
>
> However, what gets inserted into the Access table does not match the
> original characters.
>
> What am I doing wrong, and what is the correct way to read the Unicode
> file and save the contents?
>
> I have looked at the "Unicode::String" module, but am not sure how to
> use it in my case.
At a guess, M$ use utf16 instead of utf8. You want perl5.8 and the
Encode module; then you can say
my $name = encode 'UTF-16', $_;
my $sql = "INSERT INTO 'sql_table' VALUES ('$name')";
instead. You may have problems with endianness/BOMs; these may or may
not be soluble with one of
my $name = encode 'UTF-16LE', $_;
my $sql = "INSERT INTO 'sql_table' VALUES ('$name')";
my $sql = "INSERT INTO 'sql_table' VALUES ('$_')";
$sql = encode 'UTF-16', $_;
Ben
--
The cosmos, at best, is like a rubbish heap scattered at random.
- Heraclitus
ben@morrow.me.uk
------------------------------
Date: Wed, 01 Sep 2004 12:42:57 -0700
From: Michael Slass <miknrene@drizzle.com>
Subject: Re: Regex matching a string that DOESN'T contain a given word
Message-Id: <m3eklldbcu.fsf@eric.rossnet.com>
"secret" <secret@secret.com> writes:
>I know it's a strange requirement. The problem is that I'm using 'ant' as
>my build tool. Part of what it does is check cvs for new check-ins. If it
>finds one I then want to determine where it is in the module to see what
>needs rebuilding. So if the only checkins are in the test directory, I'll
>just re-run the tests. If, however, there's a checkin that's not in the
>tests dir then I have to rebuild everything and then run the tests.
>
>This is a simplification of my task, but it's close enough.
>
>I'm trying to avoid writing a custom ant task to do this work, so I'm using
>a 'grep' task, which I had hoped would suffice but, if I understand your
>posts, it won't.
>
>alan
>
Java's regular expressions, contained in java.util.regex, have
negative-lookahead, so maybe you can get what you want by writing a
path-matching class using those, and then calling it with the "java"
task. That beats shelling out to perl in that it runs in-proc with
ant (unless you specify the fork="true" attribute).
--
Mike Slass
------------------------------
Date: Wed, 01 Sep 2004 20:48:25 GMT
From: "secret" <secret@secret.com>
Subject: Re: Regex matching a string that DOESN'T contain a given word
Message-Id: <tAqZc.14607$4G.5228@newssvr29.news.prodigy.com>
That's the advice I was in need of!
Thanks Michael, negative lookahead is indeed my friend! And if this
question does make it into th FAQ then this is the answer I would have been
searching for. My problem was finding the right words to google on. I'm
sure this question has been answered before but I'm damned if I could find
it with my search words...
alan
"Michael Slass" <miknrene@drizzle.com> wrote in message
news:m3eklldbcu.fsf@eric.rossnet.com...
> "secret" <secret@secret.com> writes:
>
> >I know it's a strange requirement. The problem is that I'm using 'ant'
as
> >my build tool. Part of what it does is check cvs for new check-ins. If
it
> >finds one I then want to determine where it is in the module to see what
> >needs rebuilding. So if the only checkins are in the test directory,
I'll
> >just re-run the tests. If, however, there's a checkin that's not in the
> >tests dir then I have to rebuild everything and then run the tests.
> >
> >This is a simplification of my task, but it's close enough.
> >
> >I'm trying to avoid writing a custom ant task to do this work, so I'm
using
> >a 'grep' task, which I had hoped would suffice but, if I understand your
> >posts, it won't.
> >
> >alan
> >
>
> Java's regular expressions, contained in java.util.regex, have
> negative-lookahead, so maybe you can get what you want by writing a
> path-matching class using those, and then calling it with the "java"
> task. That beats shelling out to perl in that it runs in-proc with
> ant (unless you specify the fork="true" attribute).
>
> --
> Mike Slass
------------------------------
Date: Tue, 31 Aug 2004 19:56:06 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: using the result of a variable regular expression
Message-Id: <67ue02-fc5.ln1@osiris.mauzo.dyndns.org>
Quoth Brian McCauley <nobull@mail.com>:
> It is possible to
> convert a hard reference[1] into an address in memory simply by using it
> in a numeric context. It is not possible to go the other way[4]. If
[1] NMF
> [4] In Perl - you can of course do anything you want by dropping down
> into C.
You don't need C: unpack 'P' will work nicely... :)
Ben
--
Although few may originate a policy, we are all able to judge it.
- Pericles of Athens, c.430 B.C.
ben@morrow.me.uk
------------------------------
Date: Wed, 1 Sep 2004 01:43:04 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: What do the &= and &&= operators do?
Message-Id: <ohif02-ps6.ln1@osiris.mauzo.dyndns.org>
Quoth x3v0-usenet@yahoo.com (Xevo):
> I can not find any information on what the "and equal" operators &=
> and &&= do. I looked in the 'Programming Perl' book, searched
> perldoc.com, and tried to google it, but to no avail. Can anyone fill
> me in on how to use these strange operators?
Exactly what they say on the tin:
$a &= $b;
is equivalent to
$a = $a & $b;
except that $a is only evaluated once. Ditto &&=. Why you would want to
do that is left as an exercise for the reader :).
(actually, &= could be useful for clearing bits in a bit-vector:
$flags |= FLAG_BIT; # set the bit
$flags &= ~FLAG_BIT; # clear it
but one doesn't do that sort of thing much in Perl.)
Ben
--
I must not fear. Fear is the mind-killer. I will face my fear and
I will let it pass through me. When the fear is gone there will be
nothing. Only I will remain.
ben@morrow.me.uk Frank Herbert, 'Dune'
------------------------------
Date: Wed, 1 Sep 2004 13:38:08 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: When using system() to invoke lynx; connect_timeout ignored
Message-Id: <slrncjc5og.67f.tadmc@magna.augustmail.com>
Dan Johnson <booner@hfx.eastlink.ca> wrote:
> It has been my habit, for some time now , to use lynx; called through
> the Perl system() command; to grab web pages for processing. The LWP
> module would probably do a better job; yet old habits are hard to
> break. That said; my old habit is not doing the job for me at the
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> moment.
A perfect reason to break your old habit!
Does it work when you use LWP::* ?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 01 Sep 2004 19:06:06 -0000
From: SM Ryan <wyrmwif@tango-sierra-oscar-foxtrot-tango.fake.org>
Subject: Re: Xah Lee's Unixism
Message-Id: <10jc7cu7e57koaa@corp.supernews.com>
rpw3@rpw3.org (Rob Warnock) wrote:
# Craig A. Finseth <news@finseth.com> wrote:
# +---------------
# | Ville Vainio <ville@spammers.com> wrote:
# | >... and / as path separator still screws up most of their cmd line
# | >programs (which think / is for command line options).
# | >Microsoft probably thought avoiding compatibility is a good idea, and
# | >have only lately started to have some regrets...
# |
# | Wrong. The / was chosen as the command line option separator because
# | whoever wrote MSDOS was looking to CP/M, who modelled their commands
# | after a PDP-11 operating system (RT-11?).
# +---------------
#
# Which, like PS/8 & OS-8 [and "DECsystem-8" from Geordia Tech] for the
# PDP-8, modelled the command syntax after that of the venerable PDP-10!!
There's a story about why railroad tracks are spaced the way they are.
Dig deep enough and traces of old DEC, IBM, CDC, Honeywell, and Burroughs
can still be found.
--
SM Ryan http://www.rawbw.com/~wyrmwif/
I'm not even supposed to be here today.
------------------------------
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 6943
***************************************