[8075] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1694 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 21 14:18:14 1998

Date: Wed, 21 Jan 98 11:00:29 -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, 21 Jan 1998     Volume: 8 Number: 1694

Today's topics:
    Re: [Answer]: [Help] Global variables and use of betwee (Tarang K. Patel)
    Re: how do i get full path to $0 <merlyn@stonehenge.com>
    Re: living and free software (was: Re: source into bina <pdcawley@bofh.org.uk>
    Re: living and free software (was: Re: source into bina (Greg Bacon)
    Re: Modifying \n\r on a directory tree of html files to <tibbi_scott@REMOVETHISPARTcmug.com>
        Need to send mail from web page as user other than "nob <osullm@cork.cig.mot.com>
    Re: perl - ms sql (C Carr)
    Re: perl.y --> Perl's Yacc Grammar (Greg Bacon)
    Re: Refering to a referenced structure? <ajohnson@gpu.srv.ualberta.ca>
    Re: Simple example of Select needed please <indy@NOSPAMdemobuilder.com>
    Re: source into binary code <pdcawley@bofh.org.uk>
    Re: source into binary code <pdcawley@bofh.org.uk>
        Summary: help with sorting <msda+@andrew.cmu.edu>
    Re: Were can I get PERL (Michael J Gebis)
    Re: Were can I get PERL (Jonathan Stowe)
        Writing inetd apps in perl <johnrs@dc.net>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 21 Jan 1998 18:01:50 GMT
From: fruitbat@nas.nasa.gov (Tarang K. Patel)
Subject: Re: [Answer]: [Help] Global variables and use of between package modules.
Message-Id: <6a5d6e$2g1$1@cnn.nas.nasa.gov>
Keywords: perl5, global


 So I stumbled on to how to make use of Global variables defined in one package
 visible in another without having to fully qualify these variables with the
 package name.

 The only question remains is that :

 [Q]  Is this a side effect and not guaranteed to work every where ?

 Following the noddy example code I had given in my previous posting, here
 is the correction.

 file A.pm
 ---------

package A;
use Exporter ();
use vars     qw(@ISA @EXPORT @EXPORT_OK);
@ISA = qw(Exporter);
@EXPORT = qw($a func1);
@EXPORT_OK = ();

use English;
use Vis::B;

$a="c{}"; # GLOBAL var

sub func1 {

my ($subname);
$subname = ref bless [];
print "This is module $subname in package A, and \$a= $a\n";
$d=&c();
print  "Back in package $subname and \$a = $a, returned from \&c\(\) with $d\n";

}

 File Vis/B.pm
 -------------
package Vis::B;
use Exporter ();
use vars     qw( @ISA @EXPORT);
@ISA = qw(Exporter);
@EXPORT = qw($a &c);  # HERE IS THE CHANGE:
                      # In order to have the same common NAME SPACE shared for
                      # a variable that I wish to refer from package A::, I must
                      # export this variable in this package too.
use English;
use lib "../";
use A;

sub c {
my $module = ref bless[];
print "c(): This is module $module \$a= $a\n";
print "A Fully qualified var attempt in $module \$A::a= $A::a\n";
$a .= " $module";
return 1;
}
 ------------

to run this :

 > perl
 use A;
 &func1();

 ^D
 -------------

 RESULTS
 -------
This is module A in package A, and $a= c{}
c(): This is module Vis::B $a= c{}
c(): A Fully qualified var attempt in Vis::B $A::a= c{}
Back in A package A and $a = c{} Vis::B, returned from &c() with 1

 +++++++++++++++++++++

 Thats it.

 I'd appreciate any response to the above question just to confirm my
 understanding why this is required.

  Tarang
-- 
Tarang Kumar Patel.     WWW home:http://www.nas.nasa.gov/
NASA Ames Research Center, MS 258-1, Moffett Field, CA 94035-1000
Email: maumau@nas.nasa.gov, Tel:(650) 604-4721 fax: (650) 604 2238
Stated views are my own IDEA, as I'm another I.D.E.A man "I Didn't Explain All"


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

Date: 21 Jan 1998 11:46:19 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: MARTIN@RADIOGAGA.HARZ.DE
Subject: Re: how do i get full path to $0
Message-Id: <8chg6xfyx0.fsf@gadget.cscaper.com>

>>>>> "Martin" == Martin Vorlaender <martin@RADIOGAGA.HARZ.DE> writes:

Martin> John <john.crawshaw@london.pgs.com> said:
Martin> : I know $0 gives me the program name and also
Martin> : File::Basename will give me something similar but how
Martin> : do I get the full path to where its called from.

Martin> Have a look at the FindBin module (in the standard distribution).

And please remember that $0 is *arbitrary data* that just *sometimes*
happens to have the path (relative or absolute) to your Perl program.
Never *count* on it to be possible or accurate.  Or you'll get burned.

  system { "/ha/ha/fooled/you" } "yourscript","my_arg","my_next_arg";

(It's too bad Graham doesn't mention this in the manpage for FindBin.)

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 222 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: 21 Jan 1998 17:46:00 +0000
From: Piers Cawley <pdcawley@bofh.org.uk>
Subject: Re: living and free software (was: Re: source into binary code)
Message-Id: <54ra61hg9z.fsf@gunnar.aladdin.net>

20 Jan 1998 18:02:40 GMT stanley@skyking.OCE.ORST.EDU (John Stanley) comp.lang.perl.misc
> In article <6a2g9c$koh$1@info.uah.edu>, Greg Bacon <gbacon@adtran.com> wrote:
> >In article <6a19ht$cii$1@news.orst.edu>,
> >Has anyone suggested intentionally starving oneself or one's family?
> 
> So someone chooses to write software for a living. Do you have a problem
> with that? No? Good. So he needs to make money to feed his family. Any
> problem there? No? Good. So he decides to sell the software he writes.
> Any problem there? He learns from his first experience at selling Perl
> software that once he makes the SOURCE available he can no longer charge
> for the ability to use the software -- very few people will pay for
> something they can get and use for free. So he decides to distribute his
> work in a form that requires a license to use it. Do you have a problem
> with people requiring a license to use code? But to distribute it this
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^
> way, for Perl, he needs to hide the source. Oops, seems to be a problem.
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

No he doesn't. Take a look at WebEvent, a rather neat set of perl
scripts to do web based calendars and the like. Comes with
(unobfuscated) source and requires a keystring to get it working. The
license requires the purchaser/evaluator not to either remove or
subvert the licence handling code. We're buying the software. Sure I
could dike out the licensing stuff but what would be the point -- we
get value from the code (what's especially neat is the fact that we
can tailor it to our own requirements) so we pay for it. I'm an honest
guy.

If the author had compiled it in some way then we could still dike out
the licensing code; it would be harder to do, but it could be done.
But in compiling the code one of the advantages of the software goes
away; we can't see inside it.

Of course some unsrupulous lusers are going to circumvent the
protection and keep using the software anyway, but they'd be doing
that no matter how I distributed said software.

> Of course it would be. Thanks for agreeing with me.
> 
> >Many can and do earn good money by selling
> >the service of writing or modifying software.  
> 
> Of course they do. But they aren't writing cheap software, they are
> writing software that is complicated enough and specialized enough that
> people will pay a living wage to them while they do it. 
> 
> >They also happen to make that software freely available.  
> 
> Excuse me, but let's travel down memory lane. Yesterday I read an
> article from someone who was arguing for free software based on his
> experiences with programmers who joined cults. He claimed that the
> current version of the code he was paying to have written for him was
> "free software", even though the person who was writing it did not
> "make it freely available" to anyone except himself. Did you forget
> that he was paid to write it? Did you forget that he had already
> written it for someone else, and was just modifying it for his new
> customer, and the only reason it was made available to that customer
> was because he paid for it? How many jobs would that fellow get if he
> "gave it away free" to anyone who asks?  
> 
> The question was asked "why would people pay for code they could get
> for free?" When that was asked, there were two different programs
> written by two different people. In this case, the code was written by
> the same person. Why would anyone hire this guy to write code they
> already had?

Off the top of my head?

1. Because what exists is not precisely what they want and it's
   cheaper/easier to pay the original author to tailor it than it is
   to do it themselves.
2. Because the GPL explicity disclaims any warranty; the license
   granted someone who pays for the software may not.
3. Because its good for the client's karma.
4. All of the above.

Also, from the programmer's point of view, the free version of the
software is an advert. Look at Larry for example, I don't know how
much O'Reilly are paying him, but I'm fairly sure that they wouldn't
have employed him if he hadn't written perl.

> >Bingo!  Did I see a light bulb above your head?  It seems you're finally
> >getting the point after three rounds.  That's the same model we've been
> >describing all along.
> 
> No, it is not. Those people did not make a living by giving it away.
> They made a living by working for Uncle Sam. It didn't cost them
> anything to give it away to others also working on the same project.

Actually, some of them did give it away. Code that comes from UCB for
example was not paid for by the US government.

> Now look at someone who is trying to sell his code. He LOSES a sale
> if he gives it away. That means he loses money. He isn't being paid
> to give it away. He is NOT making a living by giving code away. Do
> you get the point yet?

Which particular sale does he lose when he gives the code away? Randal
and Tom give code away all the time, and they make a decent living
(even if it doesn't cover the legal bills...). I'm quite sure that
people wouldn't be paying them the kind of money they get paid if they
didn't have good reputation which was at least partially gained by
giving code/information away on the Internet.

-- 
Piers Cawley -- Systems Genie for Aladdin
If a `religion' is defined to be a system of ideas that contains
unprovable statements, then Godel taught us that mathematics is not
only a religion, it is the only religion that can prove itself to be
one. -- John Barrow


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

Date: 21 Jan 1998 18:26:12 GMT
From: gbacon@adtran.com (Greg Bacon)
Subject: Re: living and free software (was: Re: source into binary code)
Message-Id: <6a5ek4$i37$2@info.uah.edu>

In article <6a2os0$fm5$1@news.orst.edu>,
	stanley@skyking.OCE.ORST.EDU (John Stanley) writes:
: In article <6a2g9c$koh$1@info.uah.edu>, Greg Bacon <gbacon@adtran.com> wrote:
: >What need does software I can't use meet?
: 
: Why do YOU refuse to argue sensibly? The context of this discussion is
: paying for code, which would give you the ability to use the code. Thus,
: the only reason you claim you can't use the code is because you decided
: not to pay for it. You called it useless just because YOU made the
: choice that you wouldn't use it. 

Ah.. I see your confusion.  To paraphrase Our Former Pumpking:
``Software without sourcecode isn't software; it's hardware on disk''.
I can use an obfuscated version of someone's software until I run into
its limitations, just like I can use a Pentium processor until I try
to execute F00F.  What can I do about a limitation when I hit it with
a piece of hardware?  Nothing.  What can I do when I hit a limitation
of software?  Given the time and effort, I can remove the limitation
and share what I've done with the world.  The latter seems like a much
better situation for everyone.

: >Any sensible person should be able to see two points in this thread:
: >1) it's not possible to put food on the table if your only activity is
: >giving things away, 
: 
: That is exactly what I have been saying, and that is what people, you
: included, have been arguing with me about. Unless your sole goal is to
: type characters, you have no reason to be arguing unless you have a
: different viewpoint than mine. Why are you arguing something that has
: been settled?

You're under the impression that people are saying that it's possible to
make a living by giving things away.  I think we can both agree that no
reasonable person would believe this.  I believe that Tom {C,P} are
reasonable people.  Therefore they don't believe that it's possible to
make a living solely by giving things away.  Why would they make a claim
against their own beliefs?

: >and 2) no one is claiming the opposite--giving
: >away software is a nice side effect.
: 
: Except people HAVE been claiming the opposite. You really ought to read
: what has been written. You included such a claim. 

*sigh*

: >: Not when they are connected in the same sentence with the word "by".
: >: That's a causal relationship. The events "make meatloaf" and "running
: >: over cats" are usually independent, until you say "I make meatloaf by
: >: running over cats and cooking them." Yes, the word "by" is important.
: >
: >That is a very rigid and dogmatic reading.  
: 
: That is simple english.

There is no such thing as ``simple English''.  If English is so simple,
please provide us with a parser.  English provides a great degree of
latitude for its speakers which includes choices in word order.

: >Have you read ``Why Software Should Be Free''?  Richard Stallman makes
: >a great case.  Check it out at
: 
: Is this the same Richard Stallman who was given money to produce
: software for free?

No, people donate money to him because they find his free software very
useful.

: Now, if you want to help people, tell them where they
: can get Gnu-unix.

But GNU's Not Unix! :-)

: >There's a difference between copying software and copying something
: >concrete like a calculator.
: 
: Yes, there is, but that doesn't make what I said wrong. 

To quote Stallman:

    ``This reflects a crucial difference between copies of programs and
      cars, chairs, or sandwiches.  There is no copying machine for
      material objects outside of science fiction.  But programs are
      easy to copy; anyone can produce as many copies as are wanted,
      with very little effort.  This isn't true for material objects
      because matter is conserved: each new copy has to be built from
      raw materials in the same way that the first copy was built.''

You compared copying software to copying calculators.  There is no
secret and no potential for gain by learning how someone else copies
software.  The same is not true for material objects.

: >You're really reaching now, Stanley.  First, using your intentionally
: >obfuscated end product, they can only benefit from what you've learned
: >in that they're bound by the bugs present and the features that aren't
: >present; they can't fix or improve upon your work.  
: 
: Now you are reaching. Suppose this end product is the code to run an
: MRI. Are you REALLY SERIOUSLY claiming that the only benefit people get
: from the use of my code is that they are stuck with bugs and can't
: modify the code? Are you REALLY saying that there is NO benefit to them
: from the ability to see damage to soft tissue? There is NO benefit to
: anyone when a doctor can see where a tumor is in advance of cutting open
: someone's head? 

Try reading before refuting next time.  I didn't deny that obfuscated
software can provide benefit.  However, that benefit is limited by the
owner's knowledge and ability to program.

: Or maybe you just don't realize that there is software running the MRI.
: And CAT scanner. And most laboratory equipment these days. Do you expect
: source for all of those or they are useless?

Hukt on fonnex fayld 4 u, d00d.

: >: Did you also notice that most of the world would not benefit one tiny
: >: bit by seeing the code, but many may benefit from its use?  E.g., the
: >: code that runs the MRI systems sold by GE. I would get no benefit from
: 
: >Your straw man is burning, Stanley.
: 
: I guess when you can't argue the point, ignore it. No, you already said
: that there is no benefit to anyone from MRI software that doesn't have
: source provided with it.

First your straw man arguments, and now you're putting words in my mouth.

: >I've never suggested shooting Bill Gates because of his proprietary
: >software.  I count two burning strawmen.
: 
: Ok, so they aren't taken out an shot. They are certainly harmful to
: society (your claim), so what DO you want done to them?

I'd like to see society educated so they will know there are infinitely
better and infinitely cheaper choices.

: So someone chooses to write software for a living. Do you have a problem
: with that? No? Good. So he needs to make money to feed his family. Any
: problem there? No? Good.

So far so good...

: So he decides to sell the software he writes.
: Any problem there?

What you call ``selling software'' I (and many others) would call
``selling hardware on disk''.  Why can't he sell his services as a
programmer instead?

: He learns from his first experience at selling Perl
: software that once he makes the SOURCE available he can no longer charge
: for the ability to use the software

Horrors! :-)

: -- very few people will pay for
: something they can get and use for free.

Imagine that.

: So he decides to distribute his
: work in a form that requires a license to use it.

Evil.. was it you who first pitched this idea to Unix vendors?  'Just
think of all the money we could make.. by.. stripping out the compiler
and making them pay extra for that!  What Unix user needs a compiler?'
they must have thought.

: Do you have a problem
: with people requiring a license to use code?

Yes, I have a big problem with it.  Licenses are the equivalent of
squeezing every last drop of water out of a rag when a couple of turns
would do.

: But to distribute it this
: way, for Perl, he needs to hide the source.

Perhaps he should choose a language better suited to his greed.

: Oops, seems to be a problem.
: He must release his code for free or he is harming society.

How ironic that you hold such contempt for the truth.  I don't guess
you've read ``Why Software Should Be Free''.

: >Many can and do earn good money by selling
: >the service of writing or modifying software.  
: 
: Of course they do. But they aren't writing cheap software, they are
: writing software that is complicated enough and specialized enough that
: people will pay a living wage to them while they do it. 

So what is your problem with this arrangement?

: Excuse me, but let's travel down memory lane. Yesterday I read an
: article from someone who was arguing for free software based on his
: experiences with programmers who joined cults.

More strawmen?  It's getting really hot in here...

: He claimed that the
: current version of the code he was paying to have written for him was
: "free software", even though the person who was writing it did not
: "make it freely available" to anyone except himself.

You misuse those terms.  It would be better if you understood them
first.

: Did you forget
: that he was paid to write it?

We're all free to fix our cars or our plumbing, but we choose to call
a mechanic or a plumber for the benefit of their experience.  Why does
everyone think programming is something everyone should do for
themselves?

: Did you forget that he had already
: written it for someone else, and was just modifying it for his new
: customer, and the only reason it was made available to that customer
: was because he paid for it? How many jobs would that fellow get if he
: "gave it away free" to anyone who asks?  

You're building another straw man now.  There is an infinite amount of
programming work to be done.  Real programmers don't have to stop at
one program.

: The question was asked "why would people pay for code they could get
: for free?" When that was asked, there were two different programs
: written by two different people. In this case, the code was written by
: the same person. Why would anyone hire this guy to write code they
: already had?

They're not paying for the program.  They're paying for the services
of a programmer who can do work that they're unable to do for
themselves.

: No, it is not. Those people did not make a living by giving it away.

We've already been through this.

: Now look at someone who is trying to sell his code. He LOSES a sale if
: he gives it away. That means he loses money. He isn't being paid to
: give it away. He is NOT making a living by giving code away.  Do you
: get the point yet?

It is this sort of shortsightedness that prevents free software from
really taking over.

: >: No Utopia exists when people are hungry. Somehow, equating the Internet
: >: to Utopia lessens the value of Utopia, or inappropriately agrandizes
: >: the Internet. 
: >
: >This remark leads me to believe that either you haven't been using the
: >Internet for very long or that you haven't realized the full potential,
: >perhaps both.
: 
: I have been around long enough that I am not taken in by the hyperbole
: about the "Information Superhighway" and all the warm fuzzies of people
: wandering the great museums of Italy via cyberspace. I'm sorry that the
: AOL/IBM advertising hype has taken you in.

More shortsightedness..

: The telephone system is not a
: Utopia, and it has been around a lot longer.

Longevity does not necessarily produce Utopia.  I've never made that
claim.

Greg
-- 
open G,"|gzip -dc";$_=<<EOF;s/([0-9a-f]+)/print G pack"h*",$1/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: 21 Jan 1998 09:50:02 -0800
From: Tibbi Scott <tibbi_scott@REMOVETHISPARTcmug.com>
Subject: Re: Modifying \n\r on a directory tree of html files to \n files for UNIX
Message-Id: <6a5cga$leh@heat.cvo.roguewave.com>

According to Brian Lavender <brian@brie.com>:
>I am trying to figure out how to change an entire directory of html files
>which have the \r\n line termination to the unix style with just a \n. I
>looked at dejanews and I found this simple one line by Mr. McClellan to
>change a single file named joe.pl.


Just a small solution that I use in my scripts to turn dos-linefeeds to
unix line-feeds (when processing said files on the UNIX system).

$file="{path}/file.html"

system "unix2dos -ascii '$file' > tempoutfile.$$ 2>/dev/null";
system "mv $tempoutfile.$$ $file";


The other way:

system "dos2unix -ascii '$file' > tempoutfile.$$ 2>/dev/null";
system "mv $tempoutfile.$$ $file";


It's just an idea that might work for you.

-- 
Tibbi Scott (Standard Disclaimer: my views are my own.)


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

Date: Wed, 21 Jan 1998 17:44:02 +0000
From: Michael O'Sullivan <osullm@cork.cig.mot.com>
Subject: Need to send mail from web page as user other than "nobody"
Message-Id: <34C633E1.7E37BB2D@cork.cig.mot.com>

 Hi all,

I have a web page which sends a structured email to our helpdesk.

The problem is that I want the email to be sent as the user who completed
the form, using their email address.  If a problem is urgent I want the
first line of the body to be "Priority Urgent".

I know I can do this in two ways:

1. Use mailto
2. Use a cgi-bin script

The problem with 1. is that the email is not formatted as we need it to be,
i.e. the first line is "body=...".
The problem with 2. is that the email is send as the user "nobody"

Is there any way I can format the email AND have it sent from the user
completing the form?

Thanks in advance,

Mike.

--
 _/ \_/ \_   Michael O'Sullivan       | 'Phone : +353-21-511204
/ \_/ \_/ \  Motorola Ireland Ltd.    | Fax    : +353-21-357635
\_/ \_/ \_/  Mahon Industrial Estate  | Email  : osullm@cork.cig.mot.com
/ \ / \ / \  Blackrock, Cork, Ireland.| POST   : QCOR150@email.mot.com





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

Date: Wed, 21 Jan 1998 18:09:30 GMT
From: clint@netcom.com (C Carr)
Subject: Re: perl - ms sql
Message-Id: <clintEn5Brv.25o@netcom.com>

Robert Lubej (lubej@amis.net) wrote:
: Is there a way to get to the Microsoft SQL server database from a perl
: program (actually a cgi script) on UNIX (FreeBSD)?

: We have a database on NT server, but we don't want other people to
: have direct access to it, so we don't have a web server on that
: machine but on another under FreeBSD (Apache web server). At the
: moment i can only think of writing a server program on NT to which a
: perl script would connect through sockets...

I developed IDBS which is a server that runs on Windows and uses sockets.
It is multithreaded and has some network security checks.  It can access most
any database via an ODBC driver and I sell it for
$79.  There's a perl object that comes with the package.

Sincerely,
Clinton


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

Date: 21 Jan 1998 18:36:22 GMT
From: gbacon@adtran.com (Greg Bacon)
Subject: Re: perl.y --> Perl's Yacc Grammar
Message-Id: <6a5f77$i37$3@info.uah.edu>

[Posted and mailed]

In article <34C45A20.3299@lsil.com>,
	Todd Mendenhall <menden@lsil.com> writes:
: I'm looking for an old perl.y file. Perl's
: yacc grammar description. I can't seem to 
: find it anywhere on the web.

Use the source, Luke.  Unpack

    http://www.perl.com/CPAN/src/latest.tar.gz

and look for perly.y.

Hope this helps,
Greg
-- 
open G,"|gzip -dc";$_=<<EOF;s/([0-9a-f]+)/print G pack"h*",$1/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: Wed, 21 Jan 1998 11:50:45 -0600
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Refering to a referenced structure?
Message-Id: <34C63575.75DFBA6E@gpu.srv.ualberta.ca>

Wade Williams wrote:
> 
> This one is driving me crazy.
> 
> I've learned how to use references, but how do I get the structure pointed
> to by the reference?  For example:
> 
> @array=(1,2,3);
> 
> $theref=\@array;
> 
> $theref=($theref,4);
>          ^^^^^^^
> 
> I simply want to add something to the array pointed to by $theref.  How
> can I dereference theref in such a way that it gives me the array
> structure so I can use it in a line like the third line?
> 
> I know how to access the elements, I just can't figure out how to refer to
> the entire structure.

here's a couple examples:

@array=(1,2,3);
$theref=\@array;
print "@$theref : @array\n";
push @array,4;        # because $theref is reference to @array
print "@$theref : @array\n";
push @$theref,5;      # also changes @array
print "@$theref : @array\n";
$theref=[@$theref,6];  # $theref not a reference to @array any more
print "@$theref : @array\n";
@$theref=(@$theref,7); # $theref not reference to @array any more
print "@$theref : @array\n";

hope it helps
regards
andrew


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

Date: Wed, 21 Jan 1998 13:52:13 -0500
From: "Indy Singh" <indy@NOSPAMdemobuilder.com>
Subject: Re: Simple example of Select needed please
Message-Id: <6a5g0j$2po$1@nntp2.uunet.ca>

See example below.


Indy Singh
Mercury Systems
mailto: indy@NOSPAMzoomit.com
http://www.demobuilder.com/perl2exe.htm



# example of how to wait for data from two handles at the same time

$timeout = 30;   # seconds, 0 = no wait, undef = forever
$buflen = 1024;

vec($rin1,fileno(CLIENT),1) = 1;
vec($rin2,fileno(SERVER),1) = 1;
$rin = $rin1 | $rin2;
$connected = 1;
while($connected) {
    # wait until one of the sockes is ready_to_read or closed
    $ready = select($rout=$rin, undef, undef, $timeout);
    if (vec($rout,fileno(CLIENT),1)) {
        $len=sysread(CLIENT,$buf,$buflen);
        if ($len > 0) {
            print SERVER $buf;
            print $buf;
        }
        else {
            print STDERR "\nConnection closed by client\n";
            $connected = 0;
        }
    }
    if (vec($rout,fileno(SERVER),1)) {
        $len=sysread(SERVER,$buf,$buflen);
        if ($len > 0) {
            print CLIENT $buf;
            print $buf;
        }
        else {
            print STDERR "\nConnection closed by remote host\n";
            $connected = 0;
        }
    }
} # while ($connected)
close CLIENT;
close SERVER;


Paul Ryder wrote in message <34c4c69b.23512178@news.u-net.com>...
>Hi,
>
>Could someone just outline a simple example of how select works.
>
>Into the perl script will be coming the following :
>
>A Socket Connection
>Keyboard STDIN
>
>How can i use select to listen for both? no need to go into the
>listen/socket code, i just need to see how select works ..
>
>Thanks in advance!
>
>Regards
>
>Paul.
>
>
>_________________________________________________
>Paul Ryder                 http://www.f1world.com
>paul@pry.u-net.com         ICQ : 262573
>paul@f1world.com
>paul@quake2.com




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

Date: 21 Jan 1998 17:49:09 +0000
From: Piers Cawley <pdcawley@bofh.org.uk>
Subject: Re: source into binary code
Message-Id: <54pvllhg4q.fsf@gunnar.aladdin.net>

20 Jan 1998 16:07:59 +1100 Stuart Cooper <stuartc@ind.tansu.com.au> comp.lang.perl.misc
> Easily viewable source; such as you write in interpreted languages
> (ksh, awk, sed, TCL etc) and Perl encourage good programming because
> other people can see what you've done. 

Heh. That's the 'People who live in glass houses usually wear clothes'
argument isn't it?  

Ah. Sorry, I just felt this thread could do with a little levity.

-- 
Piers Cawley -- Systems Genie for Aladdin
If a `religion' is defined to be a system of ideas that contains
unprovable statements, then Godel taught us that mathematics is not
only a religion, it is the only religion that can prove itself to be
one. -- John Barrow


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

Date: 21 Jan 1998 17:52:54 +0000
From: Piers Cawley <pdcawley@bofh.org.uk>
Subject: Re: source into binary code
Message-Id: <54oh15hfyh.fsf@gunnar.aladdin.net>

18 Jan 1998 03:12:29 GMT stanley@skyking.OCE.ORST.EDU (John Stanley) comp.lang.perl.misc
> In article <Pine.GSO.3.96.980117174340.1296G-100000@user2.teleport.com>,
> Tom Phoenix  <rootbeer@teleport.com> wrote:
> >On 16 Jan 1998, John Stanley wrote:
> >
> >> If writing perl code were the way I wanted to make a living, I guess I
> >> couldn't do very well at it by giving it away, now could I? 
> >
> >You can make a good living by giving away the source while retaining or
> >selling the rights to use it. This is true not only for software but for
> >most other kinds of authoring as well. 
> 
> Once you can solve the problem of people using the source without
> paying for the rights to use it, yes, I agree, and if you recall, that
> was the impetus behind the start of this thread.

But they do that anyway. If you don't believe me take a look in
alt.binaries.warez.* sometime. 

-- 
Piers Cawley -- Systems Genie for Aladdin
If a `religion' is defined to be a system of ideas that contains
unprovable statements, then Godel taught us that mathematics is not
only a religion, it is the only religion that can prove itself to be
one. -- John Barrow


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

Date: Wed, 21 Jan 1998 13:04:24 -0500
From: Michael D Sohn <msda+@andrew.cmu.edu>
Subject: Summary: help with sorting
Message-Id: <0olXWc200YUd0DW1s0@andrew.cmu.edu>


I wrote:

: I have a table of information that is delineated by tabs that I want to
: sort.  The problem is that the column that I want to sort on is in
: scientific notation.  For example:

Thanks to Andrew J., Andrea G., Tad M. and Bryan W.  for the solution. 
Tad's answer was the most complete.

thanks again,
Mike


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

Tad wrote:


The problem is no problem  ;-)

Perl uses the C library to convert to a number, and the library
understands scientific notation.

Just use the usual <=> spaceship operator, and sort away, as
described in perlfunc and the sorting FMTEYEWTK.

( http://www.perl.com/CPAN/doc/FMTEYEWTK/sort.html )


-----------------------
#!/usr/bin/perl -w

@data = <DATA>;


@sorted = sort by2nd @data;                       # VERY inefficient...
foreach (@sorted) { print; }


@sorted = map  { $_->[0] }                        # Schwartzian Transform
          sort { $a->[1] <=> $b->[1] }            # use this if large list
          map  { [ $_, (split /\t/)[1] ] } @data;
foreach (@sorted) { print; }


sub by2nd { (split /\t/, $a)[1] <=> (split /\t/, $b)[1] }



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

Date: 21 Jan 1998 18:18:22 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Were can I get PERL
Message-Id: <6a5e5e$2gj@mozo.cc.purdue.edu>

"Rolf sthus" <roesthus@online.no> writes:
[His last name was mangled thanks to Purdue's 8-bit dirty software-mjg]

}Were can I get PERL from?

How does this question get asked?  It's so incredibly trivial to find
the perl web pages that posting this question to the newsgroup isn't
even laziness, since it takes MORE work![1]  Plus, you have to deal with
sarcastic bastards like me.

[1] I can't think of a way to look for perl and fail!  Any ideas?

-- 
Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net


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

Date: 21 Jan 1998 18:46:08 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Were can I get PERL
Message-Id: <6a5fpg$7vp$1@uranium.btinternet.com>

In article <6a5e5e$2gj@mozo.cc.purdue.edu>, gebis@albrecht.ecn.purdue.edu 
says...
>
<snip>
>
>[1] I can't think of a way to look for perl and fail!  Any ideas?
>

posting a question in comp.os.cpm (or such like) might be a start,
tho' perhaps not on second thoughts

/J\



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

Date: Wed, 21 Jan 1998 12:50:03 -0500
From: john -r s <johnrs@dc.net>
Subject: Writing inetd apps in perl
Message-Id: <34C6354A.51C1506C@dc.net>

I am interested in making the server side of client/server app work
under inetd.  I understand that inetd will handle the binding and
listening for the socket.  I need to understand how to get the address
using the `getsockname` function. I am not sure if my script needed to
create all of the address stuff and then call socket, like it does in
the regular stand alone version.

The client will connect to the port and pass a directory that it desires
to know the contents of. The server will execute the ls command and send
the information back to the client.  Here is an example:  Thanks for any
help.

#!/usr/local/bin/perl

use Socket;

$port = 1056;

($name, $aliases, $protocol) = getprotobyname('tcp');
if ($port !~ /^\d+$/) {
     ($name, $aliases, $port) = getservbyport($port, 'tcp');
}


socket(S,AF_INET,SOCK_STREAM,$proto) || die "socket : $!";
$sockaddr = 'S n a4 x8';
$this = pack($sockaddr, AF_INET, $port, "\0\0\0\0");

NS = getsockname(S);

if (($child = fork()) == 0) {
    $direc = (<NS>);
    $listing = `ls $direc`;
    print NS "$listing";
    exit;
 }

Any assistance is appreciated.
--
john -r s (unix spelling)
johnr~s (Windows 3.1 spelling)
JOHNRS (DOS spelling)
John R S (Win95 spelling)




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

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

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