[8614] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 2231 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 2 09:07:41 1998

Date: Thu, 2 Apr 98 06:01:00 -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           Thu, 2 Apr 1998     Volume: 8 Number: 2231

Today's topics:
    Re: Bezier Perl code needed: have C source <vladimir@cs.ualberta.ca>
    Re: Data Structure for Input File <sneaker@mediaone.net>
    Re: Data Structure for Input File (TomH)
    Re: Data Structure for Input File <cnwetzel@linguistik.uni-erlangen.de>
        DBI & suidperl causes core dump (Igor Chunikhin aka Stormbringer)
    Re: Diddling with search engines via CGI <jerryp.usenet@connected.demon.co.uk>
    Re: Extracting HTML <TITLE>...</TITLE> using Perl? <Kim.Oechsle.Hansen@uni-c.dk>
        History <sneaker@mediaone.net>
    Re: Is there a "Newsgroup" for Newbies to Perl? <ljz@asfast.com>
    Re: Munging addresses (was: Re: Perl Cgi Questions) (Peter Caffin)
    Re: Number of Perl Users/Instalitations. <sneaker@mediaone.net>
    Re: outputing dir to html page <quednauf@nortel.co.uk>
        perl cgi question.... <petros@numbat.cs.rmit.edu.au>
    Re: perl cgi question.... <Tony.Curtis+usenet@vcpc.univie.ac.at>
        perl Socket module (John Tolson)
    Re: perl Socket module <Tony.Curtis+usenet@vcpc.univie.ac.at>
        Problems with using 'glob' under IIS and NT <manne@rmg.net>
    Re: PROPOSAL: The Perl Dictionary (Todd Lehman)
    Re: sending mail using perl <quednauf@nortel.co.uk>
    Re: Someone put my munged e-mail address on a spam list (Andy Wardley)
    Re: Trouble with shebang line ... <dformosa@st.nepean.uws.edu.au>
        Tying a blessed hash (was: Re: Tie/bless vs. bless/tie  (Todd Lehman)
    Re: use strict and GD (Tom Mornini)
        WindowsNT remote access <curdin.vital@swisscom.com>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 02 Apr 1998 02:55:03 -0700
From: Vladimir Alexiev <vladimir@cs.ualberta.ca>
To: johnvv@earthling.net
Subject: Re: Bezier Perl code needed: have C source
Message-Id: <omg1jwlf9k.fsf@tees.cs.ualberta.ca>

In article <6ftpg8$4v9$1@nnrp1.dejanews.com> johnvv@earthling.net writes:

Two suggestions:

1. Write some XS to interface to the C code instead of rewriting it in
   Perl. Failing this, try to use perhaps PDL.

> I created a single 1 year graph with perl's GIFgraph out of 4,000,000 points;
> it was a mile wide... ...I really wish I had a bezier curve.

2. IMHO you don't need bezier splines, you need some aggregation
   algorithms. You want to compress these 4M data points to say 100
   data points, not to interpolate between the points.

Maybe I've misunderstood something.


------------------------------

Date: Thu, 02 Apr 1998 10:32:43 GMT
From: Sneaker's Nest <sneaker@mediaone.net>
Subject: Re: Data Structure for Input File
Message-Id: <352367D5.322C@mediaone.net>

CH3704 wrote:
> 
> I am having a hard time trying to accomplish the following task.  I am writing
> a Perl script that reads an input records from an UNIX file of approximately
> 400 bytes. The input records do have a common layout, but the records do not
> contain a separator between each individual field.  I need to figure out a way
> to define a layout of the record, so that I can modify information on the input
> record before the information is used to update columns in an Oracle instance.
> The individual fields range in size from 1 byte to 40 bytes.  The input file
> will be extremely large at times.  The file may contain up to 500,000 records.
> 
> Thank you in advance for assistance.
> 
> Carol Houts
> 

I would hazard a guess that most all data has some sort of separation,
whether defined by length, etc.  If you would post a record layout sheet
or some example data, we may be better able to help.

Thx,
Sneex :-)


