[22063] in Perl-Users-Digest
Perl-Users Digest, Issue: 4285 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 18 21:05:37 2002
Date: Wed, 18 Dec 2002 18:05:09 -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 Wed, 18 Dec 2002 Volume: 10 Number: 4285
Today's topics:
Re: copyResized producing unexpected results (Jay Tilton)
Re: Date Difference (Jay Tilton)
Re: Date Difference (Tad McClellan)
Re: Date Difference <ljohnson323@hotmail.com>
Re: Date Difference <ljohnson323@hotmail.com>
Re: extracting data from a column (Walter Roberson)
Re: extracting data from a column <snotrocket88@hotmail.com>
Re: extracting data from a column (Steve Walker)
Re: FTPing without Net::FTP (Tad McClellan)
Re: FTPing without Net::FTP (Jay Tilton)
Re: getstore not working - please help (Dennis Macdonald)
Re: Is this a bug? (5.6.1 and 5.005.04) <ndronen@io.frii.com>
Re: Is this a bug? (5.6.1 and 5.005.04) <joe+usenet@sunstarsys.com>
Mail::POP3Client vs. Sockets networking ? <jim.bloggs@eudoramail.com>
Re: Mail::POP3Client vs. Sockets networking ? <tassilo.parseval@post.rwth-aachen.de>
Re: Mail::POP3Client vs. Sockets networking ? <jim.bloggs@eudoramail.com>
Re: oracle 9i compatible perl version <rereidy@indra.com>
Re: Oracle PL/SQL split function? Perl wannabe UTF8 cod <rereidy@indra.com>
Re: Why do beginners read files into an array? <wsegrave@mindspring.com>
Re: Why do beginners read files into an array? <wsegrave@mindspring.com>
Re: Why do beginners read files into an array? <jeff@vpservices.com>
Re: Why do beginners read files into an array? (Kevin Newman)
Re: Why do beginners read files into an array? <wsegrave@mindspring.com>
Re: Why do beginners read files into an array? <ian@WINDOZEdigiserv.net>
Re: Why doesn't this foreach SMTP loop work? (Per Hedeland)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 19 Dec 2002 00:48:02 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: copyResized producing unexpected results
Message-Id: <3e01124a.6104464@news.erols.com>
ccondray@usa.net (Collin Condray) wrote:
: I am having trouble using Perl's GD module. I am trying to shrink down
: a signature from a file using copyResized. The signature is generated
: from a signature pad that records the x,y coordinates when the pen
: touches the pad. The code that I am using below generates a very
: large signature file as a jpg file with no problems. However when I
: try to shrink the lage signature file using copyResized, I get an
: image of the correct size but it is all black (just a black
: rectangle).
[Prepare for WAG]
How much is the image being shrunk?
Does the same thing happen when copyResized() is used to produce an
image the same size as the original? When it's larger than the
original?
I believe the copyResized() method uses a "nearest neighbor" algorithm
instead of real pixel averaging. Because of the one-pixel wide nature
of the lines in a signature, reducing the image size would tend to
average to the background color instead of the foreground. It would
get worse for larger image reduction ratios.
GD versions 2.0 and later have a copyResampled() method that should
prevent that from happening when reducing an image.
------------------------------
Date: Wed, 18 Dec 2002 23:41:00 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Date Difference
Message-Id: <3e010548.2774489@news.erols.com>
"Chris" <christopher.naugle@fmr.com> wrote:
: I have this program that I'm writing. One of the things that it needs to
: do is take a string that represents a date in the format "YYYYMMDD" and
: figure out if this date is N number of days old where N is some arbitrary
: number.
Lots of ways. Here's one.
#!perl -l
use warnings;
use strict;
use Date::Manip;
my $old = DateCalc('today', '-14 days');
while(<DATA>) {
chomp;
print "$_ was more than a fortnight ago."
if Date_Cmp( $old, $_ ) == 1;
}
__DATA__
20021217
20021210
20021204
------------------------------
Date: Wed, 18 Dec 2002 17:59:53 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Date Difference
Message-Id: <slrnb022vp.46h.tadmc@magna.augustmail.com>
Chris <christopher.naugle@fmr.com> wrote:
> I have this program that I'm writing. One of the things that it needs to
> do
> is take a string that represents a date in the format "YYYYMMDD" and
> figure out if this date is N number of days old where N is some arbitrary
> number.
perldoc -q date
"How can I compare two dates and find the difference?"
which leads to:
perldoc Time::Local
which leads to:
-------------------------------
#!/usr/bin/perl
use strict;
use warnings;
use Time::Local;
my $date = '20021214';
my($year, $mon, $mday) = $date =~ /(\d{4})(\d\d)(\d\d)/;
$mon--; # want 0..11, not 1..12
my $seconds = timelocal(0, 0, 0, $mday, $mon, $year);
my $nowseconds = time;
my $days_old = ($nowseconds - $seconds) / (60 * 60 * 24);
print "$date is $days_old days old\n";
-------------------------------
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 18 Dec 2002 19:37:30 -0500
From: "Lori" <ljohnson323@hotmail.com>
Subject: Re: Date Difference
Message-Id: <3e0114a2_1@nopics.sjc>
"Jay Tilton" <tiltonj@erols.com> wrote in message
news:3e010548.2774489@news.erols.com...
> "Chris" <christopher.naugle@fmr.com> wrote:
>
> : I have this program that I'm writing. One of the things that it needs
to
> : do is take a string that represents a date in the format "YYYYMMDD" and
> : figure out if this date is N number of days old where N is some
arbitrary
> : number.
>
> Lots of ways. Here's one.
>
> #!perl -l
> use warnings;
> use strict;
> use Date::Manip;
> my $old = DateCalc('today', '-14 days');
> while(<DATA>) {
> chomp;
> print "$_ was more than a fortnight ago."
> if Date_Cmp( $old, $_ ) == 1;
> }
> __DATA__
> 20021217
> 20021210
> 20021204
>
Jay,
Thanks. I was trying to use Date::Manip before and
was running into problems, mainly because I couldn't
seem to find some good examples of it being used.
Thanks for your help.
Chris
------------------------------
Date: Wed, 18 Dec 2002 19:38:38 -0500
From: "Lori" <ljohnson323@hotmail.com>
Subject: Re: Date Difference
Message-Id: <3e0114e5_2@nopics.sjc>
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnb022vp.46h.tadmc@magna.augustmail.com...
> Chris <christopher.naugle@fmr.com> wrote:
>
> > I have this program that I'm writing. One of the things that it needs
to
> > do
> > is take a string that represents a date in the format "YYYYMMDD" and
> > figure out if this date is N number of days old where N is some
arbitrary
> > number.
>
>
> perldoc -q date
>
> "How can I compare two dates and find the difference?"
>
> which leads to:
>
> perldoc Time::Local
>
> which leads to:
>
> -------------------------------
> #!/usr/bin/perl
> use strict;
> use warnings;
> use Time::Local;
>
> my $date = '20021214';
>
> my($year, $mon, $mday) = $date =~ /(\d{4})(\d\d)(\d\d)/;
> $mon--; # want 0..11, not 1..12
> my $seconds = timelocal(0, 0, 0, $mday, $mon, $year);
>
> my $nowseconds = time;
>
> my $days_old = ($nowseconds - $seconds) / (60 * 60 * 24);
> print "$date is $days_old days old\n";
> -------------------------------
>
>
> --
> Tad McClellan SGML consulting
> tadmc@augustmail.com Perl programming
> Fort Worth, Texas
Tad,
Thanks. This works pretty well. I appreciate the
help.
Chris
------------------------------
Date: 19 Dec 2002 00:19:26 GMT
From: roberson@ibd.nrc.ca (Walter Roberson)
Subject: Re: extracting data from a column
Message-Id: <atr3ae$auu$1@canopus.cc.umanitoba.ca>
In article <zs3M9.389405$WL3.116445@rwcrnsc54>,
Rick L. <snotrocket88@hotmail.com> wrote:
:> Here is a short example of what the log files look like:
:> number text text2 text3 http://testurl:80
:> number text text2 text3 http://testurl2:443
:> What I basically want to do is extract the URL from the 5th column, then
:> strip off the "http://" and the ":80" or the ":443"
:> I need to make this solution work for both linux and solaris systems. The
:> few attempts I've made have failed. I can't seem to isolate that last
:> column.
If you want to do it in two steps:
($lastcol) = /(\S+)$/;
($bareurl) = $lastcol =~ m!http://(.*):\d+$!;
You can combine the two steps into one if you are not going to need
the port number and you are sure that the last column will be in the
right format:
($bareurl) = m!http://(.*):\d+$!;
You may notice that it's easier to do it this way than to bother to extract
the last column.
You could also split() the line to get the last column.
--
Live it up, rip it up, why so lazy?
Give it out, dish it out, let's go crazy, yeah!
-- Supertramp (The USENET Song)
------------------------------
Date: Thu, 19 Dec 2002 01:01:30 GMT
From: "Rick L." <snotrocket88@hotmail.com>
Subject: Re: extracting data from a column
Message-Id: <KT8M9.67$Qm5.1225@paloalto-snr1.gtei.net>
"Walter Roberson" <roberson@ibd.nrc.ca> wrote in message
news:atr3ae$auu$1@canopus.cc.umanitoba.ca...
>
> If you want to do it in two steps:
>
> ($lastcol) = /(\S+)$/;
> ($bareurl) = $lastcol =~ m!http://(.*):\d+$!;
The /(\S+)$/ was exactly what I was looking for. Thanks for the help!
------------------------------
Date: 18 Dec 2002 17:43:16 -0800
From: J_Steven_Walker@hotmail.com (Steve Walker)
Subject: Re: extracting data from a column
Message-Id: <534c971c.0212181743.e542d80@posting.google.com>
> > I have to weed through some log files for some specific data. Basically
> > each log file is made up of 5 columns, all separated by spaces.
> > Here is a short example of what the log files look like:
> >
> > number text text2 text3 http://testurl:80
> > number text text2 text3 http://testurl2:443
> >
> > What I basically want to do is extract the URL from the 5th column, then
> > strip off the "http://" and the ":80" or the ":443"
You have a number of options: a) you might have some use for the
early columns or b) you really only care about the last bit.
a) use split() with whitespace as the delimiter
@linedata = split(" ",$line);
then process the last item for the substring with a pattern
$line ~= m/http:\/\/(.*):\d/ ;
$url = $1;
(something you can run) ---
#!/usr/bin/perl
while (<>)
{
chop($line = $_) ;
@linedata = split(" ",$line);
$lineitem = $linedata[4];
$lineitem =~ m/http:\/\/(.*):\d/ ;
$url = $1;
print "\n url is $url\n";
}
b) or just process the line for the substring with a pattern using
space and not space to get to the relevent portion of the input
$line ~= m/\S*\s*\S*\s*\S*\s*\S*\s*http:\/\/(.*):\d/ ;
$url = $1;
>
> The example I gave is only two lines of a text file. I plan on putting that
> text file into an array and from there I want to grab the URLs. I just
> wanted to show what each line looks like. The overall array will be
> thousands of lines similar to these two with the URLs (above). Each line
> has the exact same format though, 5 columns with the URL in the last column.
You can read 'em all or process line by line --
either method will let you process each line as it is input if you
wish
good luck,
S.
------------------------------
Date: Wed, 18 Dec 2002 17:13:31 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: FTPing without Net::FTP
Message-Id: <slrnb0208r.3gg.tadmc@magna.augustmail.com>
Kevin Brownhill <BROWNHIK@Syntegra.Bt.Co.Uk> wrote:
> I wonder why it is that on this newsgroup, when someone asks a question to
> solve a particular problem they have,
It is likely that the OP started with "I need to do FTP" (since
he did research and discovered Net::FTP), then found that the
sysadmin would not install the module that does that.
He then (erroneously) assumed that he could not use the FTP module.
So _then_ we in clpmisc became involved with his next-level
question of how to get it done without the module.
This is commonly called an "XY problem":
An XY problem is when you want to do X, but you ask how to do Y
instead, because you've decided that Y is the best way to accomplish X.
What he really wants to do is
transfer files (X)
but what he asked us was how to
transfer files without the Net::FTP module (Y)
because he thought that was his only option.
The followups of the regulars pointed out that it is not his only option.
> and someone else gives them a possible
> solution, there are always a couple of "regulars"
The regulars here are a generally insightful lot. They often
can detect the situation described above and "back up" to the "X",
without even being asked about the "X".
Randal Schwartz in:
Message-ID: <m18zt5muq9.fsf_-_@halfdome.holdit.com>
describes how answering the "Y" could rationally be seen
as being somewhat irresponsible.
> who pedantically state
> that this is not the correct way of doing it in Perl and is therefore WRONG.
It is an application of:
Give a man a fish; you have fed him for today.
Teach a man to fish; and you have fed him for a lifetime.
You gave him a fish.
Next week he'll ask:
how can I fetch an HTML page without LWP::Simple?
and you'll tell him
use lynx
The week after that he'll be back asking:
how can I send email without Mail::Sender
and you'll tell him
use sendmail or blat
And the next week he'll ask...
The regular's approach will avoid all of that.
> They state that "most knowledgeable people" wouldn't do it that way, in
> order to
How do you know what the intent is?
You can't really tell what their intent is without asking them,
so you must be guessing.
It is possible that you have guessed incorrectly you know, there
might be some other (even helpful) reason that you just haven't
recognized. You will learn more if you can manage to keep an open mind.
> make the person who gives a straight answer to the question asked
> look stupid.
So we should only answer the question that was asked?
Q: I need to transfer files using Perl, is this possible?
A: Yes.
You seem to be suggesting that such an exchange is desirable?
> The only person answering that question (me) was flamed by the regulars.
That kind of makes this followup of your nothing more than
sour grapes then...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 18 Dec 2002 23:44:43 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: FTPing without Net::FTP
Message-Id: <3e010774.3330126@news.erols.com>
"Kevin Brownhill" <BROWNHIK@Syntegra.Bt.Co.Uk> wrote:
: The only person answering that question (me) was flamed by the regulars.
Who did that?
The only thing that came remotely close to being flamed was your code.
You are not your code.
------------------------------
Date: 18 Dec 2002 16:11:49 -0800
From: newsgroups@bandwood.com (Dennis Macdonald)
Subject: Re: getstore not working - please help
Message-Id: <d98b592e.0212181611.11331502@posting.google.com>
THanks for your help. In deed it does work, but puts the file on my
web server. What I was after is to scrpit the download to a user not
onto the server. Do you know how to do this. I seem to be totally
off-beam with this one.
Thanks,
Dennis.
Bob Walton <bwalton@rochester.rr.com> wrote in message news:<3DFFE58F.5070608@rochester.rr.com>...
> Dennis Macdonald wrote:
>
> > Hi,
> >
> > Below is the code that I'm using. The status returned is OK but
> > nothing is downloaded. Can anyone help me with why and how to fix it.
> >
> >
> > use LWP::Simple;
> > use HTTP::Status;
> >
> > my $remote="http://www.bandwood.com/_testdir/winzip.zip";
> > my $local="winzip.zip";
> > my $rc = &getstore($remote,$local);
> > if ($rc != RC_OK) { print status_message($rc), "\n"; }
> > print ("#########\n");
> > print ("Download Status = " . status_message($rc). "\n");
> > print ("#########\n");
> >
> >
> >
> > RETURNS:
> >
> > ######### Download Status = OK #########
> >
> >
> > If you take http://www.bandwood.com/_testdir/winzip.zip and paste it
> > into a browser it will work, so the path is correct.
> ...
> > Dennis.
> >
>
> Your code copy/pasted verbatim works just fine on my system. It
> downloaded a file called winzip.zip, which, when unzipped, contained a
> gif file of the WinZip logo. AS Perl build 633, Windoze 98SE.
>
> Are you sure that's not what your system did too?
------------------------------
Date: 19 Dec 2002 00:28:06 GMT
From: Nicholas Dronen <ndronen@io.frii.com>
Subject: Re: Is this a bug? (5.6.1 and 5.005.04)
Message-Id: <3e011296$0$16013$75868355@news.frii.net>
Joe Schaefer <joe+usenet@sunstarsys.com> wrote:
> Nicholas Dronen <ndronen@io.frii.com> writes:
> [...]
>> 16 for ($self->{os}) {
> [...]
>> 29 while (<LLQ>) {
> while() does not auto-localize $_. Since your
> for() loop binds $_ to $self->{os}, you're
> actually assigning each line of LLQ to $self->{os}.
> Once you've exhausted the file, the while() loop
> exits, with $self->{os} now undefined. Your
> program dies soon afterwards.
Ah, so it is a bug . . . in my program. :-)
After posting I tested the program on Linux
and got the same results, so I figured it was
probably my poor understanding of Perl.
Thanks for clearing it up. I can always do
for my $unused ($self->{os}) {
. . .
}
to work around this, but I'd like to back away from
this particular problem and ask whether there's a
way to avoid the "for switch" in the first place.
Since this program runs on more than one operating
system and since it has to gather data from different
applications (specifically, from batch scheduler utilities)
on each OS, I use the emulated switch statement in a
number of places.
What I'd really like to do, however, is to have sub
refs dangle from the blessed reference itself, so I
could do:
sub load_running_users {
my $self = shift;
# This syntax is off the top of my head and
# may be incorrect.
return &{ $self->{load_running_user_func} };
}
This'll save clutter in the code.
But I vaguely recall that when I tried assigning
a sub ref to a value in $self, I wasn't able to
access $self's data from within that sub ref.
Forgive me. It's a slightly foggy memory.
Ring a bell?
Regards,
Nicholas
--
Please do not reply to USENET posts, at least to mine, by email.
------------------------------
Date: 18 Dec 2002 21:08:57 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Is this a bug? (5.6.1 and 5.005.04)
Message-Id: <m3d6nyoj46.fsf@mumonkan.sunstarsys.com>
Nicholas Dronen <ndronen@io.frii.com> writes:
[...]
> Thanks for clearing it up. I can always do
>
> for my $unused ($self->{os}) {
> . . .
> }
>
> to work around this, but I'd like to back away from
> this particular problem and ask whether there's a
> way to avoid the "for switch" in the first place.
>
> Since this program runs on more than one operating
> system and since it has to gather data from different
> applications (specifically, from batch scheduler utilities)
> on each OS, I use the emulated switch statement in a
> number of places.
Damian Conway put a nice Switch module on CPAN.
I'm pretty sure it's also bundled into the 5.8.0
distribution.
> What I'd really like to do, however, is to have sub
> refs dangle from the blessed reference itself, so I
> could do:
>
> sub load_running_users {
> my $self = shift;
> # This syntax is off the top of my head and
> # may be incorrect.
> return &{ $self->{load_running_user_func} };
> }
See
% perldoc perlsub
for an explanation of Perl's calling conventions.
When you write &func, you're calling func with the
current argument stack @_. Since you already shift()ed
the object $self off the argument stack, it's no longer
available in @_.
You might try writing it this way (untested):
sub load_running_users {
my ($self) = @_;
return &{ $self->{load_running_user_func} };
}
--
Joe Schaefer "Things may come to those who wait, but only the things left by
those who hustle."
-- Abraham Lincoln
------------------------------
Date: Thu, 19 Dec 2002 01:10:40 -0000
From: "doofus" <jim.bloggs@eudoramail.com>
Subject: Mail::POP3Client vs. Sockets networking ?
Message-Id: <atr6ah$1rq97$1@ID-150435.news.dfncis.de>
Hi,
I'm scared to post anything here now because I always seem to put a foot
wrong, but, since it's almost Christmas, what the heck.
Here's what has been on my mind. I have script that uses
Mail::POP3Client to access a POP3 server, oops, that's obvious, but it
takes forever doing the server transactions.
So I got to thinking, in general, is there anything, might there be
anything to be gained, speed wise by rolling your own sockets
networking. I would have thought not. I certainly very much hope not.
But this guy is telling me the POP3 server never went slow before, and
what's my problem. I think he's a bit daft.
But is it _just_ possible, that significant speed gains could be made by
demodularizing and putting the code inline?
Please say it ain't so.
Also, following the kind advice of another earlier contributor, I've
been using -d:DProf with some success, but sometimes it gives me a
really informative tmon.out and other times it gives me nothing. ( I
know about dprofpp -u ). I'm on W2k. Is that what's doing it. Maybe I
just need to read the FAQ some more. I'm sorry about that.
Thanks and Merry Christmas to y'awl.
ho, ho, ho. {:D
--
Doof
------------------------------
Date: 19 Dec 2002 01:59:06 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Mail::POP3Client vs. Sockets networking ?
Message-Id: <atr95a$ehv$1@nets3.rz.RWTH-Aachen.DE>
Also sprach doofus:
> I'm scared to post anything here now because I always seem to put a foot
> wrong, but, since it's almost Christmas, what the heck.
>
> Here's what has been on my mind. I have script that uses
> Mail::POP3Client to access a POP3 server, oops, that's obvious, but it
> takes forever doing the server transactions.
>
> So I got to thinking, in general, is there anything, might there be
> anything to be gained, speed wise by rolling your own sockets
> networking. I would have thought not. I certainly very much hope not.
I wouldn't think so either. Querying a pop-server is not a very
computational task so I don't think there is much to gain.
> But this guy is telling me the POP3 server never went slow before, and
> what's my problem. I think he's a bit daft.
>
> But is it _just_ possible, that significant speed gains could be made by
> demodularizing and putting the code inline?
>
> Please say it ain't so.
Modularization isn't the problem either. Sure, it slows parsing down and
object-oriented programs also run slower compared to mere functional
ones. But not too a degree that would render Mail::POP3Client useless.
Have you tried Net::POP3 to see whether it gives any significant
different in performance?
Tassilo
--
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;
------------------------------
Date: Thu, 19 Dec 2002 02:04:18 -0000
From: "doofus" <jim.bloggs@eudoramail.com>
Subject: Re: Mail::POP3Client vs. Sockets networking ?
Message-Id: <atr9f4$1rkra$1@ID-150435.news.dfncis.de>
Tassilo v. Parseval wrote:
> Have you tried Net::POP3 to see whether it gives any significant
> different in performance?
Yeah, I tried it too. It didn't seem to make much difference, but then
again, I wasn't doing split second timing.
Thanks for the reply.
------------------------------
Date: Wed, 18 Dec 2002 17:06:24 -0700
From: Ron Reidy <rereidy@indra.com>
Subject: Re: oracle 9i compatible perl version
Message-Id: <3E010D80.5070303@indra.com>
What version did you migrate from and why?
I have used 5.6.1 and 5.8.0 with 9iR1.
farooq wrote:
> Hello,
> I am trying to find out which version of PERL is required to talk to
> Oracle 9i database. When we moved to Oracle 8.1.7, we had to upgrade
> PERL to version 5.005_03, DBI 1.20 and DBD 1.12. Is there a CPAN or
> Oracle site where I can confirm this ?
>
> Thanks
------------------------------
Date: Wed, 18 Dec 2002 17:12:26 -0700
From: Ron Reidy <rereidy@indra.com>
Subject: Re: Oracle PL/SQL split function? Perl wannabe UTF8 code parsing
Message-Id: <3E010EEA.5070201@indra.com>
Look at http://www.perl.com/CPAN-local/modules/by-authors/Jeff_Horwitz/
for extproc_perl.
Ed Kulis wrote:
> Hi,
>
> I'm writing some functions in Oracle PL/SQL that will illustrate the coding
> and characters of UTF8 dump strings, and ISO8859-1 codesets.
>
> I'm posting this here as well as in the comp.database.oracle.misc group in
> the hope that someone here can help.
>
> Unfortunately, I can't use the Perl DBI or Oracle OCI with perl on this
> task.
>
> I'd like to be able to parse a structure like this in PL/SQL.
>
> 10, 13, 238.161.191, 194.191,112, 101, 114, 108
>
> where the comma separated elements represent the UTF8 codes which contain
> periods if the code is multi-octet. This structure will allow me to specify
> character transformations on the codes from the Oracle dump function.
>
> I'll also need to recognize the non-delimited multi-octets from the Oracle
> dump function
>
> 10, 13, 238, 161, 191, 194, 191, 112, 101, 114, 108
> ------------- --------
>
> This is easy in perl with a split function and lists but this task is
> exclusively in the realm of PL/SQL packages.
>
> I need these functions because converters like Oracle convert substitute an
> invert ? for characters that they can't recognize and our down stream
> process often choke on invert ?'s as well as other characters.
>
> I can hack this up with crude Oracle character string character functions.
>
> But is there a clever way or function some where that will do this for me?
>
> Here's a dream, is there a perl2plsql converter?
>
> -ed
>
------------------------------
Date: Wed, 18 Dec 2002 17:41:44 -0600
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: Why do beginners read files into an array?
Message-Id: <atr1ge$rbf$1@slb5.atl.mindspring.net>
"Jeff Zucker" <jeff@vpservices.com> wrote in message
news:3E00B955.3070609@vpservices.com...
<snip>
> I think it's because the diamond operator is so magical that beginners
> don't learn all of its capabilities. They know the diamond can be used
> to dump into an array and they know how to cycle through an array so
> that's what they do.
Hi, Jeff.
As an *old* beginner, i.e., still learning, I'd suggest the first thing a
beginner learns about the diamond operator might be that it can be used to
read a line of input, e.g., from STDIN. Indeed, in LP2, <STDIN> appears to
be first mentioned on page 6, and then explained in detail in Chapter 6.
The (LP2) use of the diamond operator is introduced a little later.
>They haven't figured out that they can cycle
> through the diamond itself without first turning it into something else.
I presume you mean something like
while (<ADDRESSES>){
# Do something with $_
};
instead of
my @address = <ADDRESSES>;
I've run across examples where the latter, even though it may not be
scalable to huge file sizes, is the easier of the two with which to work,
e.g., converting the one-up mailing label example in LP2, Ch. 11, Formats to
three-up labels using an appropriate format (picture lines), including the
possibility of a number of lines of label data not equal to an integer
multiple of three.
> Also, they probably don't understand the difference between a file
> and the data contained in the file so for them there isn't any
> difference between cycling through an array of the data and cycling
> through the lines of the file.
That's a pretty broad statement. What difference between a file and the data
contained in the file leads you to the conclude that a beginner doesn't know
the difference between cycling through an array of the data and cycling
through the lines of the file?
Cheers.
Bill Segraves
------------------------------
Date: Wed, 18 Dec 2002 18:30:29 -0600
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: Why do beginners read files into an array?
Message-Id: <atr4vh$dil$1@slb9.atl.mindspring.net>
"William Alexander Segraves" <wsegrave@mindspring.com> wrote in message
news:atr1ge$rbf$1@slb5.atl.mindspring.net...
<snip>
Indeed, in LP2, <STDIN> appears to
> be first mentioned on page 6, and then explained in detail in Chapter 6.
>
> The (LP2) use of the diamond operator is introduced a little later.
For those who do not have a copy of LP2, the entire contents appear to be
available at http://psu.unibel.by/biblio/books/learn/.
Randal had told me LP2 is dead. Apparently, it still lives. ;-)
Cheers.
Bill Segraves
------------------------------
Date: Wed, 18 Dec 2002 16:50:32 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Why do beginners read files into an array?
Message-Id: <3E0117D8.6090008@vpservices.com>
William Alexander Segraves wrote:
> "Jeff Zucker" <jeff@vpservices.com> wrote in message
> news:3E00B955.3070609@vpservices.com...
> <snip>
>
>
> As an *old* beginner, i.e., still learning
Me too, I hope.
> I'd suggest the first thing a
> beginner learns about the diamond operator might be that it can be used to
> read a line of input, e.g., from STDIN. Indeed, in LP2, <STDIN> appears to
> be first mentioned on page 6, and then explained in detail in Chapter 6.
Well, that would tend to reinforce my suggestion. They learn one of the
uses of the diamond operator and then don't realize that it has other
uses that behave differently in different contexts (context is a pretty
stiff concept for a beginner).
> I've run across examples where the latter, even though it may not be
> scalable to huge file sizes, is the easier of the two with which to work,
Sure, I'm not saying slurping a file into an array is always wrong.
However one should use it knowing the difference between it and reading
a line at a time.
>> Also, they probably don't understand the difference between a file
>>and the data contained in the file so for them there isn't any
>>difference between cycling through an array of the data and cycling
>>through the lines of the file.
>>
>
> That's a pretty broad statement. What difference between a file and the data
> contained in the file leads you to the conclude that a beginner doesn't know
> the difference between cycling through an array of the data and cycling
> through the lines of the file?
I'm not saying all beginners confuse a file and its data, but the
evidence for saying that many do is found in messages on clpm. For
example, there have been several over the years along the lines of -- I
read my file into an array and I am running out of memory, what should I do?
--
Jeff
------------------------------
Date: 18 Dec 2002 17:03:40 -0800
From: knewman00@yahoo.com (Kevin Newman)
Subject: Re: Why do beginners read files into an array?
Message-Id: <8ed70cf8.0212181703.5b3fc1b@posting.google.com>
"Tintin" <me@privacy.net> wrote in message news:<atpnn4$1cv63$2@ID-172104.news.dfncis.de>...
> Can anyone come up with a plausible reason why so many beginners write code
> like:
>
> open FILE, "data.txt";
> @var=<FILE>;
> close FILE;
>
> foreach $line (@var) {
> print $line;
> }
>
> Where does this logic come from?
>
> The only reason I can come up with is that the newbies are learning from bad
> examples.
Speaking as a beginner, what's the "correct" way to do it?
Thanks,
kln
------------------------------
Date: Wed, 18 Dec 2002 19:04:05 -0600
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: Why do beginners read files into an array?
Message-Id: <atr6aq$nah$1@slb5.atl.mindspring.net>
"Jeff Zucker" <jeff@vpservices.com> wrote in message
news:3E0117D8.6090008@vpservices.com...
> William Alexander Segraves wrote:
<snip>
> Well, that would tend to reinforce my suggestion. They learn one of the
> uses of the diamond operator and then don't realize that it has other
> uses that behave differently in different contexts (context is a pretty
> stiff concept for a beginner).
I agree. OTOH, in LP2, it's hard to miss it. Same paragraph.
Cheers.
Bill Segraves
------------------------------
Date: Thu, 19 Dec 2002 01:06:43 GMT
From: "Ian.H [dS]" <ian@WINDOZEdigiserv.net>
Subject: Re: Why do beginners read files into an array?
Message-Id: <gu620v0tlthe52rkicbfu08fu0f5gqr2in@4ax.com>
Keywords: Remove WINDOZE to reply
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
In a fit of excitement on 18 Dec 2002 17:03:40 -0800,
knewman00@yahoo.com (Kevin Newman) managed to scribble:
> "Tintin" <me@privacy.net> wrote in message
> news:<atpnn4$1cv63$2@ID-172104.news.dfncis.de>...
> > Can anyone come up with a plausible reason why so many beginners
> > write code like:
> >
> > open FILE, "data.txt";
> > @var=<FILE>;
> > close FILE;
> >
> > foreach $line (@var) {
> > print $line;
> > }
> >
> > Where does this logic come from?
> >
> > The only reason I can come up with is that the newbies are learning
> > from bad examples.
>
> Speaking as a beginner, what's the "correct" way to do it?
>
> Thanks,
>
> kln
Not "correct" but an alternative way:
open(FILE, "<data.txt");
while (<FILE>) {
echo $_;
}
close(FILE);
Regards,
Ian
-----BEGIN xxx SIGNATURE-----
Version: PGP Personal Privacy 6.5.3
iQA/AwUBPgEcD2fqtj251CDhEQLBQgCdGV9Te2f5KSUoB+6UeVZK7s8Qi1oAn2p8
ozTJsqkMbE/bY0zsghSwW6ri
=Yno8
-----END PGP SIGNATURE-----
--
Ian.H [Design & Development]
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Scripting, Web design, development & hosting.
------------------------------
Date: Wed, 18 Dec 2002 23:30:04 +0000 (UTC)
From: per@hedeland.org (Per Hedeland)
Subject: Re: Why doesn't this foreach SMTP loop work?
Message-Id: <atr0ds$17gq$1@hedeland.org>
In article <atq9pt$jbc$1@knossos.btinternet.com> "Nick Djurovich"
<Nick_Djurovich@NOSPAM.aimtechnology.com> writes:
> Alternatively, you might try creating
>a single To: with a list of addresses delimited with a semi-colon
>and change the code thus ;
Multiple addresses in an email header are *comma*-separated (except when
displayed by some weird MUA).
--Per Hedeland
per@hedeland.org
------------------------------
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 4285
***************************************