[8359] in Perl-Users-Digest
Perl-Users Digest, Issue: 1976 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 25 21:13:55 1998
Date: Wed, 25 Feb 98 18:00:27 -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 Wed, 25 Feb 1998 Volume: 8 Number: 1976
Today's topics:
Re: Changing From address in Mail <webmaster@fccj.cc.fl.us>
Re: Changing From address in Mail (Craig Berry)
Re: Changing From address in Mail (John Stanley)
Re: Cookie with Perl (steve)
Re: do I need file locking? <joseph@5sigma.com>
Re: Features Problem (Martien Verbruggen)
Re: file test inside grep() <fbrodsky@sedona.intel.com>
Re: Help using MacPerl please. (Rich Morin)
Re: Help using MacPerl please. <blairhj@intnet.net>
Re: Help with SYSTEM command? (Ken C.)
Re: How do I create my own perl libraries? <joseph@5sigma.com>
Re: How does the Perl-Interpreter works? (Martien Verbruggen)
Re: Newbie Question: df in a perl script <webmaster@fccj.cc.fl.us>
Re: Newbie Question: df in a perl script (Martien Verbruggen)
Re: No. of days?? <beans@bedford.net>
PASSWORD update utility for SunOS4.1.4/OpenVMS 6.2 <jwearnes@flash.net>
Perl and/or C parsing code, in Perl? (Rich Morin)
Re: POD style comments revisited <rjk@coos.dartmouth.edu>
Re: reg expression help.. <rjk@coos.dartmouth.edu>
Running a perl script on Windows 95 <tcam@ca.ibm.com>
Re: sorting array <joseph@5sigma.com>
Re: The Ineffable Tom C. <rjk@coos.dartmouth.edu>
Re: The Ineffable Tom C. <rjk@coos.dartmouth.edu>
Re: Unwanted Character Displays (Martien Verbruggen)
use system or backticks?? (Michael Shavel)
Re: Verifying a form field <westxga@ptsc.slg.eds.com>
Re: Why install perl? (Martien Verbruggen)
Re: Why PERL? [Re: Beginner in trouble] (steve)
Re: Win95 - Running scripts from browser? (Robbie Baldock (real email address at foot of message))
Re: XS dynamic loader: how to push C args? (Ken Fox)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 26 Feb 1998 00:36:01 GMT
From: Bill Jones <webmaster@fccj.cc.fl.us>
Subject: Re: Changing From address in Mail
Message-Id: <34F4B7CA.7C16A10B@fccj.cc.fl.us>
Been there, done that, see www.dejanews.com
Search on Perl Sendmail Webmaster
HTH,
Sneex :-)
Steve wrote:
> hello,
>
> I am limited to using cgi-lib.pl on my server as the sysop won't
> install cgi.pm. Therefore I am using cgi-lib.pl.
>
> I'm looking to send mail by opening a pipe to the mail command.
> However I would also like to change the "From" address of the
> resulting messages.
>
> Can this be done?
>
> I'm changing the subject line now with the -s option, but as of yet
> have been unable to find any documentation on an option to change the
> from address.
------------------------------
Date: 26 Feb 1998 00:41:57 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Changing From address in Mail
Message-Id: <6d2dol$njn$1@marina.cinenet.net>
Steve (nospamtovanhalen@coredcs.com-nospammy) wrote:
: I am limited to using cgi-lib.pl on my server as the sysop won't
: install cgi.pm. Therefore I am using cgi-lib.pl.
First, it's CGI.pm, note capitalization.
Second, why not install it locally, in the same dir as your other Perl
code? If you're on a misconfigured NT server (is that redundant?), you
may need to 'use lib' the absolute path to that dir first. Otherwise,
since . is in @INC, you're fine without any special effort.
---------------------------------------------------------------------
| 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: 26 Feb 1998 01:10:37 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Changing From address in Mail
Message-Id: <6d2fed$pj0$1@news.orst.edu>
In article <34f493b0.457051952@enews.newsguy.com>,
Steve <nospamtovanhalen@coredcs.com-nospammy> wrote:
>I'm looking to send mail by opening a pipe to the mail command.
>However I would also like to change the "From" address of the
>resulting messages.
>
>Can this be done?
Of course it can. I do it every day. When you pipe the message to
sendmail, just put whatever From: header you want in the message.
>I'm changing the subject line now with the -s option, but as of yet
>have been unable to find any documentation on an option to change the
>from address.
The -s option to sendmail has nothing to do with the subject. You set
the Subject header by putting the subject header in the message you
send.
------------------------------
Date: Thu, 26 Feb 1998 01:37:50 GMT
From: me@here.com (steve)
Subject: Re: Cookie with Perl
Message-Id: <3507c6b8.124749877@news.cent.com>
This is because your cookies file on your disk does not update until
you shut the browser. Also note, you do not need to expire a cookie if
you just want it to expire when the visitor closes their Web browser
as it is automatically set to expire upon closing of the browser.
On Wed, 25 Feb 1998 23:26:11 +0800, "Martin" <koala1998@hotmail.com>
wrote:
>Hiall,
>
>I have written a perl script to expire a cookie. But when i pressed the
>back button on the browser, the cookie is set back to its origianl value.
>Anyone experienced that? Can somebody help?
>
>Martin
>
>
------------------------------
Date: Wed, 25 Feb 1998 18:36:27 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: do I need file locking?
Message-Id: <34F4C711.1AEC85BE@5sigma.com>
All it takes is two attempts, not many. :-)
Locking is necessary when two or more processes may write to
a file simultaneously, or in many cases when a file may be
read and written simultaneously. Locking has become much more
"popular" with the advent of CGI scripting, where many
instances of a script may be running at the same time.
-joseph
Tom wrote:
>
> Hi,
>
> I have read that you use file locking if you suspect that a file will
> be accessed many times simultaniously. [...]
--
Joseph N. Hall, prop., 5 Sigma Productions mailto:joseph@5sigma.com
Author, Effective Perl Programming . . . . . http://www.effectiveperl.com
Perl Training . . . . . . . . . . . . . . . http://www.perltraining.com
------------------------------
Date: 26 Feb 1998 00:25:29 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Features Problem
Message-Id: <6d2cpp$29b$2@comdyn.comdyn.com.au>
In article <34F4A73B.399D03A1@age.net>,
Brad Atkins <batkins@age.net> writes:
> I have a chat script, that will work fine for a bit then after a while
> the private messages will stop working. It might be because I changed
> something, but chances are that isn't the case. I re-install a fresh
> copy, paths are correct, and they still don't work
I think you are experiencing GOVERNMENT CONTROL. You see, everyone
with a chat script is being scrutinised by the department of CHAT
control. Whenever they see some message they don't like, they
introduce some little goblin called feature-creep in your program. if
you have lots of these little devils, your program migth acquire so
many new features that it just stops working.
This also applies to Microsoft products.
> Does it make sense for certain features to just not work?! If you can
> help, or have suggestions, get back to me, PLEASE:)
Yes, it makes perfect sense. Especially if they're features which
really are bugs. And especially if they're 'private' messages. You
know perfectly well that the government doesn't like private messages.
Hope this explains what's going on
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | I think I think, therefore I think I
Commercial Dynamics Pty. Ltd. | am.
NSW, Australia |
------------------------------
Date: Wed, 25 Feb 1998 17:29:05 -0700
From: Franklin Brodsky <fbrodsky@sedona.intel.com>
Subject: Re: file test inside grep()
Message-Id: <34F4B751.D2362F4D@sedona.intel.com>
Thanks to Andrew and Martien for the assistance with the file tests.
I can see now that I was trying to test files in a different directory than that from which readdir() was pulling their names.
I replaced the
-f
with
-f "$dir/$_"
in the test section of grep, and now the program works as expected.
"After you have exploited someone, it never hurts to thank them... It makes it easier to exploit them again next time." - Neelix, pretending to be the Proxy for the Grand Nagus
;-)
--
Franklin Brodsky, faithful employee fbrodsky@sedona.intel.com
Opinions expressed above are mine, and not necessarily those of Intel.
------------------------------
Date: Wed, 25 Feb 1998 16:43:40 -0800
From: rdm@cfcl.com (Rich Morin)
Subject: Re: Help using MacPerl please.
Message-Id: <rdm-2502981643560001@140.174.42.30>
d shahin <dshahin@bayarea.net> writes:
> Where is a good place to look for help using Mac Perl?
The MacPerl Pages (http://www.ptf.com/macperl) have information on
MacPerl, links to other sites, etc. The Pages also contain draft
chapters from Prime Time Freeware's upcoming book:
MacPerl: Power and Ease
Hope this helps!
-r
P.S. Version 0.5 of the MacPerl CD-ROM is out; see the MacPerl
Pages for details...
------------------------------
Date: Wed, 25 Feb 1998 20:41:40 +0000
From: "Hugh J. Blair" <blairhj@intnet.net>
Subject: Re: Help using MacPerl please.
Message-Id: <34F48204.7B77@intnet.net>
I'm just starting out also and am combing through many references. The
one I found most useful (so far) is "Perl for Dummies". A CD rom is
included with examples and exercises etc. I also have the Camel book
but it really is more of a reference for someone who already (almost)
knows what they're looking for.
Good Luck !
By The Way this news group is also a great resource.
Hugh Blair
Rich Morin wrote:
>
> d shahin <dshahin@bayarea.net> writes:
>
> > Where is a good place to look for help using Mac Perl?
>
> The MacPerl Pages (http://www.ptf.com/macperl) have information on
> MacPerl, links to other sites, etc. The Pages also contain draft
> chapters from Prime Time Freeware's upcoming book:
>
> MacPerl: Power and Ease
>
> Hope this helps!
>
> -r
>
> P.S. Version 0.5 of the MacPerl CD-ROM is out; see the MacPerl
> Pages for details...
--
_______________________________________________________
Some foolish people think science takes the wonder out of the universe;
the exact opposite is true.
Genuine understanding is not only more useful than superstition or myth;
it is always much more interesting. Arthur C. Clarke
_______________________________________________________
------------------------------
Date: Thu, 26 Feb 1998 01:18:17 GMT
From: n8ptt@ibm.net (Ken C.)
Subject: Re: Help with SYSTEM command?
Message-Id: <34f4c382.0@news1.ibm.net>
How about this:
use File::Copy;
copy("oldfile.txt",$newfile);
Ken C. (Perl Novice but getting better.....I hope)
In article <34F4817D.EBBF5D2C@aesop.rutgers.edu>, "James R. McDonald"
<mcdonald@aesop.rutgers.edu> wrote:
>I'm working on a PERL program on VMS and one of the things
>I'd like the program to be capable of is to copy a file.
>I have the new file name as a variable, ie $newfile and
>I figured on using the system command to do it, but instead
>the program is copying the file and naming it $newfile.
>
>ie:
>
>$newfile=newdata.txt;
>system('copy oldfile.txt $newfile');
>
>How can I get PERL (or VMS) to interpret the string $newfile
>when doing the copy command?
>
>Thanks in advance,
>Jim McDonald
------------------------------
Date: Wed, 25 Feb 1998 18:40:58 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: How do I create my own perl libraries?
Message-Id: <34F4C820.3E6D6F79@5sigma.com>
Oh, I think that's bad advice. It's easy to create modules and
'use' is less confusing, at least to users, than 'require'. All
Joey needs is a good tutorial ... I suggest Item 45 in my book. :-)
-joseph
Cameron Kaiser wrote:
>
> Joey Garcia <bear@pacificnet.net> writes:
>
> >Hello, I'm sort of new but I'm getting the hang of everything here
> >pretty quickly. I've written a few working cgi scripts and I keep
> >coming up with more. The problem I have is that I use alot of the same
> >code in each one. I wanted to know if there was a way I can make my own
> >perl libraries or modules [...]
>
> 1. To create Perl modules (.pm) requires more knowledge than you have at
> this point.
--
Joseph N. Hall, prop., 5 Sigma Productions mailto:joseph@5sigma.com
Author, Effective Perl Programming . . . . . http://www.effectiveperl.com
Perl Training . . . . . . . . . . . . . . . http://www.perltraining.com
------------------------------
Date: 25 Feb 1998 23:25:53 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: How does the Perl-Interpreter works?
Message-Id: <6d29a1$1t1$6@comdyn.comdyn.com.au>
In article <34EEBE7C.7F1C@stud.uni-erlangen.de>,
Ingo Ruth <ingo.ruth@stud.uni-erlangen.de> writes:
> I found out, that the first time the program took more time
> for executing than any further time. I think its because of the
> interpreter.
>
> Can anybody explain, how the interpreter works?
This is most likely not a perl issue, but caching from your operating
system. You'll probably notice the same thing with other programs. The
first time it takes a little longer than subsequent times.
All sensible operating systems cache stuff here and there. Even some
not-so-sensible ones make an attempt.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Very funny Scotty, now beam down my
Commercial Dynamics Pty. Ltd. | clothes.
NSW, Australia |
------------------------------
Date: Thu, 26 Feb 1998 00:36:40 GMT
From: Bill Jones <webmaster@fccj.cc.fl.us>
Subject: Re: Newbie Question: df in a perl script
Message-Id: <34F4B7F1.5462638C@fccj.cc.fl.us>
RTFM - See system specifically.
HTH,
Sneex :-)
Mark wrote:
> Hey everyone!
>
> I'm getting a crash course in Perl scripts at work right now and I've hit
> a snag.
>
> Is there anyway to similulate or pass a df -k command in a perl script?
> Specifically, I need to find the percent of capacity occupied on the disk.
> I've tried to use stat but it isn't supplying the info I need.
>
> Thanks in advance!
>
> --Mark Witt-- --"Psychiatrists say that 1 of 4--
> --mc-witt@students.uiuc.edu-- --people are mentally ill. Check 3--
> --www.students.uiuc.edu/~mc-witt-- --friends. If they're O.K., you're it."--
------------------------------
Date: 26 Feb 1998 00:27:36 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Newbie Question: df in a perl script
Message-Id: <6d2cto$29b$3@comdyn.comdyn.com.au>
In article <Pine.SOL.3.96.980225172653.8611A-100000@ux9.cso.uiuc.edu>,
Mark <mc-witt@students.uiuc.edu> writes:
> Is there anyway to similulate or pass a df -k command in a perl script?
> Specifically, I need to find the percent of capacity occupied on the disk.
> I've tried to use stat but it isn't supplying the info I need.
Short of executing df -k and capturing its output, no reasonable ones.
perldoc perlop
look for qx/STRING/ and `STRING`
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | I'm just very selective about what I
Commercial Dynamics Pty. Ltd. | accept as reality - Calvin
NSW, Australia |
------------------------------
Date: 26 Feb 98 01:02:12 GMT
From: "TomH" <beans@bedford.net>
Subject: Re: No. of days??
Message-Id: <01bd41ee$dcc71b60$139163ce@beans.bedford.net>
Don't forget to deal with the sixteenth century problem, when the Pope
decreed (in 1582) that the day after Oct 5 would be Oct 17.
...
> I am unable to find a way to calculate the nos. of days from today from
any
> particular day in the past or the future. can any kind soul please help.
> the input format is yy/dd/mm or dd/mm/yy or mm/dd/yy
...
------------------------------
Date: Wed, 25 Feb 1998 18:36:57 -0800
From: Jim Earnest <jwearnes@flash.net>
Subject: PASSWORD update utility for SunOS4.1.4/OpenVMS 6.2
Message-Id: <34F4D549.2BFB@flash.net>
Is it possible to construct a PERL app that will allow password updates
across SunOS and OpenVMS platforms.
For instance, Write a PERL app in OpenVMS that allows the user to enter
a password then once the OpenVMS system password has been updated,
encrypt(encode) the password and then send to the SunOS system and add
to the password file. Does this sound like a valid approach?
Thanks
Confused and Befuddled
------------------------------
Date: Wed, 25 Feb 1998 17:11:44 -0800
From: rdm@cfcl.com (Rich Morin)
Subject: Perl and/or C parsing code, in Perl?
Message-Id: <rdm-2502981712000001@140.174.42.30>
I'm interested in being able to find the beginnings and endings of blocks,
as wall as definitions of (and references to) subroutines. (I'm using the
information to drive an experimental code browser.) The output, FWIW, will
look like:
# test.pl+m - meta file for test.pl
B 7 23 # if () {}
B 13 15 17 # if () {} else {}
B 23 25 27 29 # if () {} elsif () {} else {}
L 24 15 5 4 # substr(line_24,15,5) links to line 4
L 24 15 5 4 foo # substr(line_24,15,5) links to line 4 in file foo
I played around a little with some Perl code to do this and found it a bit
tricky to get right (!). I then looked around a bit in the CPAN, but didn't
find anything that seemed particualrly relevant. So, I'm asking for pointers.
Thanks, Rich
------------------------------
Date: Wed, 25 Feb 1998 20:35:47 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
To: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: POD style comments revisited
Message-Id: <34F4C6F5.F607E141@coos.dartmouth.edu>
[posted and mailed]
Tom Christiansen wrote:
>
> In comp.lang.perl.misc, rjk@coos.dartmouth.edu writes:
> :Now, replace those #'s with the easier to maintain POD-style comments, and:
> :
> :~> cat temp2
> :$a = (
> :=head1
> :blah
> :=cut
> :1);
> :~> perl temp2
> :syntax error at temp2 line 2, near "="
>
> man perlsyn:
>
> Perl has a mechanism for intermixing documentation with source code.
> While it's expecting the beginning of a new statement, if the compiler
> encounters a line that begins with an equal sign and a word, like this
>
> Notice the "expecting new statement" part.
Which is why Perl should have a true multi-line commenting syntax.
An example of its usefulness:
$guess =
'some complex expression' ?
'a tricky ' .
'multi-line expression' :
'another expression';
Now, suppose I think of another way to do the tricky multiline expression, but
I want to leave the old version there in a comment, in case I decide to go
back to to it.
I could do this:
$guess =
'some complex expression' ?
# 'a tricky ' .
# 'multi-line expression' :
'tricky expression, take two' :
'another expression';
But I cannot do this:
$guess =
'some complex expression' ?
=comment
'a tricky ' .
'multi-line expression' :
=cut
'tricky expression, take two' :
'another expression';
Instead, I'd have to do it like so:
=comment
$guess =
'some complex expression' ?
'a tricky multi-line ' .
'expression' :
=cut
$guess =
'some complex expression' ?
'tricky expression, take two' :
'another expression';
Which forces me to duplicate some complex expression. How annoying.
--
_ / ' _ / rjk@coos.dartmouth.edu
( /)//)//)(//)/( chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
It's funny 'cause it's true ... and vice versa.
------------------------------
Date: Wed, 25 Feb 1998 20:45:42 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: reg expression help..
Message-Id: <34F4C948.D80A1B3E@coos.dartmouth.edu>
Cameron Kaiser wrote:
>
> alex@gossamer-threads.com (Alex Krohn) writes:
>
> >eval { $match = ($values[$field] =~ /$expr/) };
> >
> >Does putting an eval in there every time make
> >things worse then before?
>
> If eval is being looped around, yes. eval in a loop degrades runtime because
> the block has to be recompiled each time. You should put the loop in the
> eval instead.
Programming Perl, 2nd Ed, pg 161:
eval
...
If the code to be executed doesn't vary, you should use the eval BLOCK
form to trap runtime errors; *the code in the block is compiled only
once rather than on each execution*, yielding greater efficiency.
...
[my emphasis]
--
_ / ' _ / rjk@coos.dartmouth.edu
( /)//)//)(//)/( chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
It's funny 'cause it's true ... and vice versa.
------------------------------
Date: Wed, 25 Feb 1998 19:59:43 -0500
From: Thieu <tcam@ca.ibm.com>
Subject: Running a perl script on Windows 95
Message-Id: <34F4BE7E.17275026@ca.ibm.com>
I have a Perl script that is running fine on UNIX. I now want to run it
on Windows 95 but it is not being executed at all. I am suspecting that
it cannot even find the Windows version Perl interpreter that I
installed. What is the Windows equivalent of the first line used for
UNIX (#!/usr/local/bin/perl) that tells where the Perl interpreter is?
Any other details that I should pay attention to as well? Thanks.
------------------------------
Date: Wed, 25 Feb 1998 18:37:23 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: sorting array
Message-Id: <34F4C749.D39A9027@5sigma.com>
Use my Sort::Fields module, which is designed to do exactly this.
-joseph
Brian Charles wrote:
>
> Hi,
> I have a file with the following info that I would like to hash:
> lastname|firstname|email|code
>
> Right now I have a hash with a key and value and it sorts fine, but how
> do I have more than one value? Just point me in the right direction.
--
Joseph N. Hall, prop., 5 Sigma Productions mailto:joseph@5sigma.com
Author, Effective Perl Programming . . . . . http://www.effectiveperl.com
Perl Training . . . . . . . . . . . . . . . http://www.perltraining.com
------------------------------
Date: Wed, 25 Feb 1998 20:16:09 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: The Ineffable Tom C.
Message-Id: <34F4C259.F16EAFC1@coos.dartmouth.edu>
Tom Christiansen wrote:
>
> dos2unix("elitist") => "competant"
> unix2dos("competant") => "elitist"
Hope I'm not being elitist, but as a competent speller I thought I'd point out
that "competant" is not the correct spelling. :-)
--
_ / ' _ / rjk@coos.dartmouth.edu
( /)//)//)(//)/( chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
It's funny 'cause it's true ... and vice versa.
------------------------------
Date: Wed, 25 Feb 1998 20:21:15 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: The Ineffable Tom C.
Message-Id: <34F4C38C.9B37E881@coos.dartmouth.edu>
Jeeves wrote:
>
> isn't flaming supposed to be nearly-mindless, degenerate
> insults attacking another's character (much like the subject of this post
> insinuates)?
Do you even know what "ineffable" means? Perhaps you should go look it up.
Did you even read the post which started this thread? It was not an attack on
Tom C.; it was in defense of him! ("Tom has knowledge and experience that few
others participating in this group can equal." End quote.)
--
_ / ' _ / rjk@coos.dartmouth.edu
( /)//)//)(//)/( chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
It's funny 'cause it's true ... and vice versa.
------------------------------
Date: 26 Feb 1998 00:19:40 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Unwanted Character Displays
Message-Id: <6d2ces$29b$1@comdyn.comdyn.com.au>
In article <6d24rk$vqp$1@nnrp1.dejanews.com>,
bfredett@sprynet.com writes:
> Greetings group.
>
> I'm extremely new to Perl so take it easy on me. (~_^) Thanks to everyone
> for their pointers to resources and FAQ's...they were a big help.
>
> I have this code to read in a text file and store it in a variable:
>
> my $headline = open IN, "headline.txt" || die $!;
> while (<IN>) {
> $headline .= $_;
> }
> close(IN);
>
> $foo{test} = $headline;
>
> Then in an HTML template, $headline is printed with %%%test%%%. What
> I want to happen does except for a number 1 appears in the html.
You assign the return value of the open to $headline. That's the 1.
try
$headline = "":
open(IN, "headline.txt") || die "Cannot open headline.txt: $!";
while (<IN>) { $headline .= $_ }
close (IN);
or,
open(IN, "headline.txt") || die "Cannot open headline.txt: $!";
{ local ($/) = undef; $headline = <IN> }
close (IN);
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | If at first you don't succeed, try
Commercial Dynamics Pty. Ltd. | again. Then quit; there's no use being
NSW, Australia | a damn fool about it.
------------------------------
Date: Wed, 25 Feb 1998 20:36:29 -0500
From: mshavel@erols.com (Michael Shavel)
Subject: use system or backticks??
Message-Id: <mshavel-2502982036310001@130.9.16.207>
HI
I have to execute an sql statement from a perl script.
I have created a small script that has only this line it it:
`sqr trsdmp.sqt user/pass -RT -F/export/transfer/records.txt 02/24/1998`;
the script works fine and generates the file I need it to generate.
My question is, should I be using something like "system" to call this
statement or are the backticks the way to go. Also could someone please
explain the difference between the backticks and using "system". I looked
in the Blue camel book but did not get as clear an answer as I needed.
Thanks very much
Mike Shavel
mshavel@erols.com
------------------------------
Date: Wed, 25 Feb 1998 09:03:39 +0000
From: Glenn West <westxga@ptsc.slg.eds.com>
Subject: Re: Verifying a form field
Message-Id: <34F3DE6B.3515@ptsc.slg.eds.com>
Cactus wrote:
>
> Hello, I'm writing a Perl script to read in a number from the
> query_string and verifly that it is only a number and no letters or
> neg-nums. Any clues as to how I can verify this?
>
> $order = $ENV{'QUERY_STRING'};
> ($Label,$Amount) = split(/=/,$order);
>
> #if($Amount)is a number!
>
if ($Amount =~ /^[0-9]+$/) {
print "$Amount is all digits\n";
}
else {
print "$Amount is not all digits\n";
}
------------------------------
Date: 25 Feb 1998 23:31:27 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Why install perl?
Message-Id: <6d29kf$1t1$7@comdyn.comdyn.com.au>
In article <34fa83e8.107643141@news.cent.com>,
me@here.com (steve) writes:
> As is, on your PC you can only run perl scripts from the command line,
> DOS promt. If you program your scripts to work on your PC, then they
> wont work on the Web server (from a browser) unless you modify them.
> However, it is a good idea to install Perl on your PC anyway as it
Huh?
Unless you're doing something which is very systems specific to DOS,
your scripts should run on any web server that can run perl scripts.
Any issues that might arise are web server configuration, OS specific
stuff (which you should not be using anyway), or permission problems.
None of these have anything to do with perl.
> will give you a better understanding of PERL in the long run and you
> also get the benefit of using PERL on your PC, it can be very useful
> some times.
It's perl or Perl, never PERL.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | If it isn't broken, it doesn't have
Commercial Dynamics Pty. Ltd. | enough features yet.
NSW, Australia |
------------------------------
Date: Thu, 26 Feb 1998 00:42:31 GMT
From: me@here.com (steve)
Subject: Re: Why PERL? [Re: Beginner in trouble]
Message-Id: <3506ba5c.121585458@news.cent.com>
that ain't nothing, my wife asked me what SEX was.
On Wed, 25 Feb 1998 09:48:27 -0600, mgscheue@io.com wrote:
>In article <34F1EA49.2CCA32BB@5sigma.com>,
> joseph@5sigma.com wrote:
>>
>> Something I've always wondered is where people get the
>> uppercase PERL thing from. Any ideas?
>
>I've noticed an odd tendency for people to think all short, computer-related
>terms must be acronyms. I had a person hired to, uh, help us with
>documentation ask me to expand "CRAY" for her.
>
>Mark
>
>-----== Posted via Deja News, The Leader in Internet Discussion ==-----
>http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Thu, 26 Feb 1998 01:35:08 GMT
From: postmaster@127.0.0.1 (Robbie Baldock (real email address at foot of message))
Subject: Re: Win95 - Running scripts from browser?
Message-Id: <34f4c173.3863932@news.easynet.co.uk>
burt@ici.net (Burt Lewis) wrote:
>Hi,
>
>I just installed Perl in Windows95 and all is great running from the DOS
>prompt.
>
>Problem is when I try to open a script in my browser, it wants to open it in
>Notepad.
>
>I have the script in the bin directory. Is there something I'm missing or
>need to do to get this to execute via a browser.
Well, you need to fire it up with a link or a <FORM>.
Robbie
----------------------------------
Robbie Baldock
rcb@easynet.co.uk
http://easyweb.easynet.co.uk/~rcb/
----------------------------------
------------------------------
Date: 26 Feb 1998 00:05:54 GMT
From: kfox@pt0204.pto.ford.com (Ken Fox)
Subject: Re: XS dynamic loader: how to push C args?
Message-Id: <6d2bl2$eou6@eccws1.dearborn.ford.com>
Steve Fink <sfink@cs.berkeley.edu> writes:
> I am trying to write an XS module that will allow something like:
>
> load_function('sine', "/lib/libm.so", "sin", [ 'double' ]);
> $x = sine(3.14);
>
> It's all easy to do (in fact, the above works, and took me about 15
> minutes to get working last night), except for passing the arguments to
> the C function.
What you're doing might have been done already by John Tobey. Check out
his C::DynaLib module. You can find this on CPAN.
Another place to look is Anthony Green's libffi. You can find this
at <http://www.cygnus.com/~green/libffi.html>. This library uses
custom assembler code to handle the C stack on the x86, sparc, MIPS,
Alpha, m68k and PowerPC.
Lastly, you've got to ask yourself if you *really* want to do this.
Why not just write an XS file by scanning the library and/or headers
and dumping custom code. Compile and install it once and all the
run-time work is eliminated. Of course, I've rarely seen a library
where the C API is what a Perl programmer expects. "Huh? free()?
What's that?"
> Probably the wrong place to be asking, but...
comp.lang.perl.modules would probably be better.
- Ken
--
Ken Fox (kfox@ford.com) | My opinions or statements do
| not represent those of, nor are
Ford Motor Company, Powertrain | endorsed by, Ford Motor Company.
Analytical Powertrain Methods Department |
Software Development Section | "Is this some sort of trick
| question or what?" -- Calvin
------------------------------
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 1976
**************************************