------------------------------

Date: Thu, 02 Apr 1998 02:01:21 GMT
From: beans@bedford.net (TomH)
Subject: Re: Data Structure for Input File
Message-Id: <3522ef4a.765923@news.bedford.net>

There's not enough information here to answer the question, but if by
"common layout" you mean fixed width fields you can use unpack and
pack functions, all fields would be alpha ( eg. "a10a4a8..." etc.).

 Otherwise you should include an few examples in a follow up post.

-Tom

 ...
>... I am writing
>a Perl script that reads an input records from an UNIX file of approximately
>400 bytes. The input records do have a common layout, but the records do not
>contain a separator between each individual field.  I need to figure out a way
>to define a layout of the record, so that I can modify information on the input
>record before the information is used to update columns in an Oracle instance. 
 ...


------------------------------

Date: Thu, 02 Apr 1998 13:51:57 +0200
From: Christian Wetzel <cnwetzel@linguistik.uni-erlangen.de>
Subject: Re: Data Structure for Input File
Message-Id: <35237BDD.7E3E@linguistik.uni-erlangen.de>

CH3704 wrote:

> I am having a hard time trying to accomplish the following task.  I am writing
> a Perl script that reads an input records from an UNIX file of approximately
> 400 bytes. The input records do have a common layout, but the records do not
> contain a separator between each individual field.  I need to figure out a way
> to define a layout of the record, so that I can modify information on the input
> record before the information is used to update columns in an Oracle instance.
> The individual fields range in size from 1 byte to 40 bytes.  The input file
> will be extremely large at times.  The file may contain up to 500,000 records.

If there is no way of getting the records from the
application which created them via a query language
like SQL, then you have some work to do.

There's no way of defining automatically where record
fields start or end, if there are no separator characters
like whitespace or commas. I guess you're dealing with
database records which come in binary form, usually.
If field length varies, there have to be *fixed* fields
in the record containing relative offsets which tell
you where your fields of variable length are.

So you need a numerical view of your data (emacs with
hexl-mode, for example) and a calculator (capable of 
translating hexadecimal<->decimal).
1. Search for equal bytecodes in different records of
   your example data. This will give you some hints about
   how your records are structured.
2. "Translate" a lot of bytes (which don't seem to contain
   field data) to decimal and try to read them as additive
   or subtractive offsets to other fields and test whether
   they are or not.
3. If you find such fields, determine which byte encoding 
   (and order) they have (look at perl's pack function for
   the most common encodings).
4. Code it (using loops and a lot of unpack()s) and see 
   whether your structuring was right or not.

An example database record structure could look like this:

chunk     meaning
  1    record start
  2    <some bytes of unknown meaning>
  3    <number of fields in this record>
  4    <relative offset to 1st field>      relative to 1
  5    1st field: <1st field length>
  6               <subfield #1 DATA>
  7               <subfield #2 DATA>
  8               <offset to subfield #1>  relative to 5
  9               <offset to subfield #2>  relative to 5
 10    2nd field: <2nd field length>
 ..         ...
  n    <trailing garbage bytes>

Hope that helps,
   Christian
-- 
  Zur Reinigung nur mit einem feuchten Tuch oder einem
  Antistatiktuch abwischen.



------------------------------

Date: 2 Apr 1998 12:02:52 GMT
From: igor@news.kharkov.ua (Igor Chunikhin aka Stormbringer)
Subject: DBI & suidperl causes core dump
Message-Id: <6fvupc$m40$1@news.ktts.kharkov.ua>

Hi, Perl Gurus!

I trying to use DBI library with suidperl and getting core dump in Perl_form
function. Meanwhile, non-suid perl plus DBI works fine.

Is there any fix/patch or workaround ?

regardz,
--
Igor


------------------------------

Date: Thu, 2 Apr 1998 09:40:08 +0100
From: Jerry Pank <jerryp.usenet@connected.demon.co.uk>
Subject: Re: Diddling with search engines via CGI
Message-Id: <8iKkMWAo70I1EwJC@connected.demon.co.uk>

