[13607] in Perl-Users-Digest
Perl-Users Digest, Issue: 1017 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 7 20:06:35 1999
Date: Thu, 7 Oct 1999 17:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <939341111-v9-i1017@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 7 Oct 1999 Volume: 9 Number: 1017
Today's topics:
Re: a newbie perl question (fwd) <makkulka@cisco.com>
Re: a newbie perl question (fwd) (Craig Berry)
Re: a newbie perl question (fwd) <emschwar@rmi.net>
Re: bug or feature? <ltl@rgsun5.viasystems.com>
Re: bug or feature? <uri@sysarch.com>
Re: Delete a line in a file <laurensmith@sprynet.com>
Re: Delete a line in a file <dove@synopsys.com>
Re: Delete a line in a file <sjs@yorku.ca>
Re: Does anyone know how to do ftp in perl? <dove@synopsys.com>
fdf toolkit and perl <darnold@northcoast.com>
Re: Given $fs{usr}{local}=1234, what does $fs{usr} cont <rick.delaney@home.com>
Re: Given $fs{usr}{local}=1234, what does $fs{usr} cont <mike@crusaders.no>
Re: giving a file a variable name <kpmonroe@unity.ncsu.edu>
Re: giving a file a variable name <kpmonroe@unity.ncsu.edu>
Re: Help : Read in a file.list then copy <cassell@mail.cor.epa.gov>
Re: html tables <cassell@mail.cor.epa.gov>
Re: Looking for a perl version?? (Martien Verbruggen)
Re: mkdir... and then!? (Tad McClellan)
overly simple question (XenoSage)
Re: overly simple question (Martien Verbruggen)
Re: overly simple question <laurensmith@sprynet.com>
Re: overly simple question (Craig Berry)
Perl Cookbook Chapter 14 question? <jrw@worldnet.att.net>
Re: perldoc -q <laurensmith@sprynet.com>
Re: Please compare and contrast C and Perl. luvisi@andru.sonoma.edu
Possible to Protect Code?? <vivekvp@spliced.com>
Re: set startup page <laurensmith@sprynet.com>
Re: set startup page <makkulka@cisco.com>
Re: set startup page <sjohns17@uic.edu>
Re: Test if file contains certain text <dove@synopsys.com>
Re: tool to convert BMPs to GIFs programatically? (Martien Verbruggen)
Re: tool to convert BMPs to GIFs programatically? (Martien Verbruggen)
Using a regexp in an index function, can it be done? <jwarthur@prokofiev.fccc.edu>
Re: Using a regexp in an index function, can it be done (Larry Rosler)
Re: We do complex Perl Programming (Craig Berry)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 07 Oct 1999 14:56:08 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: a newbie perl question (fwd)
Message-Id: <37FD16F8.9236107D@cisco.com>
{ Eric The Read wrote:
> This is all very bad. It doesn't handle the case of if you read less
> than the CONTENT_LENGTH number of bytes correctly...{snipp}
My response is not directly related to this thread of discussion. But it might
interest you to know that CGI.pm does not handle this either.
--
------------------------------
Date: Thu, 07 Oct 1999 22:29:54 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: a newbie perl question (fwd)
Message-Id: <rvq7n2f3d6e34@corp.supernews.com>
Eric White (ewhite@guy.ssc.wisc.edu) wrote:
: # print "$FORM{"email"}";
Note that you're using " for both your string delimiter and around the
hash index. To perl, this looks like a request to print "$FORM{", the
bareword email, and "}"...which not surprisingly causes complaints. Note
that simple hash indices don't need to be quoted. Note also that
interpolating the value of a single scalar with nothing else in the string
is pointless busywork. Run tr/"//d over the above expression and be
happy. :)
Further note: Don't reinvent the wheel, especially if you leave out
spokes and make the rim octagonal. Use CGI.pm, not a hand-rolled
solution, for CGI parm parsing.
--
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| "There it is; take it." - William Mulholland
------------------------------
Date: 07 Oct 1999 16:31:37 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: a newbie perl question (fwd)
Message-Id: <xkf7lkyajli.fsf@valdemar.col.hp.com>
Makarand Kulkarni <makkulka@cisco.com> writes:
> { Eric The Read wrote:
>
> > This is all very bad. It doesn't handle the case of if you read less
> > than the CONTENT_LENGTH number of bytes correctly...{snipp}
>
> My response is not directly related to this thread of discussion. But it might
> interest you to know that CGI.pm does not handle this either.
Thanks; I'll submit a patch later this week.
-=Eric
--
"Cutting the space budget really restores my faith in humanity. It
eliminates dreams, goals, and ideals and lets us get straight to the
business of hate, debauchery, and self-annihilation."
-- Johnny Hart
------------------------------
Date: 7 Oct 1999 22:37:05 GMT
From: lt lindley <ltl@rgsun5.viasystems.com>
Subject: Re: bug or feature?
Message-Id: <7tj7ah$7cc$1@rguxd.viasystems.com>
Ilya <ilya@speakeasy.org> wrote:
:>Can you possibly be any more helpful?
Ah oh! Baby seal bites. uri will come back with his club. It's
going to get ugly. I think I'll go get some popcorn then settle
down to watch.
--
// Lee.Lindley /// I used to think that being right was everything.
// @bigfoot.com /// Then I matured into the realization that getting
//////////////////// along was more important. Except on usenet.
------------------------------
Date: 07 Oct 1999 19:54:49 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: bug or feature?
Message-Id: <x7u2o2ohfa.fsf@home.sysarch.com>
>>>>> "I" == Ilya <ilya@speakeasy.org> writes:
I> Uri Guttman <uri@sysarch.com> wrote:
AK> *shrug*
>> try shouldering more documentation before shrugging your shoulders.
I> Can you possibly be any more helpful?
<this is for lindley>
can you possibly be more clueless? thank the perl gods that the other
ilya signs with his last name so we can filter you out.
do you want every newbie who has broken code to blame perl bugs for his
problems? are you going to answer each and every one of them with the
correct answer? you didn't even answer this problem, just commented on
my followup. so you aren't any help at all. at least i pointed out to
the newbie that the problem was with his code and understanding of perl
and not with perl itself. in doing so i shrunk his bug space by a large
factor. instead of him wandering aimlessly and lost through perl's guts,
tracing down what happens to split '.', and learning that it match all
chars and it is not a bug, he might actually go rtfm and learn about
regexes and more.
and here is a recent helpful comment from you:
The one book that covers it really well is: _Perl By Example_ by Quigley. The
_Perl Cookbook_ is also excellent. I somehow have not found much use for the
Camel book.
interesting how the camel was no good for you but the by example is. i
wish i could get a copy for my perl books page. i would take great glee
in shredding it. the TOC alone
(http://www.prenhall.com/books/ptr_0136556892.html) looks piss ass
poor. the fact that it mentions the cgi-lib.pl library is luser enough.
so your word doesn't carry much around here. don't go away, but do try
to learn stuff before you comment on what others do here. bad answers and
bad book referals are worse than silence. allowing newbies to think that
basic perl features are bugs is even worse than that.
how was that, lindley?
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Thu, 7 Oct 1999 14:51:31 -0700
From: "Lauren Smith" <laurensmith@sprynet.com>
Subject: Re: Delete a line in a file
Message-Id: <7tj4m7$jod$1@brokaw.wa.com>
Lauren Smith wrote in message <7tipv6$6ut$1@brokaw.wa.com>...
>
>At your prompt, type:
>perldoc -q perldoc -q "delete a line in a file"
No, type:
perldoc -q "delete a line in a file"
I must have been daydreaming...
>
>Lauren
>
>
------------------------------
Date: Thu, 07 Oct 1999 15:54:19 -0700
From: David Amann <dove@synopsys.com>
Subject: Re: Delete a line in a file
Message-Id: <37FD249B.36B8DC93@synopsys.com>
Hi Gaetan,
Gaetan wrote:
> What can i do to delete just one line in a file.
What I would do is the following;
1. Read in the file to delete the line from line by line
2. Write each line to the temp file unless it matches the line to
delete
3. Rename the temp file to the deleted file.
Here's a script which does that.
Hope that helps,
-=dav
#!/usr/local/bin/perl-5.004 -w
# Always use -w to catch errors.
#
# Author: Dav Amann (dove@synopsys.com)
# Version: 1.0
#
use strict; # Always use strict.
my $file_path = "delete.txt";
my $tmp_path = "tmp.txt";
open (FILE, "$file_path") # Open file to delete
or die "Can't open $file_path: $!\n"; # line from.
open (TEMP, ">$tmp_path") # Open temp file to
or die "Can't open $tmp_path: $!\n"; # write to.
print "Enter text of line to delete: "; # Get line to delete
my $delete_line = <STDIN>;
chop $delete_line;
my $deleted = 0;
while (<FILE>) {
if ($_ !~ /^$delete_line$/ # If the line matches our
or $deleted > 0) { # deleted line and we haven't
print TEMP; # deleted before, print to
# our TEMP file.
} else {
$deleted++; # If we are deleting our line,
# increment deleted so we don't
} # delete again
}
# close our files;
close TEMP or die "Can't close $tmp_path: $!\n";
close FILE or die "Can't close $file_path: $!\n";
# rename our files and create a backup.
rename ($file_path, "$file_path.bak");
rename ($tmp_path, $file_path);
------------------------------
Date: 07 Oct 1999 19:58:04 -0500
From: Steven Smolinski <sjs@yorku.ca>
Subject: Re: Delete a line in a file
Message-Id: <m3670ifz37.fsf@hank.yorku.ca>
"Lauren Smith" <laurensmith@sprynet.com> writes:
> Lauren Smith wrote in message <7tipv6$6ut$1@brokaw.wa.com>...
> >
> >At your prompt, type:
> >perldoc -q perldoc -q "delete a line in a file"
>
> No, type:
> perldoc -q "delete a line in a file"
>
> I must have been daydreaming...
Actually, being a generous person, I typed that first line into
a terminal to see what it would do. And it worked! I got the same
FAQ in perlfaq5. I'm not exactly sure why, but it works.
Steve
------------------------------
Date: Thu, 07 Oct 1999 16:12:07 -0700
From: David Amann <dove@synopsys.com>
Subject: Re: Does anyone know how to do ftp in perl?
Message-Id: <37FD28C6.8E8D73CE@synopsys.com>
Hi,
cheis01@yahoo.com wrote:
> Does anyone know how to do ftp in perl?
You'll want to use the Net::FTP module that you can find at CPAN.
Here's a quick script that I copied out of Tom Christiansen and Nate
Torkington's "Perl Cookbook". (I haven't tested it, but it should help
you get started.)
use Net::FTP;
$ftp = Net::FTP->new("ftp.host.com") or die "Can't connect: $@\n";
$ftp->login($username, $password) or die "Can't login\n";
$ftp->cwd($directory) or die "Can't change dir\n";
$ftp->get($filename) or die "Can't get $filename\n";
$ftp->put($filename) or die "Can't put $filename\n";
Hope this helps,
-=dav
------------------------------
Date: Thu, 07 Oct 1999 16:19:00 -0700
From: David Arnold <darnold@northcoast.com>
Subject: fdf toolkit and perl
Message-Id: <37FD2A64.3532F236@northcoast.com>
I need help installing the fdftoolkit for perl. I am using ActiveState
perl and have followed the instructions in fdf.pm, but I cannot get
employee_query.pl to compile. I am getting
F:\StaffDevelopment\fdftoolkit\Samples\Perl\EmployeeInfoDemo\Win>perl
employee_q
uery.pl
Bareword "OLE::VT_UI1" not allowed while "strict subs" in use at
C:/Perl/lib/Acr
obat/FDF.pm line 203.
Compilation failed in require at employee_query.pl line 60.
BEGIN failed--compilation aborted at employee_query.pl line 60.
Email response appreciated.
--
David Arnold
College of the Redwoods
Mathematics Department
7351 Tompkins Hill Road
Eureka, CA 95501
(707) 476-4222
My Home Page
http://online.redwoods.cc.ca.us/instruct/darnold/index.htm
Ordinary Differential Equations Using Matlab
http://www.prenhall.com/books/esm_0130113816.html
------------------------------
Date: Thu, 07 Oct 1999 22:24:36 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Given $fs{usr}{local}=1234, what does $fs{usr} contain?
Message-Id: <37FD1DAB.C4E1D02C@home.com>
[posted & mailed]
Bill Huston wrote:
>
> | $fs{home}=12345; # contains a scalar value
> | $fs{home}{bhuston}=987; # clobbers it with a hashref???
> |
> | print "$fs{home}{bhuston}\n"; # prints 987...
> | print "$fs{home}\n"; # HUH!? Prints 12345!
>
>
> So, does $fs{home} contain a ref to a hash, or a scalar?
> Seems like it can contain both, if carefully constructed.
> Neither Data::Dumper nor the debugger reveal any ambiguities...
Try the 'V' command in the debugger and look very closely at all the
variables that are defined. Also try 'use strict' in your program.
These will reveal that you are using a symbolic reference when you write
$fs{home}{bhuston}
so that you are actually fetching the value associated with the key
'bhuston' from the hash, %12345.
> I would like to exploit this ambiguity to create a tree
> structure, where a node contains a scalar value *and*
> a reference to a hash containing names of child nodes.
This seems kind of silly to me since it can only lead to confusion like
above. Just use a proper data structure.
%data = ({ Scalar => $foo, Ref => \%bar }, ...)
perldoc perlref
perldoc perldsc
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Fri, 8 Oct 1999 00:47:45 +0200
From: "Trond Michelsen" <mike@crusaders.no>
Subject: Re: Given $fs{usr}{local}=1234, what does $fs{usr} contain?
Message-Id: <lm9L3.925$nU4.6247@news1.online.no>
Bill Huston <bhuston@matrix.eden.com> wrote in message
news:ug8L3.1173$oq.6482@newsfeed.slurp.net...
> Someone help me understand this:
> | $fs{home}=12345; # contains a scalar value
> | $fs{home}{bhuston}=987; # clobbers it with a hashref???
> | print "$fs{home}{bhuston}\n"; # prints 987...
> | print "$fs{home}\n"; # HUH!? Prints 12345!
> So, does $fs{home} contain a ref to a hash, or a scalar?
$fs{home} contains the scalar 12345
${ "12345" }{bhuston} holds the scalar 987
use strict refs would have caught this and given the warning:
Can't use string ("12345") as a HASH ref while "strict refs" in use at -
line 42.
-w and use strict are your friends
> Seems like it can contain both, if carefully constructed.
well, yeah, sortof... If you never change the value of $fs{home} once you've
set it.
I would use an arrayref:
$fs{home} = [12345, {bhuston => [987, undef]}];
> 1: What is going on here?
You're playing with symbolic references. This is a no-no unless you know
what you're doing and why you're doing it.
>| open P, "/usr/bin/du -k /|" or die;
>| @P=reverse <P>; # why must I reverse?
> 2: Why is the reverse needed?
well, du calculates the size of a directory based on the size of all
subdirectories, and it returnes the size of a directory as soon as it
finishes one. So - if you just want to insert the top-levels of each dir
before you insert each sub-dir, you have to read du's output backwards.
> 3: Is this a feature that I can depend on being in future releases?
I can't answer that, but I wouldn't use symbolic references like this. Well,
in this case you are almost guaranteed to screw up the results since you're
bound to have two or more directories that are the same size. You also loose
the advantage with one data-structure, so you can't just use Data::Dumper to
print all values of your data-structure.
Anyway - this is a "feature" you can't depend upon if you want to use it
like this.
--
Trond Michelsen
------------------------------
Date: Thu, 07 Oct 1999 10:38:33 -0400
From: Kevin Monroe <kpmonroe@unity.ncsu.edu>
Subject: Re: giving a file a variable name
Message-Id: <37FCB069.52310C80@unity.ncsu.edu>
Thank you for your assistance. This worked perfectly.
Yeah Im glad Im not George Jempty too. Dont want to get on a kill list.
thanks
kevin
------------------------------
Date: Thu, 07 Oct 1999 10:43:34 -0400
From: Kevin Monroe <kpmonroe@unity.ncsu.edu>
Subject: Re: giving a file a variable name
Message-Id: <37FCB196.C628A362@unity.ncsu.edu>
Thank you for your assistance. Your help is greatly appreciated. As I want to
learn how to fish for myself instead of being fed, could you elaborate on why
> __ @data = <ORIG>;
> __ splice (@data,0,3);
> __ foreach $line(@data){
> __ chop;
> __ print NEW "$line";
> ^ ^
> | |
>
> Don't do that.
this should not be done that way. Is it some faulty logic on my part. Or by doing
it another way I can get rid of the unneccessary loop?
>
>
> That's because you do something wrong. Look at the argument for the
> die function, that *will* do the interpolation. Can you see the
> difference in the two strings?
>
You are quite right, as Joe Kline and yourself have since enlightened me.
thanks again
kevin
------------------------------
Date: Thu, 07 Oct 1999 15:29:47 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Help : Read in a file.list then copy
Message-Id: <37FD1EDB.5D21043@mail.cor.epa.gov>
·sÄ_®q¼Ö¶é wrote:
>
> Hi,
>
> I am very new to perl but as I have to write a script that work on NT
> and UNIX so that I choose Perl.
Logical choice. Not your only option, though.
> Suppose I am in a dir: /usr/joe and I maintain a file called file.lst
> which contains tons of filename (without abs. path) in each line. I want
> to write a Perl script first to :
>
> read in file.lst in my current dir
Try this command at a command prompt on a machine where Perl
is installed:
perldoc -f open
perldoc -f close
> All the filename in file.lst are stored physcially in /usr/foo. I need
> to copy all the files to dir. /usr/boo.
>
> How to write this script ?
perldoc File::Copy
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Thu, 07 Oct 1999 15:12:00 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: html tables
Message-Id: <37FD1AB0.D777D789@mail.cor.epa.gov>
Tom Abbott wrote:
>
> Hi All:
Howdy:
> I want to handle parse html tables and output to a file or database. Is
> there a resource I can refer to for help on this??
You may find the Perl module HTML::Parser helpful here. You'll
have to subclass the method though.
Or you could try the SGMLS and SGMLS::Output modules, which let you
handle the output of bigtime SGML parsers like 'nsgmls'.
Or you could use one of the parsers available as Perl modules, like
Parse::Yapp [to name but one].
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Thu, 07 Oct 1999 23:58:25 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Looking for a perl version??
Message-Id: <BsaL3.38$u83.3748@nsw.nnrp.telstra.net>
On Thu, 07 Oct 1999 14:23:06 +0200,
Alexandre Amelin <aamelin@mmm.com> wrote:
> I'm looking for a hold version of perl for Windows :
> Version 4.0.1.8 Build 3 Patch level 36.
> (I need to use it for Tivoli integrations)
Any software that needs a version of perl _that_ old should not be
used. There are many problems with perls of that age, and they won't
be fixed.
> Some body knows where I can find it.
First, go to history.perl.org, and find out how old it is. Then go to
CERT, and find out how vulnerable those versions of perl are.
I am not joking. The version you are talking about is _ancient_. There
were even newer releases of perl 4 after that one.
Then you open a copy of the perl faq, and go to part 2, header:
Perl on the Net: FTP and WWW Access, last paragraph:
"http:/www.oasis.leo.org/perl/ has, amongst other things, source to
versions 1 through 5 of Perl."
> Please help me!!!
Please, don't beg. It's not endearing.
Martien
--
Martien Verbruggen |
Interactive Media Division | The gene pool could use a little
Commercial Dynamics Pty. Ltd. | chlorine.
NSW, Australia |
------------------------------
Date: Thu, 7 Oct 1999 14:36:44 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: mkdir... and then!?
Message-Id: <s7pit7.33m.ln@magna.metronet.com>
emlyn_a@my-deja.com wrote:
: I need to mkdir under an existing directory called "users" (in the root
: dir) using a $NewUser variable as the name.
mkdir "/users/$NewUser", 0755 or die "could not make directory $!";
: Creating the directory is no
: problem, except it doesn't create the directory UNDER "users", it just
: creates it in the root folder.
We cannot explain unseen code.
If you show us the code that you have a problem with, we might
be able to help.
But you didn't.
So we can't.
:-(
: This is a problem, because then I need to create a new FILE within this
: newly-created directory. Is creating a new file (thefile.dat) under an
: existing directory done like this below?
: open (DATAFILE, ">/users/NewUser/thefile.dat")
^^^^^^^
Perl variables start with "funny characters", like a dollar sign.
So you don't have any variables there.
Is that what you wanted? (if so, you should have used single quotes).
And you should always, yes *always*, check the return value
from System Calls like open() and mkdir(), see above.
Really.
Always check the return value.
I mean it.
:-)
: Wouldn't a mkdir be similar?
Yes, see above.
: I'm sure this is simple to all you Perl gurus,
It would likely be simple for even a beginning Perl programmer
to help you, if you had included your code...
: but I'm having a really
: tough time telling perl to separate literal strings from paths (it
: creates a folder called "/users/$NewUser/"). I looked into the
: ENV{'PATH'}, but there are no clear examples of how this is used - and
^
: I've looked!
Huh?
$ENV{PATH} (it takes a "funny character" too) has nothing
to do with what you are doing.
The path affects executing of external programs, but you are
not using any external programs.
That's probably why you can't find examples that relate to
what you are doing, because the path does not relate to
what you are doing.
If you are not understanding how to do quoting in Perl, then
have a look at the "Quote and Quote-like Operators" section
in perlop.pod.
Of course, if there had been code, and if there had been a
problem with the quoting, we could have given you more
direct help.
But you didn't.
So we can't.
: Any help would be greatly appreciated.
Does your doctor tell you what's wrong with you without even
seeing you?
Does your mechanic tell you what's wrong with your car without
seeing it?
Does your programmer tell you what's wrong with your code without
seeing it?
The absolute best way to get an answer that directly relates to
your problem is to include a _short and complete_ program
that shows the problem you are having.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 07 Oct 1999 22:59:24 GMT
From: xenosage@aol.comNOSPAM (XenoSage)
Subject: overly simple question
Message-Id: <19991007185924.07990.00000263@ng-xb1.aol.com>
hello all,
I am currently learning BASIC after having learned html and java (odd order to
learn, I know, ) I have yet to find out how to run a perl program, I feel kind
of stupid asking how to do this as it should be quite simple but nothing I am
trying is working. If anyone could tell me how to make this work in a message
to xenosage @aol.com I would greatly appreciate it.
thanks,
-Grant
------------------------------
Date: Thu, 07 Oct 1999 23:28:50 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: overly simple question
Message-Id: <S0aL3.23$u83.2970@nsw.nnrp.telstra.net>
On 07 Oct 1999 22:59:24 GMT,
XenoSage <xenosage@aol.comNOSPAM> wrote:
> I am currently learning BASIC after having learned html and java
> (odd order to learn, I know, ) I have yet to find out how to run a
> perl program, I feel kind of stupid asking how to do this as it
> should be quite simple but nothing I am trying is working. If anyone
> could tell me how to make this work in a message
Huh? You're learning Basic, and therefore you need to know how to run
a perl program?
Never mind
You run a perl program by installing perl and typing
# perl program_file_name
On the more clever operating systems you can make the scripts
executables themselves.
If you want to know how to run it from Basic, please ask in a group
that talks about that.
> to xenosage @aol.com I would greatly appreciate it.
Nope. Post here, read here.
Martien
--
Martien Verbruggen |
Interactive Media Division | For heaven's sake, don't TRY to be
Commercial Dynamics Pty. Ltd. | cynical. It's perfectly easy to be
NSW, Australia | cynical.
------------------------------
Date: Thu, 7 Oct 1999 16:31:45 -0700
From: "Lauren Smith" <laurensmith@sprynet.com>
Subject: Re: overly simple question
Message-Id: <7tjah1$mbf$1@brokaw.wa.com>
XenoSage wrote in message
<19991007185924.07990.00000263@ng-xb1.aol.com>...
>hello all,
>I am currently learning BASIC after having learned html and java (odd
order to
>learn, I know, ) I have yet to find out how to run a perl program, I
feel kind
>of stupid asking how to do this as it should be quite simple but
nothing I am
>trying is working.
What have you tried so far?
Lauren
--
I can't believe any Perl book would leave such a thing out.
------------------------------
Date: Thu, 07 Oct 1999 23:48:02 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: overly simple question
Message-Id: <rvqc9ikcfc642@corp.supernews.com>
XenoSage (xenosage@aol.comNOSPAM) wrote:
: hello all,
: I am currently learning BASIC after having learned html and java (odd
: order to learn, I know, ) I have yet to find out how to run a perl
: program,
Well, that makes sense, given you've neither learned nor are currently
learning it. :)
: I feel kind of stupid asking how to do this as it should be quite simple
: but nothing I am trying is working.
See the 'perlrun' doc for details. In brief, there are two primary ways:
(1) Run perl manually, with your program's filename as an argument. If
your program is named 'hello', then entering 'perl hello' (minus the
quotes) at your shell prompt should compile/run hello, and its output
should appear. If this doesn't work, you probably don't have the perl
executable in your path, or some similar problem.
(2) On Unix-ish systems, you can use the "magic shebang line" at the
top of your source code to tell the shell that this is a Perl script
and automagically hand it to perl for processing. Typically, this
line should look like
#!/usr/bin/perl -w
Note that the -w is optional but strongly recommended (it turns on
compiler warnings), and that the specific path to the perl executable may
be different on your system. Having set up the magic shebang line, just
make your source file executable (chmod +x hello) and then enter 'hello'
(minus quotes) at the shell prompt. It should compile and run.
: If anyone could tell me how to make this work in a message
: to xenosage @aol.com I would greatly appreciate it.
Ask here, read the answer here. That way everybody gets to share the
knowledge (and correct wrong answers, too).
--
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| "There it is; take it." - William Mulholland
------------------------------
Date: Thu, 07 Oct 1999 03:35:40 -0400
From: "Jon R. Wright" <jrw@worldnet.att.net>
Subject: Perl Cookbook Chapter 14 question?
Message-Id: <37FC4D4C.918D7A73@worldnet.att.net>
In working through some of the examples in the Perl Cookbook, I've come
across something that I can't seem to get to work.
It's the ggh example from Chapter 14. This example uses the DB_File
module to read Netscape's history file.
I'm using the downloaded code from www.ora.com, so I don't think it's a
coding error I've made. I'm running OpenLinux with Perl as in
(jrw@sierra ~)$ perl -v
This is perl, version 5.005_02 built for i386-linux-thread
Copyright 1987-1998, Larry Wall
<snip>
The output from the file utility is
(jrw@sierra ~)$ file history.db
history.db: Berkeley DB 1.85 Hash/Little Endian (Version 2, Bucket Size
4096, Bucket Shift 12, Directory Size 256, Segment Size 256, Segment
Shift 8, Overflow Point 7, Last Freed 20, Max Bucket 94, High Mask 0x7f,
Low Mask 0x3f, Fill Factor 53, Number of Keys 3718)
(jrw@sierra ~)$
The output from ggh
(jrw@sierra ~)$ ggh -database history.db
can't dbmopen history.db: File exists at /home/jrw/bin/ggh line 47.
(jrw@noname ~)$
Finally, line 47 (the offending line) is
die "can't dbmopen $HISTORY: $!" unless dbmopen %hist_db, $HISTORY,
0666;
I've been staring at this for a while now. And searching for hints in
Programming Perl to no avail.
Is there a kind person out there that can give me a hint?
Thanks,
Jon
------------------------------
Date: Thu, 7 Oct 1999 15:05:36 -0700
From: "Lauren Smith" <laurensmith@sprynet.com>
Subject: Re: perldoc -q
Message-Id: <7tj5gg$54c$1@brokaw.wa.com>
Bob Wilcox wrote in message <939332782.145198@news.tir.com>...
>When I try something like perldoc -q perldoc -q "delete a line in a
file"
>that someone recently suggested, or any perldoc -q command, I get an
invalid
>option message. perldoc tells me the correct option is -f. Is this an
old
>version on our machine maybe?
I knew that would come back to byte me. I just posted a followup to
that with the correct syntax:
perldoc -q "delete a line in a file"
try: 'perldoc perldoc' to find out more about what it can do for you
Lauren
------------------------------
Date: 07 Oct 1999 16:17:57 -0700
From: luvisi@andru.sonoma.edu
Subject: Re: Please compare and contrast C and Perl.
Message-Id: <m2so3m221m.fsf@andru.sonoma.edu>
Neil <neil@pacifier.com> writes:
> Please compare and contrast the two languages.
C is almost portable assembly. It allows you to work with bytes and
bits and specific addresses easily. By default, any use you make of
dynamic memory requires explicit allocation and deallocation of
memory. This makes things complicated when you want to share pieces
of dynamic memory between different data structures. C doesn't have
any notion of a "string". People use library and OS functions which
use a null terminated array of chars as a string. This means you
can't normally have a null inside a string, so if you need to deal
with pieces of arbitrary data, you have to roll your own buffering and
manipulation system.
C works especially well when writing: small systems, speed critical
code, low level code (tweaking bits and bytes on hardware and such),
small programs and small operating systems. It just so happens these
are the things its inventors needed to do.
Perl handles memory management almost automatically for you by using
"reference counts" on each piece of data, which keep track of how many
data structures it is in, and releasing it when the count reaches
zero. I say "almost automatically" because when working with cyclic
or recursive data structures, you have to break the cycle before you
give up your reference to them if you want perl to release the memory.
Perl has decent built in handling of strings and large, weird data
structures. Perl is ok at handling large projects in an object
oriented fashion. Perl is competent at number crunching, file
manipulation, running other programs, functional programming, and
manipulating binary structures.
Personally, I believe the great thing about perl isn't any one ability
it has, but the fact that it is okay at a ton of things, making it
especially useful for integration type work, of which there is quite a
bit floating around. For each of these domains, I believe there is at
least one other language which is better than perl (this list is not
meant to be comprehensive, just illustrative)...
file manipulation: find + sh
running other programs: sh
string manipulation: icon
object oriented programming: C++, Eiffel, Pike, and any other language
that doesn't require that you know the names of a superclass's private
variables when subclassing in order to avoid clobbering them (note:
this kind of includes python, with it's support for automatically
mangling _foo into modulename_foo, but I'm not particularly fond of
that scheme either)
functional programming: scheme
bit twiddling devices and such: C
fast number crunching: C, FORTRAN, Pascal, etc.
big number crunching: bc, dc, icon, COBOL, Mathematica, and anything
else with arbitrary precision built in (note: this isn't all that
important since big number modules are available as an add on for perl)
...but when I need to do more than one type of task at a time, I
find that perl is good enough at each task to do what I need with a
fairly small number of keystrokes, and it's easier to just write the
whole thing in perl than to write three or four different programs or
modules in different languages and interface them, especially when the
tasks are intermingled, as they are with integration type work like
CGI and database programming. It just so happens this is the sort of
thing Larry Wall needed to do when he invented perl (integration work,
not CGI and database programming). Perl also has CPAN, the
Comprehensive Perl Archive Network, which is a huge collection of
incredibly useful modules already written for perl. Many people
consider CPAN to be the biggest advantage in writing programs with
perl.
> I am aware that Larry Wall wrote Perl in C.
yup.
have fun,
Andru
--
--------------------------------------------------------------------------
| Andru Luvisi | http://libweb.sonoma.edu/ |
| Programmer/Analyst | Library Resources Online |
| Ruben Salazar Library |-----------------------------------------|
| Sonoma State University | http://www.belleprovence.com/ |
| luvisi@andru.sonoma.edu | Textile imports from Provence, France |
--------------------------------------------------------------------------
------------------------------
Date: Thu, 07 Oct 1999 22:04:56 GMT
From: vivekvp <vivekvp@spliced.com>
Subject: Possible to Protect Code??
Message-Id: <7tj5du$d0q$1@nnrp1.deja.com>
Hello,
I have a perl script that has variables to set up at the top of the
script. Then there is a section that states it is not to be changed -
changing data might cause the script not to function. All I am trying
to do is change the spelling of a couple of words with in html brackets
<> ie. favor can be changed to favour. when i upload the script -
reset the permissions - i get an internal 500 premature end of headers 0
but when i re upload the script - changing the word 'favour' back to
favor - it works!
is it possible to protect code against modification? it look like plain
text to me - but all the code that should not be altered is bunched
together - no spaces or separation by lines...
any help - please email.
Thanks!
v
--
May your bad hair days be few. This does not
apply to the bald.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 7 Oct 1999 15:33:29 -0700
From: "Lauren Smith" <laurensmith@sprynet.com>
Subject: Re: set startup page
Message-Id: <7tj73p$j6n$1@brokaw.wa.com>
Makarand Kulkarni wrote in message <37FCF2AC.5C1A777B@cisco.com>...
>{ a1234_ec@yahoo.com wrote:
>
>> Is it possible to write a perl script to automatically set a
browser's
>> startup page?
>
>No.
I wouldn't go that far.
#!perl -w
use strict;
my $browser = "explorer"; # Or Navigator, or Opera, or Lynx, etc.
my $startpage = "http://somelink.com";
exec("$browser $startpage"); # Viola!
;-)
Lauren
------------------------------
Date: Thu, 07 Oct 1999 15:43:42 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: set startup page
Message-Id: <37FD221D.FE188300@cisco.com>
{ Lauren Smith wrote:
> I wouldn't go that far.
> #!perl -w
> use strict;
> my $browser = "explorer"; # Or Navigator, or Opera, or Lynx, etc.
> my $startpage = "http://somelink.com";
> exec("$browser $startpage"); # Viola!
>
You are right. What I was saying is that you cannot change the "home
page " setting
of some other person's browser i.e I have a script P on a website and
then
if you run P as a CGI using your browser then P changes the setting of
the home-page
on the visitor's browser itself..
--
------------------------------
Date: Thu, 7 Oct 1999 17:54:14 -0500
From: Seth David Johnson <sjohns17@uic.edu>
Subject: Re: set startup page
Message-Id: <Pine.A41.4.10.9910071753210.126932-100000@tigger.cc.uic.edu>
On Thu, 7 Oct 1999, Lauren Smith wrote:
> #!perl -w
> use strict;
>
> my $browser = "explorer"; # Or Navigator, or Opera, or Lynx, etc.
> my $startpage = "http://somelink.com";
> exec("$browser $startpage"); # Viola!
Lauren++
Cute :)
-Seth
------------------------------
Date: Thu, 07 Oct 1999 15:35:51 -0700
From: David Amann <dove@synopsys.com>
Subject: Re: Test if file contains certain text
Message-Id: <37FD2047.3CC7D498@synopsys.com>
Hi Tom,
tomschenk@my-deja.com wrote:
> So--I am trying to write a script which accepts form input from a web
> page, then checks a text file to see if that text is already in that
> file. If it isn't, I want to add it to the end of the file.
Here's a script I wrote which should do what you want. The key is to read
the file into a hash table (in this case %lines) so that you can check for
existence using the 'exists' function.
Hope this helps,
-=dav
#!/usr/local/bin/perl-5.004 -w
# Always use -w to catch errors.
#
# Author: Dav Amann (dove@synopsys.com)
# Version: 1.0
#
use strict; # Always use strict.
use CGI qw/:all/;
use CGI::Carp qw/fatalsToBrowser/;
my $file = "addwords.txt";
print header(), start_html("-title" => "Example");
$_ = param('action');
CASE: {
/^add/i and do { add_to_list(param('word'));
print_form();
last CASE;};
# default case
print_form();
}
sub print_form {
# Print out form to add word
print start_form(),
textfield("-name" => "word"),
submit("-name" => "action",
"-value" => "Add to List\n"),
end_form();
# Print out contents of file
if (-e $file) { # Check to see if
# file exists.
open (FILE, "$file")
or die "Can't open $file: $!\n";
print "<PRE>\n";
while (<FILE>) {
print;
}
print "</PRE>";
close FILE
or die "Can't close $file: $!\n";
}
}
sub add_to_list {
my $word = shift;
my %lines;
# Read file into hash table %lines to check for existence.
if (-e $file) { # Make sure file exists
open (FILE, "$file")
or die "Can't open $file: $!\n";
while (<FILE>) {
chop; # Chop new line
$lines{$_}++; # Read into hash table
}
close FILE
or die "Can't close $file: $!\n";
}
# add file if not already in file
if (!exists $lines{$word}) { # Check to see if line
# exists
open (FILE, ">>$file") # Open in append mode
or die "Can't open $file; $!\n";
print FILE "$word\n" # Print appended word
or die "Can't print $file: $!\n";
close FILE
or die "Can't close $file: $!\n";
}
}
------------------------------
Date: Thu, 07 Oct 1999 23:14:00 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: tool to convert BMPs to GIFs programatically?
Message-Id: <YO9L3.19$u83.2970@nsw.nnrp.telstra.net>
On 7 Oct 1999 15:14:55 -0500,
Abigail <abigail@delanet.com> wrote:
> No, I was referring to the fact that Unisys only wants money if you use
> their compression technique to create images. Viewers are royalty free.
> I don't know what their POV is on translators. And of course, there's no
> royalty to pay on free compression techniques. So, you can make freeware
> that supports GIFs, but you cannot do everything.
\begin{offtopic}
Well... It isn't explicitly stated, I believe that viewers are free.
Strictly speaking the viewers also implement the LZW compression
algorithm (for decompression), and are therefore subject to the
patent. Even though Unisys may at this moment in time not pursue that,
there is absolutely no guarantee that they won't in the future. They
used to not have a problem with LZW being used in PD software. They do
now. No guarantee they won't do another backflip.
\begin{rant}
I hope that people will finally start using PNG. It's better at many
things. I hope that people will finally start supporting MNG, just so
they can have their flamin' animations. Graphics on something as big
as the Web should not in any way be subject to one company's patents
and whims on the licencing issues involved.
If people are afraid of using PNG, then there is always the
possibility of doing GIF images with other compression techniques. And
once people rewrite their stuff, maybe they can also get rid of that
silly 256 colour limitation. It's not necessary.
\end{rant}
Unisys is added to the list of 'Evil ones'.
\end{offtopic}
Martien
--
Martien Verbruggen |
Interactive Media Division | Useful Statistic: 75% of the people
Commercial Dynamics Pty. Ltd. | make up 3/4 of the population.
NSW, Australia |
------------------------------
Date: Thu, 07 Oct 1999 23:39:15 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: tool to convert BMPs to GIFs programatically?
Message-Id: <DaaL3.30$u83.3748@nsw.nnrp.telstra.net>
On Thu, 07 Oct 1999 23:14:00 GMT,
Martien Verbruggen <mgjv@comdyn.com.au> wrote:
> Well... It isn't explicitly stated, I believe that viewers are free.
That sentence doesn't parse well, and in fact is not what I meant.
I meant: I do not believe that it is explicitly stated that viewers
implementing the LZW algorithm do not require a license.
The rest of the rant stands
Martien
--
Martien Verbruggen |
Interactive Media Division | You can't have everything, where would
Commercial Dynamics Pty. Ltd. | you put it?
NSW, Australia |
------------------------------
Date: Thu, 7 Oct 1999 18:07:54 -0400
From: "Jonathan W. Arthur" <jwarthur@prokofiev.fccc.edu>
Subject: Using a regexp in an index function, can it be done?
Message-Id: <Pine.SGI.4.10.9910071756520.262457-100000@prokofiev.fccc.edu>
Hello,
I need to know the position that a particular regular expression first
occurs in a line of characters. If I was looking for a particular string I
could find it easily with an index function thus:
$point = index($_, $string);
Since I am looking for a regexp I tried the analagous:
$point = index($_, /regexp/);
where "regexp" is the regular expression. This doesn't appear to work. Is
there a way I can work out where in $_ the regular expression first
matches?
Thanks,
Jonathan
------------------------------
Date: Thu, 7 Oct 1999 16:38:13 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Using a regexp in an index function, can it be done?
Message-Id: <MPG.1266cebf99e99ade98a059@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <Pine.SGI.4.10.9910071756520.262457-
100000@prokofiev.fccc.edu> on Thu, 7 Oct 1999 18:07:54 -0400, Jonathan
W. Arthur <jwarthur@prokofiev.fccc.edu> says...
> I need to know the position that a particular regular expression first
> occurs in a line of characters.
...
> ... Is there a way I can work out where in $_ the regular expression first
> matches?
#!/usr/local/bin/perl -w
use strict;
$_ = 'xyzxyzxyz';
my $pattern = 'zxy';
/$pattern/g; # Add 'o' modifier if $pattern never changes
print pos() - length $pattern, "\n";
__END__
Output:
2
Obviously, the pattern must match a fixed number of characters (i.e., no
* ? + {,} quantifiers).
perldoc -f pos
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 07 Oct 1999 23:14:47 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: We do complex Perl Programming
Message-Id: <rvqab7cjd6e84@corp.supernews.com>
Kent Perrier (kperrier@blkbox.com) wrote:
: > sehgal@del2.vsnl.net.in (Sahil) wrote in <7th2f6$n1u$1@news.vsnl.net.in>:
: > >We are an E-commerce based company and do any type of complex Perl
:
: You're E-commerce based? What city is that? I've never heard of it.
: Is it in the USA?
City of Commerce, California -- a tiny enclave embedded deep in the Los
Angeles metro area. Presumably their company is on the east side of town.
--
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| "There it is; take it." - William Mulholland
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 1017
**************************************