[10827] in Perl-Users-Digest
Perl-Users Digest, Issue: 4428 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 15 12:07:16 1998
Date: Tue, 15 Dec 98 09:01:41 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 15 Dec 1998 Volume: 8 Number: 4428
Today's topics:
Re: Perl and Zip ernie_oporto@mentorg.com
perl cgi script call from an applet <echandon@yahoo.com>
Perl newbie question.. bryanb@walls-media.com
Perl/Java cgi script with pws <pdchapin@unix.amherst.edu>
Re: Perl/Java cgi script with pws <rliu2@ford.com>
Probably a Stupid Question. <trilogy@q-net.net.au>
Re: Probably a Stupid Question. (Tad McClellan)
Re: Q:Decimal precision ? (Tad McClellan)
Query - searching for one word OR another (e-mail respo (Thomas Ash)
Re: Query - searching for one word OR another (e-mail r <Allan@due.net>
Re: Query - searching for one word OR another (e-mail r (Tad McClellan)
Question about NT (newbie) ixb9142@rit.edu
Re: Scoping of sub declarations <tchrist@mox.perl.com>
Sending SMTP MAIL with Perl <yoann.lecorvic@inrfasoft-civil.com>
Re: Sending SMTP MAIL with Perl (Clay Irving)
Silly question: list or array? (Bart Lateur)
Re: Silly question: list or array? (Matthew Bafford)
Re: Sorting a Two-dimensional Numerical Array (Andrew M. Langmead)
STDIN and NT ksimpson@my-dejanews.com
the FAQ is not the Camel Book (was Re: ($e_mail !~ /\w+ <Russell_Schulz@locutus.ofB.ORG>
the perl function split <marcov@ctrl-v.nl>
Re: the perl function split <gwebb@reedtech.com>
Re: the perl function split (Larry Rosler)
Re: Using "fork" to avoid crashing script <gwebb@reedtech.com>
Re: Why Is Perl not a Language? <tchrist@mox.perl.com>
Win32::API and C struct <dcraig@ismd.ups.com>
Re: Writing Perl with Notepad <conmara@tcon.net>
Re: Writing Perl with Notepad ptimmins@netserv.unmc.edu
Re: Y2K and Programmer Denial <keithmur@mindspring.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 15 Dec 1998 15:40:50 GMT
From: ernie_oporto@mentorg.com
Subject: Re: Perl and Zip
Message-Id: <755vu3$bb5$1@nnrp1.dejanews.com>
Any examples of how to do this? I have the "zip" executable, but I'd like to
do this 100% Perl.
In article <74u53t$pd6@panix.com>,
clay@panix.com (Clay Irving) wrote:
> In <36717d61.609910596@news1.alterdial.uu.net> beimer@uu.net (Barry Eimer)
writes:
>
> >Are there any Perl modules that provide an interface to Zip and Unzip
> Compress::Zlib
--
http://www.geocities.com/SiliconValley/Park/9276
_____/ ____ / /Ernie "Shokk" Oporto-SysAdmin
_____ ____ / \ __ / __ / Mentor Graphics Corporation
\______/ __ __ \______/ __ \___ __ \___ Ernie_Oporto@MentorG.com
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 15 Dec 1998 16:24:34 +0100
From: "Erwann Chandon" <echandon@yahoo.com>
Subject: perl cgi script call from an applet
Message-Id: <755v28$pae$1@front5.grolier.fr>
I want to invoke my perl cgi script (called writer.pl) from an applet but
the URL http://127.0.0.1/writer.pl?blabla, where blabla is the string to be
send to the script as an argument, doesn't work. How may I do ?
Erwann
------------------------------
Date: Tue, 15 Dec 1998 16:18:49 GMT
From: bryanb@walls-media.com
Subject: Perl newbie question..
Message-Id: <756257$dbn$1@nnrp1.dejanews.com>
Hello All,
Is there a way to delete an entire line in a text file if perl finds a
specific string?
Say I have a phrase "This is really cool" and anytime I find the phrase
"really cool" I want that line deleted from the file.
Thanks for the help.
Bryan
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 15 Dec 1998 09:28:39 -0500
From: "Paul Chapin" <pdchapin@unix.amherst.edu>
Subject: Perl/Java cgi script with pws
Message-Id: <3676721c.0@amhnt2.amherst.edu>
What I'm trying to do is write a cgi script in java to run on a Personal Web
Server running on a Win95 system. The server is not, during development,
connecting to anything so everything is local using 127.0.0.1
The fundamental problem with Java as cgi script is that it doesn't
understand environmental variables. The solution to this appears to be to
use a perl script that then invokes the java script, records the results,
and then prints out the resulting html page. It all looks something like
this,
@results=`...path...\\java testjava`;
foreach (@results) {
print $_;
}
At this point I'm not worrying about environmental variables.
testjava.class just spits out a basic html page including the Content-type:
header.
Now if I run the perl script from a DOS prompt, I get the results I want
displayed to the window. However, if I try to invoke the script from a
form, I get a DOS window - titled JAVA - to display briefly, then nothing
happens until the client times out. I can verify that the perl script is
being started, and getting to the Java program, but no further. Ctl-Alt-Del
indicates that a perl process is running, but no sign of Java. It looks
like Perl is not recognizing that the Java program is done.
Just to make things interesting, I took the java class, the perl script, and
the html page with the form and moved it to my Apache server on a UNIX box.
After hacking a few paths and the like so that they're UNIX and not DOS, I
find that I can invoke the perl script from the form and have it return the
Java output without problem.
My problem is that I'm not sure where the problem is, which is why this is
cross-posted all over the place. Is perl messing up and not recognizing the
end of the Java program? Is there a problem with Java causing it to not
exit properly? Is there a problem with pws so that it just can't deal with
this program within a script approach?
If anybody's interested in seeing what's suppose to work they can go to
www.amherst.edu/~pdchapin/calendar/shortform.html and hit the "Input and
time button". The page that will be returned will only contain "/n" but
that's because testjava doesn't do anything. However, a valid page is being
returned which is more than happens with pws.
(This is my second try to post this. My apologies if it ends up appearing
twice.)
-----
Paul Chapin
UNIX Manager
Amherst College
413 542-2144
http://www.amherst.edu/~pdchapin
------------------------------
Date: Tue, 15 Dec 1998 10:32:12 -0500
From: Roger Liu <rliu2@ford.com>
To: Paul Chapin <pdchapin@unix.amherst.edu>
Subject: Re: Perl/Java cgi script with pws
Message-Id: <367680F7.1C0EA126@ford.com>
Works for me.
I use PSW on Windows 95, JDK 1.2 and Perl 5.00502.
Just guess, Did you setup PWS to run Perl scripts as CGI properly?
Roger
------------------------------
Date: Tue, 15 Dec 1998 20:54:40 +0800
From: Design-A-Web Australia <trilogy@q-net.net.au>
Subject: Probably a Stupid Question.
Message-Id: <36765C0F.BEC2CCDC@q-net.net.au>
Hi all.
I have just started into the wonderful world of adding and using Perl to
enhance the websites that I develop.
Well I have been tasked to create a very simple 'shopping cart' for
about 12 items where the visitor selects an item and is then displayed
at the order page.
Question 1. Can anyone direct me to a set of scripts or Modules (I think
that is what they are called) to allow me to set up the shopping cart.
Question 2. I use a dial-up connection to my ISP and they allow the
running of scripts and the placing of them into a cgi-bin on the
account Can I just upload the scripts to their server and they would
work?. They do support Perl.
Question 3. I run windows 95 and I am pretty sure I installed the
correct version of Perl onto my System. I did this so I could test the
scripts I use in the webpages with the 'Shopping Cart" stuff..
If I put the same scripts I use in the C:/Perl/bin on my system that I
would upload to my ISP will they work the same eventhough I run Win 95
and my ISP is a Unix based system..
I am pretty sure I can incorperate the scripts quite easily in the pages
but it is knowing what scripts and how to configure them that is the
hard bit..
I am really sorry to ask these questions but I am really new to all this
CGI stuff and I really need some help to set up a shopping cart on a
site that I am creating..
Any Input would be greatly appreciated.
--
Peter DAVIS
Design-A-Web Australia
http://www.designaweb.com.au
------------------------------
Date: Tue, 15 Dec 1998 09:03:19 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Probably a Stupid Question.
Message-Id: <nnt557.gjb.ln@magna.metronet.com>
[ Please attempt to put the subject of your post in the Subject:
header.
Subject: shopping carts
would have been much better.
(some folks will simply skip reading your posts if they cannot
discern the subject from the Subject:
)
]
Design-A-Web Australia (trilogy@q-net.net.au) wrote:
: Well I have been tasked to create a very simple 'shopping cart' for
: about 12 items where the visitor selects an item and is then displayed
: at the order page.
: Question 1. Can anyone direct me to a set of scripts or Modules (I think
: that is what they are called) to allow me to set up the shopping cart.
The WWW has some sites that are called "search engines".
I believe searching for "shopping cart" in one of those would
provide you with information overload ;-)
See also:
http://www.cgi-resources.com
: Question 2. I use a dial-up connection to my ISP and they allow the
: running of scripts and the placing of them into a cgi-bin on the
: account Can I just upload the scripts to their server and they would
: work?. They do support Perl.
That depends on the particulars of your server, which we
are not privy to.
Ask your server admin.
At the very least, ask server questions in a newsgroup that has
some connection to servers. This newsgroup is not one of those.
comp.infosystems.www.servers.mac
comp.infosystems.www.servers.misc
comp.infosystems.www.servers.ms-windows
comp.infosystems.www.servers.unix
: Question 3. I run windows 95 and I am pretty sure I installed the
: correct version of Perl onto my System. I did this so I could test the
: scripts I use in the webpages with the 'Shopping Cart" stuff..
: If I put the same scripts I use in the C:/Perl/bin on my system that I
: would upload to my ISP will they work the same eventhough I run Win 95
: and my ISP is a Unix based system..
Probably, but maybe not. "Try it and see" is about the only way
to tell without reviewing all of the code. (don't post all of
the code!)
I don't see any mention of an HTTP server there.
You will need one of those installed to fully test CGI programs.
: I am really sorry to ask these questions but I am really new to all this
: CGI stuff
This is the Perl newsgroup. It is for discussing the Perl
programming language.
It has no connection to the particular domain of CGI applications
of Perl.
For those, you will get better results if you ask CGI specific
question in a newsgroup that has some connection to CGI, such as:
comp.infosystems.www.authoring.cgi
See also these URLs referenced in the fine Perl man pages that
you get when you install perl:
------------------------------------
The useful FAQs and related documents are:
CGI FAQ
http://www.webthing.com/page.cgi/cgifaq
Web FAQ
http://www.boutell.com/faq/
WWW Security FAQ
http://www.w3.org/Security/Faq/
HTTP Spec
http://www.w3.org/pub/WWW/Protocols/HTTP/
HTML Spec
http://www.w3.org/TR/REC-html40/
http://www.w3.org/pub/WWW/MarkUp/
CGI Spec
http://www.w3.org/CGI/
CGI Security FAQ
http://www.go2net.com/people/paulp/cgi-security/safe-cgi.txt
------------------------------------
http://www.perl.com/perl/faq/idiots-guide.html
http://www.perl.com/perl/faq/perl-cgi-faq.html
ftp://rtfm.mit.edu/pub/usenet/news.answers/www/cgi-faq
http://hoohoo.ncsa.uiuc.edu/cgi/interface.html
http://www-genome.wi.mit.edu/WWW/faqs/www-security-faq.html
------------------------------------
Good luck!
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 15 Dec 1998 08:14:23 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Q:Decimal precision ?
Message-Id: <vrq557.46b.ln@magna.metronet.com>
Calle Dybedahl (qdtcall@esb.ericsson.se) wrote:
: Margarit Nickolov <man@digsys.bg> writes:
: > I get the next result:
: > a=-6.93889390390723e-18
: >
: > I think the precision is not too high, but result is too bugous.
: You do realise that your result, written in a more "normal" notation
: with the two significant digits you want, is -0.0000000000000000069?
That seems pretty darn close to zero to me...
Maybe Margarit should see the Perl FAQ, part 4:
"Why am I getting long decimals (eg, 19.9499999999999)
instead of the numbers I should be getting (eg, 19.95)?"
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 15 Dec 1998 12:37:15 +0000
From: thomasash@hotmail.com (Thomas Ash)
Subject: Query - searching for one word OR another (e-mail response)
Message-Id: <thomasash-1512981237150001@max50.public.ox.ac.uk>
How can I do a grep search (or any search, I don't care) for one word OR
another. At the moment I search for one word then another, and get the
same database entry twice. How can I get rid of this problem? Please send
the answer to thomasash@hotmail.com.
Thanks in advance.
------------------------------
Date: Tue, 15 Dec 1998 08:24:38 -0500
From: "Allan M. Due" <Allan@due.net>
Subject: Re: Query - searching for one word OR another (e-mail response)
Message-Id: <755nks$nfg$1@camel18.mindspring.com>
Thomas Ash wrote in message ...
>How can I do a grep search (or any search, I don't care) for one word OR
>another. At the moment I search for one word then another, and get the
>same database entry twice. How can I get rid of this problem? Please send
>the answer to thomasash@hotmail.com.
Sorry, the cultural standard for this newsgroup is post here - read here.
If you do come back you might want to consider the alternation metacharacter
| as in
push @hits,$_ if /one|two/;
or if you demand grep
@hits2 = grep(/one|two/,@stuff);
you get the idea.
perldoc perlre
HTH
AmD
------------------------------
Date: Tue, 15 Dec 1998 08:49:18 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Query - searching for one word OR another (e-mail response)
Message-Id: <ets557.gjb.ln@magna.metronet.com>
Thomas Ash (thomasash@hotmail.com) wrote:
: How can I do a grep search (or any search, I don't care) for one word OR
: another. At the moment I search for one word then another, and get the
: same database entry twice. How can I get rid of this problem?
@hits = grep /one word/ || /another/, @db;
: Please send
: the answer to thomasash@hotmail.com.
Ask it here, get the answer here.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 15 Dec 1998 16:16:56 GMT
From: ixb9142@rit.edu
Subject: Question about NT (newbie)
Message-Id: <36768910.331065136@news.kodak.com>
Hi,
I just started to teach myself PERL yesterday. I am using a book that
was designed for Unix but I am on NT. For the most part things have
been the same with a few minor differences. One thing I am wondering
about though. It seems that If you compare two values and the result
is false, then instead of returning a zero, NT will return a null
character. Is this true? Will this really affect anything I am
trying to do in the future. Does a null character mean false in NT?
Any info would be certainly helpful. This is also my first time
posting to this group. Could people please e-mail because I'm not
sure how often I'll be checking here, although I could become a
regular reader. Thanks
Ian Blake
ixb9142@rit.edu
------------------------------
Date: 15 Dec 1998 13:29:38 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Scoping of sub declarations
Message-Id: <755o82$eup$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
"Clinton Gormley" <cgormley@netcomuk.co.uk> writes:
:Now I'm showing my Pascal roots...
:Is there lexical scoping of sub declarations in Perl ie, is :
:
:sub foo {
: sub bar {}
: }
:
:the equivalent of
:sub foo {}
:sub bar {}
:
:or not?
No, it isn't. Nested named subroutines are not
directly supported. You would use
sub foo {
local *bar = sub {
# rest of bar() goes here
};
# rest of foo() goes here
}
instead.
--tom
--
Personally, I don't care whether someone is cool enough to quote Doug
Gwyn--I only care whether Doug Gwyn is cool enough to quote. --Larry Wall
------------------------------
Date: Tue, 15 Dec 1998 13:08:11 +0000
From: Yoann Le Corvic <yoann.lecorvic@inrfasoft-civil.com>
Subject: Sending SMTP MAIL with Perl
Message-Id: <36765F3A.7C710E5A@inrfasoft-civil.com>
I have a scrip to send SMTP Mail with perl, but, I would like to modify
it so that I can send an attachement with it. This attachment would be
an html file.
Is there a way to attach a file to an E-Mail sent with perl.
Thanks
Yoann
Internet Administrator
------------------------------
Date: 15 Dec 1998 10:42:56 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Sending SMTP MAIL with Perl
Message-Id: <756020$ktk@panix.com>
In <36765F3A.7C710E5A@inrfasoft-civil.com> Yoann Le Corvic <yoann.lecorvic@inrfasoft-civil.com> writes:
>I have a scrip to send SMTP Mail with perl, but, I would like to modify
>it so that I can send an attachement with it. This attachment would be
>an html file.
>Is there a way to attach a file to an E-Mail sent with perl.
WHAAAT?! Is there a contest to see how many people are going to ask the
same damn question day after day after day after day?
This question has been asked and answered about ten times in the last
week, including sample code. Go to Dejanews and look up the answer...
--
Clay Irving
clay@panix.com
------------------------------
Date: Tue, 15 Dec 1998 13:32:20 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Silly question: list or array?
Message-Id: <367662c7.3771425@news.skynet.be>
I've got a silly question for you. Even though I can guess the answer, I
can't resist:
Why do we talk about "list context", NOT "array context", while
the name of the function to test it is called "wantarray"?
You'll probably say something like "historically developed" or something
boring like that.
I find this particularily entertaining, because authors of books about
Perl have been flamed for not knowing the difference between a list and
an array.
Bart.
------------------------------
Date: Tue, 15 Dec 1998 10:53:16 -0500
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: Silly question: list or array?
Message-Id: <MPG.10e04ffbbd18ceab989762@news.scescape.net>
In article <367662c7.3771425@news.skynet.be>, bart.lateur@skynet.be
says...
=> I've got a silly question for you. Even though I can guess the answer, I
=> can't resist:
=>
=> Why do we talk about "list context", NOT "array context", while
=> the name of the function to test it is called "wantarray"?
=>
=> You'll probably say something like "historically developed" or something
=> boring like that.
Well, the Camel says:
...This function should really have been named "wantlist", but we named
it back when list contexts were still called array contexts...
So, I guess the boring answer is what you get. :)
[snip]
=> Bart.
--Matthew
------------------------------
Date: Tue, 15 Dec 1998 15:45:55 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Sorting a Two-dimensional Numerical Array
Message-Id: <F40JsJ.H9s@world.std.com>
Tom Briles <tbriles@austin.ibm.com> writes:
>What's the best (or any!) way to sort the following array on the second
>dimension (in this example 1, 2.5, and 2.5):
[stuff deleted]
>I'd also like to sort on the first dimension after sorting on the second.
Since the first dimension contains references to array, you can pass
them to a sort comparison routine and dereference them to read the
second dimension. To sort on two criteria, perform a sort on the
secondary criteria when the first criteria is equal. (The comparison
operators "<=>" and "cmp" work well with the logical or operator
here. The "<=>" operator returns a logical true value on inequality
and a logical false value on equality. The logical or operator will
then evaluate the left hand side and only when equal will evaluate the
left.)
@util = ( [50, 1],
[45, 2.5],
[60, 2.5] );
@util = sort { $a->[1] <=> $b->[1] || $a->[0] <=> $b->[0] } @util;
for $row (@util) {
print "$row->[0] $row->[1]\n";
}
--
Andrew Langmead
------------------------------
Date: Tue, 15 Dec 1998 16:40:59 GMT
From: ksimpson@my-dejanews.com
Subject: STDIN and NT
Message-Id: <7563er$ek1$1@nnrp1.dejanews.com>
I'm new to NT, but if I have the following in a Perl script,
while (<STDIN>) {
print $_;
}
why would echo a block of test | script.pl
yield no output? I also tried putting the text in a file
and used script.pl < file.dat.
Thanks
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 14 Dec 1998 23:01:57 -0500
From: Russell Schulz <Russell_Schulz@locutus.ofB.ORG>
Subject: the FAQ is not the Camel Book (was Re: ($e_mail !~ /\w+[-\w]*\@\w+[-\w]*\.\w+/))
Message-Id: <19981214.230157.2Q5.rnr.w164w_-_@locutus.ofB.ORG>
[ I wonder how long the other thread will go on, having nothing to
do with email addresses or the regex in question... sigh. ]
emclean@slip.net (Emmett McLean) writes:
>>> In my case I researched the question for over a half hour with
>>> Wall's text and didn't come up with an answer.
>>
>> Yes, I am intimately familiar with that text, and I can assure you
>> that the answer is not there. :)
>
> Hum, first you complain I didn't read the FAQ then you agree that the
> answer is not there.
no. "Wall's text" is not the FAQ. Larry Wall didn't write the FAQ
in question.
>>> A half hour is about
>>> as much as most people spend researching a question which has
>>> a very simple answer.
>>
>> Precisely. But five minutes with Dejanews would have found your
>> answer in six minutes. So why did you waste 24 other minutes?
>> Seriously.
>
> My read on it is that, to you, the *seriously* part has more
> to do with flaming and much less to do with talking about Perl.
well, I'd guess it has to do with `you did this wrong; how can we
prevent this in the future?'.
it is also education: if you don't HAVE a good answer, then maybe you
will learn that next time you search for something, you don't spend all
your time in one place.
> I supposed the Perl FAQ says that you've been appointed you the
> Perl king of c.l.p.m.
we use the gender-neutral `Perl monarch'.
> I newsgroup is enhanced when it gets well-meaning but underinformed posts.
what? did you mean
> I think a newsgroup is enhanced when it gets well-meaning but
> underinformed posts.
if so, then I generally disagree.
> You are certainly kidding yourself if you think you are the *only*
> person having correct information about Perl.
where did you read THAT?
perhaps you misread; he was saying he might be the only person who
POSTS the correct information on advanced topics for free.
lots of people will charge you for it.
--
Russell_Schulz@locutus.ofB.ORG Shad 86c
------------------------------
Date: Tue, 15 Dec 1998 15:35:53 +0100
From: Marco Vlemmings <marcov@ctrl-v.nl>
Subject: the perl function split
Message-Id: <367673C8.F41F6F27@ctrl-v.nl>
Hi,
I have a problem with the function 'split'.
I want to split a ascii file.
Here is the piece of code.
@rows = split (/\|\n/,$chunks[0]);
In the array rows will be split by the two caracters pipe and carrage
return, but it does not split at all.How can i split on a carrage
return?
Can anybody help me.
With kind regards
Marco Vlemmings
email: marcov@ctrl-v.nl
------------------------------
Date: Tue, 15 Dec 1998 10:39:14 -0500
From: Garth Webb <gwebb@reedtech.com>
Subject: Re: the perl function split
Message-Id: <367682A2.5D85F266@reedtech.com>
Currently you are splitting on a pipe character *followed* by a carriage
return which is not the same as a pipe character *or* carriage return.
To remedy this change the split regex from:
/\|\n/
to:
/\||\n/
The following example:
$test = "red|orange\nyellow|green\nblue|indigo|violet";
@colors = split(/\||\n/, $test);
foreach (@colors) {print $_,"\n";}
prints:
red
orange
yellow
green
blue
indigo
violet
You could also change:
/\||\n/
to use a character class instead of alternation:
/[\|\n]/
with exactly the same results.
I hope I've helped!
Garth
Marco Vlemmings wrote:
> Hi,
>
> I have a problem with the function 'split'.
> I want to split a ascii file.
> Here is the piece of code.
> @rows = split (/\|\n/,$chunks[0]);
> In the array rows will be split by the two caracters pipe and carrage
> return, but it does not split at all.How can i split on a carrage
> return?
>
> Can anybody help me.
>
> With kind regards
>
> Marco Vlemmings
> email: marcov@ctrl-v.nl
--
--------------------
Garth Webb
Software Developer
Reed Technology and Information Services
gwebbQ@Qreedtech.com
(To reply to me, please remove the 'Q's from my email address. Thanks.)
------------------------------
Date: Tue, 15 Dec 1998 08:02:25 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: the perl function split
Message-Id: <MPG.10e027e871920fbd98995b@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <367673C8.F41F6F27@ctrl-v.nl> on Tue, 15 Dec 1998 15:35:53
+0100, Marco Vlemmings <marcov@ctrl-v.nl> says...
...
> @rows = split (/\|\n/,$chunks[0]);
> In the array rows will be split by the two caracters pipe and carrage
> return, but it does not split at all.How can i split on a carrage
> return?
Your snippet would split on a two-character sequence -- 'pipe' (vertical
bar) followed by 'carrage return' (new-line). One could fix that by
putting an unescaped vertical bar between then to indicate alternation:
@rows = split (/\||\n/, $chunks[0]);
But the more efficient approach is to put both of them into a character
class:
@rows = split (/[|\n]/, $chunks[0]);
No need to escape the '|' within the character class (though it would do
no harm except to sensitive eyes).
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 15 Dec 1998 10:23:39 -0500
From: Garth Webb <gwebb@reedtech.com>
Subject: Re: Using "fork" to avoid crashing script
Message-Id: <36767EFA.2FEB7230@reedtech.com>
First off, this bulk email script will be used to send email those
recipients that have actively requested it, right?
I would recommend against forking 64 processes (or anywhere near that
many) for a bulk email program. Email me off-line and I'll give you my
reasons why.
When you say its a 'sendmail' routine, do you mean to say you are using
sendmail to as the mail program? I would figure out the recipient limit
for sendmail and use perl to feed that many addresses to sendmail, one
sendmail process at a time.
If I've missunderstood your question please let me know!
Garth
JT wrote:
> I have a mass-mail script which I've successfully modified to
> accomodate my client, the problem is my server only allows 64
> processes to be forked simultaneously. We need to mail a list of 2500
> addresses at a time. I'm running this on BSDI 3.1 running Apache and
> Perl v.5.004_04
>
> Since this is a sendmail routine, the script forks several processes
> and has no inherent error handling. My server affords me 64
> simultaneous processes, but the script doesn't acknowledge this and as
> a result causes a: kvm_open: kvm_getprocs: Cannot allocate memory
> error. I realize that I need to introduce a sleep if the processes are
> tied up, but I don't know how to implement this. I'm hoping someone
> else can show me an example of how to implement a "fork" function to
> handle the child processes and sleep if ($| =~ /No more process/)
>
> I am jumping way ahead in my "programming Perl" just to get this much,
> but I know the script very well and would like to try and implement
> this as a remedy.
>
> Apologies if this a "newbie" question, but I am still rather green at
> this point.
> TIA
> -JT
>
> Remove the "not" and delete the "dot" to reply
> jett1not@homedot.com
-- --------------------
Garth Webb
Software Developer
Reed Technology and Information Services
gwebb@reedtech.com
------------------------------
Date: 13 Dec 1998 16:15:39 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Why Is Perl not a Language?
Message-Id: <750p7b$m57$4@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, irc_addict@hotmail.com (Thomas Brian Holdren) writes:
:Dear Guru's,
:My question is:
:Why is perl not a "programming language"?
:
:For example, why is C or BASIC a "programming language", and perl is just a
:"scripting language".
Have you stopped beating your wife? Since your premises are entirely
wrong, so any conclusive response will be meaningless.
There is no such thing as a `scripting language', at least, not in the
sense that this is something which differs in any meaningful way from a
`programming language'. Haven't you heard about C++ scripts that people
write for CGI work?
Once upon a time we had uucp chat scripts. That probably made sense
as a `scripting language', but the term was grabbed by people who
didn't know what they were talking about, and now it is worthless.
Eschew it.
You are either a troll, or you were tricked into marketingspeak.
Remove `script' and `scripting language' from your vocabulary,
and you'll be a lot more honest.
--tom
--
"There is no idea so sacred that it cannot be questioned, analyzed...
and ridiculed." --Cal Keegan
------------------------------
Date: Tue, 15 Dec 1998 11:09:49 -0500
From: "Douglas N. Craig" <dcraig@ismd.ups.com>
Subject: Win32::API and C struct
Message-Id: <7561fe$bj2@innsrv.ismd.ups.com>
I am trying to build to following C structure in Perl so that I may call a
DLL function (usings Aldo's Win32::API):
struct ldCons
char slic[5+1];
long addrId ;
char seqNumber[5 + 1] ;
char strNumber[5 + 1] ;
char name[5 + 1] ;
char room[5 + 1] ;
char _8020[5 + 1] ;
int DMD;
char RLANum[5 + 1];
int CDS;
char acctNum[5 + 1];
int cbOnly;
int dept;
int deptNumMin;
int custRef;
int custRefTyp;
int custRefMin;
int sdnd;
int sdndTyp;
char sdndLang[5 + 1];
} ;
The [5+1] is the size of the char with a NULL byte at the end, hence the
plus one.
Please HELP!!!!!!! This DLL Function has been loaded through Visual Basic
fairly easily. I can't figure out how to pass a reference of it to the DLL
using the API module.
Thanks in Advance!!!!!!!!!!!!!!!!!
------------------------------
Date: Tue, 15 Dec 1998 07:23:44 -0500
From: Ken McNamara <conmara@tcon.net>
Subject: Re: Writing Perl with Notepad
Message-Id: <367654D0.A4941329@tcon.net>
Evan -
You might make the first class assignment a Perl script that fixes the linefeed
problem. This would mean identifying what is really going on, then writing a
script that fixes it under all conditions. (ftp causes some problems, but
Notepad has a couple of different save options that always screw me up if I get
in a hurry and use it for anything more than simple note saving.
Just a thought.
KenMc
Evan Panagiotopoulos wrote:
> I have no problems writing Perl scripts with vi. Yesterday though, I
> tried to write a script with Notepad but after I saved it on Linux and
> tried to execute it gave me an error complaining about linefeeds or
> something like that. Can I use Notepad or different windows editor
> for script writing? I have a class of high school students and using
> vi is like pulling teeth.
>
> Thanks,
>
> ------------------------------------------------------------------------
>
> Evan Panagiotopoulos <evanp@technologist.com>
> Computer Teacher
> Valley Central High School
> Mathematics Department
>
> Evan Panagiotopoulos
> Computer Teacher <evanp@technologist.com>
> Valley Central High School HTML Mail
> Mathematics Department
> Fax: (914) 457-4056
> Home: Home Sweet Home
> Work: Valley Central High School (914) 457-3122
> Additional Information:
> Last Name Panagiotopoulos
> First NameEvan
> Version 2.1
------------------------------
Date: Tue, 15 Dec 1998 15:52:02 GMT
From: ptimmins@netserv.unmc.edu
Subject: Re: Writing Perl with Notepad
Message-Id: <7560j1$bta$1@nnrp1.dejanews.com>
In article <367815c6.2053261@news.skynet.be>,
bart.lateur@skynet.be (Bart Lateur) wrote:
> Thomas Brian Holdren wrote:
>
> >Hate Windows becuase you can't
> >"Esc:w" to save a file?
>
> Now *that* makes sense.
>
> Bart.
I currently have to read and post from DejaNews (blech!), and
I'm constantly having to backspace and delete out "dw", "dd", "j",
"0", etc, that I erroneously type after hitting my escape key ...
thinking it will respond properly ... a brain-stem, muscle wisdom
sort of thing, I guess.
Patrick Timmins
$monger{Omaha}[0]
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 15 Dec 1998 11:41:18 -0600
From: "Keith G. Murphy" <keithmur@mindspring.com>
Subject: Re: Y2K and Programmer Denial
Message-Id: <36769F3E.31AE77E6@mindspring.com>
finsol@ts.co.nz wrote:
>
> Recent debate on this and other programming newsgroups, regarding Y2K issues,
> has prompted me to write on the subject of programmer denial. This article was
> recently published in NZ Computerworld.
>
> Many of you following the debate may be interested in reading further on the
> subject discussed. My first article was on 'booby trap code', a problem that
> affects programming languages such as Perl, MacPerl, C, C++, Java,
> Javascript, CGI, MVS and CICS. The second article describes the widespread
> programmer denial that I encountered. Initially, this denial was provoked by
> my research into the subject and then, later, further debate arose when my
> "booby trap code" article was published.
>
> For those interested, links to these articles can be found at URL:
> http://www.ts.co.nz/~finsol/y2k_articles.htm
>
Most programmers are only too willing to address real, concrete
Y2K-related problems. Look at the entire thread in this forum: "Y2K
work - need suggestions".
It's when you run around like a damn Red Guard in the Cultural
Revolution, seeming to demand some kind of confession of prior
transgressions against ideological purity, that you're getting people's
hackles up. (OK, CGI *is* a programming language! To deny it is to be
a running dog lackey of the nitpicking eggheads! No problems were
caused by inappropriate specifications from our enlightened party
leaders, I mean management! It was all due to the misdeeds of we, the
elitist class of nerds! I beg you to send me to a reeducation camp,
where I will do hard physical labor, I mean boring Cobol modifications,
every day!)
Do you really think you're making a constructive contribution to the
actual effort?
But I guess when the problems hit, and folks are looking for a
scapegoat, you can say it was all due to "programmer denial". Maybe if
you're seen as one of the "good" programmers, they won't lynch *you*!
(But, yes, it is unfortunate that otherwise intelligent folks say lame
things like: "We should just check all of our code then, not just
Y2K-related stuff." That does have a pretty ivory-tower ring to it.)
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 4428
**************************************