[16251] in Perl-Users-Digest
Perl-Users Digest, Issue: 3663 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 14 06:05:30 2000
Date: Fri, 14 Jul 2000 03:05:17 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <963569117-v9-i3663@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 14 Jul 2000 Volume: 9 Number: 3663
Today's topics:
"Perl Bowling" revisited with an array question <o1technospam@skyenet.nospam.net>
Re: "Perl Bowling" revisited with an array question (Bernard El-Hagin)
Re: ATTENTION PERL MACHOES!!!!!!!!!!!!!!!!!!! <nnickee@nnickee.com>
Re: Bizarre BEGIN block problem <bart.lateur@skynet.be>
Re: Bizarre BEGIN block problem (Anno Siegel)
Re: Bizarre BEGIN block problem <bcaligari@shipreg.com>
Re: DBI - DBD:Sybase installation problem (Andy Ford)
Escaping strings. <chuckwNOchSPAM@silverlink.net.invalid>
GD module, displaying an image in a browser <stephane@siw.ch>
how to append lines to the end of file tvn007@my-deja.com
Re: how to append lines to the end of file <o1technospam@skyenet.nospam.net>
Re: how to append lines to the end of file <o1technospam@skyenet.nospam.net>
Re: how to convert "1.2.3.10" to "01020310"? (Bernard El-Hagin)
Re: how to convert "1.2.3.10" to "01020310"? <godzilla@stomp.stomp.tokyo>
Re: how to convert "1.2.3.10" to "01020310"? <bcaligari@shipreg.com>
Re: how to convert "1.2.3.10" to "01020310"? (Bernard El-Hagin)
Re: Newbies cry for help <ecco64@chello.nl>
Re: perl array references woes... <jadame@velocityhsi.com>
Re: perl array references woes... (jason)
Re: Reading fixed-length fields from a record <marc.schaefer@warwick.ac.uk>
Running a CGI-script through CGI? <arild@langtind.no>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 14 Jul 2000 03:07:59 -0500
From: "Jim Kauzlarich" <o1technospam@skyenet.nospam.net>
Subject: "Perl Bowling" revisited with an array question
Message-Id: <CMzb5.901$RX5.2065@newsfeed.slurp.net>
Ok, not wanting to beat a dead horse, but... I got started on this stuipd
thing, and I want to finish it.
You'll probably remember the "Is there a way in Perl to determine the lenght
of a string" question. Of course this got almost as many deriding comments
as it deserved, and then several people, including myself, had some fun
posting the nastiest code they could think of to do the job.
Anyway, I as fiddeled with LISP a few years ago (ok, more than a few), I was
thinking that recursion would be a (good?) way to handel this problem.
Unfortionatly, I seem to be either using the wrong tools, or using them
incorrectly.
The following is my code, inside of which are three supposidly
interchangable sections (two are commented out, so that the code actually
does work as posted). The first two work as expected. But the third
section does not. I have tracked down the problem to the fact that shift,
unlike join, returns the value of the element it shifted out of the array,
rather than the newly shifted array.
So, I guess my question is: Is there any function that will shrink (at this
point I don't care which end it comes off of) an array, and return the newly
shrunken array.
Thanks!
[Almost made the mistake of the "harmless" act of doing a search and replace
of 'crap' with 'stuff' to "clean up" my post. Luckily I cut & paste it
back and tried to run it. I am learning. (Though I don't think I've ever
posted untested code. Not that I've posted much.) ]
!/usr/bin/perl -w
use strict;
sub dumdum {
my (@crap) = split (//, $_[0]);
my ($crap);
if ($_[0] eq "") {
return 0;
}
########### The following 3 commented sections are supposed to be inter-
########### changeable, and infact, the first two are. But I'm having
########### trouble with the third version.
########### Fisrt version
########### 3 lines
# shift (@crap); # works
# $crap = join ("", @crap); # works
# return (dumdum ($crap)+1) # works
########### Second version
########### 2 lines
shift (@crap); # works
return (dumdum ( join ("", @crap))+1); # works
########### Third version
########### 1 line
# return (dumdum ( join ("", shift (@crap)))+1); # want somethin like this
########### End of sub dumdum
}
my ($string)="You suck!!";
print dumdum ($string)."\n";
JMK
------------------------------
Date: Fri, 14 Jul 2000 09:30:22 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: "Perl Bowling" revisited with an array question
Message-Id: <slrn8mtn4s.9rf.bernard.el-hagin@gdndev25.lido-tech>
Jim Kauzlarich <o1technospam@skyenet.nospam.net> wrote:
>So, I guess my question is: Is there any function that will shrink (at this
>point I don't care which end it comes off of) an array, and return the newly
>shrunken array.
perldoc -f splice
Bernard
--
perl -e'@x=(3,2,4,1,3,2,1,3,1,3,2,3,3,2,3,0,0,1,2,1,1,1,4,1,2,1,1,2,2,1,
2,1,2,1,2,1,2,1,1,1,2,1,0,0,3,2,3,2,3,2,1,1,1,1,1,2,4,2,3,2,1,2,1,0,0,1,
2,1,1,1,4,1,2,1,1,1,2,2,1,1,4,1,1,1,2,1,1,1,2,1,0,0,3,2,4,1,1,2,1,1,1,3,
1,1,1,4,1,1,1,2,1,1,3,0,0);sub x{print q x$xx$_;print q x x x shift@x};#
while(defined($_=shift @x)){s o0o\no;$_!=0?x:print}' #Symmetry yrtemmyS#
------------------------------
Date: Fri, 14 Jul 2000 02:57:40 -0500
From: Nnickee <nnickee@nnickee.com>
Subject: Re: ATTENTION PERL MACHOES!!!!!!!!!!!!!!!!!!!
Message-Id: <54AA60E1DA2F9542.03AE1CD4FD429A92.97D63CADDB1013F9@lp.airnews.net>
On Fri, 14 Jul 2000 07:01:15 GMT, someone claiming to be
pjlees@ics.forthcomingevents.gr (Philip Lees) said:
>On 13 Jul 2000 18:31:02 GMT, dha@panix.com (David H. Adler) wrote:
>>Unfortunately, many, if not most, people who have this difficulty
>>appear to show up and not point that out. They merely ask the same
>>question that is answered in the docs instead of saying "I've read the
>>docs and don't understand [insert specific point of misunderstanding
>>here]".
>Even if you do that, it doesn't help. I posted a (beginner's) question
>recently. I had read the relevant docs and said so in my post.
>However, it appeared that many of the regular posters here hadn't read
>the post carefully enough to notice that and just responded with the
>kneejerk RTFM response. When I got pissed off by that I got killfiled.
RTFM responses are GOOD responses for a couple of reasons. Number
one, they teach the beginner where they can find their own answers to
their questions, without having to wait for someone to respond to
their post. Number two, they conserve bandwidth. (Picking a faq at
random here: Compare a one line response of "perlfaq4: why am I
getting long decimals instead of the numbers I should be getting" to
the 6 paragraph answer to that question in the faq. How many times is
that question asked every day? Saving bandwidth is a GOOD thing.)
I posted a barely-beyond-beginner's question just a few hours ago.
Granted only a couple of people have answered me so far (multiple
answers from each), but not a single answer contained "see [faq | func
| whatever ]". The answers that I've gotten so far have contained
multiple examples as well as explanations of why my code was doing
what it was doing. Why did I get good answers? I believe it has
something to do with the fact that I stated which faqs / man pages I'd
read, posted multiple snippets that I'd tried, and indicated that I
had no problem whatsoever going back and re-reading the same docs /
different docs that were referred to me.
Was the post of yours that you referred to above the "strange behavior
in upper case conversion" question? I seem to remember a *lot* of
good answers to that one.
>I'm struggling on with Perl, but I don't expect to get any help from
>this newsgroup.
And you won't, if you say stuff like that. You'll get back from this
group what you put into it. If you follow the conventions and
"standards", you'll be rewarded with all the help you need.
I don't think you (and many others, not just picking on you here)
realize what a terrific resource this newsgroup is. Some of the very
best Perl coders in the world - *in the world*! - spend their valuable
free time reading this group and answering the same questions over and
over again. These folks don't have to do this. They do it to give
back to the Perl community. They don't ask for a single solitary
penny for this (and they're worth far more than that, I assure you!).
The very least that we, the beginners, the askers, can do is to follow
the Guru's "rules" since we're asking them to give us for free what
they could very well charge us for (answers, advice, code snippets,
etc.).
Just my $0.10 (yes, I do think my opinion is worth more than 2 cents
:)
Nnickee
------------------------------
Date: Fri, 14 Jul 2000 10:44:06 +0200
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Bizarre BEGIN block problem
Message-Id: <cmjtmss5dftprn2394h3c1197mhlbjms44@4ax.com>
Ed Foy wrote:
>I do not know if SGML is your employer or a pseudonym for your
>unemployment.
Gee, you really know your stuff.
If he had mentioned "XML" or "HTML" instead, would you still think it is
an employer?
Tad is a consultant, specialized in SGML-related programming. And if
that still doesn't ring a bell: SGML is the mother of both HTML and XML,
and more.
--
Bart.
------------------------------
Date: 14 Jul 2000 09:17:22 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Bizarre BEGIN block problem
Message-Id: <8kmlr2$8mf$1@lublin.zrz.tu-berlin.de>
Ed Foy <ed@nospam.com> wrote in comp.lang.perl.misc:
>
>pkay01@my-deja.com wrote in message <8kkl0e$g8t$1@nnrp1.deja.com>...
>>
>>Why not try using the CGI module, and let the CGI functions do the
>>tricky stuff for you;
[...]
>I fail to see how this remotely addresses the question I asked which was
>why there is an apparently spurious syntax error message on compilation.
Translation: "Answer my question the way I want it answered or shut up.
You're wasting my precious time."
Despite your claims elsewhere in this thread, you don't understand how
newsgroups work.
Anno
------------------------------
Date: Fri, 14 Jul 2000 11:44:36 +0200
From: "Brendon Caligari" <bcaligari@shipreg.com>
Subject: Re: Bizarre BEGIN block problem
Message-Id: <8kmmqp$1k5$1@news.news-service.com>
"Ed Foy" <ed@nospam.com> wrote in message
news:mJrb5.548$dT5.4220@newsread2.prod.itd.earthlink.net...
>
> Tad McClellan wrote in message ...
> >On Thu, 13 Jul 2000 17:53:05 GMT, Ed Foy <ed@nospam.com> wrote:
> >>
> >>Does this comment mean SGML Consulting will only work with the "Latest
> >>and Greatest" implementation of something or reinvents the wheel
> because
> >>the original wheel doesn't use the latest set of bugs?
> >
> >
> >Ad hominem attack.
> >
> >I'm not feeling sorry anymore.
> >
> >*plonk*
>
>
> Hmmm...not very professional. In fact, the question was in earnest and
> consistent with your statement. With new projects it is reasonable to
> start with a clean sheet and people who can work with currency. Those
> who are wedded to the "old ways" are fine for maintenance projects but
> useless for new projects.
>
> FYI, apart from asking the occasional question in NGs, I follow the
> questions, response, the names of the players and their companies. It is
> exceedingly useful to do so. Resumes are twitted out based on NG
> activity and companies are also similarly excluded.
>
> I do not know if SGML is your employer or a pseudonym for your
> unemployment. It matters not as both are now listed in the twit file.
> You complete childishness and lack of professionalism speak volumes.
> Alas, yes, I'm one of those stupid executive management types. But on
> the bright side, I'm on the top of the heap when it comes to who gets
> their next paycheck and who doesn't, who gets a contract and who
> doesn't, and who we conduct business with and who we don't. This facet
> makes up for being so stupid.
>
> For others in the NG take heed. It is common practice for management and
> human resources types to follow NGs for the purpose of establishing
> competency in professional fields. Those who cannot conduct themselves
> in a professional manner in a professional forum will behave the same
> way in the work environment. So if you don't mind limiting your
> horizons, by all means, get out in public and be a complete jerk - it
> save a lot of time and money to trash your resume as soon as it comes in
> the door. The same applies to your employer. Any company willing to
> tolerate childishness is not a company trustworthy to conduct business
> with.
>
> Just gotta love these NGs!
>
> Ed
>
>
what's an NG?
------------------------------
Date: Thu, 13 Jul 2000 05:28:02 -0500
From: andy@monk.ford.saint-louis.mo.us (Andy Ford)
Subject: Re: DBI - DBD:Sybase installation problem
Message-Id: <slrn8mr6dg.rhj.andy@monk.ford.saint-louis.mo.us>
On Tue, 11 Jul 2000 20:52:31 GMT, vpanicker@my-deja.com <vpanicker@my-deja.com> wrote:
>Hi All,
>
>I have a situation in which i need to connect to and access an SQL
>Server 7.0 (serv pack 2) thru a perl application residing on a
>different server. I have tried installing DBD:sybase for this, which
>led me to install CT Lib. which is a pre-requisit for DBD:Sybase. Now
>CT Lib installation requires sybase server to be available on the
>server which is running the perl application. This sounds a little
>weired(not feasible too). Does anybody know any other option for
>achiving this task?
>
>ur inputs will be greatly appreciated.
>thanx
>vinod
>
I think you need the sybase libraries. Basically the same stuff you need to compile any
client application. See http://www.mbay.net/~mpeppler/ for more info.
--
yours,
Andy
------------------------------
Date: Fri, 14 Jul 2000 02:15:04 -0700
From: chuckw <chuckwNOchSPAM@silverlink.net.invalid>
Subject: Escaping strings.
Message-Id: <10d62c60.2407c0cf@usw-ex0102-016.remarq.com>
The answer to this is not obvious to me or perhaps I have simply
been up too late. In a nutshell, I have some text in a scalar
that was submitted from a webpage for example. I then submit that
text to a database. (for the sake of argument, we'll assume the
input is secure) Whenever the inputted text has a quote or
something like that, it fouls up the code that inputs it into the
database. No big deal, I just use an RE to escape all of the
errant characters. Unfortunately the escape characters go along
with the text into the database. The problem arises when other
applications (that I have no control over) access the data. All
of the escaped characters have to be un-escaped or else the
slashes make it into the output.
My question: How do I accept input with these characters (", ', `
etc) without escaping them? Is there a way to render the string
"inert" so that when it is evaluated in my SQL statement, the
errant characters don't clog the works???
-----------------------------------------------------------
Got questions? Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com
------------------------------
Date: Fri, 14 Jul 2000 08:59:10 GMT
From: "Chello" <stephane@siw.ch>
Subject: GD module, displaying an image in a browser
Message-Id: <yDAb5.35885$7D2.642919@news.chello.at>
Hi all,
I'm trying to display an image with GD module:
use GD;
# create a new image
$im = new GD::Image(100,100);
# allocate some colors
$white = $im->colorAllocate(255,255,255);
$black = $im->colorAllocate(0,0,0);
$red = $im->colorAllocate(255,0,0);
$blue = $im->colorAllocate(0,0,255);
# make the background transparent and interlaced
$im->transparent($white);
$im->interlaced('true');
# Put a black frame around the picture
$im->rectangle(0,0,99,99,$black);
# Draw a blue oval
$im->arc(50,50,95,75,0,360,$blue);
# And fill it with red
$im->fill(50,50,$red);
binmode STDOUT;
print "Content-type: image/jpeg\n";
print "Pragma: no-cache\n";
print "Expires: now\n\n";
print $im->jpeg(100);
But it doesnt work... I only have as a result:
S~V:``E7ͳgs$?LXlYqE0{~{
"<2k.}]Pso"2 ).-_T-5g1Zgrm"1cmmz#
Gr95s'O9Sv4L$A#02Bqd\I+?"z=M<>/coKk/?j8
[Cwe^?>mBV#Ph,.Ǧ6A|]DԷ
"rVed?!?M{M>Qtk
<|Ts0?^ejb6- P%"QQcxc>wT\*˵V
";fVK4sUz?8:-"Vѩ3jL?m2wHmD_-T@?AK
^}ϼ>:I<I5R1sz",J+[dStES&_ޝ~"
"Fy)"]mL][U'j?+KqKAg] Y \SUڭF.U"۸V]AM}?)K
"Y_woV[3"d
`q"@C>"$3"C111O.#mTjjSYwo9%:-JS.榤zGe-2)S5t
1M?d/aȨJh)g"S}\{"gX?}.G?
"_м-(Nu=Y\<ӯX,L/V'S_WK &V<ǧYʸ~55T-W,z
x5'}&]?"v=g}UԥF趲.)вsT*ػrԨ?YOZP'6)ڝ.'
"_-j1j2yK^ &ʳk "ܯ3Sb$'!]mp]HPIKFAg!q?O*
oc3ۤyUfPIK'|>fsɺ۸i |>fsɺ۸i |>fsɺ۸G\
HEkeN-*HP'.^@)1R!(sO,^,.HD,kJC"2X
"O6NѼ%[5('ެu=bKs-1
<?c
,1,HSÞ%~PͩreP2_d"edTaTcB=uW?4/)
#w,zTN^uB~\oo>m69iVEP`O"`R"FP$%(N9s
7Z,2t%b"
M+4UEq᧸oӵ3d10`O>,Kg-yUs9t1s2."
Tec3<JJHf5 2~sg#W.{oM
0$~S3
J32G-
UqFfe8&cO8)g^sF^٪IOTbbBsdXd.O3O#5o]t, -
=~췮Ὼ
k4'~/\$2TT#+%:57n7 /VEj'
+'T?e+`PSvz]IeYAܾ
E?yz5JDh(c<[!ubua>[ߩs#H%TfYLIdY1sFw:zM:;
sjv3
'.ZA>\fbl3Y>|E$ͳ63(?v.Wc&*]f_R1PħOb,
`&<aBPh@wpiOT+a\i^?0~h"6"9T/0~>c@OKo
f~.fo/R?]R?b<۾) Ly
b U1PXad
What's the problem and how to solve it??? Does someone have the solution??
Thanks in advance.
Stphane
------------------------------
Date: Fri, 14 Jul 2000 08:12:59 GMT
From: tvn007@my-deja.com
Subject: how to append lines to the end of file
Message-Id: <8kmi23$ueo$1@nnrp1.deja.com>
Hi,
I am trying to write a small script to count number of
lines in the file. If number of lines in a file is less than
500 than you have to add whatever number of lines to the
end of the file so that
the total of lines in that file is 500 lines.
The line you need to add is: XXX
Here what I have so far:
#########################################
$data_file ='test.file';
open(SCORES,$data_file)|| die "cannot open test file";
$i=0;
$expression = "p_S|p_X";
while (<SCORES>){
chomp;
if ($_ =~ /$expression/){
$i++;
}
}
if ($i <500){
$line_to_add = 500 - $i;
# can some one show me how to add
# extra lines at the end of test.file so that
the total number of line is 500 lines?
where each line is: XXX
}
}
Example:
line1 abc
line2 xyz
..
...
line 498 fxt
line 499 XXX
line 500 XXX
Thanks for any help,
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 14 Jul 2000 03:56:23 -0500
From: "Jim Kauzlarich" <o1technospam@skyenet.nospam.net>
Subject: Re: how to append lines to the end of file
Message-Id: <UtAb5.905$RX5.2759@newsfeed.slurp.net>
<tvn007@my-deja.com> wrote in message news:8kmi23$ueo$1@nnrp1.deja.com...
> Hi,
>
> I am trying to write a small script to count number of
> lines in the file. If number of lines in a file is less than
> 500 than you have to add whatever number of lines to the
> end of the file so that
> the total of lines in that file is 500 lines.
>
> The line you need to add is: XXX
pg 109 "Learning Perl"
or look in "Perl and CGI for the world wide web", I know it's there
------------------------------
Date: Fri, 14 Jul 2000 04:08:06 -0500
From: "Jim Kauzlarich" <o1technospam@skyenet.nospam.net>
Subject: Re: how to append lines to the end of file
Message-Id: <TEAb5.910$RX5.1740@newsfeed.slurp.net>
"Jim Kauzlarich" <o1technospam@skyenet.nospam.net> wrote in message
news:UtAb5.905$RX5.2759@newsfeed.slurp.net...
>
> <tvn007@my-deja.com> wrote in message news:8kmi23$ueo$1@nnrp1.deja.com...
> > Hi,
> >
> > I am trying to write a small script to count number of
> > lines in the file. If number of lines in a file is less than
> > 500 than you have to add whatever number of lines to the
> > end of the file so that
> > the total of lines in that file is 500 lines.
> >
> > The line you need to add is: XXX
>
>
> pg 109 "Learning Perl"
> or look in "Perl and CGI for the world wide web", I know it's there
also perldoc -f open
------------------------------
Date: Fri, 14 Jul 2000 08:08:46 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: how to convert "1.2.3.10" to "01020310"?
Message-Id: <slrn8mtibt.9rf.bernard.el-hagin@gdndev25.lido-tech>
On Fri, 14 Jul 2000 02:09:20 GMT, ethan <woowk@my-deja.com> wrote:
>Hi,
>Hope there someone who can help me with this. I am new to PERL and am
>facing the problem of convert a string of "2.1.3.14" format
>to "02010314" format.
>Do I have to use regression expression?
This brings up an interesting question. Can this be done in a single
substitution?
I could only get it down to two:
_________________
$_ = "10.24.3.56";
s/(\b|\.)(\d)(\.|\b)/0$2/g;
s/\.//g;
print;
_________________
The second substitution would be unnecessary if the input string didn't
have neighbouring two digit numbers. Can anyone come up with a single
substitution (not using s///e or using it in such a way as to not rehash
solutions already given)?
Bernard
--
perl -e'@x=(3,2,4,1,3,2,1,3,1,3,2,3,3,2,3,0,0,1,2,1,1,1,4,1,2,1,1,2,2,1,
2,1,2,1,2,1,2,1,1,1,2,1,0,0,3,2,3,2,3,2,1,1,1,1,1,2,4,2,3,2,1,2,1,0,0,1,
2,1,1,1,4,1,2,1,1,1,2,2,1,1,4,1,1,1,2,1,1,1,2,1,0,0,3,2,4,1,1,2,1,1,1,3,
1,1,1,4,1,1,1,2,1,1,3,0,0);sub x{print q x$xx$_;print q x x x shift@x};#
while(defined($_=shift @x)){s o0o\no;$_!=0?x:print}' #Symmetry yrtemmyS#
------------------------------
Date: Fri, 14 Jul 2000 01:10:22 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: how to convert "1.2.3.10" to "01020310"?
Message-Id: <396ECAEE.B3D74520@stomp.stomp.tokyo>
ethan wrote:
> Hope there someone who can help me with this. I am new to PERL...
This seems a required preamble to virtually every
article orginating from a fake email address,
especially deja, bigfoot and hotmail. Anymore,
ninety-nine percent of all interrogatory articles
indicate "newbie" in some form or fashion.
This phenomenon's event odds seems to exceed a person's
chances of winning a state lottery or being struck dead
by a bolt of lightning.
Odd don't you think?
Even odder is this capitalization of PERL in so many
articles from newbies, very suddenly and within a short
time frame. You would have better odds of proving
O.J. Simpson guilty than the odds of this happening,
as purely mathematical coincidence.
Think I will refrain from commenting on numerous other
unique idioms appearing in virtually all newbie articles.
Has to be Divine or Devilish intervention, of which, I know
better than to question or comment upon, other than to mimic
dearly departed Carl Sagan in saying the odds are in the,
"...billions and billions."
Frustrating to be an English teacher, very frustrating.
We often notice between the lines what shouldn't be.
> facing the problem of convert a string of "2.1.3.14" format
> to "02010314" format.
A very simple alternative to methods posted so far:
$string =~ s/\./0 /g;
$string =~ s/(.*)0 (\d+)/$1$2/;
$string =~ s/ //g;
Some test results are below with my test script.
This simple method seems to work well for those
four tests performed. Don't mix in =~tr/// with
this method. A bug will appear.
Godzilla!
PRINTED RESULTS:
________________
Test One Input: 2.1.3.14
Test One Output: 2010314
Test Two Input: 1.2.3.0
Test Two Output: 102030
Test Three Input: 123.456.789.10
Test Three Output: 1230456078910
Test Four Input: 10.987.654.3210
Test Four Output: 10098706543210
TEST SCRIPT:
____________
#!/usr/local/bin/perl
print "Content-Type: text/plain\n\n";
$string = "2.1.3.14";
print "Test One Input: $string\n";
&Do_It;
print "Test One Output: $string\n\n";
$string = "1.2.3.0";
print "Test Two Input: $string\n";
&Do_It;
print "Test Two Output: $string\n\n";
$string = "123.456.789.10";
print "Test Three Input: $string\n";
&Do_It;
print "Test Three Output: $string\n\n";
$string = "10.987.654.3210";
print "Test Four Input: $string\n";
&Do_It;
print "Test Four Output: $string\n\n";
sub Do_It
{
$string =~ s/\./0 /g;
$string =~ s/(.*)0 (\d+)/$1$2/;
$string =~ s/ //g;
}
exit;
------------------------------
Date: Fri, 14 Jul 2000 11:17:47 +0200
From: "Brendon Caligari" <bcaligari@shipreg.com>
Subject: Re: how to convert "1.2.3.10" to "01020310"?
Message-Id: <8kml8h$4d$1@news.news-service.com>
"Bernard El-Hagin" <bernard.el-hagin@lido-tech.net> wrote in message
news:slrn8mtibt.9rf.bernard.el-hagin@gdndev25.lido-tech...
>
> s/(\b|\.)(\d)(\.|\b)/0$2/g;
or s/(\b\d\b)/0$1/g;
\. will match as a word boundary
> s/\.//g;
------------------------------
Date: Fri, 14 Jul 2000 09:26:43 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: how to convert "1.2.3.10" to "01020310"?
Message-Id: <slrn8mtmu0.9rf.bernard.el-hagin@gdndev25.lido-tech>
Brendon Caligari <bcaligari@shipreg.com> wrote:
>
>"Bernard El-Hagin" <bernard.el-hagin@lido-tech.net> wrote in message
>news:slrn8mtibt.9rf.bernard.el-hagin@gdndev25.lido-tech...
>>
>> s/(\b|\.)(\d)(\.|\b)/0$2/g;
>
>or s/(\b\d\b)/0$1/g;
>\. will match as a word boundary
What a silly git I am. :-)
Bernard
--
perl -e'@x=(3,2,4,1,3,2,1,3,1,3,2,3,3,2,3,0,0,1,2,1,1,1,4,1,2,1,1,2,2,1,
2,1,2,1,2,1,2,1,1,1,2,1,0,0,3,2,3,2,3,2,1,1,1,1,1,2,4,2,3,2,1,2,1,0,0,1,
2,1,1,1,4,1,2,1,1,1,2,2,1,1,4,1,1,1,2,1,1,1,2,1,0,0,3,2,4,1,1,2,1,1,1,3,
1,1,1,4,1,1,1,2,1,1,3,0,0);sub x{print q x$xx$_;print q x x x shift@x};#
while(defined($_=shift @x)){s o0o\no;$_!=0?x:print}' #Symmetry yrtemmyS#
------------------------------
Date: Fri, 14 Jul 2000 07:58:57 GMT
From: "Ecco" <ecco64@chello.nl>
Subject: Re: Newbies cry for help
Message-Id: <5Lzb5.376669$k22.1631945@flipper>
K, I got it! Thanx every1!
--
-----------------------------------------------------
Click here for Free Video!!
http://www.gohip.com/free_video/
"Ecco" <ecco64@chello.nl> wrote in message
news:T7ab5.363371$k22.1585697@flipper...
> Greetings guru's! I just recently started programming with Perl, and I'm
> looking for a script that pop-ups a new browser-window, but I have NO clue
> how to do that... Thanx 4 ur time,
> ~ecco~
>
>
------------------------------
Date: Fri, 14 Jul 2000 00:20:12 -0700
From: Jim Adame <jadame@velocityhsi.com>
Subject: Re: perl array references woes...
Message-Id: <396EBF2C.E54260F3@velocityhsi.com>
Colin Reinhardt wrote:
> I just can't figure out what is wrong here...
>
> This is an excerpt...
>
> ### load up array
> while ( @arrayref = $sth->fetchrow_arrayref ) {
> $count++;
> push @stash, [ @$arrayref ]; # copy the contents, not a ref
> }
>
I'm not exactly sure what you're trying to do with this, but from a quick
glance at 12:15am,
you can probably just do something like
while ( $arrayref = $sth->fetchrow_arrayref ) {
$accounts = $accounts . $arrayref->[0] . ',';
}
that will create a comma delimited string with the first element from each
fetched array(ref). If you don't want the comma on the end of the string, just
delete it with:
$accounts =~ s/,$//;
------------------------------
Date: Fri, 14 Jul 2000 08:15:39 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: perl array references woes...
Message-Id: <MPG.13d96978a21ed5139896ad@news>
Colin Reinhardt wrote ..
>I just can't figure out what is wrong here...
>
>This is an excerpt...
>
> ### load up array
> while ( @arrayref = $sth->fetchrow_arrayref ) {
the clue is in the name .. fetchrow_arrayref .. it fetches a row from
the rowset and returns an array REFERENCE to it
irrespective of what you call it .. @arrayref is an ARRAY .. assigning
an array reference to it simply sets the first element of that array to
the scalar array reference
you either want
@array = $sth->fetchrow_array
or
$arrayref = $sth->fetchrow_arrayref
> $count++;
> push @stash, [ @$arrayref ]; # copy the contents, not a ref
if you had used strict then Perl would have told you that $arrayref is
undefined here .. stick this at the top of your program for some more
helpful hints
use strict;
>__need__help__. Thanks!
perldoc DBI
read the examples at the beginning - they'll show you what should be on
the LHS
perldoc perldata
talks about different types of variables in Perl .. and ..
perldoc perlref
talks specifically about references
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: 14 Jul 2000 10:29:25 +0200
From: Marc Schaefer <marc.schaefer@warwick.ac.uk>
Subject: Re: Reading fixed-length fields from a record
Message-Id: <m3u2dt5d3u.fsf@mapgw.csv.warwick.ac.uk>
Hi Alejandro,
"Alejandro Kurczyn" <akurczyn@usa.net> writes:
> Can anyone recommend a good way to split fixed-length records ?
perldoc -f unpack, especially the 'A' template:
print join ':', unpack( 'A7A8A9','1234 Someone Somewhere')
prints
1234:Someone:Somewhere
Best,
Marc
------------------------------
Date: Fri, 14 Jul 2000 08:04:02 GMT
From: "langtind" <arild@langtind.no>
Subject: Running a CGI-script through CGI?
Message-Id: <SPzb5.2817$Dxe.185818112@news.telia.no>
Hi!
I was wondering if it's possible to start a CGI-script through a CGI?
something like:
#!/usr/bin/perl
print "I'm running count now\n";
insert.cgi afile #this is the script I want to start
In my HTML-page I can use:
<!--#exec cmd="/usr/bin/perl cgi-bin/insert.cgi nettet" -->
Trond Aage
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 3663
**************************************