[18384] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 552 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 23 06:05:42 2001

Date: Fri, 23 Mar 2001 03:05:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <985345512-v10-i552@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 23 Mar 2001     Volume: 10 Number: 552

Today's topics:
        "Here" documents and function evaluation <gtoomey@usa.net>
    Re: "Here" documents and function evaluation <krahnj@acm.org>
        A very simple question.... <lamuench@home.com>
    Re: A very simple question.... <gtoomey@usa.net>
    Re: A very simple question.... (Bernard El-Hagin)
    Re: A very simple question.... <lamuench@home.com>
    Re: CGI/setuid: "insecure dependency"? <je@bton.ac.uk>
    Re: Creating array context <uri@sysarch.com>
    Re: Creating array context <bart.lateur@skynet.be>
        Default @INC in ActiveState (Win32) nobull@mail.com
    Re: FAQ 8.10:   How do I read and write the serial port <iltzu@sci.invalid>
        fetch back STDERR outputs <johnlin@chttl.com.tw>
        Followup - evaluating functions in a FILE <gtoomey@usa.net>
    Re: h2xs recursive failure in assign_typemap_entry (Ilya Zakharevich)
        How do I find out how much space a group uses from with <batespd@ntlworld.com.nospam>
        Incorporating a Newsfeed <chris@nottsent.co.uk>
    Re: is there a way too.. (Bernard El-Hagin)
    Re: is there a way too.. <mrmead@canada.com>
        mail alias 2 html <amity@mainsoft.com>
    Re: Need help with script as I suck at perl. <mkuin@globalrangers.com>
    Re: Novice user can't get search and replace to work (Abigail)
    Re: perl OOP <johnlin@chttl.com.tw>
        PERL <girish66@yahoo.com>
    Re: PERL (Bernard El-Hagin)
    Re: Pointers in Perl <iltzu@sci.invalid>
    Re: Pointers in Perl (Abigail)
    Re: Read from file into hash <uri@sysarch.com>
    Re: Read from file into hash (Abigail)
        regexp with // in the input string <zander@xs3.xs4all.nl>
    Re: regexp with // in the input string (Abigail)
    Re: regexp with // in the input string <tinamue@zedat.fu-berlin.de>
    Re: Simulating keyboard activity (Gwyn Judd)
    Re: Spawning a separate process (Rafael Garcia-Suarez)
    Re: Weird(?) magic word for sh to invoke perl under Lin (Michael Wang)
    Re: Weird(?) magic word for sh to invoke perl under Lin (Abigail)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 23 Mar 2001 16:46:53 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: "Here" documents and function evaluation
Message-Id: <c7Cu6.1672$45.7902@newsfeeds.bigpond.com>

Can here documents be used to evaluate functions as well as expressions?

The following cgi fragment works in Perl 5. Perl will expand expressions as
expected:

my @mylist=('a','b','c','d');
print <<EOF;
Element is $mylist[1+2]
Server is $ENV{"SERVER_NAME"}
EOF

However, if you have a function myfunc and reference it as myfunc() or
&myfunc()
it appears unevalauted.
Is it possible to call a function in a here document?

gtoomey




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

Date: Fri, 23 Mar 2001 07:43:52 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: "Here" documents and function evaluation
Message-Id: <3ABB005A.DC36DA39@acm.org>

Gregory Toomey wrote:
> 
> Can here documents be used to evaluate functions as well as expressions?
> 
> The following cgi fragment works in Perl 5. Perl will expand expressions as
> expected:
> 
> my @mylist=('a','b','c','d');
> print <<EOF;
> Element is $mylist[1+2]
> Server is $ENV{"SERVER_NAME"}
> EOF
> 
> However, if you have a function myfunc and reference it as myfunc() or
> &myfunc()
> it appears unevalauted.
> Is it possible to call a function in a here document?

print <<EOF;
Element is $mylist[1+2]
Server is $ENV{"SERVER_NAME"}
@{[myfunc()]}
EOF


John
-- 
use Perl;
program
fulfillment


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

Date: Fri, 23 Mar 2001 06:50:42 GMT
From: "Laurie Muench" <lamuench@home.com>
Subject: A very simple question....
Message-Id: <6nCu6.605904$U46.18457382@news1.sttls1.wa.home.com>

I am new to perl and trying to write to the file:

 /photo/family/album.htm

from:

/photo/cgi-bin/family/submit.cgi

and I do not know the correct way to reference it.  Do I use the variable:

