[20012] in Perl-Users-Digest
Perl-Users Digest, Issue: 2207 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 26 09:10:35 2001
Date: Mon, 26 Nov 2001 06:10:14 -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: <1006783813-v10-i2207@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 26 Nov 2001 Volume: 10 Number: 2207
Today's topics:
Re: Creating a Perl app. Help with installation? <mgjv@tradingpost.com.au>
Re: Declaring a filehandle <p.tomkins@virgin.net>
Re: File position of of every word in a file (Rob van Strien)
Re: File position of of every word in a file <ahamm@programmer.net>
http::response problem (still - sorry) (paul)
Re: MakeMaker and 'make uninstall' <comdog@panix.com>
Re: modify arguments in a sub / function... <bart.lateur@pandora.be>
pb whith fork and gtk. <slegros@mandrakesoft.com>
Problem with XML::DOM <noemail@---stealthmode---.com>
Still having trouble.. <perl@cableone.net>
Re: String matching... irc hostmasks <jonni@ifm.liu.nospam.se>
Re: use File:Find non-recursive <bart.lateur@pandora.be>
Re: use File:Find non-recursive <mgjv@tradingpost.com.au>
Why doesn't Perl define an evaluation order? <joe+usenet@sunstarsys.com>
Re: { in s///; ? <nilram@boisdarc.tamu-commerce.edu>
Re: { in s///; ? <mgjv@tradingpost.com.au>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 26 Nov 2001 19:25:33 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Creating a Perl app. Help with installation?
Message-Id: <slrna03v3s.ghk.mgjv@martien.heliotrope.home>
On 26 Nov 2001 02:07:37 GMT,
<mcnuttj@dnps-linux1.telecom.missouri.edu> wrote:
> mcnuttj@dnps-linux1.telecom.missouri.edu wrote:
>
>> 3) MIBs. This is the hard one. Right not I include a *bunch* of MIB
>> files and store them in /usr/local/lib/jscan/mibs (with a bunch of
>> subdirs). Again, right now this is hard-coded in there, but I'd like to
>> somehow make this relative to PREFIX from the Makefile (perhaps
>> $(PREFIX)/JScan/mibs). What's the best way to accomplish this?
>
> Okay, I've taken everybody's advice and set up MakeMaker (mostly). I
> still have a few problems to solve, though, the most important being this
> one. What do I do with the MIB files?
>
> My first thought is that the modules are installed in $(PREFIX)/perl5/
> site_perl/JScan (thus, 'use JScan::JVars;' works). The easiest thing to
> do seemed to be to add a subdirectory under JScan named 'mibs' to hold
> them all. Since I was using /usr/local/lib/jscan/mibs before, this
> isn't much of a stretch. I just moved the source 'mibs' dir to lib/JScan
> in the source tree and added the files to the MANIFEST. No problem,
> right?
>
> Well, sort of. Now I have to teach the application where to find the
> files. I have two thoughts on the matter, and they aren't mutually
> exclusive.
>
> 1) Determine at runtime where the modules are like this:
>
> MIBPATH: foreach $path ( @INC ) {
> # Stat a module that we've already "use"d.
> stat "$path/JScan/JVars.pm";
I am not sure wether this has to be portable, and if so, to which
platforms, but the File::Spec module provides more portable ways of
doing this.
> if ( -e _ ) {
> # This is where the modules are.
> $mibpath = $path . "/JScan/mibs";
>
> # Stat this dir to make sure it's really there.
> last MIBPATH;
> }
> }
You can do this by simply looking at the %INC hash. Something like
$INC{JScan/JVars.pm} should tell you where that module was loaded from.
Stripping off the module bit should be easy enough. If you want to do
that in a more or less portable form, you could use File::Basename,
otherwise a regular expression or rindex with a substr should be able to
do the trick.
Alternatively, you can do all of this at install time. Pick one of the
%Config installation trees, put this path in your module (using perl -p
maybe), and install it then.
> 2) Okay, the second idea is to have a config file option, environment
> variable, and/or a command-line option that points at the mibdir's
> location. An offshoot of this would be that the config file could be
> written or at *least* a blurb could be printed to the screen at
> install-time to help the user set this variable.
This would make it easier to do the above at install time, instead of
at runtime, _and_ it gives you the option of letting the user/admin
install the MIBs outside of the Perl library tree.
> Yet another option would be to combine the two approaches, when the
> script looks in the 'default' location (with the modules) only if
> none of the the other methods are specified. I.e. "in the same place
> as the other JScan modules" is the default, which is overridden by
> the config file/variable/cmdline option.
Sure.
> Thoughts? Suggestions? I'm pretty sure I could make one of these
> approaches work, but I'm wondering if there isn't a more elegant way
> to do this.
I can't easily think of one. I'd probably prefer the JScan/Config.pm
approach, where at install time you determine the directory, optionally
overridable by the installer. Then at runtime you could still look in
the default place if the other one isn't there.
> Coming Up: How do I *optionally* install 'xjscan' when 'make install'
> is invoked, but only if the Tk.pm module is detected, and print a
> warning message if it is not?
I'd suggest that somewhere in your Makefile.PL there is something like:
eval 'require Tk';
if ($@)
{
print STDERR "Cannot load Tk.pm";
# Maybe do other stuff
}
else
{
# Add xjscan to EXE_FILES
}
Martien
--
Do not pay any attention to what Godzilla says. It is a troll, and has
no decent working knowledge of Perl or programming in general. Search
groups.google.com to see a history of its posts and replies to these posts.
------------------------------
Date: Mon, 26 Nov 2001 12:46:40 -0000
From: "news.bmthonline.net" <p.tomkins@virgin.net>
Subject: Re: Declaring a filehandle
Message-Id: <3c023a2d$1_2@news2.vip.uk.com>
Thanks for your replies. They are really appreciated. I guess the answer can
be summarized as
local *FILE_HANDLE works but my *FILE_HANDLE does not.
and that is really the only reliable way to achieve it.
> {
> open( my $fh, "my_pants") or die "Could not open my pants! $!";
> my $var = <$fh>; # reads the next line. (je nach $/)
> }
> This trick only works with recent versions of perl. 5.6.1 certainly, and I
> think 5.6.0, but I'd check perldelta before counting on it. Certainly
> doesn't work well with 5.004_0x or 5.005_0x.
> Dan
------------------------------
Date: Mon, 26 Nov 2001 09:40:52 GMT
From: strien@inl.nl (Rob van Strien)
Subject: Re: File position of of every word in a file
Message-Id: <3c020c98.8334750@news.leidenuniv.nl>
Thanks to all of you who helped me with this problem.
This is my solution (apart from the discussion of what
a 'word' might be, which isn't solved yet in my case).
while ($startOfLine = tell, $line = <INV>) {
chomp($line);
while ($line =~ m/\b([a-zA-Z]+)\b/g) {
$match = $&;
$position = $startOfLine+pos($line);
print TEMP "$match:$position\n";
}
}
-Rob
On Wed, 21 Nov 2001 15:40:39 GMT, strien@inl.nl (Rob van Strien)
wrote:
>Hi,
>
>How can I get the file position of each single word in a file?
>I can read the file line by line and chop it up in words, but
>the tell-function will always return the file position of the
>(end of the) line I'm on, not the words.
>
>Thanks,
>Rob van Strien
>strien@inl.nl
------------------------------
Date: Mon, 26 Nov 2001 21:11:46 +1100
From: "Andrew Hamm" <ahamm@programmer.net>
Subject: Re: File position of of every word in a file
Message-Id: <3c021560$1_1@news.iprimus.com.au>
Rob van Strien wrote in message <3c020c98.8334750@news.leidenuniv.nl>...
>Thanks to all of you who helped me with this problem.
>This is my solution (apart from the discussion of what
>a 'word' might be, which isn't solved yet in my case).
>
Ain't that the way with English? I thought there was a module on CPAN which
did a damn fine job of intuiting english words, but I couldn't find it the
other day. Pity. Anyways, you just gotta do what correctly handles 99.99% of
your data. The other 0.01% is pathalogical sick English. I pray that your
data isn't complete English ;-)
> $match = $&;
>
This is a bad habit to get into. If you use $` $& or $' then you are
imposing a performance penalty on yourself. I haven't got the time to
explain but it's in the Programming Perl book, which you have bought, right?
For the pattern you have shown, you'd be better off to use $1 instead - it
represents the stuff inside the first ( ) pair and it doesn't come with a
cost.
--
Space Corps Directive #723
Terraformers are expressly forbidden from recreating Swindon.
-- Red Dwarf
------------------------------
Date: 26 Nov 2001 05:06:15 -0800
From: paulthomson@hotmail.com (paul)
Subject: http::response problem (still - sorry)
Message-Id: <464e478f.0111260506.bdfc57f@posting.google.com>
Hi,
I am still playing with http requests and responses. I have no problem
making http requests with LWP. I know my requests work ok as I am
using a third party application with no errors.
Here it is in full:
print "Content-type:text/html\n\n";
use LWP::UserAgent;
my $ua = LWP::UserAgent->new();
$ua->timeout( 5 ); # set timeout to 5 seconds.
my $request = new HTTP::Request POST
=>'http://blah/cgi-bin/http_request.pl';
$request->content_type('application/x-www-form-urlencoded');
$reqcontent ="UserName=UserNameTest&Key=strKeyTest";
$request->content($reqcontent);
my $response = $ua->request($request);
$rcode = $response->content;
print "rcode: $rcode<br>";
print "content: ".$response->content;
I have written (well tried)a script to send a response code back to
this script as follows:
use LWP::UserAgent;
my $res = HTTP::Response->new(200);
$res->code("200\n");
$res->content("OK\n");
That is all the second script does at the moment. The first script
doesn't recieve any response content or code. All I want to get is the
code at present.
Thanks in advance,
Paul
------------------------------
Date: Mon, 26 Nov 2001 02:19:44 -0600
From: brian d foy <comdog@panix.com>
Subject: Re: MakeMaker and 'make uninstall'
Message-Id: <comdog-7D886D.02194426112001@news.panix.com>
In article <9tse1p$mt6$1@dipsy.missouri.edu>,
<mcnuttj@dnps-linux1.telecom.missouri.edu> wrote:
> Could someone tell me how to override MakeMaker so that the resulting
> Makefile includes something like this:
>
> uninstall:
> /bin/echo "Prefix was $(PREFIX)."
> /bin/echo "Your override worked."
to do exactly that you'd have to override the install() sub in
ExtUtils::MM_Unix (and the homologous module for other platforms).
it's not a pretty function.
however, the 'install' target is a '::' one, meaning that it
can show up more than once in the Makefile. you can use
postamble() to give it additional dependencies.
package MY;
sub postamble
{
my $uninstall = <<"HERE";
uninstall ::
/bin/echo "Prefix was $(PREFIX)."
/bin/echo "Your override worked."
HERE;
}
then once you create the Makefile, you should find that text
at the end.
how this plays with perl5.6.1's uninstall is left to you :)
--
brian d foy <comdog@panix.com> - Perl services for hire
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html
------------------------------
Date: Mon, 26 Nov 2001 13:19:42 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: modify arguments in a sub / function...
Message-Id: <q6g40ugnan83mjqv04dv24rvcn1ff28i7a@4ax.com>
Andrew Hamm wrote:
>What's really freaky is, there's some good ideas in about 5% of the
>postings but then there's all the madness thrown in for laughs. Perhaps
>(s)he's practicing for the Edinburgh Comedy Festival?
It's a she.
And yes, though she does have some good ideas, she usually succeeds to
destroy it by throwing in some technicalities that are oh so obviously
wrong, that it's hard to take anything at all seriously.
--
Bart.
------------------------------
Date: Mon, 26 Nov 2001 12:46:36 +0100
From: slegros <slegros@mandrakesoft.com>
Subject: pb whith fork and gtk.
Message-Id: <3c022b85$0$9961$626a54ce@news.free.fr>
hi, i've some litle pb whith gtk perl and fork.
i try to create a litle front end in gtk-perl that call a back end program
and run a activity bar during the run a the back-end prog. and i'd like to
hide the activity bar when the back end prog end. so, here is the code i
produce to test this :
[french]
Je cherche a faire une petit interface en gtk qui appele un programme en
tache de fond et qui fait tourner une barre d'activitee pendant que le prog
tourne, puis fait disparaitre la barre d'activitee losque le prog en tache
de fond se termine. Voici le code que j'ai produit afin de tester ca :
[/french]
#!/usr/bin/perl -w
use Gtk;
use strict;
use POSIX ":sys_wait_h";
init Gtk;
my $window;
my $ppal_box;
my $spacing;
my $false = 0;
my $true = 1;
$window = new Gtk::Window( "toplevel" );
$window->signal_connect( "delete_event", sub { Gtk->exit( 0 ); } );
$window->border_width( 10 );
#boite ppale - ppal box
$spacing = 5;
$ppal_box = new Gtk::VBox( $false, $spacing );
$window->add( $ppal_box );
$ppal_box->border_width( 5 );
$ppal_box->show();
my $button_box;
my $button_quit;
my $button_test;
# Crée les boutons et les ajoute à la fenêtre
# make the new buttons and add them to windows
$button_box = new Gtk::HBox( $false, 0 );
$ppal_box->pack_start( $button_box, $false, $true, 0 );
$button_box->show();
$button_test = new Gtk::Button( " Test fork " );
$button_quit = new Gtk::Button( " Quit ! " );
$button_box->pack_start( $button_test, $true, $true, 0 );
$button_box->pack_start( $button_quit, $true, $true, 0 );
my $activ_bar;
$button_test->signal_connect( "clicked", \&button_test_clicked, $activ_bar
);
$button_quit->signal_connect( "clicked", sub { exit (0); } );
$button_test->show();
$button_quit->show();
$window->show();
my $activ_box;
#activity bar
$activ_box = new Gtk::HBox( $false, 0 );
$ppal_box->pack_start( $activ_box, $false, $true, 0 );
$activ_box->show();
$activ_bar = new Gtk::ProgressBar();
$activ_box->pack_start($activ_bar, $false, $true, 0 );
my $timer = Gtk->timeout_add(100, \&progress_timeout);
#$timer = Gtk->timeout_add( $interval, \&function, @function_data );
$window->show();
main Gtk;
exit( 0 );
sub button_test_clicked
{
my ( $widget, $clist ) = @_;
my $pid;
$activ_bar->show();
if ($pid = fork)
{
sleep(5);
$activ_bar->hide();
}
elsif (defined($pid))
{
return;
}
else
{
print "Erreur de Fork\n";
}
return;
}
sub progress_timeout
{
my ($widget) = @_;
my $new_val;
my $adj;
$new_val = $activ_bar->get_value() + 1;
$adj = $activ_bar->adjustment;
$new_val = $adj->lower if ($new_val > $adj->upper);
$activ_bar->set_value($new_val);
return ($true);
}
my pb comes from the front end die when i do the
$activ_bar->hide();
after 5 seconds in the fork(). does anyone find the same pb ?
thxx.
[french]
mon pb vien du fait que l'interface meure quand je fait le
$activ_bar->hide();
apres avoir attendu 5 secondes dans mon fork. qqun a il deja rencontre ce
type de pb ? merci.
[/french]
--
slegros@mandrakesoft.com - legros_s@epitech.net
Samuel Legros - {epitech}. - Promotion 2005
------------------------------
Date: Mon, 26 Nov 2001 08:25:03 -0500
From: M Pritchard <noemail@---stealthmode---.com>
Subject: Problem with XML::DOM
Message-Id: <MPG.166c0cba42b2212798978d@news1.server.wcom.com>
Hello
I've been using ActivePerl on a Windows NT machine and I've just started
playing with the XML::DOM package. I seem to be having a strange problem
with the createProcessingInstruction function.
This:
$element = $doc->createProcessingInstruction(
"xml", "version=\"1.0\" encoding=\"UTF-8\"");
Throws this exception:
XML::DOM::DOMException(Code=5, Name=INVALID_CHARACTER_ERR,
Message=bad ProcessingInstruction Target [xml])
But changing "xml" to something else, like
$element = $doc->createProcessingInstruction(
"xyz", "version=\"1.0\" encoding=\"UTF-8\"");
Seems to work fine, except for the resulting XML has the wrong processing
instruction.
Am I doing something dumb?
- mp -
------------------------------
Date: Mon, 26 Nov 2001 03:52:53 -0600
From: "Jason Gray" <perl@cableone.net>
Subject: Still having trouble..
Message-Id: <u0448uehm1s0f3@corp.supernews.com>
I'm still having trouble with creating a link for the next page results,
here is my code to show the results. Any help with the link would be
considerable.
($rs, $re) = getrange($#array, $page, 10);
foreach my $i ($rs .. $re) {
print $array[$i];
}
sub getrange {
my ($num, $page, $perpage) = @_;
my ($rs, $re);
$page = 1 if(!$page || $page == 0);
if($page == 1){
$perpage--;
$rs = '0';
$re = $perpage;
} else {
$re = $page * $perpage;
$rs = $re - $perpage;
if($re > $num){ $re = $num; }
$re -= 1 if($re != $num);
}
if($rs && $re) {
return ($rs, $re);
}else {
return (0, $perpage);
}
}
Regards,
Jason Gray
"Just Another Perl Programmer"
------------------------------
Date: Mon, 26 Nov 2001 12:54:02 +0100
From: "Jonas Nilsson" <jonni@ifm.liu.nospam.se>
Subject: Re: String matching... irc hostmasks
Message-Id: <9ttaf3$e4g$1@news.island.liu.se>
| I'm looking for a snippet of code that will match a host address to a host
| mask.
|
Try this:
use strict;
my $address = 'Nickname!~name@nice.address.org';
my @nomatch =
('Nickname!~xxxx@nice.address.org','Nickname!~name@nice.address.com');
my $hostmask = '*!*name*@*.address.org';
my $hostmatch='^'.join('.*',map "\Q$_",split('\*',$hostmask)).'$';
for ($address,@nomatch) {
print "$_ is a match\n" if /$hostmatch/i;
print "$_ isn't a match\n" unless /$hostmatch/i;
}
/jN
------------------------------
Date: Mon, 26 Nov 2001 10:45:38 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: use File:Find non-recursive
Message-Id: <59740u45tcbp2bnvl605so3sbkjnv2pec4@4ax.com>
hugo wrote:
>opendir(DH, $dir) or die "Unopenable: $!";
> @a = readdir(DH);
> for ($j = 0; $j < @a; $j++) {
> if ( $a[$j] =~ /$filext$/ ) {
> $file[$j] = $a[$j];
> print "file is: $file[$j]\n";
> }
>}
You appear to be reimplementing glob(). Why not use that?
chdir $dir;
@file = glob("*.$fileext");
--
Bart.
------------------------------
Date: Mon, 26 Nov 2001 22:37:18 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: use File:Find non-recursive
Message-Id: <slrna04abe.ghk.mgjv@martien.heliotrope.home>
[Please in the future, put your reply _after_ the suitably trimmed text
you reply to. It is the commonly accepted quoting style on this
newsgroup, and Usenet in general]
On Mon, 26 Nov 2001 12:22:12 +0800,
hugo <hugo@fractalgraphics.com.au> wrote:
>
> Here is the code. Perhaps you could let me know what I am doing wrong.
>
> opendir(DH, $dir) or die "Unopenable: $!";
> @a = readdir(DH);
> for ($j = 0; $j < @a; $j++) {
> if ( $a[$j] =~ /$filext$/ ) {
> $file[$j] = $a[$j];
> print "file is: $file[$j]\n";
> }
> }
You are trying to get a list of all files with a certain extension,
right? The normal idiom for that is:
opendir(DH, $dir) or die "Cannot open '$dir': $!";
my @files = grep { /\.$filext$/ } readdir DH;
or, if you need to make sure they really are files, and not anything
else:
opendir(DH, $dir) or die "Cannot open '$dir': $!";
my @files = grep { /\.$filext$/ && -f "$dir/$_" } readdir DH;
Of course, you could just use globbing:
my @files = glob "*.$filext"; # Or with <> if you must
[snip of bottom-quoted complete article]
Martien
--
Do not pay any attention to what Godzilla says. It is a troll, and has
no decent working knowledge of Perl or programming in general. Search
groups.google.com to see a history of its posts and replies to these posts.
------------------------------
Date: 26 Nov 2001 08:24:20 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Why doesn't Perl define an evaluation order?
Message-Id: <m3oflp64xn.fsf@mumonkan.sunstarsys.com>
From a language designer's point of view, what is the advantage
of leaving the order of evaluation undefined in Perl? Unlike C,
Java specifies the order of evaluation (unwrapped url)-
http://java.sun.com/docs/books/jls/second_edition/html/expressions.doc.html#4779
(I'm told APL is another such language). It appears to me, from
reading the clp* google archives, that although perl tries to obey
a left-to-right rule in most cases, the canonical answer is that
evaluation order is still an undefined aspect of the language;
so much so that AFAIK even C's notion of _sequence point_ has
*no* recognizable analog in Perl.
I'm wondering what the real advantage of this situation is for Perl.
In C/C++, it is often said that leaving the evaluation order undefined
(between sequence points) allows compiler manufacturers greater freedom
in optimization; however some recent benchmarks show that Java keeps
up quite well (I'd post a url if it really mattered here, but I'd like
to avoid straying too far offtopic.)
Has this additional flexibility for the perl implementers ever
resulted in significantly faster code? What about Perl6?
One situation I came across was that slicing is apparently
done R-to-L, whereas "simple access" is L-to-R:
@{second}{first} @{second}[first] (second)[first]
${first}{second} ${first}[second]
Is this DWIMery, optimization, backwards-compatibility, or
coincidence?
Finally, here's a table I made some time ago that shows 5.6.1's
evaluation order and access order (when the scalar's value is actually
examined), for some common binary ops in Perl (the code I used to
generate it is appended below). I've used it for manufacturing a JAPH
or two, but *not* for any real code. 5.00503 seems to have the same
evaluation order, but the access column is occasionally different.
(L)EFT-(R)IGHT ORDERING
BINARY OP EVAL ACCESS
_______________________________________________
comp(str) LR LR
comp(num) LR RL
x LR LR
. LR LLR *
math LR RL
logic LR LR (or just L, depending on truth value)
bit(num) LR RL
bit(str) LR LR
range LR LRLRLR *
op-assign LR RLL (LRL:&|&&||^) *
match LR RL
= RL RL
-> (subs) RL RL **
-> (vars) LR LR **
* probably a bug
**a guess (-> is untested below)
==================================================
#!/usr/bin/perl -w
use strict;
# warning: this is arcane stuff- it tests
# evaluation order and variable access
# for common binary operations in LIST context
# (I'm pretty sure SCALAR context gives similar results)
my %num;
my @obj;
my %tests = (
math => [qw( + - / * % **)],
logic => [qw/&& ||/],
bit => [qw/>> << & | ^/],
range => [qw/.. .../],
string => [qw/x ./],
comp => [qw/ eq ne lt gt cmp == != >= <= < > <=> /],
assign => [qw(= += *= /= &&= ||= |= &= -= .= **= ^= <<= >>=)],
re => [qw/=~m !~m/],
);
$\="\n";
@_= (e_ord(),a_ord()) foreach map @$_, values %tests;
exit;
sub TIESCALAR {
my $ob;
${$obj[++$#obj]} = 0;
bless $obj[-1];
}
sub FETCH {
my $ob = shift;
for ($ob) {
print ++$num{$ob} . " fetch of object " .
(grep $obj[$_] eq $ob, 0..$#obj)[0];
}
++$$ob;
}
sub STORE {
${$_[0]} = $_[1];
}
sub e_ord { # eval order
my ($op) = (@_,$_);
tie $a, __PACKAGE__ or die;
tie $b, __PACKAGE__ or die;
print "EVALUATE:$op";
eval '${\($a+0)} ' . $op . '(0+$b)';
}
sub a_ord { # access order
my ($op) = (@_,$_);
tie $a, __PACKAGE__ or die;
tie $b, __PACKAGE__ or die;
print "ACCESS:$op";
eval '$a ' . $op . '($b)';
}
__END__
Thanks in advance.
--
Joe Schaefer
------------------------------
Date: 26 Nov 2001 03:35:59 -0600
From: Dale Henderson <nilram@boisdarc.tamu-commerce.edu>
Subject: Re: { in s///; ?
Message-Id: <87wv0dlvr4.fsf@camel.tamu-commerce.edu>
>>>>> "TM" == Tad McClellan <tadmc@augustmail.com> writes:
TM> sysop <vze33mmh@verizon.net> wrote:
>> On Mon, 19 Nov 2001 18:25:10 -0500, Dale Henderson wrote:
>>> I was trying to quote '{' and '}' and ran across this compile
>>> error
>>> s/{/@{/g; s/}/@}/g;
>> All's well, except that braces (these two: { }) have special
>> meaning in a regular expression. Try:
TM> It is not the regex that is the problem, it is the replacement
TM> string.
I never thought of that! I was concentrating on the '{' in the
first replacement *doh*. Thanks.
Now I'm wondering why the next line:
s/@/@@/g;
works perfectly. I've experimented and found that @@ is a valid
name for a perl list.
--
Dale Henderson
"Imaginary universes are so much more beautiful than this stupidly-
constructed 'real' one..." -- G. H. Hardy
------------------------------
Date: Mon, 26 Nov 2001 21:57:55 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: { in s///; ?
Message-Id: <slrna0481j.ghk.mgjv@martien.heliotrope.home>
On 26 Nov 2001 03:35:59 -0600,
Dale Henderson <nilram@boisdarc.tamu-commerce.edu> wrote:
>>>>>> "TM" == Tad McClellan <tadmc@augustmail.com> writes:
>
> TM> sysop <vze33mmh@verizon.net> wrote:
> >> On Mon, 19 Nov 2001 18:25:10 -0500, Dale Henderson wrote:
> >>> I was trying to quote '{' and '}' and ran across this compile
> >>> error
>
> >>> s/{/@{/g; s/}/@}/g;
> >> All's well, except that braces (these two: { }) have special
> >> meaning in a regular expression. Try:
>
>
> TM> It is not the regex that is the problem, it is the replacement
> TM> string.
>
> I never thought of that! I was concentrating on the '{' in the
> first replacement *doh*. Thanks.
>
> Now I'm wondering why the next line:
>
> s/@/@@/g;
>
> works perfectly. I've experimented and found that @@ is a valid
> name for a perl list.
Array.
And yes, it is. Just like %@ is a valid name for a hash, and $@ a valid
name for a perl scalar (they all come as different faces of the same GV,
err. coin). There's even a file handle called @, even though you can't
really use it directly, because the parser gets confused.
#!/usr/local/bin/perl -w
open \*@, "/tmp/data" or die $!;
@@ = readline \*@;
print @@;
(You can leave out the backslashes, and put in some parens).
Martien
--
Do not pay any attention to what Godzilla says. It is a troll, and has
no decent working knowledge of Perl or programming in general. Search
groups.google.com to see a history of its posts and replies to these posts.
------------------------------
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 2207
***************************************