In <comp.lang.perl.misc> 
John Russell <john13@interlog.com>, writes:
>I've done some launching of search engines like Altavista via
>Javascript.  (Open a window with the URL http:// ... + my query.)  Now
>I would like to do more elaborate things using Perl and LWP.
<snip>

If I read your question correctly, Randall's done all the hard work for
you.

http://www.stonehenge.com/merlyn/WebTechniques/

Web Techniques Column 3 comes close. 

HTH
-- 
Jerry Pank           mailto:jerryp.usenet@connected.demon.co.uk

The choice of approaches could be made the responsibility of the
programmer.
-- Larry Wall in <199709081901.MAA20863@wall.org>


------------------------------

Date: Thu, 02 Apr 1998 15:17:13 +0200
From: Kim Oechsle Hansen <Kim.Oechsle.Hansen@uni-c.dk>
Subject: Re: Extracting HTML <TITLE>...</TITLE> using Perl?
Message-Id: <35238FD9.62F790DA@uni-c.dk>

djhoward@uiuc.edu wrote:
> 
> Matt Sephton <u5ms@csc.liv.ac.uk> wrote:
> > How would I go about extracting the HTML tag <TITLE>...</TITLE> using
> > Perl? Would a regular expression suffice?
> 
> ### Working code snippet;
> # http://www.dannyland.org/~dannyman/warez/daze-lib.txt
> 
>   open(HTML, "$base_dir/$file") or warn "Error opening $file: $!"; {
>     $file_string = join($",<HTML>);
>     if( $file_string =~ /<title>(.*?)<\/title>/is ) {
>       $title = $1; $title =~ s/\n//g; }
> 
>     if( $file_string =~ /<meta name="description" content="(.*?)">/is ) {
>       $description = $1; $description =~ s/\n//g; }
 
You can also consider using the LibWWW HTML::HeadParser object,
if your are only interested in the head portion. There's also
a parser for full HTML if you need more info from the file.

Ex.
  use HTML::HeadParser();

  my $parser = HTML::HeadParser->new;
  $parser->parse_file($myfile);
  print $parser->header('Title');

Regards,

Kim Oechsle Hansen


------------------------------

Date: Thu, 02 Apr 1998 10:21:16 GMT
From: Sneaker's Nest <sneaker@mediaone.net>
Subject: History
Message-Id: <35236527.2485@mediaone.net>

Bob Trieger wrote:
> 
> Sneaker's Nest wrote:
> 
> > Dwelling on the past will cause one
> > to lose track of the future :-)
> 
> "Those who don't know history are doomed to repeat it."
> 
> --
> Bob Trieger               |  Titanic: big boat, bigger
> sowmaster@juicepigs.com   |           iceberg, big deal

:-)

That's why I said don't dwell.

:-)


------------------------------

Date: 02 Apr 1998 07:56:45 -0500
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: Is there a "Newsgroup" for Newbies to Perl?
Message-Id: <lud8f04c1e.fsf@asfast.com>

Tom Phoenix <rootbeer@teleport.com> writes:

> On Tue, 31 Mar 1998, Howard Davies wrote:
> > Has anyone thought of setting up a "comp.lang.perl.help" newsgroup?
> 
> If this newsgroup doesn't work for you, why would one with that name
> succeed? :-)

If in this hypothetical ".help" or ".novices" newsgroup, an arrogant
twit discourteously and condescendingly dismissed a question posed by
a novice without suggesting anything more useful than to read the FAQ
(if even that), the novice might feel a lot more justified in telling
the arrogant twit something like this:

  This is a newsgroup where people who are not well versed in
  Perl can come to share information and to receive useful and
  meaningful help.  Therefore we are not impressed by your clever,
  but low-in-actual-information pronouncements.  Learn some courtesy
  or else shut up and go back to comp.lang.perl.misc.

I believe that this is one reason why many people believe that such a
".help" or ".novices" newsgroup would be a distinct benefit.  :)