$hfile = ".../family/album.htm" ???

Can't get it to work.  Thanks for any help.
Laurie

PS  I don't know the complete path





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

Date: Fri, 23 Mar 2001 17:04:34 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Re: A very simple question....
Message-Id: <NnCu6.1690$45.7880@newsfeeds.bigpond.com>

Assuming your are on Unix, use two dots instead of three
"../family/album.htm".

there can also be probs on how your web server is set up:
make sure of your current directory (use system("pwd"))
make sure you have write permission (try writing to ANY file)

gtoomey
--------------
"Laurie Muench" <lamuench@home.com> wrote in message
news:6nCu6.605904$U46.18457382@news1.sttls1.wa.home.com...
> I am new to perl and trying to write to the file:
>
>  /photo/family/album.htm
>
> from:
>
> /photo/cgi-bin/family/submit.cgi
>
> and I do not know the correct way to reference it.  Do I use the variable:
>
> $hfile = ".../family/album.htm" ???
>
> Can't get it to work.  Thanks for any help.
> Laurie
>
> PS  I don't know the complete path
>
>
>




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

Date: Fri, 23 Mar 2001 07:06:36 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: A very simple question....
Message-Id: <slrn9blt9c.qlm.bernard.el-hagin@gdndev32.lido-tech>

[You really need to try to come up with better subjects which say more
about the question you want to ask.]

On Fri, 23 Mar 2001 06:50:42 GMT, Laurie Muench <lamuench@home.com> wrote:
>I am new to perl and trying to write to the file:
>
> /photo/family/album.htm
>
>from:
>
>/photo/cgi-bin/family/submit.cgi
>
>and I do not know the correct way to reference it.  Do I use the variable:
>
>$hfile = ".../family/album.htm" ???

Read about the 'open' function:

perldoc -f open

And read the "tutorial on opening things in Perl":

perldoc perlopentut

>PS  I don't know the complete path

And you expect one of us to?

Cheers,
Bernard
--
#requires 5.6.0
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'


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

Date: Fri, 23 Mar 2001 09:15:46 GMT
From: "Laurie Muench" <lamuench@home.com>
Subject: Re: A very simple question....
Message-Id: <6vEu6.606138$U46.18483928@news1.sttls1.wa.home.com>

Nevermind.  I figured it out.  I am too used to Windows.
"../../family/album.htm" is what I wanted.




"Laurie Muench" <lamuench@home.com> wrote in message
news:6nCu6.605904$U46.18457382@news1.sttls1.wa.home.com...
> I am new to perl and trying to write to the file:
>
>  /photo/family/album.htm
>
> from:
>
> /photo/cgi-bin/family/submit.cgi
>
> and I do not know the correct way to reference it.  Do I use the variable:
>
> $hfile = ".../family/album.htm" ???
>
> Can't get it to work.  Thanks for any help.
> Laurie
>
> PS  I don't know the complete path
>
>
>




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

Date: Fri, 23 Mar 2001 09:07:53 +0000
From: John English <je@bton.ac.uk>
Subject: Re: CGI/setuid: "insecure dependency"?
Message-Id: <3ABB1269.4722AF2A@bton.ac.uk>

Rafael Garcia-Suarez wrote:
> 
> John English wrote in comp.lang.perl.misc:
> >
> > I've got a CGI script which is setuid to allow me to write to a
> > log file, but the server (Apache) barfs and I get a message in
> > the server error log to the effect that there's an "insecure
> > dependency" in the call to open.
> 
> Look up this error message in perldiag, this will explain to you its
> meaning. Then, read about the tainting mechanism in the perlsec manpage.

Ah, many thanks. Found it, and all is clear.

> Alternatively, instead of making your CGI scripts setuid, learn about
> the suExec feature of Apache.

Thanks, that sounds like it might be preferable.

-----------------------------------------------------------------
 John English              | mailto:je@brighton.ac.uk
 Senior Lecturer           | http://www.it.bton.ac.uk/staff/je
 Dept. of Computing        | ** NON-PROFIT CD FOR CS STUDENTS **
 University of Brighton    |    -- see http://burks.bton.ac.uk
-----------------------------------------------------------------


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

Date: Fri, 23 Mar 2001 06:33:40 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Creating array context
Message-Id: <x78zlx2dve.fsf@home.sysarch.com>

>>>>> "BH" == Bjoern Hoehrmann <bjoern@hoehrmann.de> writes:

  BH> my $B = scalar @{[$user =~ m|[$comp]|g]} # [1] [2]

