[23232] in Perl-Users-Digest
Perl-Users Digest, Issue: 5453 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 6 14:06:34 2003
Date: Sat, 6 Sep 2003 11:05:11 -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 Sat, 6 Sep 2003 Volume: 10 Number: 5453
Today's topics:
Active Perl, Windows scheduler, regular task... <flavell@mail.cern.ch>
Re: Active Perl, Windows scheduler, regular task... <pne-news-20030906@newton.digitalspace.net>
Re: Active Perl, Windows scheduler, regular task... <flavell@mail.cern.ch>
AI::GA (Arthur T. Murray)
Re: Embedded Perl or Python (XPost) <tassilo.parseval@rwth-aachen.de>
Re: Embedded Perl or Python (XPost) <aleax@aleax.it>
flash form strange encoding (Sem K.)
Re: How to replace globally a string1 with string2 only (giri alamuri)
Re: How to replace globally a string1 with string2 only (Tad McClellan)
Re: How to replace globally a string1 with string2 only (Tad McClellan)
Re: libxml-perl-0.07 and perl5.8.0 - fails test <thecommissioner@hotmail.com>
Re: looking for a nedit Syntax Pattern file for perl <andrew@NOSPAM_andicrook.demon.co.uk>
Re: Net::SSH::Perl <abuse@mweb.co.za>
Re: Perl - Absolute min. environment required. <newsfeed@boog.co.uk>
Re: PHP vs Perl <newsfeed@boog.co.uk>
Re: read VB file with Perl <tassilo.parseval@rwth-aachen.de>
splitting an array (debraj)
Re: splitting an array <laocoon@fastmail.fm>
Re: splitting an array (Jay Tilton)
system und metachar <adjudant.tassin@laposte.net>
Re: system und metachar <shawn@magma.ca>
Re: system und metachar (Tad McClellan)
Trouble with Class::DBI (Tore Aursand)
Re: uping and downing letters <abigail@abigail.nl>
Re: <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 6 Sep 2003 14:53:05 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Active Perl, Windows scheduler, regular task...
Message-Id: <Pine.LNX.4.53.0309061432020.5496@lxplus084.cern.ch>
Folks, At risk of being ruled OT, I'd appreciate guidance for the
following kind of task which we need to solve, which I'm proposing to
do from an Active Perl script. Assume Win2K or similar (NT4 maybe).
A particular piece of software on laptops is to be kept updated "over
the network" from a distribution server. The laptops are only
intermittently active, and even when they're active they may or may
not have network access.
The network copy that they're to be kept updated against will be
changed (let's say) once a day. So: once an update has been
successful, it's pointless to run it again until the next distribution
is due (although I suppose it would be OK for a low-fat script to
start up, take a look at some last-successful-run timestamp, and then
calmly exit). But we want that if the laptop goes online even once in
a day, then we don't want to miss that day's update.
However, if we set the task scheduler to run the script every couple
of hours, it could well go for days before the scheduled run happens
to hit a moment when the laptop is active and has network access.
If we set it to run every few minutes, the users complain of the task
disrupting their work. Especially as - despite much hunting around -
I don't seem to be able to get the Perl script to run without
flashing-up a DOS window briefly (there must be an answer to that but
somehow I can't find it - you can tell that I'm no great Windows fan)
Is the task scheduler the right approach to this at all, or should I
perhaps be looking to run the script as a system service or something?
This kind of job doesn't seem to be to be an unusual requirement, I
feel sure someone has successfully done something similar. Please?
------------------------------
Date: Sat, 06 Sep 2003 17:56:13 +0200
From: Philip Newton <pne-news-20030906@newton.digitalspace.net>
Subject: Re: Active Perl, Windows scheduler, regular task...
Message-Id: <qp0klv0bve888vsm4fm6m0k6adt2n2h9v9@4ax.com>
On Sat, 6 Sep 2003 14:53:05 +0200, "Alan J. Flavell"
<flavell@mail.cern.ch> wrote:
> I don't seem to be able to get the Perl script to run without
> flashing-up a DOS window briefly (there must be an answer to that but
> somehow I can't find it - you can tell that I'm no great Windows fan)
From README.win32 in the source distribution (which gets installed as
"perlwin32", and may be in <ActivePerl
directory>/html/lib/Pod/libwin32.html):
If you want to start a copy
of C<perl> without opening a command-line window, use the C<wperl>
executable built during the installation process. Usage is exactly
the same as normal C<perl> on Win32, except that options like C<-h>
don't work (since they need a command-line window to print to).
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Sat, 6 Sep 2003 18:42:27 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Active Perl, Windows scheduler, regular task...
Message-Id: <Pine.LNX.4.53.0309061809531.5496@lxplus084.cern.ch>
On Sat, Sep 6, Philip Newton inscribed on the eternal scroll:
> From README.win32 in the source distribution (which gets installed as
> "perlwin32", and may be in <ActivePerl
> directory>/html/lib/Pod/libwin32.html):
Thanks! Sigh, I had dutifully hunted around under the sub-headings
of "Windows Specific", and several other likely places, and drawn a
blank. It never occured to me to read the instructions for _building_
Perl, since I had no intention of "building Perl". Sorry!
> If you want to start a copy
> of C<perl> without opening a command-line window, use the C<wperl>
> executable built during the installation process.
Thanks! - so I've defined the windows scheduler task to be
wperl c:\path\to\script.pl
and can confirm that it works fine, thanks.
I'm still wondering whether I'm heading down the wrong track and ought
to be looking to define a script as a system service, but I think this
approach will work. Thanks for the help!
cheers
------------------------------
Date: 6 Sep 2003 09:47:35 -0800
From: uj797@victoria.tc.ca (Arthur T. Murray)
Subject: AI::GA
Message-Id: <3f5a0fa7@news.victoria.tc.ca>
Keywords: AI, artificial intelligence, genetic algorithms, supercomputers
AI::GA - a general genetic algorithm library is at
http://www.skamphausen.de/software/AI/ga.html from
AI Modules for Perl -- by Stefan Kamphausen
http://www.skamphausen.de/software/AI/index.html found at
http://www.nooranch.com/synaesmedia/wiki/wiki.cgi?AgentsBotsEtc
in the ThoughtStorms Wiki of Phil Jones.
http://mentifex.virtualentity.com/perl.html "Perl AI Weblog"
is the start of an ambitious effort to code Supercomputer AI.
A.T. Murray
--
http://www.kurzweilai.net/mindx/profile.php?id=26 - Mind-eXchange
------------------------------
Date: 6 Sep 2003 09:27:32 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Embedded Perl or Python (XPost)
Message-Id: <bjc9a4$qso$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Alex Martelli:
[ embedding an interpreter ]
> Another option you may want to consider is Ruby. I don't know
> how easy it is to interface it specifically to C++, and in
> particular to get the cross-language subclassing and overriding
> effect you want (which Boost provides so smoothly) -- but it's
> basically the same power as Perl or Python, a distinctive style
> of its own that along some axes lies in-between the two P's,
> and a small but enthusiastic community. Size-wise, though, I
> don't think it will significantly help you.
The C interface of Ruby is very simple and clear (likewise the C code in
which Ruby was written). It almost made me cry when I saw it and
compared it to that of Perl. :-) It's probably also smaller than both
Python and Perl. I don't know about Python, but Perl's unwrapped source
is currently well beyond 50meg. In compiled form it's still pretty large
due to all the modules that come with Perl. Not sure whether the OP
needs all of them though.
The bridge to C++ should not be so hard considering that a C++ compilers
wont mind to include C code as well (or can at the very least easily be
convinced to do so).
But anyway, embedding Perl is known to be hard.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Sat, 06 Sep 2003 15:30:09 GMT
From: Alex Martelli <aleax@aleax.it>
Subject: Re: Embedded Perl or Python (XPost)
Message-Id: <54n6b.22635$hE5.830077@news1.tin.it>
Tassilo v. Parseval wrote:
> Also sprach Alex Martelli:
>
> [ embedding an interpreter ]
>
>> Another option you may want to consider is Ruby. I don't know
>> how easy it is to interface it specifically to C++, and in
>> particular to get the cross-language subclassing and overriding
>> effect you want (which Boost provides so smoothly) -- but it's
>> basically the same power as Perl or Python, a distinctive style
>> of its own that along some axes lies in-between the two P's,
>> and a small but enthusiastic community. Size-wise, though, I
>> don't think it will significantly help you.
>
> The C interface of Ruby is very simple and clear (likewise the C code in
> which Ruby was written). It almost made me cry when I saw it and
> compared it to that of Perl. :-) It's probably also smaller than both
> Python and Perl. I don't know about Python, but Perl's unwrapped source
> is currently well beyond 50meg. In compiled form it's still pretty large
For Python, I count 1.8 MB of .h files, 7.6 MB of .C files, and
1.8 MB of .py files. Of course, that includes all sort of things
such as the RISCOS and Mac/OS implementations, the Tkinter GUI
library, the IDLE integrated development environment, and a
bazillion other tools, unit and integration tests, and "weird" library
modules (Python lacks Perl's CPAN, so far, but does have a huge included
library).
In terms of compiled size, I see:
[alex@lancelot src]$ size /usr/bin/ruby
text data bss dec hex filename
569672 4192 56768 630632 99f68 /usr/bin/ruby
[alex@lancelot src]$ size /usr/bin/python*
text data bss dec hex filename
514283 90792 9240 614315 95fab /usr/bin/python2.1
(these are the latest statically linked ones I have around)
so the sizes would appear to be very directly comparable (sorry,
no statically linked perl around for comparison!).
> due to all the modules that come with Perl. Not sure whether the OP
> needs all of them though.
He did say he plans to cut things out selectively (e.g. sockets).
> The bridge to C++ should not be so hard considering that a C++ compilers
> wont mind to include C code as well (or can at the very least easily be
> convinced to do so).
Ah, but what the OP wants is specifically for (Python/Perl/Ruby) classes
to be able to inherit from C++ classes, override some methods, and be
callable from C++ with the overridden methods smoothing and transparently
executed. That's far from being as simple as it sounds -- it just can't
be done at a purely C level, and Boost Python does manage to pull it off
with much C++ template metaprogramming (David Abrahams, Boost Python's
author, is one of the true magicians in this specific area).
Alex
------------------------------
Date: 6 Sep 2003 02:28:53 -0700
From: ibt325@bk.ru (Sem K.)
Subject: flash form strange encoding
Message-Id: <12c42ee3.0309060128.1dc0d89e@posting.google.com>
Hi,
I have an internationalized flash form, that posts (via GET) to a perl
cgi script.
The form has a name field. 3/4 of the times, I receive the name, as I
expect in unicode. However, in other cases, I receive something like
that: "áãéºä ...." .
Have someone encountered something similar ?
It is not "escaping" as far as I understand. And I can't identify the
encoding.
Any help will be appretiated.
Thanks,
Sem K.
------------------------------
Date: 6 Sep 2003 02:34:27 -0700
From: galamuri81@yahoo.com (giri alamuri)
Subject: Re: How to replace globally a string1 with string2 only if string1 does not have a sub_strig
Message-Id: <1547077a.0309060134.558aa64a@posting.google.com>
I tried negative look ahead, but it does not work.
Having (?!...) does not have any effect. The ... string
is matched as normal string.
Am I doing any mistake in using negative look ahead?
Here is the sample code and output:
#!/usr/lecal/bin/perl -w
foreach (<DATA>) {
s/abc($!_do_not_match_)def/uvwxyz/g;
print;
}
__DATA__
abc_do_not_match_def
abc_do_not_matchmatch_def
abcdef
script output:
---------------
uvwxyz
abc_do_not_matchmatch_def
abcdef
Here, the first line should not have matched - it did.
second line did not match as expected.
third line should have matched - it did not.
It is as if (?!...) does not have any effect.
As a side note, it does has a side effect. It does not
set $1, which I was expecting the behavior of ($:)
I am using perl V5.60
Please answer.
Thanks,
Giri
Brian Harnish <bharnish@technologist.com> wrote in message news:<pan.2003.09.05.21.17.19.983253@technologist.com>...
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
>
> On Fri, 05 Sep 2003 13:24:46 -0700, giri alamuri wrote:
>
> > What I want to do is:
>
> Go ahead, we're not going to stop you.
>
> > s/begin(^(abc)).*end//xyz/gs
> >
> > What I meant above is, find string begin which is not followed by abc and
> > then followed by any string till it find "end" and replace the whole string
> > with "xyz" globally.
> >
> > That is, I want to replace begin.*end with xyz only if begin is not followed
> > by "abc".
> >
> > I want to do it globally. So, following will not work:
> >
> > unless (/beginabc/) {
> > s/begin(^(abc)).*end//xyz/gs
> > }
>
> Try a negative look ahead.
>
> Also, when asking a question in english, the sentence should end with a
> question mark (?).
>
> - Brian
> -----BEGIN xxx SIGNATURE-----
> Version: GnuPG v1.2.2 (GNU/Linux)
>
> iD8DBQE/WP1aiK/rA3tCpFYRAvtEAJ9X6FNtOuXIgrOHCvXH3SC6BgrEEwCgjrqz
> CgXyJBYJrRcmk0Y1ckEXHgM=
> =MNE9
> -----END PGP SIGNATURE-----
------------------------------
Date: Sat, 6 Sep 2003 08:35:29 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: How to replace globally a string1 with string2 only if string1 does not have a sub_strig
Message-Id: <slrnbljol1.5cr.tadmc@magna.augustmail.com>
giri alamuri <galamuri81@yahoo.com> wrote:
> Here is the sample code and output:
>
> #!/usr/lecal/bin/perl -w
^
^
Do not re-type Perl code
Use copy/paste or your editor's "import" function rather than
attempting to type in your code. If you make a typo you will get
followups about your typos instead of about the question you are
trying to get answered.
Like this one.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 6 Sep 2003 08:34:32 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: How to replace globally a string1 with string2 only if string1 does not have a sub_strig
Message-Id: <slrnbljoj8.5cr.tadmc@magna.augustmail.com>
giri alamuri <galamuri81@yahoo.com> wrote:
> Having (?!...) does not have any effect.
^^^
> s/abc($!_do_not_match_)def/uvwxyz/g;
^^^
One of these things is not like the other, one of these things
just isn't the same...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 6 Sep 2003 22:34:08 +1000
From: "dj" <thecommissioner@hotmail.com>
Subject: Re: libxml-perl-0.07 and perl5.8.0 - fails test
Message-Id: <3f59d442$0$4191$afc38c87@news.optusnet.com.au>
Hi,
Yes, I have read the README: not much there.
The fail does not give any specific information about why the failure
occurs, except that it is test 11 of 11 in t/stream.t
I tried running 'perl t/stream.t' and it gave even less info: Not OK!
I don't have the source code in front of me at the moment, but to be honest
I didnt really make much sense of it :(
The mailing archive I read suggested that it _may_ have been something to
with Unicode compatability, but as I mentioned, I only found a single
reference to this.
I have been wrestling with this for a while: all I really want to do is put
the text content from an xml file into an easily readable data structure.
Am I going about this the wrong way?
regards,
Drew
"James Willmore" <jwillmore@cyberia.com> wrote in message
news:20030906020512.10b2538f.jwillmore@cyberia.com...
> On Sat, 06 Sep 2003 05:42:32 GMT
> "dj" <thecommissioner@hotmail.com> wrote:
> > during the make test, libxml-perl fails at t/stream (test 11) every
> > other test is fine except this one.
> >
>
> Does it say why it fails? Have you read the README for the module?
>
> --
> Jim
>
> Copyright notice: all code written by the author in this post is
> released under the GPL. http://www.gnu.org/licenses/gpl.txt
> for more information.
>
> a fortune quote ...
> Garbage In -- Gospel Out.
>
------------------------------
Date: Sat, 6 Sep 2003 11:49:51 +0100
From: "Andrew Crook" <andrew@NOSPAM_andicrook.demon.co.uk>
Subject: Re: looking for a nedit Syntax Pattern file for perl
Message-Id: <bjce46$naa$1$830fa79d@news.demon.co.uk>
okay i will take a look
thanks
Andi
"Joerg Fischer" <jf505@yahoo.de> wrote in message
news:3f54d0b4$0$25257$9b622d9e@news.freenet.de...
> Andrew Crook wrote:
> > looking for a nedit Syntax Pattern file for perl
> > can anyone help?
>
> Isn't it already built in? What NEdit version do you have?
> Anyway here is a pattern set (seems to be newer than the default
> pattern set built into NEdit 5.4):
> http://npr.opendocuments.com/
>
> Cheers,
> Jörg
>
> --
> Niki -- The NEdit WiKi:
> http://www.nr.no/~joachim/Niki/
------------------------------
Date: Sat, 06 Sep 2003 11:21:42 +0200
From: "Nico Coetzee" <abuse@mweb.co.za>
Subject: Re: Net::SSH::Perl
Message-Id: <pan.2003.09.06.09.21.40.160468@mweb.co.za>
On Fri, 05 Sep 2003 10:07:49 -0800, blob wrote:
> Hi all,
>
> Below is my script that will be used to connect to a remote host and
> change my password automatically:
>
> ===========================================
> #!/usr/bin/perl
>
>
> use strict();
> use Net::SSH::Perl;
>
>
> $user="jaws";
> $pass="password";
> $host="xxx.xxx.xxx.xxx";
> $old_password="password";
> $new_password="newpass";
>
>
> my $ssh = Net::SSH::Perl->new($host,debug=>1,use_pty=>1);
> $ssh->login($user, $pass);
>
>
> $ssh->register_handler("stderr", sub {
> my($channel, $buffer) = @_;
> my $str = $buffer->bytes;
>
>
> if ($str eq "Enter login password: ") {
> $channel->send_data($old_password);
> }
>
>
> elsif ($str eq "New password: ") {
> $channel->send_data($new_password);
> }
>
> elsif ($str eq "Re-enter new password: ") {
> $channel->send_data($new_password);
> }
> });
> $ssh->cmd('passwd');
> ==========================================
>
> After running the program, my password didnt changed I was still able to
> connect using the old password.
>
> Does anybody has an idea what's missing or wrong with my script?
>
> Thanks.
>
> Jaws
Instead of waiting for the exact string, why not use regular expresions,
which might eliminate typo's. Something like:
if ($str =~ /enter\s+login\s+password/i ) {
$channel->send_data($old_password);
}
elsif ($str =~ /new\s+password/i ) {
$channel->send_data($new_password);
}
elsif ($str =~ /re.enter\s+new\s+password/i ) {
$channel->send_data($new_password);
}
Cheers
--
Nico Coetzee
http://www.itfirms.co.za/
http://za.pm.org/
http://forums.databasejournal.com/
To the systems programmer, users and applications serve only to provide a
test load.
------------------------------
Date: Sat, 6 Sep 2003 15:22:56 +0100
From: "Peter Cooper" <newsfeed@boog.co.uk>
Subject: Re: Perl - Absolute min. environment required.
Message-Id: <bjcqkt$hhhvj$2@ID-194358.news.uni-berlin.de>
"James Willmore" <jwillmore@cyberia.com> wrote in message:
> If you are a long time Windows user, you should know better.
I'd argue that if you /are/ a long time Windows user, you clearly don't know
better ;-)
Pete
------------------------------
Date: Sat, 6 Sep 2003 15:21:38 +0100
From: "Peter Cooper" <newsfeed@boog.co.uk>
Subject: Re: PHP vs Perl
Message-Id: <bjcqks$hhhvj$1@ID-194358.news.uni-berlin.de>
"John Taylor-Johnston" <taylorjo@collegesherbrooke.qc.ca> wrote:
> Comparison study. Can this be done in Perl? How many lines?
Perhaps this horrible code will give you a clue :-)
use Time::Local;
my $a = timelocal (0,0,0, 1, 8, 103);
my $b = timelocal (59,59,23, 30, 8, 103);
if ((time > $a) && (time < $b)) { print "x"; }
I personally do not advise using the POSIX functions, as Perl is
cross-platform (read: works on non-POSIX platforms too). Convert times to
and from epoch time using Time::Local and localtime/gmtime, etc.. or use
Time::Piece objects (more elegant, and more code).
Pete
------------------------------
Date: 6 Sep 2003 09:18:16 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: read VB file with Perl
Message-Id: <bjc8oo$qfu$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Jay Tilton:
[ reading binary files according to a given template ]
> I didn't either when I looked a few years ago, so I wrote a Perl
> module that suited my needs at the time.
>
> It's probably still not ready for CPAN prime time, but perhaps it
> could become so. Anybody who wants to have a look and offer
> suggestions, it's at
> http://users.erols.com/tiltonj/perl/Data-Struct.02.20030613.zip
Have a look at Convert::Binary::C. This module is really awsome, coming
with a complete yacc grammar for C:
use Convert::Binary::C;
use Data::Dumper;
my $c = Convert::Binary::C->new->parse ( <<'EOC' );
#define int32_t long
#define int16_t short
struct wav_header {
char RiffTag[4];
int32_t FileLength;
char FormatTag[8];
int32_t FormatLength;
int16_t DataFormat;
int16_t NumChannels;
int32_t SampleRate;
int32_t BytesPerSecond;
int16_t BlockAlignment;
int16_t SampleDepth;
char DataTag[3];
int32_t DataLength;
};
EOC
open WAV, "file.wav" or die $!;
read(WAV, (my $header), $c->sizeof("wav_header"));
my $list = $c->unpack('wav_header', $header);
print Dumper $list;
__END__
$VAR1 = {
'RiffTag' => [
82,
73,
70,
70
],
'DataLength' => 1797020769,
'DataTag' => [
100,
97,
116
],
'SampleDepth' => 16,
'BlockAlignment' => 4,
'FileLength' => 23796864,
'DataFormat' => 1,
'SampleRate' => 44100,
'NumChannels' => 2,
'BytesPerSecond' => 176400,
'FormatLength' => 16,
'FormatTag' => [
87,
65,
86,
69,
102,
109,
116,
32
]
};
The module is able to deduce all the important figures (such as
byte-order, width of each type, alignment etc.) from almost every C
compiler on this planet automatically.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 6 Sep 2003 00:18:25 -0700
From: debhatta@hotmail.com (debraj)
Subject: splitting an array
Message-Id: <f9f243e.0309052318.1696c5bb@posting.google.com>
Hi All ,
I have one array of numbers say (12 17 18 19 120 121 122 123 124 379
480 481).
Now I want to get the starting and ending of any cosecutive numbers
from this array .
For eg. result should be (12--12,17--19,120--124,379--379,480--481) .
Note that if a number without any sequence is present it will be
printed in the format 12--12 .
Thanx
debhatta
------------------------------
Date: Sat, 6 Sep 2003 10:17:50 +0200
From: Lao Coon <laocoon@fastmail.fm>
Subject: Re: splitting an array
Message-Id: <bjc57e$3l7$04$1@news.t-online.com>
debhatta@hotmail.com (debraj) wrote in
news:f9f243e.0309052318.1696c5bb@posting.google.com:
> Hi All ,
>
> I have one array of numbers say (12 17 18 19 120 121 122 123 124 379
> 480 481).
> Now I want to get the starting and ending of any cosecutive numbers
> from this array .
> For eg. result should be (12--12,17--19,120--124,379--379,480--481) .
> Note that if a number without any sequence is present it will be
> printed in the format 12--12 .
One way:
my @list = (12,17,18,19,120,121,122,123,123,379,480,481);
my @res;
for(my $i = $j = 0; $i < @list; $i++) {
$j++ if $i && $list[$i] != $list[$i-1]+1;
push @{$res[$j]}, $list[$i];
}
HTH
Lao
------------------------------
Date: Sat, 06 Sep 2003 08:53:37 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: splitting an array
Message-Id: <3f59a041.295248494@news.erols.com>
debhatta@hotmail.com (debraj) wrote:
: I have one array of numbers say (12 17 18 19 120 121 122 123 124 379
: 480 481).
: Now I want to get the starting and ending of any cosecutive numbers
: from this array .
: For eg. result should be (12--12,17--19,120--124,379--379,480--481) .
: Note that if a number without any sequence is present it will be
: printed in the format 12--12 .
my @ary = (12,17,18,19,120,121,122,123,124,379,480,481);
my $seqs = join ',', map "$_--$_", sort {$a <=> $b} @ary;
1 while $seqs =~ s/(\d+),(??{$1+1})--(\d+)/$2/;
print "($seqs)\n";
------------------------------
Date: Sat, 06 Sep 2003 18:12:53 +0200
From: Tof <adjudant.tassin@laposte.net>
Subject: system und metachar
Message-Id: <adjudant.tassin-B80A11.18125306092003@news4-2.free.fr>
Hi from a newby,
I wanted to use system like: system("mv","*","targetDir);
But * ist not interpreted at all and the commande failed.
What would be the best way to do that ?
Greetings from Paris,
Christophe
------------------------------
Date: Sat, 06 Sep 2003 12:50:40 -0400
From: Shawn Corey <shawn@magma.ca>
Subject: Re: system und metachar
Message-Id: <KR-cnSjK07-qjceiXTWJiA@magma.ca>
Tof wrote:
> Hi from a newby,
>
> I wanted to use system like: system("mv","*","targetDir);
> But * ist not interpreted at all and the commande failed.
> What would be the best way to do that ?
>
> Greetings from Paris,
>
> Christophe
Bonjour,
Try: system( "mv * targetdir" );
------------------------------
Date: Sat, 6 Sep 2003 12:44:29 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: system und metachar
Message-Id: <slrnblk77t.6qk.tadmc@magna.augustmail.com>
Tof <adjudant.tassin@laposte.net> wrote:
> I wanted to use system like: system("mv","*","targetDir);
This part of the description of the system() function will
be important here:
Note
that argument processing varies depending on the
number of arguments. If there is more than one
argument in LIST, or if LIST is an array with more
than one value, starts the program given by the
first element of the list with arguments given by
the rest of the list. If there is only one scalar
argument, the argument is checked for shell
metacharacters, and if there are any, the entire
argument is passed to the system's command shell
for parsing
So your call above will not invoke a shell.
> But * ist not interpreted at all
Because it is the shell that interprets it, and there is no shell.
> and the commande failed.
> What would be the best way to do that ?
Either expand it yourself:
!system('mv', glob('*'), 'targetDir') or die "mv failed $!";
#or
!system('mv', <*>, 'targetDir') or die "mv failed $!";
Or call system such that it _will_ invoke a shell (and accept
all of the dangers that go with it):
!system('mv * targetDir') or die "mv failed $!";
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 6 Sep 2003 03:55:09 -0700
From: tore@aursand.no (Tore Aursand)
Subject: Trouble with Class::DBI
Message-Id: <23c1f47f.0309060255.145be771@posting.google.com>
Hi!
After being recommended this module for the past few weeks, I gave it
another look. The module itself looks very good, but I have a few
problems making it work with my "complex" data structures (which
aren't all that complex, really).
I have created a utility which converts Gedcom (genealogical) data to
a MySQL database. As it's pretty common in genealogy that one
individual can have more than one name, and I wanted to save as much
space as possible, I came up with the following tables;
individual
----------
individual_id mediumint unsigned not null,
sex char(1) default '?' not null,
modified date not null
individual_name
---------------
individual_id mediumint unsigned not null, /* references
'individual' */
given_names_id mediumint unsigned not null, /* references 'name'
*/
surname_id mediumint unsigned not null, /* references 'name'
*/
is_primary tinyint unsigned default 0 not null
name
----
name_id mediumint unsigned auto_increment primary key,
name varchar(255) not null
Getting an individual's name from this is fairly simple with an SQL
query:
SELECT gn.name as given_names,
sn.name as surname
FROM name gn,
name sn,
individual_name ina
WHERE ina.individual_id = ?
AND ina.given_names_id = gn.name_id
AND ina.surname_id = sn.name_id
Trying to represent these tables by using Class::DBI seems harder,
though, and I've been forced to look into Class::DBI::Join to make
this 'many-to-many' relationship work.
However - it doesn't work, and I really don't have a clue what to do.
Maybe I should try with something easier, I won't. :-) Here are the
Class::DBI classes I've made so far:
package Individual;
use strict;
use warnings;
use base 'TestDBI';
Individual->table( 'individual' );
Individual->columns( All => qw(individual_id sex modified) );
package Name;
use strict;
use warnings;
use base 'TestDBI';
Name->table( 'name' );
Name->columns( All => qw(name_id name) );
package IndividualName;
use strict;
use warnings;
use base 'TestDBI';
IndividualName->table( 'individual_name' );
IndividualName->columns( All => qw(individual_id given_names_id
surname_id) );
Can anyone please help me out there? All help is greatly appreciated!
Thanks!
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: 06 Sep 2003 13:23:39 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: uping and downing letters
Message-Id: <slrnbljnuq.fud.abigail@alexandra.abigail.nl>
John W. Krahn (krahnj@acm.org) wrote on MMMDCLVIII September MCMXCIII in
<URL:news:3F59684D.A654B57F@acm.org>:
,, john wrote:
,, >
,, > Thanks for the help as for -,_,z,Z etc. I am just looking to push to the
,, > next character in askii. And I am recieving the letters in a string but
,, > have written the code to parse the string into an array of chars
,,
,, To go "up":
,,
,, $string =~ tr/\x0-\xFF/\x1-\xFF\x0/;
Since he said ASCII, he wants:
$string =~ tr/\x0-\x7F/\x1-\x7F\x0/;
,, To go back "down" again:
,,
,, $string =~ tr/\x1-\xFF\x0/\x0-\xFF/;
And that would be:
$string =~ tr/\x1-\x7F\x0/\x0-\x7F/;
Abigail
--
#!/opt/perl/bin/perl -- # Remove trailing newline!
BEGIN{$SIG{__WARN__}=sub{$_=pop;y-_- -;print/".*(.)"/;
truncate$0,-1+-s$0;exec$0;}}//rekcaH_lreP_rehtona_tsuJ
------------------------------
Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re:
Message-Id: <3F18A600.3040306@rochester.rr.com>
Ron wrote:
> Tried this code get a server 500 error.
>
> Anyone know what's wrong with it?
>
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {
(---^
> dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
...
> Ron
...
--
Bob Walton
------------------------------
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.
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 5453
***************************************