-- 
 Lloyd Zusman
 ljz@asfast.com


------------------------------

Date: Wed, 01 Apr 1998 21:04:49 GMT
From: UCE-trap_synic@omen.net.au (Peter Caffin)
Subject: Re: Munging addresses (was: Re: Perl Cgi Questions)
Message-Id: <3522a9b9.1226655@news.omen.net.au>

gbacon@cs.uah.edu (Greg Bacon) did cunningly address to comp.lang.perl.misc..
:In article <352257d8.1077128@news.omen.net.au>,
:	UCE-trap_synic@omen.net.au (Peter Caffin) writes:
:: Tom Phoenix <rootbeer@teleport.com> did cunningly address to
:: comp.lang.perl.misc..
::
:: Think about what's more efficient when it comes to talking NNTP.
:: You could check far more articles by pulling down the header only for three
:: newsgroups than checking the headers+bodies of one. Commonsense. [1]
:
:What happens when someone posts a followup with a Cc: to the original
:poster and did take the time to unmunge the Cc:'d address?  You still
:lose.  All your munging has bought you is the irritation of others
:and breaking a system that has always worked.

Erm, I wish you hadn't snipped out Tom's statement. Context, ta. You see, we
weren't actually talking about munging addresses at all at this point! Tom was
trying to imply that Karl Dyson was incompetent because he imagines email addy
trawlers grabbing only the headers (using the NNTP "head" command rather than
either the "body" or "article" commands). I disagreed.

Greg, whether or not someone CC's someone else or whatnot doesn't mean a stuff
to the NNTP email spider. 

:: :Why not do that? Because most folks won't bother to un-munge; I know I
:: :won't. Cheers!
:: 
:: Who cares about the lazy? ;).
:
:Lazy?  Are you lazy because you would probably object to dialing a
:telephone number along with its length and the sum of the digits
:modulo ten?

Not even vaguely similar. This is a boring topic, IMHO. I only added my 2c
here again because it gave me the chance to crow over my newly acquired skills
in sockets and NNTP :). You can check my POV on nospams_ in more detail in
dejanews if you're that curious.

--:     _         ___  _    _ _ 
 _oo__ |_|_ |__  _ |  |  _ |_|_' _   synic at omen dot net dot a u
//`'\_ | (/_|(/_| .|. |_(_|| | || |  http://www.omen.net.au/~synic
/              PO Box 869, Hillarys WA 6923, AUSTRALIA


------------------------------

Date: Thu, 02 Apr 1998 10:28:43 GMT
From: Sneaker's Nest <sneaker@mediaone.net>
Subject: Re: Number of Perl Users/Instalitations.
Message-Id: <352366E6.3A47@mediaone.net>

John C. Quillan wrote:
> Actually I am just trying to get a ball park range.  I figure I can come closewith a few sets
> of figures.

OK.  Where I work, FCCJ, between the NT people and Unix people - we have
installed 5 different releases of perl on several machines (who knows
how many.)  I myself have installed 6 release levels at home, on three
different architectures, and will be doing so again this weekend for
Solaris x86.

HTH,
Sneex :-)


------------------------------

Date: Thu, 02 Apr 1998 11:03:21 +0100
From: "Frank L. Quednau" <quednauf@nortel.co.uk>
Subject: Re: outputing dir to html page
Message-Id: <35236269.7DBEE17C@nortel.co.uk>

Mike Lai wrote:

> I am trying to output a directory listing within a html page.

 Hello Mike. I have written the following Perl code to this:

#!/opt/corp/local/perl-5.004/bin/perl5.00404 -w
###########################
# By Fictional Reality                              #
# Copyright 1998 Frank Quednau       #
###########################

# Modules I use for making life easier
use CGI qw(:standard);
use File::stat;

$cbdir = "/directory you want to display";
$explan_file = "/a text file to list explanations alongside the dir files";
$url_path = "/a url path to link the listed files";
$layout = CGI -> new();