well the less ugly (but ugly enough) way to do that is:

	my $B = () = $user =~ m/[$comp]/g ;

and since that is just a char class if you know the chars in advance you
can use tr/// to count them even faster:

	my $B = $user =~ tr/chars// ;

you can't select the chars at runtime without an eval string call.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Fri, 23 Mar 2001 09:31:59 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Creating array context
Message-Id: <es5mbt8qiqkqb2of16bjr89h4dfvd9roqu@4ax.com>

Randal L. Schwartz wrote:

>Bjoern>   my $B = scalar @{[$user =~ m|[$comp]|g]} # [1] [2]
>
>Simpler to go:
>
>  my $count = () = $user =~ m/[$comp]/g;
>

Addendum: there has been some heavy discussion on the Perl6 mailing list
around the request of adding a "list" keyword. It turns out that this is
a grey area in perl, there's no way to uniquely define what exactly it
would do in all cases, especially in combination with "scalar".
Therefore it won't be added. You'll have to help yourself with various
workarounds, like this one, which all behave slightly different in
border cases. You can check the Perl6 archives.

-- 
	Bart.


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

Date: 23 Mar 2001 09:57:32 +0000
From: nobull@mail.com
Subject: Default @INC in ActiveState (Win32)
Message-Id: <u9k85giz8z.fsf@wcl-l.bham.ac.uk>

Can I add to the default @INC when intalling a binary ActiveState
distribution on Win32?  

I want to be able to use PERL5LIB to tweek @INC on a per-user or
per-process basis without having to worry about preserving system wide
setting.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 23 Mar 2001 09:34:29 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: FAQ 8.10:   How do I read and write the serial port?
Message-Id: <985339849.29958@itz.pp.sci.fi>

[Posted and mailed to faq@denver.pm.org]

In article <N67u6.127$T3.170583552@news.frii.net>, PerlFAQ Server wrote:
>+
>  How do I read and write the serial port?
 [snip]
>        to give the numeric values you want directly, using octal ("\015"),
>        hex ("0x0D"), or as a control-character specification ("\cM").

Should be "\x0D" instead of "0x0D", surely?

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla / Kira -- do not feed the troll.


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

Date: Fri, 23 Mar 2001 17:04:13 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: fetch back STDERR outputs
Message-Id: <99f3ff$q53@netnews.hinet.net>

Dear all,

I write a program which redirect the STDERR messages to a file.
Then, if there WERE errors, fetch them back (by seek and read)
for further processing (for example: email to notify).

The little testing program works, but when I put it in a module
it fails.

use strict;
local *ERR;
open ERR,"+>>test.err" or die $!;
open STDERR,">>&ERR" or die $!;
my $tell = tell STDERR;
warn "hello\n";
if(tell(STDERR) > $tell) {
    seek ERR,$tell,0 or die "seek failed\n";
    print for <ERR>;
}

It works.  Now I put it in a module

package AG;
use strict;
local *ERR;
open ERR,"+>>test.err" or die $!;
open STDERR,">>&ERR" or die $!;
my $tell = tell STDERR;
END {
    if(tell(STDERR) > $tell) {
        seek ERR,$tell,0 or die "seek failed\n";
        print for <ERR>;
    }
}
1

And call it with a small program

use AG;
warn "hello\n";

It won't work.  The error message is:

seek() on unopened file at AG.pm line 9.
seek failed
END failed--call queue aborted.

I tried everything to fix it up, but failed.
Could you help me?  Thank you very much.

John Lin






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

Date: Fri, 23 Mar 2001 18:39:33 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Followup - evaluating functions in a FILE
Message-Id: <PMDu6.1757$45.8063@newsfeeds.bigpond.com>

Thanks John for the fast response. It works fine.

Now assume we have a file test.htm that contains the following 3 lines:
Element is $mylist[1+2]
Server is $ENV{"SERVER_NAME"}
Func is @{[myfunc()]}

It's trivial to read the file into a list or variable.
But can the file be processed to correctly evaluate each line?

