[22501] in Perl-Users-Digest
Perl-Users Digest, Issue: 4722 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 17 21:05:38 2003
Date: Mon, 17 Mar 2003 18:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 17 Mar 2003 Volume: 10 Number: 4722
Today's topics:
Re: 'Wraping' die() (James Willmore)
Re: Anyone For Golf? (Resistor Colour Codes) (Jay Tilton)
Re: CGI: how to clear form? <goldbb2@earthlink.net>
Re: database connecting error <rereidy@indra.com>
Determining String Membership <member26707@dbforums.com>
Re: Determining String Membership (Walter Roberson)
Re: Determining String Membership <No_4@dsl.pipex.com>
Re: Determining String Membership <tony_curtis32@yahoo.com>
Re: Determining String Membership <noreply@gunnar.cc>
Re: Determining String Membership (Tad McClellan)
Re: Expression with varying number of conditions (Tad McClellan)
Re: Expression with varying number of conditions <goldbb2@earthlink.net>
Re: How to execute find -exec in perl? <goldbb2@earthlink.net>
IO::Socket::SSL usage of SSL_reuse_ctx option <thomas.haselberger@ucpmorgen.com>
Re: IO::Socket::SSL usage of SSL_reuse_ctx option <ndronen@io.frii.com>
Re: new Perl feature request: call into shared libs <nospam-abuse@ilyaz.org>
regex help (david)
Re: regexp and grouping <abigail@abigail.nl>
Removal of duplicate entries from mutidimentional array (Stephen Adam)
Re: Removal of duplicate entries from mutidimentional a <jkeen@concentric.net>
Re: Removal of duplicate entries from mutidimentional a <skuo@mtwhitney.nsc.com>
Re: return value of 'accept' in PF_UNIX sockets <goldbb2@earthlink.net>
Re: splitting an array into two arrays <goldbb2@earthlink.net>
Re: Win32 Perl newsgroup? <bobx@linuxmail.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 17 Mar 2003 17:51:04 -0800
From: jwillmore@cyberia.com (James Willmore)
Subject: Re: 'Wraping' die()
Message-Id: <e0160815.0303171751.20a59bb1@posting.google.com>
> It sounds like you want to print an error message, and then die again,
> or am I mistaken?
>
> Your form is at least correct to override the sig handler.
I was afraid this would happen .... I sometimes have trouble putting
into words what I'm thinking, so bear with me.
I wanted to have a signal handler in the package that would be used
when errors occur within the package. I would use Carp, but the
requirements for the script that is soon to become a package don't
allow me to use 'English' error messages. Instead, if the script ends
without error, a '0' is returned. If there's an error, a '40' is
returned. I'd much rather use Carp and be done with it, but you know
what they say about requirements :)
The real crux of the issue is when you use the package from within a
script that already has a signal handler. The package overrides the
script's signal handler. If I put the package's signal handler in a
closure, the script's signal handler overrides the package's.
I guess the real question is .....
Can two signal handlers co-exsist?
------------------------------
Date: Mon, 17 Mar 2003 23:34:02 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Anyone For Golf? (Resistor Colour Codes)
Message-Id: <3e764de1.80697313@news.erols.com>
Benjamin Goldberg <goldbb2@earthlink.net> wrote:
: How about:
: @c{@c=qw(k wn d ge w en ue t y te)}=0..9;$"='|';
: @s=map@c{/(@c)$/i},@ARGV;print@s[0,1],0 x$s[2],$/
That got me thinking about finding the shortest possible substring of
each color that would identify it without being anchored.
black => k
brown => br
red => d
orange => or
yellow => ye
green => ee
blue => u
violet => v
grey => ey
white => h
Then, just for kicks, I added the "use re 'debug';" pragma to watch
the matching engine's behavior. Nice surprises.
orange => o
yellow => y
Since the matching engine inspects substrings starting from the left,
/br/ will match brown earlier than /o/ will,
/o/ will match orange earlier than it will match yellow or violet,
/y/ will match yellow earlier than it will match grey.
IOW, it relies heavily on the matching engine's order of operations.
I can easily see it going to pieces if any of the engine's internal
wizardry changes in future, but at least it works in 5.8.0.
So, a 94-character solution.
@c{@c=qw(k br d o y ee u v ey h)}=0..9;$"='|';
@s=map@c{/(@c)/i},@ARGV;print@s[0,1],0 x$s[2],$/
Shaving more from this one would need the color names to change. I'd
like "grey" to be called "slate" from now on. :)
------------------------------
Date: Mon, 17 Mar 2003 20:14:09 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: CGI: how to clear form?
Message-Id: <3E7672E1.A2035057@earthlink.net>
Josef Möllers wrote:
[snip]
> Unfortunately it doesn't seem to work. I just tried using the "Simple
> Script" example (the "eenie meenie minie moe" form) from the CGI
> manpage and inserted
>
> my $query = new CGI;
> $query->delete_all();
>
> right at the top but the reply page generated (the one with the
> response below the ruler) still has the name in the entry field.
>
> Even if I change the
> textfield('name')
> to any of
> textfield('name', "XXX")
> or
> textfield(-name=>'name', -default=>'XXX',)
>
> it is still initialized with the value I inserted before.
This is because when you do textfield('name'), it is using the special
internal $CGI::Q object, rather than your 'my $query' object.
Change your line at the top to:
my $query = $CGI::Q ||= new CGI;
$query->delete_all();
And all should be well.
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Mon, 17 Mar 2003 18:35:49 -0700
From: Ron Reidy <rereidy@indra.com>
Subject: Re: database connecting error
Message-Id: <3E7677F5.7090907@indra.com>
This is not a Perl problem. See the Oracle docs or your DBA.
--
Ron Reidy
Oracle DBA
ramesh wrote:
> hi
>
> when i am getting following error..........when i am trying to connect
> the database and executing the code.
>
> my code
>
> use DBI;
> #use DBD::ODBC;
> $dsname="hrvd1";
> $absdsname= "dbi:Oracle:$dsname";
> $objectnumber = 142;
> $username = "harvest";
> $password ="harvest";
> # Making connection with the database. This call will automatically
> load the
>
> my $dbh = DBI->connect($absdsname, $username, $password, {RaiseError
> =>1,
> AutoCommit =>1,}) ;
>
>
>
>
> my $sth =$dbh->prepare(q{ select ITEMNAME from HARVEST_HARITEMS }) or
> die(" cann
> ot prepare statement:", $dbh->errstr(),"\n");
>
>
> $sth->execute() or
> die ("Could not execute SQL statement, maybe invalid?",
> $sth->errstr(),"\n
> ");
>
> my @array;
> while (@array = $sth->fetchrow_array()){
> write();
> }
>
> warn($DBI::errstr) if $DBI::err;
> $dbh->disconnect();
> $sth->finish();
>
>
>
>
> errors:
> DBD::Oracle::db prepare failed: ORA-00942: table or view does not
> exist (DBD ERROR: OCIStmtExecute/Describe) at perlmodule5 line 19.
>
> please help me. thanks
------------------------------
Date: Mon, 17 Mar 2003 22:51:19 +0000
From: rymoore <member26707@dbforums.com>
Subject: Determining String Membership
Message-Id: <2653596.1047941479@dbforums.com>
I have a PERL dilema.
I have an array of server names that is read in from a config file.
So I end up with an array like this.
@SERVERS = ("fred","barney","wilma");
I then need to search through a file and keep any lines that have these
server names in them.
while(<FILE>) {
if (current line contains one of the server names) {
print the line;
}
I'm certain there is an simple way to do this but I can't put my
thumb on it.
Thanks
Ryan
--
Posted via http://dbforums.com
------------------------------
Date: 17 Mar 2003 23:42:24 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: Determining String Membership
Message-Id: <b55mh0$7ev$1@canopus.cc.umanitoba.ca>
In article <2653596.1047941479@dbforums.com>,
rymoore <member26707@dbforums.com> wrote:
:I have an array of server names that is read in from a config file.
:So I end up with an array like this.
:@SERVERS = ("fred","barney","wilma");
:I then need to search through a file and keep any lines that have these
:server names in them.
:while(<FILE>) {
: if (current line contains one of the server names) {
: print the line;
:}
one approach:
$pattern = join '|', @SERVERS;
print (($_ =~ m/$pattern/o) ? $_ : '') foreach <FILE>;
--
I've been working on a kernel
All the livelong night.
I've been working on a kernel
And it still won't work quite right. -- J. Benson & J. Doll
------------------------------
Date: Mon, 17 Mar 2003 23:42:38 +0000
From: Big and Blue <No_4@dsl.pipex.com>
Subject: Re: Determining String Membership
Message-Id: <3e765d72$0$29597$cc9e4d1f@news.dial.pipex.com>
> I have an array of server names that is read in from a config file.
> So I end up with an array like this.
>
> @SERVERS = ("fred","barney","wilma");
>
>
> I then need to search through a file and keep any lines that have these
> server names in them.
>
> while(<FILE>) {
> if (current line contains one of the server names) {
> print the line;
> }
>
Something like:
my $rx_list = 'qr/(' . join('|', @SERVERS) . ')/';
my $rx;
eval {\$rx = $rx_list};
while (<FILE>) {
if ($rx) {
do_something_appropriate();
}
}
--
-*- Just because I've written it here doesn't -*-
-*- mean that you should, or I do, believe it. -*-
------------------------------
Date: Mon, 17 Mar 2003 17:45:08 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Determining String Membership
Message-Id: <87el55h81n.fsf@limey.hpcc.uh.edu>
>> On Mon, 17 Mar 2003 22:51:19 +0000,
>> rymoore <member26707@dbforums.com> said:
> I have an array of server names that is read in from a
> config file. So I end up with an array like this.
> @SERVERS = ("fred","barney","wilma");
> I then need to search through a file and keep any lines
> that have these server names in them.
perldoc -f grep
However, putting the names into a hash would be more
efficient rather than a linear grep through a list.
hth
t
------------------------------
Date: Tue, 18 Mar 2003 01:00:32 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Determining String Membership
Message-Id: <b55nrb$259sk7$1@ID-184292.news.dfncis.de>
rymoore wrote:
> I have an array of server names that is read in from a config file.
> So I end up with an array like this.
>
> @SERVERS = ("fred","barney","wilma");
>
> I then need to search through a file and keep any lines that have these
> server names in them.
while (<FILE>) {
for my $server (@SERVERS) {
if ((index $_, $server) >= 0) {
print;
last;
}
}
}
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Mon, 17 Mar 2003 19:35:56 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Determining String Membership
Message-Id: <slrnb7ctvs.4r6.tadmc@magna.augustmail.com>
rymoore <member26707@dbforums.com> wrote:
> I have an array of server names that is read in from a config file.
> I then need to search through a file and keep any lines that have these
> server names in them.
"How do I efficiently match many regular expressions at once?"
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 17 Mar 2003 17:35:55 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Expression with varying number of conditions
Message-Id: <slrnb7cmur.4jv.tadmc@magna.augustmail.com>
Joly, Patrick: IAC <Joly.Patrick@ic.gc.ca> wrote:
> Hello all. I have a module which sorts through the keys of a hash keys
> based on its values, as follows:
>
> # given:
> # ($var1, $var2, $var3) = @_
> # and hashes such as %hash1, %hash2, %hash3, defined
^ ^ ^
Variables with consecutively increasing numbers in them often
indicates a poor choice of data structure.
But maybe that's just "meta" to you trying to describe your problem...
> # earlier in the code and containing integers as keys
>
> @keys = sort {
> ( ( $var1 =~ m|string| )
> ? $hash1{$a} cmp $hash1{$b}
> : $hash1{$a} <=> $hash1{$b}
> )
> ||
> ( ($var2 =~ m|string|)
> ? $hash2{$a} cmp $hash2{$b}
> : $hash2{$a} <=> $hash2{$b}
> )
> ||
> ( ($var3 =~ m|string|)
> ? $hash3{$a} cmp $hash3{$b}
> : $hash3{$a} <=> $hash3{$b}
> )
>
> } keys %hash1; # by value
You are using keys from %hash1 to index into the _other_ hashes?
So all of the hashes are guaranteed to have exactly identical keys?
If so, your data structure is a very poor choice indeed.
> The code works as expected. However, I need to generalize it to
> situations where the length of the @_ array is different than 3 (could
> be any length, anywhere between 2 to 20)
But then you also have from 2 to 20 global hashes, if I understand
your earlier description correctly.
Do I understand your earlier description correctly?
If so, then the chances of you having chosen a sub-optimal
data structure are getting stronger...
> I was thinking of building the string of code contained within the -sort
> { ... }- using a foreach loop:
> '( ( $var$j =~ m|string| )
^^^^^^
What you are trying to do there is use "symbolic references".
Don't try to do that:
http://www.plover.com/~mjd/perl/varvarname.html
http://www.plover.com/~mjd/perl/varvarname2.html
http://www.plover.com/~mjd/perl/varvarname3.html
Now there is no doubt that your real problem is with the data structure
you've chosen. Choose a different one. :-)
Looks like LoH (list of hashes aka array of references to hashes)
would be just the ticket. Instead of having N global hashes, have
a single array containing N references to hashes.
my @var;
$var[0] = { hash1 => 'stuff goes here' };
$var[1] = { hash2 => 'stuff goes here' };
...
Then use $var[$j] instead of ${var$j}.
> and then issue
>
> @keys = sort {
> qx/$code/
> } keys %hash1; # by value
>
> But this doesn't work for probably numerous reasons, the first one being
> that $j will *not* interpolate as I want it to.
There IS NO interpolation there. Interpolation only happens in
double-quotish _strings_, it does not happen in _code_ (which is
what $var$j is).
> But even if it did
> interpolate, the
> qx/$code/
> part doesn't work --
bacticks are for running external _programs_, not for eval()uating
snippets of Perl code.
> Any idea how to tackle this?
Choose a data structure that makes it easy to do what it is that
you need to do.
My problem at this point is that I am not at all sure what it is that
you want to do.
If you had supplied a short and complete program the I could run,
as suggested in the Posting Guidelines, then I could have given you
an exact answer with code and everything.
But you didn't, so I can't.
Look into how to do complex data structures in Perl:
perldoc perlreftut
perldoc perlref
perldoc perllol
perldoc perldsc
Or post a complete program (showing the populating of %hash1, %hash2...),
and we'll then be able to provide more concrete help.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 17 Mar 2003 21:07:35 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Expression with varying number of conditions
Message-Id: <3E767F67.D9D089C@earthlink.net>
"Joly, Patrick: IAC" wrote:
>
> Hello all. I have a module which sorts through the keys of a hash
> keys based on its values, as follows:
>
> # given:
> # ($var1, $var2, $var3) = @_
> # and hashes such as %hash1, %hash2, %hash3, defined
> # earlier in the code and containing integers as keys
>
> @keys = sort {
> ( ( $var1 =~ m|string| )
> ? $hash1{$a} cmp $hash1{$b}
> : $hash1{$a} <=> $hash1{$b}
> )
> ||
> ( ($var2 =~ m|string|)
> ? $hash2{$a} cmp $hash2{$b}
> : $hash2{$a} <=> $hash2{$b}
> )
> ||
> ( ($var3 =~ m|string|)
> ? $hash3{$a} cmp $hash3{$b}
> : $hash3{$a} <=> $hash3{$b}
> )
>
> } keys %hash1; # by value
>
> The code works as expected. However, I need to generalize it to
> situations where the length of the @_ array is different than 3 (could
> be any length, anywhere between 2 to 20)
Hmm... Something like this:
my $sortsub = "sub {\n" . join("\n\t\tor\n",
map "\t\$hash$_{\$a} COMPARE \$hash$_{\$b}" 1 .. @_
) . ";\n}\n";
for (@_) {
if( /string/ ) {
$sortsub =~ s/COMPARE/cmp/;
} else {
$sortsub =~ s/COMPARE/<=>/;
}
}
warn $sortsub if $debugging;
$sortsub = eval($sortsub) || die $@;
@keys = sort $sortsub keys %hash1;
[untested]
[snip]
> @keys = sort {
> qx/$code/
> } keys %hash1; # by value
The qx// quote-like operator doesn't do what I think you think it does.
It's the same as the readpipe() operator.
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Mon, 17 Mar 2003 20:42:39 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: How to execute find -exec in perl?
Message-Id: <3E76798F.9FD00EC8@earthlink.net>
Bernd Fischer wrote:
>
> Hi,
>
> I want to recursively change the permissions mode
> of a directory and files of that selected directory.
>
> In UNIX I can do a
> find . -type f -exec chmod 664 {} \;
> and a
> find . -type d -exec chmod 775 {} \;
>
> If I want to implement that in Perl
>
> foreach( @dir_list ){
> @args = ( "find", "$_ -type f -exec chmod 464 {} \\\;" );
> system( @args );
> @args = ( "find", "$_ -type d -exec chmod 757 {} \\\;" );
> system( @args );
> }
>
> I got
>
> find: cannot open 'file_name' -type f -exec chmod 464 {} \;:
> No such file or directory
> find: cannot open 'file_name' -type d -exec chmod 757 {} \;:
> No such file or directory
>
> What's wrong?
Try this:
s<^([-(),!])><./$1> for @dirlist;
system( "find", @dup_dirlist, qw(
( -type f -exec chmod 664 {} ; ) -o
( -type d -exec chmod 757 {} ; )
) );
[untested]
The s<><> is due to the fact that if a directory name starts with any
character in [-(),!], it will be interpreted as start of the expression.
Of course, executing a program for each and every file to change is
expensive -- that's what xargs is for.
s<^([-(),!])><./$1> for @dirlist;
my @quoted = map quotemeta, @dirlist;
system( "find @quoted -type f | xargs chmod 664" );
system( "find @quoted -type d | xargs chmod 757" );
[untested]
> Is there an elegant way to do this complete in Perl rather than
> calling the UNIX find command?
See Randal Schwartz's solution -- but note that you can replace the "."
in his example with @dir_list, since File::Find::find() accepts a
directory *list*, not just a single directory.
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Tue, 18 Mar 2003 00:15:35 +0100
From: Thomas Haselberger <thomas.haselberger@ucpmorgen.com>
Subject: IO::Socket::SSL usage of SSL_reuse_ctx option
Message-Id: <uhea1k2js.fsf@ucpmorgen.com>
Started using IO::Socket::SSL these days and am at a loss with
the *SSL_reuse_ctx* option.
Any hints on the usage of that option would be appreciated -
I just don't get what I should pass as the value for it
(the perldoc and examples show no usage).
thx,
tom
------------------------------
Date: 18 Mar 2003 01:58:55 GMT
From: Nicholas Dronen <ndronen@io.frii.com>
Subject: Re: IO::Socket::SSL usage of SSL_reuse_ctx option
Message-Id: <3e767d5f$0$196$75868355@news.frii.net>
Thomas Haselberger <thomas.haselberger@ucpmorgen.com> wrote:
TH> Started using IO::Socket::SSL these days and am at a loss with
TH> the *SSL_reuse_ctx* option.
TH> Any hints on the usage of that option would be appreciated -
TH> I just don't get what I should pass as the value for it
TH> (the perldoc and examples show no usage).
Once you've created an IO::Socket::SSL object with a "full" context,
you can simply provide that object as the SSL_resuse_ctx argument
to new().
That an IO::Socket::SSL object has a context implies that you've
provided values for all of the following arguments to new():
SSL_use_cert SSL_key_file
SSL_cert_file
SSL_passwd_cb
SSL_ca_file
SSL_ca_path
SSL_verify_mode
You should only need to care about SSL_reuse_ctx in the case that
you're creating more than one object. If you're just creating one,
I think the argument should be undef.
Regards,
Nicholas
--
"Why shouldn't I top-post?" http://www.aglami.com/tpfaq.html
"Meanings are another story." http://www.ifas.org/wa/glossolalia.html
------------------------------
Date: Mon, 17 Mar 2003 22:53:39 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: new Perl feature request: call into shared libs
Message-Id: <b55jlj$30cn$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Matt Taylor
<para@tampabay.rr.com>], who wrote in article <v9gca.58137$lW3.2011891@twister.tampabay.rr.com>:
> > > > Actually, one could also duplicate the last min(3, num_params)
> > > > arguments in EAX, EDX, ECX. This way the same code could call
> > > > __regparam__(3) functions too.
> >
> > > Why not have the calling convention used as a parameter?
> >
> > What for - if one can avoid it?
>
> The premise is not valid. That is, you can't avoid it.
See above recipe; which translates the calling convention into
reordering of arguments.
> > > I don't see why you would try to satisfy all schemes with one
> > > function.
> >
> > Why not - if this is easy to do? Change 3 to 6 above, and duplicate
> > the last 6 arguments in 6 standard registers; then providing arguments
> > to the wrapper function in a "correct" order will satisfy any "input"
> > calling convention.
>
> Last I checked GCC did not support __regparm__(6) on x86. That was GCC 2.x.
> It may be supported in GCC 3.x, but I doubt it. Most industrial-strength
> compilers do not support more than 3 registers for a register call scheme
> for 2 reasons:
When I checked it circa 10 years ago, Watcom allowed (more or less?)
arbitrary calling conventions (by #pragmas).
> 1. eax, ecx, and edx are typically not preserved
> 2. More than 3 often results in register spill anyway since esp never gets
> used for computation except in lame hand-coded assembly. (Unreal Tournament
> actually did this.)
I was planning to do this last week; turned out that I could simplify
the algorithm so that even gcc 2.8.1 could fit everything into
registers - without any assembler. Deep sigh...
> Also, you can't simply "duplicate" parameters and expect it to work. They
> exist in one place, and it's either in a register or on the stack.
??? Since the callee does not care about extra values on stack, and
extra values in registers, your arguments is not only wrong, it also
makes no sense. ;-) To call a function which expects the argument A
on stack, and B in %esi, you call the interface as
my $n_a = 0; # place holder
call_params($function, $A, $B, ($n_a) x 5);
(here I assume that the 6th argument from the end is duplicated in
%esi). Rearranging $A, $B, and $n_a, one can satisfy all the input
calling conventions (which preserve a given register, e.g., %ebp).
> Yes, Sparc is a register stack machine. It's designed for this. There is no
> way to write a completely polymorphic native call that interfaces with
> multiple machines. Somewhere, somehow you're going to have to write assembly
> for the target machine, and you'll have to give specifics about calling
> conventions for that machine.
This is exactly my point, when explaining why Perl has no call_param()
implemented.
> Speaking strictly about x86, it is -still- very difficult to generically
> describe all of the calling conventions that are commonly used let alone
> describe weird cases.
Given that you know which register is preserved by the call, and which
(may) contain the return value, it is easy to write assembler which
will delegate all the hard work to the caller, which may be a pure
Perl code.
Hope this helps,
Ilya
------------------------------
Date: 17 Mar 2003 17:23:57 -0800
From: dwlepage@yahoo.com (david)
Subject: regex help
Message-Id: <b09a22ae.0303171723.456b0102@posting.google.com>
I am trying to hammer out a regex to search to the value S/N: (\w+)
that could happen anywhere in field 7 of my data. My original data
file has fields seperated by commas, EXCEPT for field 7, which is
seperated by spaces from what I can tell. There can be many different
values in this field, but what I am interested in is anything matching
{S/N:\s(\w+)}. Any suggestions on making this a workable regex?
So it looks something like this:
dlepage,engineering,mn,field4,field5,field6, some random S/N: A12345
data,field8
while ( <FILE> ) {
# Split fields by comma
my @fields = split ( /,/ );
# Grab token serial number from Comments field
if ( $fields[7] =~ m{^\$\$S\/N:(\w+)} ) {
my $tok = '$$' . $1 . '$$';
my $subtok = $1;
Thanks..
------------------------------
Date: 17 Mar 2003 23:44:34 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: regexp and grouping
Message-Id: <slrnb7cnf2.ug8.abigail@alexandra.abigail.nl>
Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMMCDLXXXV
September MCMXCIII in <URL:news:b55csg$2ar$1@mamenchi.zrz.TU-Berlin.DE>:
:: Abigail <abigail@abigail.nl> wrote in comp.lang.perl.misc:
:: > Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMMCDLXXXV
:: > September MCMXCIII in <URL:news:b547i5$1hs$2@mamenchi.zrz.TU-Berlin.DE>:
:: > [] Bjørnar Libæk <bjoernal@ifi.uio.no> wrote in comp.lang.perl.misc:
:: > [] > Given the string "what is wrong with my brain", I want to get every
:: > [] > two-letter composition that starts with an 'r' into the grouping-variables,
:: > [] > that is, $1='ro' and $2='ra' in this example. How do I do this?
:: > []
:: > [] my @hits = 'what is wrong with my brain' =~ /(r.)/g;
:: >
:: >
:: > That doesn't set $2, and doesn't set $1 to 'ro'. It only sets $1,
:: > and sets it to 'ra'.
::
:: Right.
::
:: > The following will set $1 to 'ro', and $2 = 'ra':
:: >
:: >
:: > $_ = 'what is wrong with my brain';
:: > /@{[".*(r.)" x (() = m(r.)g)]}/;
:: > print "<$1> <$2>\n";
:: > __END__
:: > <ro> <ra>
::
:: ... or
::
:: /@{[ do { local $_ = $_; s!r.!(r.)!g; $_}]}/;
That would fail on:
$_ = "what is (wrong) with my brain";
You want to use something like:
/@{[ do { local $_ = "\Q$_"; s!r.!(r.)!g; $_}]}/;
instead.
Abigail
--
$_ = "\x3C\x3C\x45\x4F\x54";
print if s/<<EOT/<<EOT/e;
Just another Perl Hacker
EOT
------------------------------
Date: 17 Mar 2003 16:40:38 -0800
From: 00056312@brookes.ac.uk (Stephen Adam)
Subject: Removal of duplicate entries from mutidimentional arrays
Message-Id: <945bf980.0303171640.2842254@posting.google.com>
Hi there, I have checked out perl FAQ 4 and it says how to remove
deuplicates from one dimentional array (in a really slick way) though
I can't get the code to work for a multidimentional array.
The array I am using using is two dimentional and I want to check the
the first element (i.e @array[$i][0]) to see if any other elements
share the same value and if so remove them. It is going to be a string
that I am checking against not a number.
What change do I ned to make to the code, I don't want to use lots of
nasty loops.
Cheers for the help in advance
Steve
------------------------------
Date: 18 Mar 2003 01:19:35 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: Removal of duplicate entries from mutidimentional arrays
Message-Id: <b55s77$bpg@dispatch.concentric.net>
"Stephen Adam" <00056312@brookes.ac.uk> wrote in message
news:945bf980.0303171640.2842254@posting.google.com...
> Hi there, I have checked out perl FAQ 4 and it says how to remove
> deuplicates from one dimentional array (in a really slick way) though
> I can't get the code to work for a multidimentional array.
>
I suggest posting the code that's not working.
------------------------------
Date: Mon, 17 Mar 2003 17:23:06 -0800
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: Removal of duplicate entries from mutidimentional arrays
Message-Id: <Pine.GSO.4.21.0303171720020.29910-100000@mtwhitney.nsc.com>
On 17 Mar 2003, Stephen Adam wrote:
> Hi there, I have checked out perl FAQ 4 and it says how to remove
> deuplicates from one dimentional array (in a really slick way) though
> I can't get the code to work for a multidimentional array.
>
> The array I am using using is two dimentional and I want to check the
> the first element (i.e @array[$i][0]) to see if any other elements
> share the same value and if so remove them. It is going to be a string
> that I am checking against not a number.
>
> What change do I ned to make to the code, I don't want to use lots of
> nasty loops.
> ...
Do you man that you want each child-level array to have no repeats of
its first element?
Something like:
#! /usr/local/bin/perl
use strict;
use warnings;
use Data::Dumper;
my @recitation = (
[qw(fair is foul and foul is fair)],
[qw(out damn spot out I say)]
);
my $first;
my @out = map { [ ($first = $_->[0]), grep {$_ ne $first} @$_ ] } @recitation;
print Dumper \@out;
--
Hope this helps,
Steven
------------------------------
Date: Mon, 17 Mar 2003 20:19:07 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: return value of 'accept' in PF_UNIX sockets
Message-Id: <3E76740B.A73FA58C@earthlink.net>
Marek Zawadzki wrote:
>
> On Thu, 13 Mar 2003, Benjamin Goldberg wrote:
>
> / ...
> > > I'm trying to make something like "username based" authentication with
> > > PF_UNIX, so only clients owned by certain users are allowed to connect
> > > (ownership of a socket won't help this time)...
> >
> > Consider using the sendmsg()/recvmsg() functions with an SCM_CREDENTIALS
> > message. (You may need to consult an additional manpage ("cmsg") for
> > the various types of "struct msghdr" manipulation macros/functions).
>
> Thanks, this would suit my needs. The problem is sendmsg/recvmsg aren't
> implemented in Perl. Can anybody provide me with more help on how to send
> 'out-of-bound' data via Unix-domain sockets in Perl?
Either XS or Inline::C.
Look at the C and XS parts of File::FDpasser for inspiration.
> I'd like to send credentials of a process or a file descriptor (see FAQ
> reference below) from one process to another via Unix-domain socket.
>
> In another post, Ilja Tabachnik directed me to this resource:
> Secure UNIX Programming FAQ
> (http://www.whitefang.com/sup/secure-faq.html),
> section "4.4) How do I authenticate a non-parent process?"
>
> This is exactly what I want, however, I'm having troubles implementing it
> in Perl (possibly under IRIX).
You can't use pure-perl... there has to be a compiled part.
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Mon, 17 Mar 2003 21:12:59 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: splitting an array into two arrays
Message-Id: <3E7680AB.C90724F7@earthlink.net>
"David K. Wall" wrote:
>
> The purpose of this snippet of code is to split an array into halves.
> If there are an odd number of elements, the first array should be the
> largest, e.g.; an array with 9 elements should be split into arrays
> with 5 and 4 elements.
>
> my @full_array = 1..9;
> my @second = @full_array;
> my @first = splice @second, 0, int(scalar(@second)/2 + 0.8);
>
> This was part of a quick-and-dirty program I wrote this morning, so I
> took what seemed to be the easiest way. Just out of curiousity, is
> there a better way?
I would do:
my @full_array = 1..9;
my @first = @full_array;
my @second = splice @first, ((@first+1)/2);
Since it removes from the end, instead of from the beginning.
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Tue, 18 Mar 2003 00:11:47 GMT
From: "Bob X" <bobx@linuxmail.org>
Subject: Re: Win32 Perl newsgroup?
Message-Id: <7vtda.1704$FN.1329841@news2.news.adelphia.net>
Here you go:
news://news.roth.net/
------------------------------
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 4722
***************************************