[19590] in Perl-Users-Digest
Perl-Users Digest, Issue: 1785 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 21 06:05:42 2001
Date: Fri, 21 Sep 2001 03:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1001066710-v10-i1785@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 21 Sep 2001 Volume: 10 Number: 1785
Today's topics:
a question about comments in perl <Rene.Scheibe@gmx.net>
Re: a question about comments in perl <Thomas@Baetzler.de>
Re: a question about comments in perl <josef.moellers@fujitsu-siemens.com>
Re: Access CGI-Bin on IIS 4 or 5 (Jonadab the Unsightly One)
Re: CGI params to a hash [was: Use symbol table like ' (Bianka Martinovic)
Re: Creating a file <please@no.spam>
Re: Creating a file <s_grazzini@hotmail.com>
Re: Creating a file <rogier@arpadrive-in.com>
Re: Creating a file <liviu@mediaimage.ro>
How to get the path of current directory in perl (Merina)
i feel i miss some important knowledge !! (hugh1)
Re: Interrupted Server Socket Connections (Ilja Tabachniks)
Re: perl pattern matching question <Graham.T.Wood@oracle.com>
Process ID <dahlin.jkpg@swipnet.se>
Re: Process ID news@roaima.demon.co.uk
Re: Reading cookies from a different path (Mark-Jason Dominus)
Re: Reading cookies from a different path (Mark-Jason Dominus)
regex effeciency question (Rodney Rindels)
strip links out of html (Dav Lam)
Re: Use symbol table like 'real' hash (Bianka Martinovic)
Re: Use symbol table like 'real' hash (Bianka Martinovic)
using a variable to call a function (Andy)
Re: using a variable to call a function <Thomas@Baetzler.de>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 21 Sep 2001 09:26:31 +0200
From: "Rene Scheibe" <Rene.Scheibe@gmx.net>
Subject: a question about comments in perl
Message-Id: <9oeq43$d387v$1@ID-65612.news.dfncis.de>
Can someone tell me how to not just comment
out one line with # but a whole section?
Thanx
------------------------------
Date: Fri, 21 Sep 2001 09:57:27 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: a question about comments in perl
Message-Id: <ukslqtkbesf6hut13forqdmrj8f4b6cpf4@4ax.com>
On Fri, 21 Sep 2001, "Rene Scheibe" <Rene.Scheibe@gmx.net> wrote:
>Can someone tell me how to not just comment
>out one line with # but a whole section?
Simple - just put a # in front of each line you want to comment out.
:-P
SCNR,
--
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl
------------------------------
Date: Fri, 21 Sep 2001 10:33:33 +0200
From: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: a question about comments in perl
Message-Id: <3BAAFB5D.1200AC3D@fujitsu-siemens.com>
Rene Scheibe wrote:
> =
> Can someone tell me how to not just comment
> out one line with # but a whole section?
Can't you use pod style sections?
Just an idea ...
-- =
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: Fri, 21 Sep 2001 04:06:09 GMT
From: jonadab@bright.net (Jonadab the Unsightly One)
Subject: Re: Access CGI-Bin on IIS 4 or 5
Message-Id: <3baabb80.11205349@news.bright.net>
scztjp@yahoo.com (Danish King) wrote:
> I am looking for someone to help me understand how to gain access to a
> remote IIS 4 & 5 CGI directory.
This is a bad time to ask about IIS on a group full of geeks
who probably use a better web server and are probably very
tired of getting logs full of requests for nonextent files and
may well be considering writing an IIS worm that installs the
$%@! patch or maybe even downloads Apache and replaces IIS
with it.
--
$_=$j="(.";s/$/.)/;$o=$_;s/..//;$k=reverse;($a,$b,$c,)="U r bad"=~
"$j$k$j$k$j+)";($f,$d)="lyons"=~"$o.$o";$_=$d;s/s/o/;$;=reverse($c
."a$_");s/o/e/ ;$e="O$_";$g="h";s/$/t/;$ := ".$_";($i) =/(.)$/;$,=
"ig$g$i";$\="he $a$d$,$f $e <j$;\@b$b$,$:>$/";print"$/-- $/J$; $i";
------------------------------
Date: 21 Sep 2001 07:59:29 GMT
From: blackbird@chatterpages.de (Bianka Martinovic)
Subject: Re: CGI params to a hash [was: Use symbol table like 'real' hash]
Message-Id: <9oes11$fcq$2@penthesilea.materna.de>
In article <1001026980.9565@itz.pp.sci.fi>, iltzu@sci.invalid says...
>
>You can already get the parameters from CGI.pm in a (tied) hash. See
>the section "COMPATIBILITY WITH CGI-LIB.PL" in the CGI.pm documentation
>for details.
>
Hello, Ilmari,
well, let's give this a try. Thanks a lot. :-)
Greetings, Bianka
--
Jede Epoche der Menschheit hat so ihre Plagen: Heuschreckenschwaerme
im Altertum, die Pest im Mittelalter, Microsoft in der Neuzeit.
------------------------------
Date: Fri, 21 Sep 2001 04:15:45 GMT
From: Andrew Cady <please@no.spam>
Subject: Re: Creating a file
Message-Id: <87u1xxchah.fsf@homer.cghm>
"Steve Grazzini" <s_grazzini@hotmail.com> writes:
> '>' will create... so you should certainly double check the
> variable, as suggested.
>
> If you want to don't want to clobber a (possibly) existing file,
> test first with -e
>
> open FILE, -e $file ? ">> $file" : "> $file"
> or die "Couldn't open '$file': $!.";
>
> (Seems like there should be an easier way to
> append-but-create-if-necessary, but I do not know it.)
NO, that's a RACE CONDITION. ">>" *will* create if necessary, just
like the shell's ">>". The difference between ">" and ">>" is
O_TRUNC, not O_CREAT. They *both* create the file if necessary (just
like in the shell). It's "<" which doesn't create the file (just like
in the shell).
------------------------------
Date: Fri, 21 Sep 2001 04:24:10 GMT
From: "Steve Grazzini" <s_grazzini@hotmail.com>
Subject: Re: Creating a file
Message-Id: <Khzq7.34250$n5.4200273@typhoon.nyc.rr.com>
eek! thanks
"Andrew Cady" <please@no.spam> wrote in message
news:87u1xxchah.fsf@homer.cghm...
> "Steve Grazzini" <s_grazzini@hotmail.com> writes:
>
> > '>' will create... so you should certainly double check the
> > variable, as suggested.
> >
> > If you want to don't want to clobber a (possibly) existing file,
> > test first with -e
> >
> > open FILE, -e $file ? ">> $file" : "> $file"
> > or die "Couldn't open '$file': $!.";
> >
> > (Seems like there should be an easier way to
> > append-but-create-if-necessary, but I do not know it.)
>
> NO, that's a RACE CONDITION. ">>" *will* create if necessary, just
> like the shell's ">>". The difference between ">" and ">>" is
> O_TRUNC, not O_CREAT. They *both* create the file if necessary (just
> like in the shell). It's "<" which doesn't create the file (just like
> in the shell).
------------------------------
Date: Fri, 21 Sep 2001 07:12:14 +0200
From: "Rogier" <rogier@arpadrive-in.com>
Subject: Re: Creating a file
Message-Id: <9oei4g$52r$1@cyan.nl.gxn.net>
Yes i saw, sorry :-)
Andrew Cady <please@no.spam> schreef in berichtnieuws
87g09hehzc.fsf@homer.cghm...
> "Rogier" <rogier@arpadrive-in.com> writes:
>
> > Lorimer <djdjokic@yahoo.com> schreef in berichtnieuws
> > a18e5d95.0109200913.688a8c90@posting.google.com...
> >
> > > Here is the problem: I want to open a file if exist and if it is
> > > not exist then I want to create it and then open for writting in
> > > it. Opening existing one is not a problem but how to create new
> > > one.
> > >
> > > open (FILE, "> $file") || die "Could not open $!"; print FILE
> > > 'nesto'; close (FILE);
> > >
> > > And I am getting this message
> > >
> > > Could not open No such file or directory at line 650
> > >
> > > if there is no such file
> > >
> > > Can someone help?
> >
> > Change open(FILE, ">> $file") || die.... The >> is important
>
> No it isn't. "> $file" should create the file. It must be either
> that the string $file is empty, or the directory that the the file is
> in does not exist. If it were a permission problem the error would be
> permission denied. The only difference between ">" and ">>" is that
> ">" will use O_TRUNC, truncating the file to zero bytes.
------------------------------
Date: Fri, 21 Sep 2001 09:25:26 GMT
From: Liviu BURCUSEL <liviu@mediaimage.ro>
Subject: Re: Creating a file
Message-Id: <aIDq7.64838$107.2169357@telenews.teleline.es>
Lorimer wrote:
> Here is the problem: I want to open a file if exist and if it is not
> exist then I want to create it and then open for writting in it.
> Opening existing one is not a problem but how to create new one.
>
> open (FILE, "> $file") || die "Could not open $!";
> print FILE 'nesto';
> close (FILE);
>
> And I am getting this message
>
> Could not open No such file or directory at line 650
>
> if there is no such file
>
> Can someone help?
if (-f $file) {
## the file esists
open (FILE, "> $file") || die "Could not open $!";
print FILE 'nesto';
close (FILE);
}
else {
## the file doesn't exist
open (FILE, "+> $file") || die "Could not create $!";
## bla, bla bla
}
--
Liviu BURCUSEL
Registerd Linux user #221627
------------------------------
Date: 21 Sep 2001 02:54:22 -0700
From: merigrace@rediffmail.com (Merina)
Subject: How to get the path of current directory in perl
Message-Id: <b860cf59.0109210154.29bc5244@posting.google.com>
Hi,
I want to get the path of the current directory in a variable using perl?
Any idea regarding this?
with thanks,
Merina.
------------------------------
Date: 21 Sep 2001 01:07:29 -0700
From: weiwe1@yeah.net (hugh1)
Subject: i feel i miss some important knowledge !!
Message-Id: <7dcf30ba.0109210007.3a092fe0@posting.google.com>
i first read <<learning perl >> ,and now read << advanced perl
programming>>. i feel i miss some base ,important knowledge.
i think i should read as this : 1 <<learning perl>>
2 << programming perl >> or others
3 <<advanced perl programming >>
can you tell me which book i should read on step 2 ?? i realy hope
i can get the bible book <<programming perl>> early. but it is be
translating .
the perl is so great ! i think C + perl can do everything(under
UNIX ) but sometimes perl difficult to understand .
i have one question , not clearly understand , thanks every one
who help me!!! and good luck weekend!!!
*******************************************************************
#!/usr/bin/perl -w
sub greet {
my ($greeting )=@_;
return sub {
my ($subject )=@_;
return sub { ------------
my ($content )=@_; |----> my add
return sub { ------------
my ($extent )=@_;
print "$greeting $subject $content
$extent\n ";
};
};
};
}
$rs1=greet("hello");
&$rs1("world");
&{&$rs1("world")}("music");
&{&{&$rs1("world")}("music")}("nirvana");
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
in << advanced perl programming >> i add two sub ,it work well .but i
do not know principle . i looks hello <-> $greeting world <->
$subject music<-> $content ......
------------------------------
Date: 21 Sep 2001 02:39:24 -0700
From: billy@arnis-bsl.com (Ilja Tabachniks)
Subject: Re: Interrupted Server Socket Connections
Message-Id: <5d4a715a.0109210139.33752f31@posting.google.com>
Lyle_Goldman@ibi.com (Lyle Goldman) wrote in message news:<ed639144.0109201335.34c76aee@posting.google.com>...
> So nobody has ANY idea?
>
> Lyle_Goldman@ibi.com (Lyle Goldman) wrote in message news:<ed639144.0109170810.38da4e66@posting.google.com>...
> > -
> > Hello. I am trying to write a client-server system using sockets. In the
> > code that I have written, the client reads lines of text from standard input and
> > sends them to the server, which prints the lines to standard output. Under
> > normal situations, it work fine. However, when I interrupt the server process,
> > the client does not realize that the server has disconnected until it sends
> > two (not one, but two!) more lines of output. Why is this happening, and how
> > can I detect when the connection has closed sooner?
> >
> > The code follows. I am running under Solaris 5.6. Thank you for any help
> > you can provide me.
> >
>
IMHO, really this is a socket question, not a Perl-specific one.
And (IMHO) it looks working as expected (see below).
I'm not a socket expert, so maybe it's better for you to consult
Unix Socket FAQ at, say, http://www.lcg.org/sock-faq.
From Unix Socket FAQ:
> Questions regarding both Clients and Servers (TCP/SOCK_STREAM):
> How can I tell when a socket is closed on the other end?
>
> From Andrew Gierth ( andrew@erlenstar.demon.co.uk):
>
> AFAIK:
>
> If the peer calls close() or exits, without having messed with SO_LINGER,
> then our calls to read() should return 0. It is less clear what happens to
> write() calls in this case; I would expect EPIPE, not on the next call, but
> the one after.
> If the peer reboots, or sets l_onoff = 1, l_linger = 0 and then closes,
> then we should get ECONNRESET (eventually) from read(), or EPIPE from write().
>
> I should also point out that when write() returns EPIPE, it also raises the
> SIGPIPE signal - you never see the EPIPE error unless you handle or ignore the
> signal.
>
>If the peer remains unreachable, we should get some other error.
>
> ...
Hope this helps.
Ilja.
------------------------------
Date: Fri, 21 Sep 2001 11:04:05 +0100
From: Graham Wood <Graham.T.Wood@oracle.com>
Subject: Re: perl pattern matching question
Message-Id: <3BAB1095.2333F1AF@oracle.com>
This is a multi-part message in MIME format.
--------------E78502DCF39D4DEE2BD2E1C7
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Thestar Onedallbe wrote:
> Hi:
> I got a file like this :
> # cat glo.txt
> malay@uakron.edu>
> >To: Anisa Zubery <ZuberyA@idhw.state.id.us>, Ajay Rathi
> ><ajayrathi@northwesternmutual.com>, Alok Das
> <axdas@uswest.com>,
> >Amitaksha Nag <amitaksha@myiris.com>, Amit DasAdhikary
> ><amit_da@chequemail.com>, Amlan Guha <amlguha@yahoo.com>, Amlan
> Ray
> ><amlan@met.iitb.ernet.in>, Angshuman Dey
> ><deyangshuman@rediffmail.com>, "Anindya K. Paul"
> ><akpaul@bechtel.com>, Anindita Mitra
>
> ....et etc.This is the header of a email.I want to grep only the
> email addresses.Not the names or the <> signs.I have tried perl
> and awk but all of them gives me the full line ..How can I limit my
> search to just the pattern?
open(INPUT,"glo.txt") || die "Can't open glo.txt $!\n";
$string=join('',<INPUT>); # that's 2 single quotes not double quote
(@addresses)=$string =~ /\<([^\<\>]+\@[^\<\>]+)\>/g;
# match is "<" followed by one or more characters that are not "<" or ">",
followed
# by "@" followed by one or more characters that are not "<" or ">"
followed by ">"
# the initial "<" and the final ">" are outside the "(" and ")" so are not
included
foreach(@addresses){
print "$_\n";
}
--------------------------------------------------
OUTPUT:
ZuberyA@idhw.state.id.us
ajayrathi@northwesternmutual.com
axdas@uswest.com
amitaksha@myiris.com
amit_da@chequemail.com
amlguha@yahoo.com
amlan@met.iitb.ernet.in
deyangshuman@rediffmail.com
akpaul@bechtel.com
Graham Wood
--------------E78502DCF39D4DEE2BD2E1C7
Content-Type: text/x-vcard; charset=UTF-8;
name="Graham.T.Wood.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Graham Wood
Content-Disposition: attachment;
filename="Graham.T.Wood.vcf"
begin:vcard
n:;Graham
x-mozilla-html:FALSE
adr:;;;;;;
version:2.1
email;internet:Graham.T.Wood@oracle.com
fn:Graham Wood
end:vcard
--------------E78502DCF39D4DEE2BD2E1C7--
------------------------------
Date: Fri, 21 Sep 2001 10:25:40 +0200
From: "Dahlin" <dahlin.jkpg@swipnet.se>
Subject: Process ID
Message-Id: <KOCq7.1325$Ad3.4287@nntpserver.swip.net>
Im developing an cgi -application i perl.
This application i call three times from whitin a webpage.
The problem is i nedd to get a random number each time, but since all three
calls occur within a second, i cant use just time() as seed. And all tree
calls get the same processid, unless i change the querystring.
How do i solve this?
Why do they have the same processID?
------------------------------
Date: 21 Sep 2001 09:58:39 GMT
From: news@roaima.demon.co.uk
Subject: Re: Process ID
Message-Id: <3bab013f@news.netserv.net>
Dahlin <dahlin.jkpg@swipnet.se> wrote:
> The problem is i nedd to get a random number each time, but since all three
> calls occur within a second, i cant use just time() as seed. And all tree
> calls get the same processid, unless i change the querystring.
> How do i solve this?
Don't seed the random number generator! (The seed starts the "random"
sequence off at a particular point, so you're thwarting the "randomness"
of the generator.)
Chris
------------------------------
Date: 21 Sep 2001 06:26:02 GMT
From: mjd@red.seas.upenn.edu (Mark-Jason Dominus)
Subject: Re: Reading cookies from a different path
Message-Id: <9oemhq$762$1@netnews.upenn.edu>
In article <3baa07b8.8853924@news.bright.net>,
Jonadab the Unsightly One <jonadab@bright.net> wrote:
>Maybe it's a system-dependent thing; I'm using the ActiveState
>Windoze build here. Your headers don't tell me much about
>your system, so I'm guessing it's some kind of Unix?
This program is never going to work on windows; you can tell because
of the presence of pipe() and fork() in the source code.
Also the string 'xinU' may be suggestive. :)
------------------------------
Date: 21 Sep 2001 06:32:23 GMT
From: mjd@red.seas.upenn.edu (Mark-Jason Dominus)
Subject: Re: Reading cookies from a different path
Message-Id: <9oemtn$ajs$1@netnews.upenn.edu>
In article <1001021039.5096@itz.pp.sci.fi>,
Ilmari Karonen <usenet11585@itz.pp.sci.fi> wrote:
> This is perl, version 5.004_04 built for sun4-solaris
>
>This is my ISP's perl. I've got 5.005_03, 5.7.1 and bleadperl installed
>on Linux, and none of those have any problems with the script.
Freaky. It works perfectly for me with 5.004_04 under both Solaris and Linux.
------------------------------
Date: 21 Sep 2001 01:15:04 -0700
From: rrindels@pd46.com (Rodney Rindels)
Subject: regex effeciency question
Message-Id: <91fccb3c.0109210015.72a098ef@posting.google.com>
I am wondering if their is a simpler way to map this protocol
specification to variables.The '&' (That was used for space padding on
an existing protocol) must be pulled off of some of the variables
after we find them in a specific place in the string. The code snippet
below works but seems very code intensive.
Thank You,
Rodney Rindels
Kirtland Air Force Base
ABQ, NM
<<Code Snippet
use strict;
my $input="\@2001090121225633LOG1928823066102.&62.229.&&4102.&62.229.&56&&&&&6ADBCKE2195&&[DATA]&&&&\@";
my $start=substr($input,0,1);
if ($start eq "\@"){
my $year=substr($input,1,4);
$year=~s/(&*?)//g;
my $month=substr($input,5,2);
$month=~s/(&*?)//g;
my $day=substr($input,7,2);
$day=~s/(&*?)//g;
my $data_length=substr($input,60,6);
$data_length=~s/(&*?)//g;
print "$data_length\n";
my $key=substr($input,66,10);
print "$key\n";
my $data=substr($input,78,$data_length);
print "$data\n";
print "$month/$day/$year\n";
} else {
print "Protocol Parsing Unsuccessful";
#Code to ask for resend of packet goes here
};
------------------------------
Date: 21 Sep 2001 02:14:10 -0700
From: crud@hongkong.com (Dav Lam)
Subject: strip links out of html
Message-Id: <fc25f4f2.0109210114.7ba7b1d8@posting.google.com>
i got the following script, i can't discover any thing wrong but it just
doesn't work out..
can anyone point out what's wrong in the script?
thanks in advance
require HTML::TokeParser;
use LWP::Simple;
$base = '';
$newspage = '';
@links;
$next = 1;
while($next){
$cnt = get($newspage);
$next = strip($cnt);
}
print join "\n", @links;
sub strip{
my ($tkpr) = HTML::TokeParser->new(\$_);
my $href;
while($token = $tkpr->get_tag('a')){
$href = $token->[1]{href};
push @links, $href if $href =~ /^news.fpl/;
if ($tkpr->get_text =~ /^next/i){
$newspage = $base.$href;
return 1;
}
}
}
------------------------------
Date: 21 Sep 2001 07:57:45 GMT
From: blackbird@chatterpages.de (Bianka Martinovic)
Subject: Re: Use symbol table like 'real' hash
Message-Id: <9oertp$fcq$1@penthesilea.materna.de>
In article <81okqt4rlflct0gr0d6tsq489gd8mmq9sk@4ax.com>,
bart.lateur@skynet.be says...
>
>You can't. Not because the symbol table isn't a normal hash (it is!) ,
>but what it contains are typeglobs and not just normal scalars. So the
>sub at least needs to be aware of *that*.
>
>Perhaps try
>
> template( <path>, \%IN::);
>
Hello, Bart,
thanks for your comment. I have tried the idiom you suggested, but it does
not work, either. It has the same effect as with the {}.
I really hoped that there is a way to treat a symbol table as if it
contained scalars. If there is not, I don't have to search any more and
can try to find another way to get what I want.
Greetings, Bianka
--
Jede Epoche der Menschheit hat so ihre Plagen: Heuschreckenschwaerme
im Altertum, die Pest im Mittelalter, Microsoft in der Neuzeit.
------------------------------
Date: 21 Sep 2001 09:59:51 GMT
From: blackbird@chatterpages.de (Bianka Martinovic)
Subject: Re: Use symbol table like 'real' hash
Message-Id: <9of32n$shf$1@penthesilea.materna.de>
In article <9od9fi$bhh$1@penthesilea.materna.de>,
blackbird@chatterpages.de says...
>Now, I don't find the right way to pass the %IN:: hash the right way. If
I
>call the function like
>&template( <path>, { \%IN:: });
>I am getting nothing into the template. Passing like
>&template( <path>, { %IN:: });
>sets the symbol names instead of the 'real' values.
>
Well, the solution REALLY is easy. :-) For those who may have the same
problem, here it is:
I have passed a hash to a subroutine and made a reference named $hash.
If I want to get the value of a certain hash key now, I get it like this:
$$hash{'value'}
or if the name of the key is in a var
$$hash{$val}
Now, if I have passed a symbol table and want to get the value of a symbol
table entry, I can get it like
$ { $$hash{$val} }
If it IS a symbol table. If it is not, this is not defined.
And this is the simple solution within my &template subroutine:
$text =~ s{ %% ( .*? ) %% }
{ exists( $fillings->{$1} )
? ( defined ${ $$fillings{$1} } # only defined if key is symbol
? ${ $$fillings{$1} } # take this
: $$fillings{$1} ) # or not
: ""
}gsex;
&template( <file>, { %IN::, %hash } );
I tried this and it works fine with both, the symbol table IN and the
hash. :-)))
I hope my explanation is okay.
Greetings, Bianka
--
Jede Epoche der Menschheit hat so ihre Plagen: Heuschreckenschwaerme
im Altertum, die Pest im Mittelalter, Microsoft in der Neuzeit.
------------------------------
Date: 21 Sep 2001 01:50:38 -0700
From: ccsam@bath.ac.uk (Andy)
Subject: using a variable to call a function
Message-Id: <e6f95c88.0109210050.3d5f7454@posting.google.com>
I am trying to use a variable to make up part or all of a function
name. I have tried:
1 #!/usr/bin/perl -w
2
3 use strict;
4
5 {
6 my $func = shift or die "usage: $0 [function-name]\n";
7 &foo ($func);
8 }
9
10 sub foo {
11 my $f = shift;
12 &\$f(); # How do you call a function using a
variable?
13 }
14
15 sub bar {
16 my $p = shift;
17 print $p; # do I need to access this as reference?
18 }
19
and many more "hacks". The two offending lines are 12 and 16.
Regards
Andy
------------------------------
Date: Fri, 21 Sep 2001 11:46:27 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: using a variable to call a function
Message-Id: <l23mqt4h1526d1na9c3tl82i5q5htb90r7@4ax.com>
On 21 Sep 2001 01:50:38 -0700, ccsam@bath.ac.uk (Andy) wrote:
>I am trying to use a variable to make up part or all of a function
>name.#!/usr/bin/perl -w
You shouldn't do that. But if you must, try this:
use strict;
sub baz {
print join( ', ', @_ ), "\n";
}
sub foo {
my $func = shift;
{
no strict "refs";
&{$func};
}
}
foo( 'baz', 'bar', 'boo' );
__END__
HTH,
--
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 1785
***************************************