gtoomey
------------------
"John W. Krahn" <krahnj@acm.org> wrote in message
news:3ABB005A.DC36DA39@acm.org...
> Gregory Toomey wrote:
> >
> > Can here documents be used to evaluate functions as well as expressions?
> >
> > The following cgi fragment works in Perl 5. Perl will expand expressions
as
> > expected:
> >
> > my @mylist=('a','b','c','d');
> > print <<EOF;
> > Element is $mylist[1+2]
> > Server is $ENV{"SERVER_NAME"}
> > EOF
> >
> > However, if you have a function myfunc and reference it as myfunc() or
> > &myfunc()
> > it appears unevalauted.
> > Is it possible to call a function in a here document?
>
> print <<EOF;
> Element is $mylist[1+2]
> Server is $ENV{"SERVER_NAME"}
> @{[myfunc()]}
> EOF
>
>
> John
> --
> use Perl;
> program
> fulfillment




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

Date: 23 Mar 2001 07:33:07 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: h2xs recursive failure in assign_typemap_entry
Message-Id: <99eu7j$m80$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to david carter
<david_no_spam@carter.net>],
who wrote in article <KCeu6.159518$Z8.34327128@typhoon.southeast.rr.com>:
> (1) commented out the union-typedef'd member of the struct. (Left the union
> defined, but unreferenced.) h2xs completed with no errors.
> Now looks like this:
> 
> typedef union arm_user_metric1_u {
>     arm_unsigned32_t  counter32;       /*  Counter32  */

 ...

Thanks for your detective work.  But let me give you a free advice
from another side of the fence: it would be much easier to understand
what is going on (and thus you get much fatter chance of it being
fixed in a timely manner) if you first reduce your problematic .h file
while preserving your problem.

Given what you found, I would estimate that you can produce a failing
10-liner which does not include anything else.

Another thread of info: I won't be able to look into this in a
foreseeable future.  The code to autogenerate struct-accessors was
written by Hugo.  You may have a better chance Cc'ing him too.

Thanks again for your time and enthusiam, and hope this helps,
Ilya


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

Date: Fri, 23 Mar 2001 08:31:08 -0000
From: "batespd" <batespd@ntlworld.com.nospam>
Subject: How do I find out how much space a group uses from within perl
Message-Id: <IPDu6.20808$Q4.3902713@news2-win.server.ntlworld.com>

How do I findout how much space a group uses from within a perl script under
unix?
I can find out how much a user has used but I want to know how to get group
usage stats?

Paul





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

Date: Fri, 23 Mar 2001 08:45:21 -0000
From: "Chris Spencer" <chris@nottsent.co.uk>
Subject: Incorporating a Newsfeed
Message-Id: <tbm38o7m9bj1eb@xo.supernews.co.uk>

Does anyone know of an existing cgi script that will allow me to display
(preferably filtered) UK news on my site.

I would like to be able to add some keywords into the script (eg.
Nottinghamshire, Derbyshire) and just display the headlines that are related
to the keywords..

Is there such thing (free or otherwise)

Thanks

I have posted this in this group as well as the PERL group incase either
group members can help me




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

Date: Fri, 23 Mar 2001 06:49:11 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: is there a way too..
Message-Id: <slrn9blscg.qlm.bernard.el-hagin@gdndev32.lido-tech>

On Fri, 23 Mar 2001 01:36:36 GMT, Mr. Man <mrmead@canada.com> wrote:
>I need to capture a cgi script from another web site is this possible?

What you *really* need is to come up with better subjects, post to a
suitable newsgroup, stop trying to 'capture' cgi scripts you weren't
meant to 'capture'.

Cheers,
Bernard
--
#requires 5.6.0
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'


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

Date: Fri, 23 Mar 2001 06:55:16 GMT
From: "Mr. Mead" <mrmead@canada.com>
Subject: Re: is there a way too..
Message-Id: <orCu6.35675$5P1.470711@news1.rdc1.ab.home.com>

actually I'm working from a remote computer and I would like to work on MY
scripts thank you.  As for any other normal way(ie ftp, telnet) I wasn't
expecting to need this and I didn't start my servers before I left.


"Tim Hammerquist" <tim@vegeta.ath.cx> wrote in message
news:slrn9blc24.g2o.tim@vegeta.ath.cx...
> Mr. Man <mrmead@canada.com> wrote:
> > I need to capture a cgi script from another web site is this possible?
>
> Does this sound suspicious to anyone else?  ;)
>
> Basically, if you were meant to have the script, it would be made
> available to you.
>
> --
> -Tim Hammerquist <timmy@cpan.org>
>
>
> scanf() is evil.




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

Date: Thu, 22 Mar 2001 13:25:52 +0200
From: "ronen amity" <amity@mainsoft.com>
Subject: mail alias 2 html
Message-Id: <99cnb1$djp$1@news.netvision.net.il>

