[9285] in Perl-Users-Digest
Perl-Users Digest, Issue: 2880 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 16 02:07:25 1998
Date: Mon, 15 Jun 98 23:00:28 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 15 Jun 1998 Volume: 8 Number: 2880
Today's topics:
Re: Apache and Perl <ask@netcetera.dk>
Re: Case of newbie and .db (Martien Verbruggen)
Re: CGI Perl Programming Problem. <zeos@gti.com>
Re: Date fomatting. (Larry Rosler)
Re: Eval questions. (Ronald J Kimball)
Re: Finding size of JPEG images in Perl <rootbeer@teleport.com>
Re: Format Irritation <rootbeer@teleport.com>
getspnam() <0x74_0x6F_0x64_0x64@0x40.0x7A.0x65.0x72.0x6F.0x6B.0x61.0x72.0x6D.0x61.0x2E.0x64.0x79.0x6E.0x2E.0x6D.0x6C.0x2E.0x6F.0x72.0x67>
Re: Have we got a good free Perl manual? birgitt@my-dejanews.com
Re: HELP WITH SOME NEWBIE HACKED CODE??? (Martien Verbruggen)
How can I run Perl in Microsoft Access ? <rsb018@email.sps.mot.com>
IE 5.0, COM and PERL. <ahill@users.arco.com>
Input type="file" <andrew@deltanet.com>
Re: Input type="file" <bowlin@sirius.com>
Re: Keeping the global value of a local variable. (Ronald J Kimball)
Newbie question <freek@writeme.com>
Re: Newbie trying to capture(control) output from pipe <rootbeer@teleport.com>
Re: perl cgi generated html with java app "class not fo <rootbeer@teleport.com>
Perl Contract Programmer Available <71022.3700@CompuServe.COM>
pod syntax error <ask@netcetera.dk>
print <<END (with variables) <zeos@gti.com>
Re: print <<END (with variables) <bowlin@sirius.com>
Replacing multiple 'empty' lines (Dan Lucas)
Re: Replacing multiple 'empty' lines (Craig Berry)
Running commands <azman@bnex.com>
Script to monitor email traffic <adam@universal.net.au>
Re: Simple Q - Splitting Array by Spaces <rootbeer@teleport.com>
Use cgi <p-lanphier@psu.edu>
Re: Use cgi <bowlin@sirius.com>
Windows95, Perl-32 and Personal Web Server (PWS) <psattler@bestweb.net>
Re: Windows95, Perl-32 and Personal Web Server (PWS) <bowlin@sirius.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 16 Jun 1998 06:27:03 +0200
From: Ask Bjoern Hansen <ask@netcetera.dk>
Subject: Re: Apache and Perl
Message-Id: <m3ium2as4o.fsf@balder.netcetera.dk>
"Patrick Lanphier" <p-lanphier@psu.edu> writes:
> What are the settings for the srm file for Apache so the when the file
> extension pl or plx is used it will automatically fire the Perl interpreter?
> Better yet has anybody compiled the modperl for NT for version 1.3b7 of
> Apache?
It should be at:
$CPAN/authors/id/JBAKER/mod_perl-1.11-bin-bindist3-i386-win32-vc5.zip
It's not the latest and greatest (v1.12), but expect it to be there
rsn. It's compiled to work with 1.3.0 and the latest betas, down to
1.3b7.
Hope this helps,
ask
------------------------------
Date: 16 Jun 1998 04:35:20 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Case of newbie and .db
Message-Id: <6m4sm8$64n$1@comdyn.comdyn.com.au>
In article <6m44lv$m4o$1@nnrp1.dejanews.com>,
jharris01@my-dejanews.com writes:
> I just dove into PERL and I am curious about the dbmopen function. I have a
> 238M .db file that I would like to open up and peek into. Once I figure this
> out then I can decide what I want to do with the db. Can someone point me in
> the direction of how to open and just print out the .db file?
What sort of file is that .db file? dbmopen works with the standard
dbm, ndbm, sdbm, gdbm or berkeley DB file, as documented in perldoc -f
dbmopen. Normally files of this format have a .dir and .pag extension.
What you have probably is something totally different.
Once you figure out what sort of DB file you have, you should go to
http://www.perl.com/CPAN/modules/00modlist.long.html and find out if
there is a module for you there that does what you want. Without
knowing what the format of your file is, you don't have much chance.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Little girls, like butterflies, need no
Commercial Dynamics Pty. Ltd. | excuse - Lazarus Long
NSW, Australia |
------------------------------
Date: Mon, 15 Jun 1998 23:53:50 -0400
From: David Wasserstrum <zeos@gti.com>
To: emery@wizweb.com
Subject: Re: CGI Perl Programming Problem.
Message-Id: <3585EC4E.30FA0D5A@gti.com>
I'm a little confused... lets say two users log on at the same time... one
named Adam and the other named Bob...
Lets say that you have two forms... the first is where you pick what kind
of fruit you want to buy and the second is how you will pay
(Visa,Mastercard, etc.)
Lets say Adam decideds he wants to buy apples... you now return him a web
form for a payment method with his selection (apples) in a hidden form..
Then Bob logs in and decides he wants to buy bananas, so you return him a
web form for a payment method with his selection (bananas) in a hidden
form...
Now when Adam or Bob submit their credit card information you will have the
type of fruit that they want to buy already in their form (hidden from
their view of course...)
So exactly where is your problem???
-Dave
------------------------------
Date: Mon, 15 Jun 1998 21:47:41 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Date fomatting.
Message-Id: <MPG.fef98c87f9146dc9896bb@nntp.hpl.hp.com>
In article <3581a69b.16861879@news2.cais.com>,
root.noharvest.\@not_even\here.com (-) says...
...
> sub get_date {
>
> ($sec, $min, $hour, $mday, $mon, $yr, $wday, $yday, $isdst) =
> localtime(time);
>
> if ($mday <= 9)
> {
> $mday = '0' . $mday;
> }
> if ($mon <= 9)
> {
> $mon = '0' . $mon;
> }
>
> $now_date = "$yr$mon$mday";
>
> return $now_date);
> }
>
>
> Now, $now_date looks like this "980612" on June 12th, 1998. ...
As written, $now_date looks like this "980512" on June 12th, 1998. And
it will look like this "1000512" on June 12th, 2000. I doubt that either
of those is what you want.
--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: Tue, 16 Jun 1998 01:24:55 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Eval questions.
Message-Id: <1daomk6.ns3qjwx0pq7wN@bay1-107.quincy.ziplink.net>
John Bokma <postmaster@castleamber.com> wrote:
> I am very happy now, since you can't answer the original
> question. From the original posting it must have been clear
> that it where tiny examples. As you stated, it won't even
> compile, so how can I have it working? The only answer
> is, I typed from memory. (Or I use a special Perl version
> which can guess.).
I wonder if you would have the same attitude if Charles had answered
your question with the same lack of care that you demonstrated in
posting your question. Suppose he had answered by typing some Perl code
from memory, and it turned out to have syntax errors in it so it
wouldn't even compile. Not very useful, eh?
By the way, here's a quote from one of your earlier messages:
> I've only added the snippets to make clear what I mean.
Snippets with syntax errors in them don't exactly make it clear what you
mean, do they?
I think I should point out that you have not only alienated Charles with
your attitude, you have also alienated almost everyone else in this
newsgroup who might otherwise have been willing and able to answer your
question.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Tue, 16 Jun 1998 03:16:21 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Finding size of JPEG images in Perl
Message-Id: <Pine.GSO.3.96.980615201445.17943S-100000@user2.teleport.com>
On Tue, 16 Jun 1998, Mark Thompson wrote:
> Is there a publically available routine that would allow me to find the
> height and width of a JPEG image in Perl?
Yes; look on CPAN for the Image::Size module (or something like that).
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 16 Jun 1998 03:08:06 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Format Irritation
Message-Id: <Pine.GSO.3.96.980615200514.17943R-100000@user2.teleport.com>
On Mon, 15 Jun 1998 jduncan@hawk.igs.net wrote:
> I get one row of data and then I want to append the data to the format,
> rather than perform multiple writes. I'd much rather have it just make
> one write() at the end. Why-o-why doesn't format support .='s - and if
> it does, why is perl giving me a syntax error?
You can use expressions within a format, but it sounds as if you're
mis-using them. Of course, without seeing your code, I can only guess.
The worst thing about formats is when you need something they can't do, of
course. Then you have to completely re-write your code. :-P
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 16 Jun 98 04:30:42 GMT
From: Todd Santos <0x74_0x6F_0x64_0x64@0x40.0x7A.0x65.0x72.0x6F.0x6B.0x61.0x72.0x6D.0x61.0x2E.0x64.0x79.0x6E.0x2E.0x6D.0x6C.0x2E.0x6F.0x72.0x67>
Subject: getspnam()
Message-Id: <3585f4f2.0@206.170.198.12>
hey, where's Perl's shadow passwd support? =(
- Todd
--
Todd Santos :: Just Another Aspiring Perl Hacker :: todd@zerokarma.dyn.ml.org
...Yeah, I know I have a munged From: header. I was bored.
------------------------------
Date: Tue, 16 Jun 1998 03:59:05 GMT
From: birgitt@my-dejanews.com
Subject: Re: Have we got a good free Perl manual?
Message-Id: <6m4qi9$o5m$1@nnrp1.dejanews.com>
In article <6m49tv$v6d$1@nnrp1.dejanews.com>,
birgitt@my-dejanews.com wrote:
> I would then remind you all gently that
I apologize, the previous post was not meant to come to c.l.p.m,
I overlooked the crosspost of the poster to whom I replied in
gnu.misc.discuss.
I am sorry.
Birgitt Funk
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 16 Jun 1998 03:08:21 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: HELP WITH SOME NEWBIE HACKED CODE???
Message-Id: <6m4nj5$5o1$1@comdyn.comdyn.com.au>
Please read the following information on how to choose a good subject
line:
http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post
In article <3585437A.4D64@hotkey.net.au>,
Stephan Carydakis <steph@hotkey.net.au> writes:
> Hi All,
>
> I have a quaestion about the following code:
>
> sub get_data
> {
> $how_much=11;
> open(FILE,"<$dat_file") or die "can't open $dat_file";
> while ($line = <FILE>) {
What happens if a line from that file evaluates to a false value? What
you really want is:
while (defined($line = <FILE>)) {
> (@dat_recs) = split(",", $line);
No need for the parens around @dat_recs
You do realise that your last field will contain a newline, right?
> $stat_bar++;
> foreach $page_counts (@page_counts) {
> if ($dat_recs[3] == $page_counts) {
You never checked to see if @dat_recs has at least 4 elements.
> $to_be_sorted{$page_counts}++;
> next;
> }
> }
> if ($stat_bar > ($FORM{'montot'} / $how_much)) {
Aha, a CGI application, hmm?
You realy should have mentioned that, because it does make a big
difference to the answer to your question.
> print "* ";
> $stat_bar=0;
> }
> }
> close (FILE);
> }
>
> My problem is with the last 'if' statement. What I think should happen
> is every time the condition is met(10 times all up), the script spews
> out '* ' to STDOUT.
>
> What actually happens is it spews out 10 '* ' all at once, and not 1 at
> a time as I would expect. Can someone tell me why this is so?
If you run your application from the command line, it will do what you
expect, IF you set the $| variable. Since this is a CGI, I suspect
that your application output is being buffered by the server. You
might want to try to set the $| variable (see the perlvar
documentation with: perldoc perlvar), but that might not help.
If setting $| doesn't help, then it isn't a perl question anymore, but
a CGI/your webserver question. You should ask in a newsgroup that
talks about those.
The question would become: How do I get unbuffered output from my CGI
application?
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au |
Commercial Dynamics Pty. Ltd. | Curiouser and curiouser, said Alice.
NSW, Australia |
------------------------------
Date: Tue, 16 Jun 1998 11:22:35 +0000
From: Henry Ng <rsb018@email.sps.mot.com>
Subject: How can I run Perl in Microsoft Access ?
Message-Id: <3586557B.FCAFD5F9@email.sps.mot.com>
Hi,
My name is Finie, how can I run Perl in Microsoft Access ?
Regards
Finie
------------------------------
Date: Mon, 15 Jun 1998 22:57:13 -0700
From: "Adam Hill" <ahill@users.arco.com>
Subject: IE 5.0, COM and PERL.
Message-Id: <6m4qou$kuh$1@argentina.it.earthlink.net>
The manager of the Windows Scripting group posted this to the
ms.public.scripting newsgroup on the 11th.
---------
The next beta of scriplets is released to web today. You can get either by
downloading Internet Explorer 5.0 or going to the scripting site after 3:00
PST today.
... stuff omitted
Any ActiveX Script Engine
* Our last release only worked with engines that support IDispatchEx and
Cloning of engines. This release works with any engine that supports
ActiveX Scripting. This means you can now write COM objects in PERL!
----------
Thought the group might be interested.
adam hill...
------------------------------
Date: Mon, 15 Jun 1998 20:40:04 -0700
From: "Andrew Arrow" <andrew@deltanet.com>
Subject: Input type="file"
Message-Id: <6m4pkk$3i5$1@news01.deltanet.com>
Hi all,
Can anyone tell me where to find information on the:
<input type="file" name="whatever">
It makes a nice text field with a "browse" button next to it, but how do I
go about reading the file the user selects?
Say the user selects "c:\textfile.txt" How do I read that file off the
user's hard drive from my web application?
Please respond to andrew@deltanet.com
Thanks!
------------------------------
Date: Mon, 15 Jun 1998 21:31:21 -0700
From: Jim Bowlin <bowlin@sirius.com>
To: Andrew Arrow <andrew@deltanet.com>
Subject: Re: Input type="file"
Message-Id: <3585F519.C6D5C7A7@sirius.com>
Andrew Arrow wrote:
>
> Hi all,
>
> Can anyone tell me where to find information on the:
>
> <input type="file" name="whatever">
>
> It makes a nice text field with a "browse" button next to it, but how do I
> go about reading the file the user selects?
>
> Say the user selects "c:\textfile.txt" How do I read that file off the
> user's hard drive from my web application?
>
> Please respond to andrew@deltanet.com
>
> Thanks!
CGI.pm -- Jim Bowlin
------------------------------
Date: Tue, 16 Jun 1998 01:24:57 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Keeping the global value of a local variable.
Message-Id: <1daonqc.1tvojybpjnjqcN@bay1-107.quincy.ziplink.net>
<letranger@my-dejanews.com> wrote:
> Okay, I've looked through all of the perl docs, but I'm still a little
> confused about the order of evaluation of operands of an assignment operator
> when used with local(). Specifically, will this do what I want it to:
>
> local $foo = $foo;
~> perl
{
$foo = 'bar';
local $foo = $foo;
print "$foo\n";
}
print "$foo\n";
__END__
bar
bar
Yes.
> (That is, localize $foo and initialize it to contain the value of the global
> $foo.) Does it make a difference how I parenthesize things, or whether I'm
> using local on a list rather than a scalar? I.e. will all of these be
> equivalent:
>
> (local $foo) = $foo;
> local($foo) = $foo;
~> perl
{
$foo = 'bar';
(local $foo) = $foo;
print "$foo\n";
}
print "$foo\n";
__END__
bar
bar
Yes.
~> perl
{
$foo = 'bar';
local ($foo) = $foo;
print "$foo\n";
}
print "$foo\n";
__END__
bar
bar
Yes.
> and will this work:
>
> local ($foo, $bar) = ($foo, $bar);
~> perl
{
($foo, $bar) = ('abc', 'xyz');
local($foo, $bar) = ($foo, $bar);
print "$foo $bar\n";
}
print "$foo $bar\n";
__END__
abc xyz
abc xyz
Yes.
> And just for future reference, does my() work the same way? Are there any
> strange perl "traps for the unwary" I should be aware of when doing this sort
> of thing?
{
($foo, $bar) = ('abc', 'xyz');
my($foo, $bar) = ($foo, $bar);
print "$foo $bar\n";
}
print "$foo $bar\n";
__END__
abc xyz
abc xyz
Yes.
Nothing comes to mind.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Mon, 15 Jun 1998 23:52:48 -0400
From: Freek <freek@writeme.com>
Subject: Newbie question
Message-Id: <3585EC10.D38FB56F@writeme.com>
I am a newbie in the perl world. i curently have a simple problem, i
hope.
I need to display the images in a directory, directly on a web page,
without having to hardcode the files into html, this would take to long
to add pics. i have been unable to do this in javascript, and now, am
having probs with perl doing it. the directory will only have images,
and there will be a limited number of images per directory, but they
will change periodically.
if this script exsists i have been unable to find it.
any help is apprieciated.
please, if possible respond directly, as i usually can only check news
once or twice a week
freek
freek@writeme.com
------------------------------
Date: Tue, 16 Jun 1998 02:32:07 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Newbie trying to capture(control) output from pipe
Message-Id: <Pine.GSO.3.96.980615192456.17943O-100000@user2.teleport.com>
On Sun, 14 Jun 1998, Tom Kent wrote:
> Subject: Newbie trying to capture(control) output from pipe
Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.
http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post
> I am trying to assign this result to a variable
> open(ON, "|sort|uniq|wc -l");
> foreach $line (@array) {
> ($Fld1) = split(' ',$line);
> print ON "($Fld1)\n";
> }
>
> close (ON);
Well, you seem to be asking how to open a command for input and output.
That's covered in the FAQ.
But in this case, you seem to be trying to find out how many unique items
you would output, and Perl can do that too easily to require an external
command or four.
my $items;
{
my %hash;
for (@array) {
my($Fld1) = split ' ';
$hash{$Fld1} = 1;
}
$items = keys %hash;
}
print "There were $items items\n";
You could make it even shorter (and probably faster) by using map, but
this probably has enough new features to keep you busy. :-) Does it do
what you need? Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 16 Jun 1998 03:22:45 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: perl cgi generated html with java app "class not found"
Message-Id: <Pine.GSO.3.96.980615202100.17943U-100000@user2.teleport.com>
On Mon, 15 Jun 1998, David Innes wrote:
> I have a perl script which reads an existing html document and creates
> another one from it, with minor changes. The newly created html document
> can not find the Lake.class (which the java needs) while running in the
> perl script. The new html doc runs fine on it's own with the Lake.class
> in the same directory.
Sounds as if it's a Java problem, since the Perl is running all right.
Perhaps the docs, FAQs, or newsgroups about Java will be able to help you.
Good luck!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 15 Jun 1998 19:56:10 -0400
From: Mr James <71022.3700@CompuServe.COM>
Subject: Perl Contract Programmer Available
Message-Id: <u3kxskLm9GA.311@ntdwwaaw.compuserve.com>
Perl contract programmer available immediately. Experienced with
text processing, Web CGI, and database development. Familiar
with Perl modules, objects, CGI security and programming
standards in banking and telco industries. Prefer CA, NY, TX or FL.
(P.S. Yes, I've already tried posting this in the jobs groups.)
--
Mr. James,CP-ASEL-IA,PP-AMEL,Internet Consultant,71022.3700@compuserve.com
------------------------------
Date: 16 Jun 1998 05:16:19 +0200
From: Ask Bjoern Hansen <ask@netcetera.dk>
Subject: pod syntax error
Message-Id: <m3k96iavek.fsf@balder.netcetera.dk>
What's wrong with this?
=head1 TEST
$r-E<gt>push_handlers(PerlHandler =E<gt>
$self-E<gt>perl_handler_method($r);
It returns:
/usr/bin/pod2man: bad option in paragraph 2 of test.pod:
``perl_handler_method($r)'' should be [LCI] <perl_handler_method($r)>
I've tried all sorts (well, all I can imagine) of removing and
replacing >'s with E<gt>.
ask
------------------------------
Date: Tue, 16 Jun 1998 00:49:23 -0400
From: David Wasserstrum <zeos@gti.com>
Subject: print <<END (with variables)
Message-Id: <3585F953.B270498A@gti.com>
So heres the problem... I am using a print <<"END" command so that I can
print out a table... within the table are a bunch of graphics... some
times they should be button_left.gif and other times they should be
buttonon_left.gif. This depends on what the $a variable is.
SO IF $a = "" THEN button$a_left.gif SHOULD BE button_left.gif
AND IF $a = "on" THEN button$a_left.gif SHOULD BE buttonon_left.gif
but the problem is perl thinks that my variable name is $a_left and
makes it evaluate to button.gif... how do i correct this problem???
actual source code:
$a = "";
$a="on" if (substr($in,0,1)!=0);
print <<"END";
<table><tr><td><img src="graphics/button$a_left.gif"></td><td><img
src="graphics/button$a_top.gif"></td><td><img
src="graphics/button$a_left.gif"></tr>
<tr><td></td></tr>
<tr><td></td></tr>
</table>
END
------------------------------
Date: Mon, 15 Jun 1998 22:09:10 -0700
From: Jim Bowlin <bowlin@sirius.com>
To: David Wasserstrum <zeos@gti.com>
Subject: Re: print <<END (with variables)
Message-Id: <3585FDF6.87AAEA0E@sirius.com>
David Wasserstrum wrote:
>
> So heres the problem... I am using a print <<"END" command so that I can
> print out a table... within the table are a bunch of graphics... some
> times they should be button_left.gif and other times they should be
> buttonon_left.gif. This depends on what the $a variable is.
>
> SO IF $a = "" THEN button$a_left.gif SHOULD BE button_left.gif
> AND IF $a = "on" THEN button$a_left.gif SHOULD BE buttonon_left.gif
>
> but the problem is perl thinks that my variable name is $a_left and
> makes it evaluate to button.gif... how do i correct this problem???
>
> actual source code:
> $a = "";
> $a="on" if (substr($in,0,1)!=0);
>
> print <<"END";
> <table><tr><td><img src="graphics/button$a_left.gif"></td><td><img
> src="graphics/button$a_top.gif"></td><td><img
> src="graphics/button$a_left.gif"></tr>
> <tr><td></td></tr>
> <tr><td></td></tr>
> </table>
> END
Use ${a} inside the string. -- Jim Bowlin
------------------------------
Date: Tue, 16 Jun 1998 05:26:22 GMT
From: dlucas@deletethis.gol.com (Dan Lucas)
Subject: Replacing multiple 'empty' lines
Message-Id: <35860140.80717345@nnrp.gol.com>
My apologies in advance for this beginner's FAQ.
I have a number of text files containing multiple 'empty' lines, which
are lines containing just a newline. I want to replace bunches of 2 or
more empty lines with one empty line.
If the file was placed in a single string (each line concatenated onto
a string as read), my tentative approach would be to do a
s/\n\n\n+/\n/m (<-? sorry, I forget the 'multiple line string' switch)
on the string and then write it back out to a file. It seems to me
that this would work, although one might run into trouble with a very
large file (unlikely, and would be checked first anyway).
However, this seems an unnatural and rather 'brute force' way to do
it. Another way would perhaps be to read the file into an array, loop
through the array, check to see if both the current line and the
previous one are empty then delete one or the other. This doesn't seem
very elegant either.
Can anybody suggest a better, more Perl-ish way to replace these
multiple \n lines with a single \n?
Regards,
Dan Lucas
Osaka
Japan
------------------------------
Date: 16 Jun 1998 05:44:51 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Replacing multiple 'empty' lines
Message-Id: <6m50oj$8s5$1@marina.cinenet.net>
Dan Lucas (dlucas@deletethis.gol.com) wrote:
: I have a number of text files containing multiple 'empty' lines, which
: are lines containing just a newline. I want to replace bunches of 2 or
: more empty lines with one empty line.
:
: If the file was placed in a single string (each line concatenated onto
: a string as read),
Rather than concatenating lines as you read them, it's far easier to
(locally) undefine $/ and read the entire file into a scalar in a single
'$text = <FILE>' operation.
: my tentative approach would be to do a
: s/\n\n\n+/\n/m (<-? sorry, I forget the 'multiple line string' switch)
(a) That actually replaces groups of *three* or more \n with a single \n.
(b) /m doesn't mean anything here; it only changes how ^ and $ are
interpreted. /s, the other similar switch, only changes how .
is interpreted. Neither would have any effect on what you're trying
to do.
: on the string and then write it back out to a file. It seems to me
: that this would work, although one might run into trouble with a very
: large file (unlikely, and would be checked first anyway).
Quite true.
: However, this seems an unnatural and rather 'brute force' way to do
: it. Another way would perhaps be to read the file into an array, loop
: through the array, check to see if both the current line and the
: previous one are empty then delete one or the other. This doesn't seem
: very elegant either.
Yes, I think the s/// method is a lot more 'perlish' and elegant. It's
also reasonably efficient, given Perl's regex and replacement
optimizations.
: Can anybody suggest a better, more Perl-ish way to replace these
: multiple \n lines with a single \n?
About all I'd do is rewrite your substitution as
s/\n{2,}/\n/
Change the 2 to 3 if you really mean 3 or more as you wrote it above.
HTH!
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Tue, 16 Jun 1998 12:11:48 +0800
From: Azman Shariff <azman@bnex.com>
Subject: Running commands
Message-Id: <3585F084.84C9FF75@bnex.com>
---------------CODE---------------------
$domain = "microsoft.com"
$user = "billgates"
#Create User Directories
($shortdomain , $extension) = split( /./, $domain );
@shellresult = `mkdir /virtual/$domain/home/$user`;
@shellresult = `chmod 711 /virtual/$domain/home/$user`;
-------SNIP SNIP----------------------------------------
what is wrong there? ...... can i run a command thru perl codes? .... i
think the double "`" would do the job rite?
but it doesn't seem so in this case. Or is it not able to run commands
with variables in there? Please advice
Azman Shariff
portal@pacific.net.sg
------------------------------
Date: Tue, 16 Jun 1998 15:28:58 +1000
From: John Smith <adam@universal.net.au>
Subject: Script to monitor email traffic
Message-Id: <3586029A.F7734AB6@universal.net.au>
Hi.
I need a script for a linux box that will measure the email traffic for
a particular user. I know it is simple - I don't have much experience
with linux and I'm not sure where to start.
Adam.
------------------------------
Date: Tue, 16 Jun 1998 03:27:29 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Simple Q - Splitting Array by Spaces
Message-Id: <Pine.GSO.3.96.980615202337.17943V-100000@user2.teleport.com>
On Mon, 15 Jun 1998, Jesse Rosenberger wrote:
> I have an array called @options, it contains several numbers seperated
> by spaces (i.e. 62 63 65 67 69 70 81 96) the numbers may vary
> everytime.
This is ambiguous; here are two possible meanings:
@options = ( '62 63 65 67 69 70 81 96' );
@options = ( '62 63 65', '67 69 70 81 96');
What meaning do you intend?
> I need to be able to have the script print an <option> tag for each one:
Maybe you want the split function, possibly combined with map or within a
loop. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 16 Jun 1998 00:05:17 -0400
From: "Patrick Lanphier" <p-lanphier@psu.edu>
Subject: Use cgi
Message-Id: <6m4r4c$ire@r02n01.cac.psu.edu>
When the below is run the following error occurs "Undefined subroutine
&main::param called at script line 3." How do I correct this problem?
#!D:\Perl\perl5\bin\perl
use cgi qw(:standard);
my $contact = param("contact") ;
Patrick Lanphier
------------------------------
Date: Mon, 15 Jun 1998 22:07:12 -0700
From: Jim Bowlin <bowlin@sirius.com>
To: p-lanphier@psu.edu
Subject: Re: Use cgi
Message-Id: <3585FD80.73B3D00A@sirius.com>
Patrick Lanphier wrote:
>
> When the below is run the following error occurs "Undefined subroutine
> &main::param called at script line 3." How do I correct this problem?
>
> #!D:\Perl\perl5\bin\perl
> use cgi qw(:standard);
> my $contact = param("contact") ;
>
> Patrick Lanphier
s/cgi/CGI/; In other words the CGI module is called "CGI"
not "cgi".
HTH -- Jim Bowlni
------------------------------
Date: 16 Jun 1998 04:09:13 GMT
From: "Pete Sattler" <psattler@bestweb.net>
Subject: Windows95, Perl-32 and Personal Web Server (PWS)
Message-Id: <01bd98d4$5331c020$LocalHost@VOYAGER>
I am trying to set-up an environment on Windows 95 for developing web
applications. I have installed ActiveState's Perl for Win32 (build 316)
along with Microsoft's personal web server (PWS). I'm finding that anytime
I try to make a call using system() or backticks PWS hangs. I've found
some recent postings in this newsgroup that discussed the lack of
intelligence in the standard Windows command shell (command.com). I
installed the more intelligent 4DOS shell from JP Software, but I have been
unable to correct the problem.
Has anyone else been able to successfully implement this environment? Any
help is greatly appreciated!
Pete Sattler
Chase Manhattan Bank
------------------------------
Date: Mon, 15 Jun 1998 21:14:49 -0700
From: Jim Bowlin <bowlin@sirius.com>
To: Pete Sattler <psattler@bestweb.net>
Subject: Re: Windows95, Perl-32 and Personal Web Server (PWS)
Message-Id: <3585F139.A79ECB45@sirius.com>
Pete Sattler wrote:
>
> I am trying to set-up an environment on Windows 95 for developing web
> applications. I have installed ActiveState's Perl for Win32 (build 316)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Bad move. The standard distribution is much better than ActiveState's.
It has lot's of built in modules, fewer bugs, MUCH better documentation.
Now that the standard distribution has been ported to Window, I really
don't know how much support there will be for the ActiveState version.
> along with Microsoft's personal web server (PWS). I'm finding that anytime
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Not a great move either. If you want something free and easy, I suggest
Xitami from iMatix.
> I try to make a call using system() or backticks PWS hangs. I've found
> some recent postings in this newsgroup that discussed the lack of
> intelligence in the standard Windows command shell (command.com). I
> installed the more intelligent 4DOS shell from JP Software, but I have been
> unable to correct the problem.
>
> Has anyone else been able to successfully implement this environment? Any
> help is greatly appreciated!
Pete, I have seen the problems you mention. I don't think PWS allows
CGI scripts to shell. I think this is the MS version of web security or
something. I recommend that you try changing your Perl and your Web server.
This may not solve all of your problems but it is a big step in the right
direction (IMHO).
I hope this is of some help, -- Jim Bowlin
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 2880
**************************************