[23862] in Perl-Users-Digest
Perl-Users Digest, Issue: 6065 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 2 03:05:45 2004
Date: Mon, 2 Feb 2004 00:05:07 -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 Mon, 2 Feb 2004 Volume: 10 Number: 6065
Today's topics:
A Grep and a couple Awks <and a lot of Tassilo help> (Agrapha)
Re: A Grep and a couple Awks <and a lot of Tassilo help <uri@stemsystems.com>
Re: A Grep and a couple Awks <and a lot of Tassilo help <tassilo.parseval@rwth-aachen.de>
Re: add multiple email to script <1usa@llenroc.ude>
Re: bunzip2 when exec()-ed from perl script outputs gar (Walter Roberson)
Re: bunzip2 when exec()-ed from perl script outputs gar <usenet@morrow.me.uk>
Re: Clarifications <jwkenne@attglobal.net>
Re: Clarifications <jwkenne@attglobal.net>
Re: Clarifications <tadmc@augustmail.com>
Re: difficult substitution patterns (commafying) <jwkenne@attglobal.net>
Re: Extract text from a file and write to another. (Sesa Woruban)
Re: Help with creating Movies Database <tassilo.parseval@rwth-aachen.de>
Re: ISO lightweight OO-RDBMS in Perl <jwillmore@remove.adelphia.net>
Re: MIME::Lite problem <pdconetwofour_numbers_@yahoo.co.uk>
Re: network card <wherrera@lynxview.com>
open a ascii file and rotate the content 90 deg... <lyoute@softhome.net>
Re: open a ascii file and rotate the content 90 deg... <tadmc@augustmail.com>
Re: Perl, Python, and Ruby <jwkenne@attglobal.net>
Re: Please repost post r-armed.r040 armed and dangerous <1usa@llenroc.ude>
Re: Please repost post r-armed.r040 armed and dangerous <jurgenex@hotmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 1 Feb 2004 21:22:30 -0800
From: brian@box201.com (Agrapha)
Subject: A Grep and a couple Awks <and a lot of Tassilo help>
Message-Id: <11aabb15.0402012122.4e77845@posting.google.com>
First let me state that Tassilo v. Parseval helped me a bunch last
April. I would not have been able to complete this project without his
help. I promised last year to post a working copy of this script. It's
not perfect but it works. I'll clean it up a bit more this year.
Tassilo, would you e_mail me directly in order that I may thank you
properly? mail to: nethaniel at box201.com
Up top is the results from the script. The way this script was forged
is documented in the history of this forum. Search on "Grep Once Awk
Twice" to find it. The names and numbers here have been slightly
altered to protect the innocent.
[agrapha@f3dd43-01 scripts]$ ./triag.pl 5555554999 0127 lon1
total_calls 523 total_failures 14 access number 5555554999
success rate for dates selected: 97.3231357552581%
ErrorCodes / Totals
-------------------
31,10 / 3
31,185 / 8
33,185 / 1
75,81 / 1
75,185 / 1
PhoneNumber / TotalFail
-----------------------
5550001111 / 2
5550001118 / 2
5550001110 / 1
5550001131 / 1
5550001811 / 4
5550001114 / 1
5550001211 / 1
5550001191 / 1
5550001119 / 1
Number / Error / Totals
-----------------------
5550001110 - 75,185,75,81 - 2
5550001111 - 31,185 - 1
5550001114 - 31,185 - 2
5550001118 - 31,185 - 4
5550001119 - 31,10 - 1
5550001131 - 31,10 - 1
5550001191 - 31,10 - 1
5550001211 - 33,185 - 1
5550001811 - 31,185 - 1
triag.pl script complete
[agrapha@f3dd43-01 scripts]$ cat triag.pl
#!/usr/bin/perl -w
use strict;
#####
# This script was made possible by the excellent help
# from the people on the perl usenet forum.
# The project would not have been possible without them.
# triage.pl was designed to look up an number and gather
# info about it. We begin by making sure they enter one
# on the command line or give them an example if they
# fail to do so.
###
if (!$ARGV[0] or !$ARGV[1] or !$ARGV[2]) {
print "Syntax is \"./triag.pl accessnumber yyyymmdd mkt\"\n";
print "example: ./triag.pl 2015551212 20040101 lon1
die "Include an access number, date and market when starting
Triag\n";
}
### Variable Initialization
my %error_codes;
my %error_users;
my %err_per_usr;
my $code = 0;
my $users = 0;
my $badusr = 0;
### End Variable Init
#####
# Next we go and find all the radius log files
# the push here will push the line into @selected
# if the line matches @ARGV (the command line value)
###
my @selected=`zgrep $ARGV[0]
./radiuslog/$ARGV[1]/server.$ARGV[2].Detail.$ARGV[1].gz`;
my @badcalls= grep /,0 /, @selected;
#####
# Ok so now we have a zgrep pushed into our
# @selected array. This is because the files are gunzipped.
# That give us all the calls made to the access number.
# Next we need to sort out the calls with zero session time
# by looking for /,0_/ that is a space after the ,0
# because typically failed calls have zero browsing time
###
#####
# now with the failed calls in @badcalls we filter and sort
###
foreach (@badcalls[0..$#badcalls]) {
my @errors = split /\s+/, $_;
$code = $errors[7];
$users = $errors[3];
$error_codes{$code}++;
$error_users{$users}++;
}
#####
# ok here is a difficult part to my script.
# Thanks Tassilo,
# this script would not have been possible without him.
###
my %errorsz;
foreach (@badcalls[0..$#badcalls]) {
my ($phonez, $err_codez) = (split)[3,7];
$errorsz{ $phonez }->{ $err_codez }++;
}
#####
# So the phone-numbers are the primary keys of the hash and the
# error-codes the keys of the nested hash.
# Next we perform a little math to get and average call sucess ratio
###
my $total = @selected;
my $fail = @badcalls;
print "\ntotal_calls $total\ttotal_failures $fail\taccess number
$ARGV[0]\n";
print "success rate for dates selected: ", (100 - (($fail / $total) *
100)), "%\n";
#####
# Finally I print out the information to the screen
###
print "\nErrorCodes / Totals\n";
print "-------------------\n";
foreach my $key (keys %error_codes) {
print "$key\t\/\t$error_codes{$key}\n";
}
print "\nPhoneNumber / TotalFail\n";
print "-----------------------\n";
foreach my $key (keys %error_users) {
print "$key\t\/\t$error_users{$key}\n";
}
#####
# this one is now fixed. Adding the perfect flourish
# to my first perl program.
###
print "\nNumber / Error / Totals\n";
print "-----------------------\n";
for my $n (sort { $a <=> $b } keys %errorsz) {
# $errorsz{ $n } is now itself a reference to a hash
my %codesz = %{ $errorsz{ $n } };
# compute the total numbers of errors for this phone-number
my $qty;
for ( keys %codesz ) {
$qty += $codesz{ $_ };
}
# display the stats for a given phone-number $n
print "$n - ", join (",", keys %codesz), " - $qty\n";
}
print "\n\ntriag.pl script complete\n";
------------------------------
Date: Mon, 02 Feb 2004 05:56:15 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: A Grep and a couple Awks <and a lot of Tassilo help>
Message-Id: <x7r7xeja81.fsf@mail.sysarch.com>
>>>>> "A" == Agrapha <brian@box201.com> writes:
A> #!/usr/bin/perl -w
A> use strict;
good!
A> if (!$ARGV[0] or !$ARGV[1] or !$ARGV[2]) {
eww!
if ( @ARGV != 3 ) {
A> print "Syntax is \"./triag.pl accessnumber yyyymmdd mkt\"\n";
A> print "example: ./triag.pl 2015551212 20040101 lon1
A> die "Include an access number, date and market when starting
A> Triag\n";
why not a single die? and lose the \" stuff. here docs to the rescue!!
die <<DIE ;
Syntax is "./triag.pl accessnumber yyyymmdd mkt"
example: ./triag.pl 2015551212 20040101 lon1
Include an access number, date and market when starting Triag
DIE
what i like to do is make a usage sub like this:
sub usage {
my ( $err_text ) = @_ ;
$err_text ||= '' ; # stop undef warnings
die <<DIE ;
$err_text
Syntax is "./triag.pl accessnumber yyyymmdd mkt"
example: ./triag.pl 2015551212 20040101 lon1
Include an access number, date and market when starting Triag
DIE
}
then you can call that in different places in the arg parsing stuff like
this:
usage( "missing arguments ) if @ARGV < 3 ;
usage( "too many arguments ) if @ARGV > 3 ;
A> }
A> ### Variable Initialization
A> my %error_codes;
A> my %error_users;
A> my %err_per_usr;
A> my $code = 0;
A> my $users = 0;
A> my $badusr = 0;
declare your variables in the tightest scope possible. these are file
scoped globals and are possibly too visible.
A> my @selected=`zgrep $ARGV[0]
A> ./radiuslog/$ARGV[1]/server.$ARGV[2].Detail.$ARGV[1].gz`;
CPAN has modules to read .gz files so you can save on a fork.
A> my @badcalls= grep /,0 /, @selected;
A> #####
A> # ok here is a difficult part to my script.
A> # Thanks Tassilo,
A> # this script would not have been possible without him.
A> ###
A> my %errorsz;
that is a better place to declare something, right before its first use.
also use _ to make your var names more readable:
my %errors_z;
A> foreach (@badcalls[0..$#badcalls]) {
A> my ($phonez, $err_codez) = (split)[3,7];
A> $errorsz{ $phonez }->{ $err_codez }++;
^^
no need for that -> between pairs of nest derefs (hash or array).
A> }
A> my $total = @selected;
A> my $fail = @badcalls;
A> print "\ntotal_calls $total\ttotal_failures $fail\taccess number
A> $ARGV[0]\n";
A> print "success rate for dates selected: ", (100 - (($fail / $total) *
A> 100)), "%\n";
here docs again! precalculate the rate value:
my $rate = 100 - (($fail / $total) * 100)
print <<TOTALS ;
total_calls $total total_failures $fail access number $ARGV[0]
success rate for dates selected: $rate
TOTALS
A> #####
A> # Finally I print out the information to the screen
A> ###
A> print "\nErrorCodes / Totals\n";
A> print "-------------------\n";
A> foreach my $key (keys %error_codes) {
A> print "$key\t\/\t$error_codes{$key}\n";
^^
there is no need to escape / in a plain double quoted string. that is
only needed (and another delimiter should be chosen) in regex ops.
A> }
A> print "\nPhoneNumber / TotalFail\n";
A> print "-----------------------\n";
A> foreach my $key (keys %error_users) {
A> print "$key\t\/\t$error_users{$key}\n";
A> }
again, i would build it all up in a single string and then print it. it
is cleaner, faster and lets you control where you print it all. and
statement modifiers will make it look even better:
my $text = '' ;
$text .= <<TXT ;
ErrorCodes / Totals
-------------------
TXT
$text .= <<TXT foreach keys %error_codes ;
$_ / $error_codes{$_}
TXT
$text .= <<TXT ;
PhoneNumber / TotalFail
-----------------------
TXT
$text .= <<TXT foreach keys %error_users ;
$_ / $error_users{$_}
TXT
etc.
notice how much easier it is to read what will be printed and also to
line it up? no extra " or \n or \t chars to provide visual noise. of
course some don't like here docs as much as i do but they are infidels! :)
A> for my $n (sort { $a <=> $b } keys %errorsz) {
A> # $errorsz{ $n } is now itself a reference to a hash
A> my %codesz = %{ $errorsz{ $n } };
no need to copy that hash. see below
A> # compute the total numbers of errors for this phone-number
A> my $qty;
A> for ( keys %codesz ) {
for ( keys %{ $errorsz{ $n } } ) {
A> $qty += $codesz{ $_ };
A> }
and that can be shrunk with a statement modifier (i like those too!).
$qty += %{ $errorsz{ $_ } } for keys %{ $errorsz{ $n } } ;
but you are only accessing and summing the values of the subhash and you
don't need the keys for that. use the values function:
$qty += $_ for values %{ $errorsz{ $n } } ;
that is all you need there AFIACT from your code.
A> # display the stats for a given phone-number $n
A> print "$n - ", join (",", keys %codesz), " - $qty\n";
A> }
A> print "\n\ntriag.pl script complete\n";
here docs there as well.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 2 Feb 2004 07:30:53 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: A Grep and a couple Awks <and a lot of Tassilo help>
Message-Id: <bvkubd$7ko$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Agrapha:
> First let me state that Tassilo v. Parseval helped me a bunch last
> April. I would not have been able to complete this project without his
> help. I promised last year to post a working copy of this script. It's
> not perfect but it works. I'll clean it up a bit more this year.
>
> Tassilo, would you e_mail me directly in order that I may thank you
> properly? mail to: nethaniel at box201.com
Worry not. I did get your email after christmas. Btw, most people in
this group wont expect an explicit thank you (but it can't hurt to
send one nonetheless of course).
However, it's a good idea to make a post summing up your experiences and
showing your results as you do right now.
> [agrapha@f3dd43-01 scripts]$ cat triag.pl
>
> #!/usr/bin/perl -w
> use strict;
>
> #####
> # This script was made possible by the excellent help
> # from the people on the perl usenet forum.
> # The project would not have been possible without them.
> # triage.pl was designed to look up an number and gather
> # info about it. We begin by making sure they enter one
> # on the command line or give them an example if they
> # fail to do so.
> ###
>
>
> if (!$ARGV[0] or !$ARGV[1] or !$ARGV[2]) {
> print "Syntax is \"./triag.pl accessnumber yyyymmdd mkt\"\n";
> print "example: ./triag.pl 2015551212 20040101 lon1
> die "Include an access number, date and market when starting
> Triag\n";
> }
This is mostly a question of good style: usage-messages should go to
stderr really:
if (@ARGV != 3) {
warn <<EOWARN;
Syntax is $0 accessnumber yyyymmdd mkt
example: $0 2015551212 20040101 lon1
Include an access number, date and market when starting Triag
EOWARN
exit(1);
}
I use $0 because it is shorter and because it contains the exact path
which you used to call your script.
> ### Variable Initialization
>
> my %error_codes;
> my %error_users;
> my %err_per_usr;
> my $code = 0;
> my $users = 0;
> my $badusr = 0;
Some of these variables shouldn't have file-scope. As far as I can see,
$code and $users is only used in a for-loop later on. Better restrict
their scope to this loop.
> ### End Variable Init
>
> #####
> # Next we go and find all the radius log files
> # the push here will push the line into @selected
> # if the line matches @ARGV (the command line value)
> ###
> my @selected=`zgrep $ARGV[0]
> ./radiuslog/$ARGV[1]/server.$ARGV[2].Detail.$ARGV[1].gz`;
> my @badcalls= grep /,0 /, @selected;
Maybe a pipe-open is more appropriate here:
open ZGREP, "|", "zgrep $ARGV[0] ./radiuslog/..."
or die "Could not spawn zgrep: $!";
my (@badcalls, $total);
while (<ZGREP>) {
$total++;
push @badcalls, $_ if /,0 /;
}
close ZGREP;
This needs less memory and gets rid of @selected altogether.
> #####
> # Ok so now we have a zgrep pushed into our
> # @selected array. This is because the files are gunzipped.
> # That give us all the calls made to the access number.
> # Next we need to sort out the calls with zero session time
> # by looking for /,0_/ that is a space after the ,0
> # because typically failed calls have zero browsing time
> ###
>
> #####
> # now with the failed calls in @badcalls we filter and sort
> ###
>
> foreach (@badcalls[0..$#badcalls]) {
> my @errors = split /\s+/, $_;
> $code = $errors[7];
> $users = $errors[3];
> $error_codes{$code}++;
> $error_users{$users}++;
> }
foreach (@badcalls) {
my ($code, $users) = (split /\s+/, $_)[3,7];
$error_codes{ $code }++;
$error_users{ $users }++;
}
> #####
> # ok here is a difficult part to my script.
> # Thanks Tassilo,
> # this script would not have been possible without him.
> ###
>
> my %errorsz;
> foreach (@badcalls[0..$#badcalls]) {
> my ($phonez, $err_codez) = (split)[3,7];
> $errorsz{ $phonez }->{ $err_codez }++;
> }
There is quite some redundancy in the above two loops. You can squeeze
that into one:
my %errorsz;
foreach (@badcalls) {
my ($code, $users) = (split)[3,7];
$error_codes{ $code }++;
$error_users{ $users }++;
$errorsz{ $code }->{ $users }++;
}
I am a little bit confused over the naming of the variables. In the
first loop, the 4th and 7th field of each @badcall-item are named $code
and $users respectively. In the second loop however, you call them
$phonez and $err_codez.
As for what Uri said on not using the explicit dereference operator '->':
This is mostly a question of personal style. They aren't needed when
working with nested references. However, it adds a little bit of
consistency. Leaving them off somewhat implies that this:
my $hash_ref = { key => value };
print $hash_ref{ key };
would also work, but it doesn't.
> #####
> # So the phone-numbers are the primary keys of the hash and the
> # error-codes the keys of the nested hash.
> # Next we perform a little math to get and average call sucess ratio
> ###
>
> my $total = @selected;
This is now obsolete as $total has already been computed in the
while(<ZGREP> loop.
[...]
For the rest, Uri has already given good advise and there#s nothing to
add.
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: 2 Feb 2004 02:42:24 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: add multiple email to script
Message-Id: <Xns9482DCD08A74Fasu1cornelledu@132.236.56.8>
<bbhtigger@hotmail.com> wrote in news:tihTb.15783$QJ3.14976@fed1read04:
> help, How do I add multiple emails to this script
>
> # if you would like to be notified of uploads, enter your email
> address # between the SINGLE quotes. leave this blank if you would not
> like to be notified $notify = 'help@help.com';
Set up a forwarder which forwards the messages to multiple address. BTW,
this has nothing to do with Perl because you have not posted any Perl
related information. No, that single statement above does not count.
Sinan.
--
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)
------------------------------
Date: 2 Feb 2004 02:07:17 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: bunzip2 when exec()-ed from perl script outputs garbage data.
Message-Id: <bvkbcl$cdg$1@canopus.cc.umanitoba.ca>
In article <pan.2004.02.02.01.49.26.895156@shaw.ca>,
Thomas Covello <pmjcovello@shaw.ca> wrote:
:On Mon, 02 Feb 2004 01:03:38 +0000, Walter Roberson wrote:
:> You read 4 bytes from STDIN and then you exec off bunzip2 without
:> having restored those 4 bytes.
:The -f option of bunzip2, according to the manpage, is supposed to
:permit operation without the magic number.
On my system, bunzip2 -? says
-f --force overwrite existing output files
--
Preposterous!! Where would all the calculators go?!
------------------------------
Date: Mon, 2 Feb 2004 05:45:42 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: bunzip2 when exec()-ed from perl script outputs garbage data.
Message-Id: <bvko66$ht0$1@wisteria.csv.warwick.ac.uk>
roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote:
> In article <pan.2004.02.02.01.49.26.895156@shaw.ca>,
> Thomas Covello <pmjcovello@shaw.ca> wrote:
> :On Mon, 02 Feb 2004 01:03:38 +0000, Walter Roberson wrote:
>
> :The -f option of bunzip2, according to the manpage, is supposed to
> :permit operation without the magic number.
>
> On my system, bunzip2 -? says
>
> -f --force overwrite existing output files
but man bzip2 says
| -f --force
|
| Force overwrite of output files.
<snip>
| bzip2 normally declines to decompress files which don't have the
| correct magic header bytes. If forced (-f), however, it will
| pass such files through unmodified.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OP: it won't attempt to bunzip them without the magic number. You
probably want to open a pipe to bunzip2 and print the magic number to
it, and then use IO::SendFile to copy the rest. If you can't use
IO::SendFile you'll have to do it by hand, something like
$\ = undef;
$/ = \4096;
print BZIP2 $_ while <STDIN>;
close BZIP2 or die "close of bunzip2 failed: $!";
exit ($? >> 8);
Ben
--
Heracles: Vulture! Here's a titbit for you / A few dried molecules of the gall
From the liver of a friend of yours. / Excuse the arrow but I have no spoon.
(Ted Hughes, [ Heracles shoots Vulture with arrow. Vulture bursts into ]
/Alcestis/) [ flame, and falls out of sight. ] ben@morrow.me.uk
------------------------------
Date: Mon, 02 Feb 2004 04:04:36 GMT
From: "John W. Kennedy" <jwkenne@attglobal.net>
Subject: Re: Clarifications
Message-Id: <o%jTb.37505$gw3.14298110@news4.srv.hcvlny.cv.net>
Michele Dondi wrote:
> I don't know Ruby, but FWIW I've heard very good cmts about it. OTOH
> you surely know that there is not such a thing called 'PERL', don't
> you?!?
When I first learned the language, I was told in no uncertain terms that
the name was an acronym. Acronyms are capitalized in English.
I do understand that the acronym is now officially spurious. (Sigh!) I
wish people would get their stories straight the first time.
--
John W. Kennedy
"But now is a new thing which is very old--
that the rich make themselves richer and not poorer,
which is the true Gospel, for the poor's sake."
-- Charles Williams. "Judgement at Chelmsford"
------------------------------
Date: Mon, 02 Feb 2004 04:26:11 GMT
From: "John W. Kennedy" <jwkenne@attglobal.net>
Subject: Re: Clarifications
Message-Id: <DjkTb.37592$gw3.14401190@news4.srv.hcvlny.cv.net>
Sumit Garg wrote:
> are there any other advantages of ruby over perl ?
Well the main thing is that it's a pure OO language. Even plain old
integers are first-class objects, as in SmallTalk. And because it's
always been an OO language, you don't have the conceptual confusion that
Perl has between modules and classes, and objects and hashes, or the
wierdity of "bless".
Which means a Ruby learner can plunge straight into OO.
In general, Ruby runs slower than non-OO Perl, and probably always will,
but in more advanced cases Ruby can be faster. (My perfect-number
generator is a lot faster in Ruby than Perl, though it's fastest in GCLISP.)
Oh yes. Ruby has exceptions. No more remembering to put "or die" on
everything.
I'd really have to say that Ruby is better than Perl for casual
programmers. In fact, I'd say it's the best language I know (out of
perhaps thirty) for casual programmers.
--
John W. Kennedy
"But now is a new thing which is very old--
that the rich make themselves richer and not poorer,
which is the true Gospel, for the poor's sake."
-- Charles Williams. "Judgement at Chelmsford"
------------------------------
Date: Sun, 1 Feb 2004 23:01:43 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Clarifications
Message-Id: <slrnc1rmdn.a3q.tadmc@magna.augustmail.com>
John W. Kennedy <jwkenne@attglobal.net> wrote:
> When I first learned the language, I was told in no uncertain terms that
> the name was an acronym.
You were told wrong then, eh?
Who told you?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 02 Feb 2004 04:38:14 GMT
From: "John W. Kennedy" <jwkenne@attglobal.net>
Subject: Re: difficult substitution patterns (commafying)
Message-Id: <WukTb.37634$gw3.14456398@news4.srv.hcvlny.cv.net>
Joe Smith wrote:
> John W. Kennedy wrote:
>
>> The correct form of the line is:
>> 1 while s/(\d)(\d\d\d)(?!\d)/$1,$2/;
>
>
> Any advantage of using that form as opposed to
> 1 while s/(\d+)(\d\d\d)/$1,$2/;
> ?
I didn't write it -- just corrected a syntax error.
--
John W. Kennedy
"But now is a new thing which is very old--
that the rich make themselves richer and not poorer,
which is the true Gospel, for the poor's sake."
-- Charles Williams. "Judgement at Chelmsford"
------------------------------
Date: 1 Feb 2004 22:36:40 -0800
From: me@sesaworuban.net (Sesa Woruban)
Subject: Re: Extract text from a file and write to another.
Message-Id: <12db4fb.0402012236.6855a17b@posting.google.com>
> If this is a mailbox, you would be better off using one of the Mail::
> modules on CPAN to parse it.
Possibly, and I went to have a look at these modules but I think the
learning curve for those will be even higher than just getting this
simple programme cobbled together... unless you can give me a quick
intro?
Cheers
Sesa
------------------------------
Date: 2 Feb 2004 06:29:08 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Help with creating Movies Database
Message-Id: <bvkqnk$53l$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Tad McClellan:
> TP <pin@purdue.edu> wrote:
>> &open_file("FILE1",">>",$filename);
>
>
> Don't use the ampersand on function calls unless you know what it
> does, and what it does is what you want (it seldom is what you want).
>
> You should always, yes *always*, check the return value from open():
>
> open_file("FILE1", ">>", $filename) or
> die "could not open '$filename' $!";
That applies to open(), but what is open_file()?
When looking at this sequence:
&open_file("FILE1",">>",$filename);
write_file('FILE1', join '|', $NameText, $moviedescription,"$moviecast\n";
close FILE1;
I get pain in my stomach. In the first two lines, "FILE1" is used as a
string, while in the last line it is used as a filehandle. This can only
work if the filehandle is created in open_file() through a symbolic
reference or so.
We need to see the code of open_file() and write_file().
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: Sun, 01 Feb 2004 21:30:04 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: ISO lightweight OO-RDBMS in Perl
Message-Id: <pan.2004.02.02.02.30.02.800331@remove.adelphia.net>
On Sun, 01 Feb 2004 13:40:53 +0000, kj wrote:
> I have 4 or 5 personal coding projects in my to-do list, all of which
> feature simple relational databases (e.g. a catalog of TV show episodes
> on tape; a catalog of all my books; a catalog of all my CDs; a catalog
> of xeroxed/printed journal articles archive; etc.) Therefore, I'm
> looking CPAN modules to facilitate the process of creating, querying,
> updating, and maintaining *persistent* tables of Perl objects.
>
> The applications I have in mind have pretty light requirements. The
> tables may be relationally linked, so their management should preserve
> the integrity of the relational schema. But, they will interact with a
> single user at a time; security is not a big issue; nor is transaction
> management; performance demands are light, since no table would be
> bigger than a few hundred records.
>
> I have run across modules in CPAN (e.g. ObjStore or DB::Objects) that at
> first glance seem as though they *may* be suitable to this task, but I
> can't tell from the documentation exactly how adequate they are.
> Therefore, I would appreciate recommendations from *users* of modules
> like what I describe above.
>
> Note: I'm *not* interested in Perl interfaces to standard RDBMSs like
> MySQL or Oracle.
You may want to look over DBD::AnyData. It allows you to have in memory
access to a variety of data sources (RDBMS or "flat file" or even XML).
You could also use DBD::SQLite and DBD::Sprite. Or, if on a Windows box,
you could use DBD::Excel.
HTH
--
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 ...
"... After all, all he did was string together a lot of old,
well-known quotations." -- H. L. Mencken, on Shakespeare
------------------------------
Date: Mon, 02 Feb 2004 07:07:28 GMT
From: p cooper <pdconetwofour_numbers_@yahoo.co.uk>
Subject: Re: MIME::Lite problem
Message-Id: <QGmTb.4061$K%2.37556346@news-text.cableinet.net>
Gunnar Hjalmarsson wrote:
> p cooper wrote (in comp.lang.perl.modules):
>> i want to email an excel format file
>
> You posted about the same problem a few hours ago in
> comp.lang.perl.misc, and now you post again in comp.lang.perl.modules,
> seemingly ignoring the response you got in comp.lang.perl.misc.
>
> That's very bad manners, and reduces the chances that somebody will
> help you further.
>
sorry - dont mean to be rude - more like getting desperate....
Perhaps the title is wrong as well - more a Spreadsheet::WriteExcel problem
I _think_ (but dont know enough but it Im afraid to be certain) i
pinpointed the initial problem ( add_worksheet error message ) to the fact
that the original script didnt work the same run from the command line -
no idea why that is though.
I think that what is happening now is a problem with the script that opens
the filehandle and then doesnt write the information to the file as
expected
(??? something to do with the
my $workbook = Spreadsheet::WriteExcel->new(\*TEST);
line being incorrect/not appropriate/ in the wrong place/something
else/something missing before or after it
FWIW the commented out loop above it works , so now its not a file
permissions type of problem.
-----Not rude , just frustrated by it.
------------------------------
Date: Sun, 01 Feb 2004 21:41:24 -0700
From: Bill <wherrera@lynxview.com>
Subject: Re: network card
Message-Id: <d9qdnbWdrtZuSYDdRVn-jg@adelphia.com>
Xaver Biton wrote:
> I see some Programms, that by installing it, they create a network
> connection, for the current user, how they do that. I ve tried with
> Win32::IPHelper and with Win32::IPConfig, but a can see only the current
> configuration, the question is how can I create a totally new connection?
Well...
The problem with your question is that the term 'network connection' can
trefer to many things, many but not all of which can be done with Perl.
Can you explain what you want to do with the network connection once you
have it? That might allow people here to better understand what kind on
'connection' you mean...
------------------------------
Date: Mon, 02 Feb 2004 12:36:47 +0800
From: lyoute <lyoute@softhome.net>
Subject: open a ascii file and rotate the content 90 deg...
Message-Id: <401dd3de_3@rain.i-cable.com>
i got a set of files all looks like: (with fixed dimension 8x8)
.X..XO..
X...XO..
OXX.XO..
OOOXXO..
...OO.O.
..O.....
........
........
how can i produce output with 90 deg rotated:
.XOO....
X.XO....
..XO.O..
...XO...
XXXXO...
OOOO....
....O...
........
actually i got this done while i still storing the pattern in a
@pattern[8][8].
just doubt if i still can rotate it after the pattern was written into a
file....
------------------------------
Date: Sun, 1 Feb 2004 23:04:37 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: open a ascii file and rotate the content 90 deg...
Message-Id: <slrnc1rmj5.a3q.tadmc@magna.augustmail.com>
lyoute <lyoute@softhome.net> wrote:
> how can i produce output with 90 deg rotated:
> actually i got this done while i still storing the pattern in a
> @pattern[8][8].
> just doubt if i still can rotate it after the pattern was written into a
> file....
Read it from the file into an 8x8 matrix and rotate it the
way you are already doing it.
What problem do you see with that?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 02 Feb 2004 04:30:56 GMT
From: "John W. Kennedy" <jwkenne@attglobal.net>
Subject: Re: Perl, Python, and Ruby
Message-Id: <4okTb.37609$gw3.14424737@news4.srv.hcvlny.cv.net>
edgrsprj wrote:
> I took a look at Python and Ruby Web sites to see what those programs look
> like. Perl, Python, and Ruby all look like they could easily handle the
> types of data processing that I need to do. If any of them had specific
> commands installed for controlling Windows programs and screens then I might
> decide to use that program. And this coming week I am planning to try to
> determine if there are actually routines like that which I did not see in my
> first check of the Python and Ruby documentation.
All of them have the Tk library (which originated with yet another
language, Tcl). The Tk library was originally written for Unix
windowing, but has been ported to Windows, and probably (I don't know
offhand) to MacOS.
--
John W. Kennedy
"But now is a new thing which is very old--
that the rich make themselves richer and not poorer,
which is the true Gospel, for the poor's sake."
-- Charles Williams. "Judgement at Chelmsford"
------------------------------
Date: 2 Feb 2004 02:43:08 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: Please repost post r-armed.r040 armed and dangerous
Message-Id: <Xns9482DCF0CAB52asu1cornelledu@132.236.56.8>
<bbhtigger@hotmail.com> wrote in news:ghhTb.15779$QJ3.14460@fed1read04:
> help, How do I add multiple emails to this script
>
> # if you would like to be notified of uploads, enter your email
> address # between the SINGLE quotes. leave this blank if you would not
> like to be notified $notify = 'help@help.com';
Do not post the same inane question multiple times.
--
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)
------------------------------
Date: Mon, 02 Feb 2004 03:00:07 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Please repost post r-armed.r040 armed and dangerous
Message-Id: <X2jTb.12298$9a4.1452@nwrddc01.gnilink.net>
bbhtigger@hotmail.com wrote:
Sorry, you must be using some proprietary identification schema for Usenet
articles. I can't find teh post "r-armed.r040 armed and dangerous" anywhere.
> help, How do I add multiple emails to this script
>
> # if you would like to be notified of uploads, enter your email
> address # between the SINGLE quotes. leave this blank if you would
> not like to be notified $notify = 'help@help.com';
What script? There is just one single line of code.
And what do you mean by "adding email to script"? Do you want to append the
body of emails to your script (not that that would make any sense to me, but
who knows what you have in mind)?
Well, what about copy-and-paste in your favourite editor?
jue
------------------------------
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 6065
***************************************