i am looking for a script that will make a html file with all my aliases
from /etc/aliases as links (and expand them).
do you know of anything ?




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

Date: Fri, 23 Mar 2001 11:39:30 +0100
From: "Mark Kuin" <mkuin@globalrangers.com>
Subject: Re: Need help with script as I suck at perl.
Message-Id: <99f9j1$n6p$1@news1.xs4all.nl>

You don't only suck at perl. You also suck in telling what you actually
need. This has nothing to do with perl, but with asking the wrong guy to do
something he doesn't understand, and who doesn't know how to get things
clear. Please get some education before posting to this newsgroup.

hth Mark

> I am suppose to call this link:
> http://www.abc.com/xxx.cgi?link=Dude/1/test&seed=41FLZ9FJJ
> which return this:
> http://www.xzy.com/default.asp?seed=41FLZ9FJJ &pop=12&receipt=12
> Then I am suppose to pass the pop to a function called valid.
> How heck to I do this??
> I am suppose to recall the abc.com link but I cant figure it out.





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

Date: Fri, 23 Mar 2001 10:26:04 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: Novice user can't get search and replace to work
Message-Id: <slrn9bm95s.dtp.abigail@tsathoggua.rlyeh.net>

John W. Krahn (krahnj@acm.org) wrote on MMDCCLXI September MCMXCIII in
<URL:news:3ABACD07.B6E1B4C3@acm.org>:
@@ "John W. Krahn" wrote:
@@ > 
@@ > [snip]
@@ > 
@@ > > while (<STATUS>){
@@ > >  s/(<\B\>Last Updated<\/B\><\br\>*?);/$update/;
@@                                 ^^
@@ I just noticed this. You are trying to match a backspace character (\b).


Eh, no. The poster is trying to match a word boundary.


Abigail
-- 
#!/opt/perl/bin/perl -w
$\ = $"; $; = $$; END {$: and print $:} $SIG {TERM} = sub {$ := $_}; kill 15 =>
fork and ($; == getppid and exit or wait) foreach qw /Just another Perl Hacker/


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

Date: Fri, 23 Mar 2001 13:41:32 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: perl OOP
Message-Id: <99enjj$20d@netnews.hinet.net>

I was shocked!!!  How could our hero "Abigail" <abigail@foad.org> wrote
such a terrible thing in news:slrn9bke6m.n30.abigail@tsathoggua.rlyeh.net...
> You can change the inheritance tree of a class by modifying @INC.
Dear, Isn't it @ISA?
John Lin





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

Date: Fri, 23 Mar 2001 16:44:55 +1000
From: "Vontel Girish" <girish66@yahoo.com>
Subject: PERL
Message-Id: <99erk0$heu$1@kraken.itc.gu.edu.au>

I am creating a shopping cart in Perl Language. Can any one tell me if any
code is available on the net????




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

Date: Fri, 23 Mar 2001 07:10:35 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: PERL
Message-Id: <slrn9bltkj.qlm.bernard.el-hagin@gdndev32.lido-tech>

On Fri, 23 Mar 2001 16:44:55 +1000, Vontel Girish <girish66@yahoo.com> wrote:
>I am creating a shopping cart in Perl Language. Can any one tell me if any
>code is available on the net????

Yes, there is.

Cheers,
Bernard
--
#requires 5.6.0
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'


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

Date: 23 Mar 2001 09:24:14 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Pointers in Perl
Message-Id: <985339013.29144@itz.pp.sci.fi>

In article <b7thbtgsbho1hjdmmulod8nhnou86ghvfu@4ax.com>, Bart Lateur wrote:
>Milliwave wrote:
>
>>Has anyone come across the usage of pointers in Perl? I certainly have not
>>see these being used.
>
>What would you want to do with pointers that you can't do    with
>references?

Pointer arithmetic?

There's a really nice -- in a twisted way -- example in the _Art of
Computer Programming_ of saving space in a doubly linked list by XORing
the previous and next node pointers together.  You can still traverse
such a list, provided you always keep pointers to two adjacent nodes.

Try showing that to a garbage collector..

(Before anyone jumps up and says it: No, of course there's no point in
doing that in Perl, except perhaps making people's heads explode.  But
it _is_ a lot of fun to implement in assembly.)

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla / Kira -- do not feed the troll.


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

Date: Fri, 23 Mar 2001 10:45:55 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: Pointers in Perl
Message-Id: <slrn9bmab3.dtp.abigail@tsathoggua.rlyeh.net>

Ilmari Karonen (iltzu@sci.invalid) wrote on MMDCCLXI September MCMXCIII
in <URL:news:985339013.29144@itz.pp.sci.fi>:
][ In article <b7thbtgsbho1hjdmmulod8nhnou86ghvfu@4ax.com>, Bart Lateur wrote:
][ >Milliwave wrote:
][ >
][ >>Has anyone come across the usage of pointers in Perl? I certainly have not
][ >>see these being used.
][ >
][ >What would you want to do with pointers that you can't do    with
][ >references?
][ 
][ Pointer arithmetic?
][ 
][ There's a really nice -- in a twisted way -- example in the _Art of
][ Computer Programming_ of saving space in a doubly linked list by XORing
][ the previous and next node pointers together.  You can still traverse
][ such a list, provided you always keep pointers to two adjacent nodes.
][ 
][ Try showing that to a garbage collector..
][ 
][ (Before anyone jumps up and says it: No, of course there's no point in
][ doing that in Perl, except perhaps making people's heads explode.  But
][ it _is_ a lot of fun to implement in assembly.)


I don't think Knuth would be a big fan of Perl, but he loves a programming
trick just like many people here, and he certinly likes to play golf.

I recently read an article where Knuth describes a game of golf on a 50's
machine. The machine read cards, and one could put 8 machine instructions
on a card. The goal was to write a program fitting on one card that would
read in a number, and reverse it.

Noone was able to do it, but Knuth once stunned his fellow students.
He came in, put a card in the reader, entered the number 123456789,
ran the program, and the program outputted 987654321.

Of course, the program would always output 987654321, regardless of
the number on input.

Later, the machine got an extension. A whopping extra register, with
front panel toggles. Which could be used to store an instruction as
well. Knuth was delighted that that enabled him to write a single card
program that reversed a number.



Abigail
-- 
perl -le 's[$,][join$,,(split$,,($!=85))[(q[0006143730380126152532042307].
          q[41342211132019313505])=~m[..]g]]e and y[yIbp][HJkP] and print'


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