# Get the directory
opendir(CB,"$cbdir") || die "Cannot opendir:$!";
foreach $file (sort readdir(CB)) {
  push (@files, $file);
}
closedir(CB);

# Getting rid of "., .., description file"
splice (@files, 0, 3);

# Getting the entries from the description file
open(BLA, $explan_file);
  @blabla = <BLA>;
close(BLA);

$i = 0;

# Output to webserver
print header;
print $layout->start_html(-title=>'Departmental procedures', -BGCOLOR=>'white');
print h1('Departmental procedures');
print "<table width=100%>";
print "<tr><td><b>Filename:</b><hr noshade></td><td><b>Description:</b><hr noshade></td>";
print "<td><b>Last modified:</b><hr noshade></td></tr>";
foreach $file (@files) {
 $fullpath = $cbdir."/".$file;
 $status = stat($fullpath) or die p("Darn, that didn't work:$!");
 # Listing the last modified time alongside the files
 $time = localtime($status->mtime);
 print "<tr><td><a href='$url_path$file'>",$file,"</a></td>";
 print "<td>",@blabla[$i],"</td>";
 print "<td>",$time,"</td></tr>";
  $i++;
}
print "</table>";
print end_html;

I hope that helped.

--
____________________________________________________________
Frank Quednau
Phone: +44 (0)1279 402447
http://www.surrey.ac.uk/~me51fq MailTo:F.L.Quednau@bnr.co.uk
____________________________________________________________





------------------------------

Date: 2 Apr 1998 06:02:26 GMT
From: "chris..." <petros@numbat.cs.rmit.edu.au>
Subject: perl cgi question....
Message-Id: <6fv9li$oap$1@goanna.cs.rmit.edu.au>

I am doing some web page work and have a specific question
with regard to CGI and Perl.

Is there anyway to maintain a list of elements and pass this list
from script to script and add and remove items from this list.

 eg ...http://ww...../myscript.cgi?the_list=....
                                        ~~~~~~~~~~
myscript.cgi would read in this value and add to it / remove from it...
etc etc...

How would I do this in Perl? ie represent the list and manipulate it

_email prefered_

Thanks in advance

-------------------------------------
Chris Petros -> petros@cs.rmit.edu.au
http://yallara.cs.rmit.edu.au/~petros
-------------------------------------


------------------------------

Date: 02 Apr 1998 14:37:59 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
To: petros@numbat.cs.rmit.edu.au
Subject: Re: perl cgi question....
Message-Id: <7xhg4ce6vs.fsf@beavis.vcpc.univie.ac.at>

Re: perl cgi question...., chris
<petros@numbat.cs.rmit.edu.au> said:

chris> Is there anyway to maintain a list of elements and
chris> pass this list from script to script and add and
chris> remove items from this list.

Yes.  Use "hidden" fields in the form.

chris> How would I do this in Perl? ie represent the list
chris> and manipulate it

If you're using the standard CGI module then the param()
method can be used for hidden fields just as for all fields
of the form.  There's of course a hidden() method for
constructing such fields.

hth
tony
-- 
Tony Curtis, Systems Manager, VCPC,      | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, AT | http://www.vcpc.univie.ac.at/

"Everything I am, I learned on the back of cereal boxes" ~ RJ, "Over the Hedge"


------------------------------

Date: Thu, 2 Apr 1998 10:56:18 GMT
From: tci@netcom.com (John Tolson)
Subject: perl Socket module
Message-Id: <tciEqs91u.7vI@netcom.com>

I am trying to run a spam filter from my shell account, the filter is
a perl script.  It uses Socket to mail out.  I get an error on the:

use Socket; // error here

Is this not part of the standard distribution of perl.  And if so, what could
be the problem?





------------------------------

Date: 02 Apr 1998 13:03:59 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: perl Socket module
Message-Id: <7xhg4cbi3k.fsf@beavis.vcpc.univie.ac.at>

Re: perl Socket module, John <tci@netcom.com> said:

John> I am trying to run a spam filter from my shell
John> account, the filter is a perl script.  It uses Socket
John> to mail out.  I get an error on the:

I'd use the Mail::Mailer module instead or one of its
friends.

John> use Socket; // error here

Not that you tell us what the error is...

John> Is this not part of the standard distribution of perl.
John> And if so, what could be the problem?

I'd guess you're still using perl version 4 (bleagh :-)

What does the command "perl -v" say?

hth
-- 
Tony Curtis, Systems Manager, VCPC,      | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, AT | http://www.vcpc.univie.ac.at/

"Everything I am, I learned on the back of cereal boxes" ~ RJ, "Over the Hedge"


------------------------------

Date: Thu, 02 Apr 1998 14:20:12 +0200
From: manne <manne@rmg.net>
Subject: Problems with using 'glob' under IIS and NT
Message-Id: <3523827C.4DB65164@rmg.net>

I'm trying to run a CGI application at an NT server running MS IIS 3.0,
but it seems that the server prevents me from using Perl's glob command.

To test if this was really the case, I wrote the following script:

print "Content-type: text/plain\n\n";
print "HEJ!\n";
print join(" ", glob('*'));

If I run this from the command prompt, it works fine - the scripts lists

all the files in the same directory. However, when I execute it as a CGI

script (using a browser), only the first two statements get executed! (i

e, only the Swedish word 'HEJ!' appears on the screen).

I should add that it works fine with another server that I've tried
(Omni HTTPd 1.0 under Windows 95).

Does anybody know why this doesn't work? Is this caused by security
restrictions in IIS or NT? And if so, is there a work-around?

Any help very much appreciated,
     Manne Fagerlind <manne@rmg.net>





------------------------------

Date: Thu, 02 Apr 1998 10:42:07 GMT
From: lehman@javanet.com (Todd Lehman)
Subject: Re: PROPOSAL: The Perl Dictionary
Message-Id: <3YJU.3$T51.14638@ptah.visi.com>

In article <35187584.F3740951@vais.net>, Ed Finch <efinch@vais.net> writes:
> Perl is going to take over the world.

Amen.  :-)