Date: Fri, 23 Mar 2001 07:17:46 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Read from file into hash
Message-Id: <x766h12btx.fsf@home.sysarch.com>

>>>>> "AF" == Alan Friedman <afried@mediaone.net> writes:

  AF> Fruits|apple
  AF> Fruits|pear
  AF> Fruits|orange
  AF> Fruits|peach
  AF> Animals|cat
  AF> Animals|dog
  AF> Animals|mouse
  AF> Birds|sparrow
  AF> Birds|crow
  AF> Birds|cardinal
  AF> Car|Ford

  AF> %thehash = ( "Fruits"    => ["apple","pear","orange","peach"],
  AF> "Animals"   => ["cat","dog","mouse"],
  AF> "Birds"     => ["sparrow","crow","cardinal"],
  AF> "Car"       => ["Ford"]
  AF> );

while( <FH> ) {

	my( $key, $val ) = split /\|/ ;
	push( @{$thehash{$key}}, $val ) ;
}

see my tutorial on autovivification at:

http://tlc.perlarchive.com/articles/perl/ug0002.shtml

that will explain the push line.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Fri, 23 Mar 2001 10:53:51 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: Read from file into hash
Message-Id: <slrn9bmapv.dtp.abigail@tsathoggua.rlyeh.net>

Alan Friedman (afried@mediaone.net) wrote on MMDCCLXI September MCMXCIII
in <URL:news:3ABAB2F6.4BBAC09B@mediaone.net>:
|| I have a text file with a pair of words separated by the "or" bar
|| on each line as follows:
|| 
|| Fruits|apple
|| Fruits|pear
|| Fruits|orange
|| Fruits|peach
|| Animals|cat
|| Animals|dog
|| Animals|mouse
|| Birds|sparrow
|| Birds|crow
|| Birds|cardinal
|| Car|Ford
|| 
|| etc.
|| 
|| 
|| I need to read in the pairs and assign them to a hash
|| as follows:
|| 
|| %thehash = ( "Fruits"    => ["apple","pear","orange","peach"],
||              "Animals"   => ["cat","dog","mouse"],
||              "Birds"     => ["sparrow","crow","cardinal"],
||              "Car"       => ["Ford"]
||            );
|| 


Well, that is nice. What do you have so far, or are you just using
this group to have someone do you homework for you?


Abigail


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

Date: 23 Mar 2001 09:06:41 GMT
From: Thomas <zander@xs3.xs4all.nl>
Subject: regexp with // in the input string
Message-Id: <99f3n1$9um$1@news1.xs4all.nl>

Hi, 

I have a regexp to find strings in a C-source file;
    m/i18n\(\"(.*?)\"/;
    $theString .= $1;

This maches fine, and all i18n("blaat") are found,
except when the text between the quotes contains a double slash.
The 
  i18n("http://blaat")
did not mach; any idea how to mach this anyway?

Using perl, version 5.005_03 built for i586-linux 

Thanx!


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

Date: Fri, 23 Mar 2001 10:57:53 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: regexp with // in the input string
Message-Id: <slrn9bmb1h.dtp.abigail@tsathoggua.rlyeh.net>

Thomas (zander@xs3.xs4all.nl) wrote on MMDCCLXI September MCMXCIII in
<URL:news:99f3n1$9um$1@news1.xs4all.nl>:
,, Hi, 
,, 
,, I have a regexp to find strings in a C-source file;
,,     m/i18n\(\"(.*?)\"/;
,,     $theString .= $1;
,, 
,, This maches fine, and all i18n("blaat") are found,
,, except when the text between the quotes contains a double slash.
,, The 
,,   i18n("http://blaat")
,, did not mach; any idea how to mach this anyway?


   $ perl -wle '$_ = q{i18n("http://blaat")}; m/i18n\(\"(.*?)\"/; print $1'
   http://blaat
   $


Abigail
-- 
#!/opt/perl/bin/perl   --    # No trailing newline after the last line!    
BEGIN{$|=$SIG{__WARN__}=sub{$_=$_[0];y-_- -;print/(.)"$/;seek _,-open(_ 
,"+<$0"),2;truncate _,tell _;close _;exec$0}}//rekcaH_lreP_rehtona_tsuJ


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

Date: 23 Mar 2001 10:59:47 GMT
From: Tina Mueller <tinamue@zedat.fu-berlin.de>
Subject: Re: regexp with // in the input string
Message-Id: <99fab3$ukev$3@fu-berlin.de>

hi,
Thomas <zander@xs3.xs4all.nl> wrote:

> I have a regexp to find strings in a C-source file;
>     m/i18n\(\"(.*?)\"/;
              ^^     ^^
no need to escape

>     $theString .= $1;

> This maches fine, and all i18n("blaat") are found,
> except when the text between the quotes contains a double slash.
> The 
>   i18n("http://blaat")
> did not mach; any idea how to mach this anyway?

> Using perl, version 5.005_03 built for i586-linux 

works for me:
11:56am tina.mueller@lolland tina.mueller > perl -e'
$_=qq~i18n("http://blaat")~;
print if m/i18n\("(.*?)"/;
'
i18n("http://blaat")

11:56am tina.mueller@lolland tina.mueller > perl -v
This is perl, version 5.005_03 built for sun4-solaris

regards,
tina

-- 
http://tinita.de    \  enter__| |__the___ _ _ ___
tina's moviedatabase \     / _` / _ \/ _ \ '_(_-< of
search & add comments \    \ _,_\ __/\ __/_| /__/ perception
please don't email unless offtopic or followup is set. thanx


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

Date: Fri, 23 Mar 2001 05:33:58 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Simulating keyboard activity
Message-Id: <slrn9blo24.vsm.tjla@thislove.dyndns.org>

I was shocked! How could Tim Walton <walton@gatwick.geco-prakla.slb.com>
say such a terrible thing:
>Why? Im using a dialup connection and because of a software bug
>over which I have no control , the dialup closes down after 5 mins 
>of inactivity and my user loses what he was doing: all his apps
>die when the line dies. So I just want to keep the line alive by 
>making the thing think theres someone tapping away at the kbd.

Why not just simulate some network activity every five minutes? Simply
put a 'ping -c 1 your.nearest.router' in your crontab. Nothing to Perl
here, move along.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
"You can't teach people to be lazy - either they have it, or they
don't."
		-- Dagwood Bumstead


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

Date: Fri, 23 Mar 2001 07:22:49 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Spawning a separate process
Message-Id: <slrn9blueg.co9.rgarciasuarez@rafael.kazibao.net>

hgajarla@hotmail.com wrote in comp.lang.perl.misc:
> Can anyone tell me how to spawn a process in a new shell or window.  I am
> looking for a perl command that lets me use on windows and unix platforms.
> For example in windows I can say "system("start cmd")" for
> opening a new dos
> process. Similarly I can use -sh command to start a new shell in Unix. But
> both of these are platform specific and I am looking for a command which is
> perl native. Appreciate your help. 

My suggestion :
Make your own module, that tests the current OS (with $^O) and that
performs this operation accordingly. Then, use this module in your
programs.

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Fri, 23 Mar 2001 05:17:44 GMT
From: mwang@mindspring.com (Michael Wang)
Subject: Re: Weird(?) magic word for sh to invoke perl under Linux
Message-Id: <Y%Au6.3610$5%5.769639@news.uswest.net>

>You mean mere users can't modify their PATH in their own shell profile or rc
>files? If people are smart enough to write scripts, wouldn't they be smart
>enough to change PATH? Assuming neither . not ~/bin is in their default
>path, they're either going to get very sick of typing ./ or similar before
>every command or they're going to change their path.

For non-interactive use, cron as an example, you expect people to use

PATH=/usr/local/bin /whatever/path/perl-program-with-#!/usr/bin/env-perl?



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

Date: Fri, 23 Mar 2001 09:34:06 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: Weird(?) magic word for sh to invoke perl under Linux
Message-Id: <slrn9bm64e.cpv.abigail@tsathoggua.rlyeh.net>

Harlan Grove (hrlngrv@aol.com) wrote on MMDCCLXI September MCMXCIII in
<URL:news:6oxu6.741$9i1.47915@bgtnsc04-news.ops.worldnet.att.net>:
[] Abigail <abigail@foad.org> wrote in ...
[] >* Tong * (sun_tong_001@yahoo.com) wrote on ...
[] >%% abigail@foad.org (Abigail) writes:
[] ...
[] >%% > Then /usr/bin/env only works for those who have the correct path.
[] >%%
[] >%% yes, Abigail, but the normal situation is that the sys admin won't
[] >%% change anything for any personal requests. Setting my path correctly
[] >%% is far more easier than making them believe /usr/bin/perl is the
[] >%% right place for perl...
[] >
[] >Hmmm. So, setting the path correctly on all systems for all users under
[] >all circumstances (cron! -T!) is *easier* than setting #! once for each
[] >program on each system? Which you could do from 'make install' anyway?
[] ...
[] 
[] The sysadmin would only do custom software installations into /usr/local or
[] /opt but would allow mere users to write generally available scripts?
[] Wouldn't it be FAR MORE LIKELY that this is an individual user writing
[] scripts for personal use? S/he does have to ensure her/his path is correct,
[] but if so, then getting the path right would be the way to go - allowing
[] individuals to put /usr/local/bin, /opt/bin or (Solaris-specific) the POSIX
[] bin directory before /usr/bin without affecting general stuff.

If it's just an individual writing a program for personal use, why would
such an individual have the need for the env trick, or the eval one?
It isn't hat perl will be walking all over. Perl will remain in one place.
Stick that place in the top line, and you're done.

[] It should be obvious from the original post that the OP is running a script
[] in ~. Presumably ALL USERS wouldn't need access to it. Only ONE user would
[] need the appropriate path. Seems practical.

Seems to me that the OP planned to distribute the program. Or else,
the stated problem would not be a problem at all.

[] >As for that sysadmin, I am such a sysadmin. I do believe that
[] >/usr/bin/perl is the right place - for the perl that comes with the
[] >OS. The perl that's current, compiled with the available compiler and
[] >compiled with the options desired does live elsewhere. /opt/perl for
[] >instance. And guess what, that isn't in someones default $PATH.
[] ...
[] 
[] You mean mere users can't modify their PATH in their own shell profile or rc
[] files? If people are smart enough to write scripts, wouldn't they be smart
[] enough to change PATH? Assuming neither . not ~/bin is in their default
[] path, they're either going to get very sick of typing ./ or similar before
[] every command or they're going to change their path.

People putting . in their PATH will be bitten sooner or later anyway.



Abigail
-- 
               split // => '"';
${"@_"} = "/"; split // => eval join "+" => 1 .. 7;
*{"@_"} = sub {foreach (sort keys %_)  {print "$_ $_{$_} "}};
%{"@_"} = %_ = (Just => another => Perl => Hacker); &{%{%_}};


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

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 V10 Issue 552
**************************************


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