> Therefore, the word perl and its
> derivitives are going to become part of everyday speech, just as "dude"
> is now. I propose the Perl Dictionary in order to establish - for those
> unfortunate enough not to know about perl - the proper use of the word.
> Sample entries:
>
> perlify (perl-i'fy), verb - 1) The process of converting an existing
> program or script into perl, for the obvious reasons. 2) The process of
> improving any person, place or thing by the addition of perl.
>
> perlification (perl-i-fi-ca'tion), noun - The superior result gained
> from the act of perlifying.
>
> perilified (perl-i'fied), past tense verb - E.g., "I perlified gcc and I
> get the tightest code ever".
>
> More entries, anyone?
> Ed


hyperltext (hy'perl-text), n. double-quotish-interpolated hypertext markup:
  Example:
    print qq{<LI><A HREF="$self->{url}">@{[ucfirst $self->{title}]}</A>\n};

--Todd


------------------------------

Date: Thu, 02 Apr 1998 10:06:04 +0100
From: "Frank L. Quednau" <quednauf@nortel.co.uk>
Subject: Re: sending mail using perl
Message-Id: <352354FC.34DA4EEB@nortel.co.uk>

Hello Aaron,
I'd like to point you to my homepage and there especially at:
http://www.surrey.ac.uk/~me51fq/perl/perl.htm

In there I describe how to send a MIME encoded attachment with Perl (my very
first perl section!),
but it should also give you enough ideas to send normal mail...

--
____________________________________________________________
Frank Quednau
Phone: +44 (0)1279 402447
http://www.surrey.ac.uk/~me51fq MailTo:F.L.Quednau@bnr.co.uk
____________________________________________________________





------------------------------

Date: Thu, 2 Apr 1998 11:33:55 GMT
From: abw@cre.canon.co.uk (Andy Wardley)
Subject: Re: Someone put my munged e-mail address on a spam list
Message-Id: <EqsAsJ.37q@cre.canon.co.uk>

Tom Christiansen  <tchrist@mox.perl.com> wrote:
>Usenet is a public forum.  

John Stanley <stanley@skyking.OCE.ORST.EDU> wrote:
>USENET is not mail.

But the replies that Tom is trying to make are in response to questions
posted in USENET, which *is* public forum.  If you ask for help publicly, 
I think it's rude to make it difficult for people to help you.


A
--
Andy Wardley <abw@kfs.org> http://www.kfs.org/~abw    
Signature lost in transit.  We apologise for any inconvenience caused.


------------------------------

Date: 2 Apr 1998 11:56:33 GMT
From: ? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au>
Subject: Re: Trouble with shebang line ...
Message-Id: <891518193.34028@cabal>

In <Pine.SGI.3.95.980401082620.18265C-100000@vangogh.bergen.org> "I have a life, and I can prove it!" <jefpin@bergen.org> writes:

>>	% perlscript.pl
>>
>>i get perlscript.pl: Command not found.  Yes, the file is executable,
>>and Yes,  i have the correct path for the interpreter.  If anyone has
>>any suggestions as to what it might be that i am over-looking, they
>>would be appreciated.  

>Try this:
>	% ./perlscript.pl

Also chack your shabang line.  Sometimes a ^M will get added to the end of
it and brake your script.

--
I'm a perl programer if you need perl programing hire me. Buy easter bilbies.
Please excuse my spelling as I suffer from agraphia see the url. Support NoCeM
http://www.cit.nepean.uws.edu.au/~dformosa/Spelling.html  http://www.cm.org/ 
I'm sorry but I just don't consider 'because its yucky' a convincing argument


------------------------------

Date: Thu, 02 Apr 1998 10:23:23 GMT
From: lehman@visi.com (Todd Lehman)
Subject: Tying a blessed hash (was: Re: Tie/bless vs. bless/tie and segmentation fault)
Message-Id: <vGJU.2$T51.8066@ptah.visi.com>

In article <FyHU.281$CX.779179@ptah.visi.com>, <lehman@javanet.com> writes:
> [more code & more text snipped]

Well I'll be a monkey's uncle.  It -is- possible after all to tie a blessed
hash with a single-class implementation.  And the solution is fast and clean
-- and no crashing perl either.  :-)

I had been laboring under the misconception that tying a blessed hash (that
is, the data inside an already blessed or soon-to-be-blessed hash object)
-had- to be done using two classes/packages.  It certainly can be, and that's
what I got working first, but my first few attempts a couple days ago at
putting it all in one class failed miserably and resulted in infinite
recursion in the FETCH method.  But -- big duh -- I was trying to do it with
only one constructor, and I needed to try it with two constructors (TIEHASH()
and new()).

new() creates a dummy hash which is never really used.  TIEHASH() creates
the real guts for the object -- the hash which contains "public" data (the
stuff you get at by overloading the hash indexing syntax) and "private" data
(the stuff that only the object itself is supposed to see).  So even though
there is only one class, there are actually two objects created each time
new() is invoked, since new() invokes TIEHASH implicitly via tie.

When you dereference the object returned by new(), you implicitly invoke the
FETCH() method for the hash inside that object.  But FETCH doesn't blow up
the stack through infinite recursion when it accesses $self because it's
accessing a different $self -- it's the $self that's tied to the dummy hash
inside the other object.  In fact, the $self that FETCH sees is a reference
to an anonymous array of two elements (a first containing a hash of public
values and a second containing a hash of private values).

One nice thing about it all taking place in one class is that it's easier to
subclass.  But one icky thing is that the object created actually belong to
two different classes -- at least conceptually -- in that they contain
completely different types of data and behave completely differently.  Yet,
to the outsider of the package, who cares?

Has this all been done before a million times?  I've had a few looks around
and maybe I just don't know the right keywords for searches...

--
Todd Lehman
lehman@javanet.com

_____________________________________________________________________________

#!/bin/perl
use strict;
$^W = 1;

package Foo;

sub new
{
   my $class = shift;
   my $self = {};
   tie %$self, $class, @_;
   return bless $self, $class;
}
sub TIEHASH
{
   my $class = shift;
   return bless [ {@_}, {FetchCount=>0} ], $class;
}
sub DESTROY
{
   my ($self) = shift;
   my $tied = !!tied %$self;  # Use of a temporary variable prevents retention
   untie %$self if $tied;     # of a reference to the tied object before untie.
}
sub FETCH
{
   my ($self, $k) = @_;
   $self->[1]{FetchCount}++;
   return $self->[0]{$k};
}
sub STORE
{
   my ($self, $k, $v) = @_;
   return $self->[0]{$k} = $v;
}
sub AUTOLOAD
{
   print "Autoloading $Foo::AUTOLOAD...\n";
   eval qq{ sub $Foo::AUTOLOAD { shift; print "$Foo::AUTOLOAD \@_\n"; } };
   goto &$Foo::AUTOLOAD;
}



package main;

my $DB = new Foo;
$DB->{Person} = new Foo;

$DB->{Person}{1} = new Foo;
$DB->{Person}{1}{FirstName} = "Fred";
$DB->{Person}{1}{LastName} = "Flintstone";
print "1 = $DB->{Person}{1}{FirstName} $DB->{Person}{1}{LastName}\n";
$DB->{Person}{1}->Smite("Belly", "Dino");

$DB->{Person}{2} = new Foo;
$DB->{Person}{2}{FirstName} = "Barney";
$DB->{Person}{2}{LastName} = "Rubble";
print "2 = $DB->{Person}{2}{FirstName} $DB->{Person}{2}{LastName}\n";
$DB->{Person}{2}->Smite("Big-Toe", "Bowling-Ball");
$DB->{Person}{2}{Buddy} = $DB->{Person}{1};
print "Buddy(2) = $DB->{Person}{2}{Buddy}{FirstName}\n";
$DB->{Person}{2}{Buddy}{Buddy} = $DB->{Person}{2};
print "Buddy(1) = $DB->{Person}{1}{Buddy}{FirstName}\n";
print "Buddy(1) = $DB->{Person}{2}{Buddy}{Buddy}{FirstName}\n";

$DB->{Person}{3} = new Foo(FirstName=>"George", LastName=>"Jetson");
print "3 = $DB->{Person}{3}{FirstName} $DB->{Person}{3}{LastName}\n";
$DB->{Person}{3}->Smite("Cheek", "Astro-Slobber");



------------------------------

Date: Thu, 2 Apr 1998 10:07:49 GMT
From: tmornini@netcom.com (Tom Mornini)
Subject: Re: use strict and GD
Message-Id: <tmorniniEqs6t2.4wE@netcom.com>

I wrote:

: I'm now having trouble with the following line:

:   $im->string(gdSmallFont,$CENX,$CENY,$LOTNUMBER,$black);

: The error message is:

: Bareword "GD::Font::gdSmallFont" not allowed while "strict subs" in use at
:         /usr/local/etc/httpd/perl/pq-mp.mod_perl line 879 (#1)

Sorry, everyone. Cut and paste will wipe you out every time! This should read

Bareword "gdSmallFont" not allowed while "strict subs" in use at
         /usr/local/etc/httpd/perl/pq-mp.mod_perl line 879 (#1)

-- Tom Mornini
-- InfoMania


------------------------------

Date: Thu, 2 Apr 1998 14:06:35 +0200
From: "Curdin Vital" <curdin.vital@swisscom.com>
Subject: WindowsNT remote access
Message-Id: <6fvuvv$gmb@gd2inews.swissptt.ch>

How I can write a perl-script(Build 316), where I can connect from a
Client to another Server with TCP/IP. And how I send the username
and password in a secure way?

Thank you for your help

Curdin




------------------------------

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 2231
**************************************

home help back first fref pref prev next nref lref last post