[22482] in Perl-Users-Digest
Perl-Users Digest, Issue: 4703 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 13 09:06:29 2003
Date: Thu, 13 Mar 2003 06:05:10 -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 Thu, 13 Mar 2003 Volume: 10 Number: 4703
Today's topics:
Building a hierarchy <tore@aursand.no>
Re: Building a hierarchy <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Re: comma delimited s/r <abigail@abigail.nl>
Convert & to %26 (Mike)
Re: Convert & to %26 (Walter Roberson)
Re: Convert & to %26 <grazz@nyc.rr.com>
Expand ENV var within another ENV var (Michael)
Re: Expand ENV var within another ENV var (Anno Siegel)
Re: Expand ENV var within another ENV var (Tony L. Svanstrom)
Re: Grabbing module name on the fly (Anno Siegel)
Re: handling multiple reponses from a Net::Telnet sessi (Anno Siegel)
Re: How to use unzip files to current directory <johndoe44@hotmail.com>
Re: http cgi and perl (Jay Tilton)
Re: http cgi and perl <tore@aursand.no>
Math::Pari, Win32 and gcc <kalinabears@hdc.com.au>
Re: process name of own <VVVshengh_ccc@xxxspamxxx.com>
Re: remove anything from string except two words (Pynex)
return value of 'accept' in PF_UNIX sockets <mzawadzk@man.poznan.pl>
Re: small parsing problem (Helgi Briem)
Re: Telnet.pm, buffering output (sean)
Re: Telnet.pm, buffering output (sean)
Re: Uninitialised variable - no it isn't! <bigj@kamelfreund.de>
War against spam <vincentg@datashaping.com>
Re: War against spam (Jay Tilton)
Re: War against spam (Anno Siegel)
Re: what is current user from .htaccess? <peakpeek@purethought.com>
Re: what is current user from .htaccess? <dont@want.spam>
What's wrong with the Perl docs <me@privacy.net>
Re: What's wrong with the Perl docs (Anno Siegel)
Re: What's wrong with the Perl docs <tassilo.parseval@post.rwth-aachen.de>
Re: What's wrong with the Perl docs (Helgi Briem)
Re: XS, SWIG? Accessing C API easily <tassilo.parseval@post.rwth-aachen.de>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 13 Mar 2003 13:50:04 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Building a hierarchy
Message-Id: <pan.2003.03.13.12.49.46.6148@aursand.no>
I had a hard time figuring out a subject which could cover the topic of my
post, so bear with me. :)
PROBLEM: I need to build a hierarchy from my elements in my database. The
elements are stored in an 'element' table, while they relations (and
positions based on the relations) are stored in an 'element_parent' table;
+----------------+ +----------------+
| element | | element_parent |
+----------------+ +----------------+
| element_id | | element_id |
| elementtype_id | | parent_id |
+----------------+ | position |
+----------------+
Why do it this way? Why don't just store 'parent_id' in the 'element'
table? Reason: One element can have more than one parent, and in
addition have different 'position' values depending on the parent element.
Now I build the hierarchy (slightly simplified);
sub build_hierarchy
{
## Fetch input argument(s)
my $self = shift;
## Initialise variables
my $hierarchy = {};
## Prepare SQL statements
my $stElements = $dbh->prepare('SELECT e.element_id, e.elementtype_id
FROM element e, element_parent ep
WHERE e.element_id = ep.element_id
ORDER BY ep.parent_id, ep.position');
my $stParents = $dbh->prepare('SELECT parent_id, position
FROM element_parent
WHERE element_id = ?');
## Do the work
$stElements->execute();
while ( my ($element_id, $elementtype_id) = $stElements->fetchrow() ) {
my %info = (
'ELEMENT_ID' => $element_id,
'ELEMENTTYPE_ID' => $elementtype_id,
'PARENTS' => {},
'CHILDREN' => [],
);
$stParents->execute( $element_id );
while ( my ($parent_id, $position) = $stParents->fetchrow() ) {
$info{'PARENTS'}->{$parent_id} = $position;
push( @{$hierarchy->{$parent_id}->{'CHILDREN'}}, $element_id );
}
$hierarchy->{$element_id} = \%info;
}
## Finish SQL statements
$stElements->finish();
## Return
return $hierarchy;
}
There are room for optimizing the code above, but I know that it works
fine so I'll wait with that.
The problem is that I also want to store the following information in the
'$hierarchy' hash above, if possible:
a) Each possible path to reach an element. This can be resolved
_after_ the "do the work" part above, using a method mentioned
in "Mastering Algoritms with Perl", but I want to know if it's
possible to resolve the possible paths _while_ I'm processing
each element.
b) I also need to know what "level" each element is on. However,
the more I think of it, this can't be resolved ahead of actually
displaying the element structure/hierarchy. With "level" I
actually mean the indentation level the element would get if
you were to output the structure as a menu;
Element 1 (level = 1, path = 1)
Element 2 (level = 2, path = 1,2)
Element 3 (level = 3, path = 1,2,3)
Element 4 (level = 2, path = 1,4)
Element 5 (level = 1, path = 5)
Remember: In the example above, 'Element 3' is a child of
'Element 2'. Please have in mind that it could _also_ be a
child of 'Element 4', thus giving it two possible paths.
Speed isn't really an issue here, at least not yet; The code above is
slightly simplified. In a real world scenario, I would cache the result
of the calculations above.
Any ideas on how I should approach these problems? Anywhere I can go to
read more about related topics?
Thanks in advance!
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: Thu, 13 Mar 2003 14:28:29 +0100
From: Koos Pol <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Subject: Re: Building a hierarchy
Message-Id: <newscache$h3wobh$bj8$1@news.emea.compuware.com>
Tore Aursand wrote (Thursday 13 March 2003 13:50):
> PROBLEM: I need to build a hierarchy from my elements in my database. The
> elements are stored in an 'element' table, while they relations (and
> positions based on the relations) are stored in an 'element_parent' table;
>
> +----------------+ +----------------+
> | element | | element_parent |
> +----------------+ +----------------+
> | element_id | | element_id |
> | elementtype_id | | parent_id |
> +----------------+ | position |
> +----------------+
>
> Why do it this way?
Without checking your code and logic or commenting on it in any way, there
is one big issue you should be trying to avoid: Projecting your data model
directly onto you table structure. It will give you lots of headaches if
you need to change your data model. Your database implementation should
ideally be completely independent of the data model. The data structures,
dependencies and hierarchy are instantiated and molded by your application,
not by your database.
FWIW and HTH.
--
KP
------------------------------
Date: 13 Mar 2003 07:02:53 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: comma delimited s/r
Message-Id: <slrnb70b8t.4u4.abigail@alexandra.abigail.nl>
david (dwlepage@yahoo.com) wrote on MMMCDLXXXI September MCMXCIII in
<URL:news:b09a22ae.0303121731.437fa163@posting.google.com>:
__ What is the best way to do a s/r on a comma delimited file? What I
__ have is a data file with about 30+ fields per line. They are all
__ seperated by comma's. I need to replace field 2 with field 4 as long
__ as field 4 matches (/S\/N\:). I then need to take the contents of
__ field 2 and field 4 and write them out to a seperate file.
__
__ Something like this:
__ 1,dlepage,group,S/N:A12345
__ 2,dlepage2,group,nothing
__ 3,dlepage3,group,S/N:G3423
__
__ to something like this:
__ 1,S/N:A12345,group,S/N:A12345 3/11/03
__ 2,dlepage2,group,nothing
__ 3,S/N:G3423,group,S/N:G3423 3/15/34
__ *(Note field 4 can have multiple values seperated by spaces)
__
__ and write out dlepage,S/N:A12345 and dlepage3,S/N:G3423 to a seperate
__ file.
__
__ Any suggestions? I am currently saving value 1 and 2 to arrays and
__ thinking about adding them to a hash and iterating through this. Maybe
__ there is an easier way?
$ perl -F, -alwne 'print "$F[1],$F[3]" if $F [3] =~ m!S/N!' file > new_file
The above is untested.
Abigail
--
sub _ {$_ = shift and y/b-yB-Y/a-yB-Y/ xor !@ _?
exit print :
print and push @_ => shift and goto &{(caller (0)) [3]}}
split // => "KsvQtbuf fbsodpmu\ni flsI " xor & _
------------------------------
Date: 12 Mar 2003 21:13:22 -0800
From: csdude@hotmail.com (Mike)
Subject: Convert & to %26
Message-Id: <46cdc619.0303122113.6dce5e23@posting.google.com>
Hey,
I'm trying to convert & into %26, but it's trickier than I thought. I
tried what I thought would work:
$str =~ tr/&/%26/;
But this just converted the & into %. I tried escaping the %, but no
go, and I also tried using "%26" and (%26), just hoping, but still
nothing. None of these give me an error (and I do have the -w switch
this time), they just didn't do what I expected.
Any thoughts?
TIA,
Mike
------------------------------
Date: 13 Mar 2003 05:22:11 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: Convert & to %26
Message-Id: <b4p4i3$355$1@canopus.cc.umanitoba.ca>
In article <46cdc619.0303122113.6dce5e23@posting.google.com>,
Mike <csdude@hotmail.com> wrote:
:I'm trying to convert & into %26, but it's trickier than I thought. I
:tried what I thought would work:
:$str =~ tr/&/%26/;
tr can only be used for one-to-one mapping; you are trying to do
a one-to-three mapping. Use the s operator instead.
$str =~ s/&/%26/g;
--
Warning: potentially contains traces of nuts.
------------------------------
Date: Thu, 13 Mar 2003 06:05:36 GMT
From: Steve Grazzini <grazz@nyc.rr.com>
Subject: Re: Convert & to %26
Message-Id: <QcVba.7311$Em1.532096@twister.nyc.rr.com>
Walter Roberson <roberson@ibd.nrc-cnrc.gc.ca> wrote:
> In article <46cdc619.0303122113.6dce5e23@posting.google.com>,
> Mike <csdude@hotmail.com> wrote:
> :I'm trying to convert & into %26, but it's trickier than
> :I thought. I tried what I thought would work:
>
> :$str =~ tr/&/%26/;
>
> tr can only be used for one-to-one mapping; you are trying
> to do a one-to-three mapping. Use the s operator instead.
>
> $str =~ s/&/%26/g;
And in case you (the OP) might want to escape other characters
some day, there's a more general solution given in the faq:
$ perldoc -q "%-encoding"
And there's also URI::Escape.
--
Steve
------------------------------
Date: 13 Mar 2003 04:06:54 -0800
From: michael.saville@lmco.com (Michael)
Subject: Expand ENV var within another ENV var
Message-Id: <dc64da3.0303130406.1aee22fd@posting.google.com>
HELP. using one var to setup multipe vars as follows:
$ENV{LOCALPATH} = /opt/perfmet;
$ENV{LIB} = $ENV{LOCALPATH}/lib;
$ENV{CONF} = $ENV{LOCALPATH/conf;
$ENV{BIN} = $ENV{LOCALPATH}/bin;
etc...
program looks for file in CONF but fails to find it:
open(CONF, "<$ENV{CONF}/cpu.cfg") or die "Reason: $!\n";
error: no such file ...
added debug to print env vars:
print "ENV{LOCALPATH} = $ENV{LOCALPATH}\n";
print "ENV{CONF} = $ENV{CONF}\n";
OUTPUT:
ENV{LOCALPATH} = /opt/perfmet
ENV{CONF} = $ENV{LOCALPATH}/conf
It seems that it doesn't automatically expand the LOCALPATH variable.
Any idea how to make this work?
------------------------------
Date: 13 Mar 2003 12:19:44 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Expand ENV var within another ENV var
Message-Id: <b4pt10$h57$1@mamenchi.zrz.TU-Berlin.DE>
Michael <michael.saville@lmco.com> wrote in comp.lang.perl.misc:
> HELP. using one var to setup multipe vars as follows:
>
> $ENV{LOCALPATH} = /opt/perfmet;
This doesn't compile. Show your real code.
[snip]
Anno
------------------------------
Date: Thu, 13 Mar 2003 12:52:58 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: Expand ENV var within another ENV var
Message-Id: <1frri8i.zdp39f1ame906N%tony@svanstrom.com>
Michael <michael.saville@lmco.com> wrote:
> HELP.
#!/usr/bin/perl -Tw
use strict;
use warnings;
> It seems that it doesn't automatically expand the LOCALPATH variable.
{1} perl -e '$ENV{LOCALPATH} = /opt/perfmet;$ENV{LIB} = $ENV{LOCALPATH}/lib;'
Bareword found where operator expected at -e line 1, near "/opt/perfmet"
(Missing operator before perfmet?)
syntax error at -e line 1, near "/opt/perfmet"
Execution of -e aborted due to compilation errors.
{2} perl -e '$ENV{LOCALPATH} = "/opt/perfmet";$ENV{LIB} = "$ENV{LOCALPATH}/lib"; print $ENV{LIB}'
/opt/perfmet/lib
> Any idea how to make this work?
I seriously doubt that the code that you showed is the code you're
using; anyways, look at my example and you'll get it right (hint: use "
and not ').
--
# Per scientiam ad libertatem! // Through knowledge towards freedom! #
# Genom kunskap mot frihet! =*= (c) 1999-2002 tony@svanstrom.com =*= #
perl -e'print$_{$_} for sort%_=`lynx -source svanstrom.com/t`'
------------------------------
Date: 13 Mar 2003 09:37:40 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Grabbing module name on the fly
Message-Id: <b4pjh4$arm$1@mamenchi.zrz.TU-Berlin.DE>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in comp.lang.perl.misc:
> Steve Grazzini wrote:
> > FYI, you can use a variable for the package name:
> >
> > $something = "Foo";
> >
> > require "$something.pm";
> > $something->import("extras");
> ----^^^^^^^^^^
>
> Hmm.. I thought that was a symlink, that didn't work under "use strict
> 'refs';" (and that was one of my restrictions). Obviously I was wrong.
With object methods it should hardly come as a surprise that the object
in "$obj->method(...)" can be given as a variable. The same is true for
the class in a class method call. After all, the object or class is
just another parameter in the actual call, though given in an unusual
position.
What comes closer to a symref (not symlink) is giving the *method name*
in a variable: "$obj->$method(...)". This also works under strict 'refs',
though this time is is the method itself that is accessed indirectly.
Method dispatch happens at run-time through the method name, otherwise
inheritance couldn't work the way it does. So method lookup is symbolic
by nature, whether the name is known at compile time or only later
at run time. It wouldn't make much sense to forbid the latter case.
Incidentally, a method can also be given as a hard (code-) reference:
my $meth = sub { my $self = shift; ... };
$obj->$meth(...);
Anno
------------------------------
Date: 13 Mar 2003 11:00:15 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: handling multiple reponses from a Net::Telnet session?
Message-Id: <b4pobv$bit$3@mamenchi.zrz.TU-Berlin.DE>
Beeblebrox <sl1433@hotmail.com> wrote in comp.lang.perl.misc:
> Hello,
>
> I have a perl script that telnet's into some of our network equipment,
> to automate some tasks. I use a series of "print"/"waitfor"s; it
> works great, unless the last person to login didn't save a config
> change on the network device, in which case the network device prompts
> for a confirmation (that I saw the alert).
>
> So, how do I handle more-than-1 possible response to a particular
> "print" entry I make within an Net::Telnet session? A couple examples
> would be fantastic. I've read thru the perl.org cpan doc, but it
> didn't have any examples that fit my situation.
Have you noticed you can give waitfor() a regular expression to wait for?
Anno
------------------------------
Date: Thu, 13 Mar 2003 07:48:16 GMT
From: Steve Monty <johndoe44@hotmail.com>
Subject: Re: How to use unzip files to current directory
Message-Id: <3E7037B6.70806@hotmail.com>
That worked perfectly. Thank you.
I apologize for not catching on before. It makes sense now.
Monty
Gunnar Hjalmarsson wrote:
> Steve Monty wrote:
>
>>
>>>> I'm using the system command "unzip" to unzip a file.
>>>>
>>>> system ("unzip ../zipdir/zipfile.zip");
>>>
>>>
>>> chdir '../zipdir';
>>> system (unzip zipfile.zip);
>>
>>
>> Thank you so much for the help but is that the exact code to use?
>
>
> Yes, that was the thought.
>
>> I tried what you posted above and it didn't work. I get an error saying
>>
>> unzip: cannot find ../californiakid90/photos/photo.zip,
>> ../californiakid90/photos/photo.zip.zip or
>> ../californiakid90/photos/photo.zip.ZIP. Content-type: text/html TEST
>> The code I used was:
>> ########################## chdir '../californiakid90/photos';
>> system ("unzip ../californiakid90/photos/photo.zip");
>> ##########################
>
>
> In that case you did not follow my suggestion. Applied to the real
> filenames it should be:
>
> chdir '../californiakid90/photos';
> system ("unzip photo.zip");
>
> The first line changes the current directory, so you should not use
> the same relative path in the system call.
>
> (As pointed out by Drew, an alternative is to state the output
> directory directly in the system call.)
>
> / Gunnar
>
------------------------------
Date: Thu, 13 Mar 2003 05:29:44 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: http cgi and perl
Message-Id: <3e701629.17362438@news.erols.com>
Mario542 <member17678@dbforums.com> wrote:
: I have a web page the references a perl scripts, but when I try to run
: it tries to download the perl file instead of running it. Any ideas??
This is a web server configuration issue, not a Perl one.
: Here is the perl script.
Irrelevant.
------------------------------
Date: Thu, 13 Mar 2003 13:50:03 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: http cgi and perl
Message-Id: <pan.2003.03.13.11.28.27.393635@aursand.no>
On Thu, 13 Mar 2003 00:12:37 +0000, Mario542 wrote:
> I have a web page the references a perl scripts, but when I try to run
> it tries to download the perl file instead of running it.
This problem is not related to Perl, but the web server you're running.
You must tell your web server to _execute_ Perl scripts, but just serve
them as plain text.
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: Thu, 13 Mar 2003 19:33:55 +1100
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Math::Pari, Win32 and gcc
Message-Id: <3e70434c$0$22385@echo-01.iinet.net.au>
Hi,
I have perl5.6.1 built with mingw32 (gcc and dmake) on Windows 2000.
Been trying to build Math::Pari for a couple of days.
I was getting 'unresolved references' to 'geteuid', 'getpwnam' and 4 other
nixy-type functions - so I amended the makefile.pl's (there are 2) to link
to libcygwin.a by using the '-L' and '-l' switches.
Now I get:
D:\gcc\bin\..\lib\gcc-lib\i386-mingw32msvc\2.95.2..\..\..\..\i386-mingw32msv
c\lib\libmingw32.a(gccmain.o)(.text+0x80): multiple definition of `__main`
D:\cygwin\usr\lib\libcygwin.a(ds000029.o)(.text+0x0): first defined here
dmake.exe: Error code 1, while making 'blib\arch\auto\Math\Pari\Pari.dll'
And the dll does not get built. I think this is the only thing that's now
stopping the build process from completing successfully.
Seems to be telling me that '__main' is to be found in both libmingw32.a and
libcygwin.a, and that's unacceptable.
Trouble is I need to link to both of those libraries - and all my attempts
to resolve the problem (by messing about in the makefiles) either result in
that error or the 'unresolved references'. I also tried linking to libc.a
instead of libcygwin.a but that makes no difference. '__main' is also to be
found in libc.a.
If anyone has any ideas on how/if this problem can be worked around I'd be
glad to hear them.
Otherwise I'll have to find another way to deal with the nixy stuff.
Cheers,
Rob
------------------------------
Date: Thu, 13 Mar 2003 10:35:19 +0100
From: Sheng Han <VVVshengh_ccc@xxxspamxxx.com>
Subject: Re: process name of own
Message-Id: <3E7050D7.D2941E78@xxxspamxxx.com>
--------------BB32CA5FBA14E3E5985C1952
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
thank you Gunnar & The_Shadow! it works!
Gunnar Hjalmarsson wrote:
> The_Shadow wrote:
> > Use this to get just the file name.
> > my @file = split(/\\/, $0);
> --------------------^^
>
> You are on Windows, I presume? Modifying your expression, this would
> make it work on *nix as well:
>
> my @file = split(/[\/\\]/, $0);
> print "$file[-1]\n";
>
> But an even more OS independent reply to Sean's question would be:
>
> use File::Basename;
> print basename($0);
>
> / Gunnar
>
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
------------------------------------------------------------
Sheng Han
Cadence Design Systems GmbH
Methodology Services Europe Mozartstr. 2
Email: shengh@cadence.com 85622 Feldkirchen Germany
Phone: +49 (0) 89-4563-1876
Fax:: +49 (0) 89-4563-1819
------------------------------------------------------------
--------------BB32CA5FBA14E3E5985C1952
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
thank you Gunnar & The_Shadow! it works!
<p>Gunnar Hjalmarsson wrote:
<blockquote TYPE=CITE>The_Shadow wrote:
<br>> Use this to get just the file name.
<br>> my @file = split(/\\/, $0);
<br>--------------------^^
<p>You are on Windows, I presume? Modifying your expression, this would
<br>make it work on *nix as well:
<p> my @file = split(/[\/\\]/, $0);
<br> print "$file[-1]\n";
<p>But an even more OS independent reply to Sean's question would be:
<p> use <a href="File::Basename">File::Basename</a>;
<br> print basename($0);
<p>/ Gunnar
<p>--
<br>Gunnar Hjalmarsson
<br>Email: <a href="http://www.gunnar.cc/cgi-bin/contact.pl">http://www.gunnar.cc/cgi-bin/contact.pl</a></blockquote>
<pre>--
------------------------------------------------------------
Sheng Han
Cadence Design Systems GmbH
Methodology Services Europe Mozartstr. 2
Email: shengh@cadence.com 85622 Feldkirchen Germany
Phone: +49 (0) 89-4563-1876
Fax:: +49 (0) 89-4563-1819
------------------------------------------------------------</pre>
</html>
--------------BB32CA5FBA14E3E5985C1952--
------------------------------
Date: 13 Mar 2003 05:10:41 -0800
From: pynex@gmx.de (Pynex)
Subject: Re: remove anything from string except two words
Message-Id: <d57585e5.0303130510.6300c3e4@posting.google.com>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in message news:<b4ms1c$225dt1$1@ID-184292.news.dfncis.de>...
> But.. I already posted a suggestion 'the other way around':
>
> http://groups.google.com/groups?dq=&hl=en&lr=&ie=UTF-8&selm=b4iafh%241snfja%241%40ID-184292.news.dfncis.de
>
> / Gunnar
I'm sorry. I've seen on your hind.
It works, but now I've seen that "Version" in $oldstring sometimes has
two-digits before the point and in the brackets.
Example :
Version 5.6(12) and
Version 12.3(5)
Version 5.6(12) <--- this is show in $newstring
Version 12.3(5) <--- this not
I know that \d is for one digit. So that
oldstring =~ s{((?:XZ-\d{4})|(?:Version \d\.\d\(\d\d\)))}
{ $newstring .= $1 . ' '; $1 }ge;
is for ?.?(??) only, but now i want it for ??.?(??), too
So I don't know what to do (again).
------------------------------
Date: Thu, 13 Mar 2003 09:57:28 +0100
From: Marek Zawadzki <mzawadzk@man.poznan.pl>
Subject: return value of 'accept' in PF_UNIX sockets
Message-Id: <Pine.GSO.4.44.0303130951310.26054-100000@rose.man.poznan.pl>
Hello,
What would be returned by accept call in case of Unix domain sockets?
Could it be a translated to the PID of a client process?
The following code doesn't print accept's return value -- why?
my $paddr = accept(CLIENT, SERVER);
my ($iaddr) = sockaddr_un($paddr);
print "from: $iaddr\n";
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)...
-marek
------------------------------
Date: Thu, 13 Mar 2003 12:54:11 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: small parsing problem
Message-Id: <3e707f1e.2941559448@news.cis.dfn.de>
On Wed, 12 Mar 2003 11:06:28 -0600, Bryan Krone
<cbk047@email.mot.com> wrote:
<!doctype html public "-//w3c//dtd html 4.0
transitional//en">
Please stop posting to Usenet in HTML.
Usenet is a text-only medium.
For further guidelines on posting to comp.lang.perl.misc,
see:
http://mail.augustmail.com/~tadmc/clpmisc.shtml
For more information about netiquette in general, see
the "Netiquette Guidelines" at:
http://andrew2.andrew.cmu.edu/rfc/rfc1855.html
--
Regards, Helgi Briem
helgi AT decode DOT is
------------------------------
Date: 13 Mar 2003 04:10:23 -0800
From: oxandrolone@hotmail.com (sean)
Subject: Re: Telnet.pm, buffering output
Message-Id: <2b051f5c.0303130410.23b5347c@posting.google.com>
oxandrolone@hotmail.com (sean) wrote in message news:<2b051f5c.0303121255.46e680d9@posting.google.com>...
> I'm fairly green with PERL.
>
> I have a need to retrieve the output from a bunch of commands from a
> large number of Cisco routers. For some reason, which i think is due
> to buffering, i never get all the data back.
>
> Here is the snip...
>
> open(current_device, "error.log");
>
> my $telnet = new Net::Telnet ( Timeout => 10,
> # prompt => '/[\w().-]*[\$#>]\s?
> Errmode => "return"
> );
>
> snip..lots of logic for getting into the things...
>
> $ok = $telnet->cmd("set len 0");
> @shconf = $telnet->cmd(String => "show conf",Timeout => 300);
> @shver = $telnet->cmd(String => "show ver",Timeout => 300);
> @shvlan = $telnet->cmd(String => "show vlan",Timeout => 300);
> print current_device @shconf;
> print current_device @shver;
> print current_device @shvlan;
>
> close it all up and clean up.
>
> My problem is, no matter what I seem to do, all of the data never
> makes it into the file.
OK, I have a little more info to add to this. I started running it
with individual commands. It turns out, the only one that is failing
is the sho conf command. The configs can be faily large 50-100k, but
size doesn't seem to be the issue. What I am seeing is, the data that
is pulled back looks like it is captured out of order, the first lines
printed into the file from the sho conf is about 1/4 of the way into
the actual config file, then the begining of the data is tacked onto
the end.
------------------------------
Date: 13 Mar 2003 04:39:04 -0800
From: oxandrolone@hotmail.com (sean)
Subject: Re: Telnet.pm, buffering output
Message-Id: <2b051f5c.0303130439.3bbb5a23@posting.google.com>
oxandrolone@hotmail.com (sean) wrote in message news:<2b051f5c.0303121255.46e680d9@posting.google.com>...
> I'm fairly green with PERL.
>
> I have a need to retrieve the output from a bunch of commands from a
> large number of Cisco routers. For some reason, which i think is due
> to buffering, i never get all the data back.
>
> Here is the snip...
>
> open(current_device, "error.log");
>
> my $telnet = new Net::Telnet ( Timeout => 10,
> # prompt => '/[\w().-]*[\$#>]\s?
> Errmode => "return"
> );
>
> snip..lots of logic for getting into the things...
>
> $ok = $telnet->cmd("set len 0");
> @shconf = $telnet->cmd(String => "show conf",Timeout => 300);
> @shver = $telnet->cmd(String => "show ver",Timeout => 300);
> @shvlan = $telnet->cmd(String => "show vlan",Timeout => 300);
> print current_device @shconf;
> print current_device @shver;
> print current_device @shvlan;
>
> close it all up and clean up.
>
> My problem is, no matter what I seem to do, all of the data never
> makes it into the file.
litte more info...
more debugging, noticed that the command 'set Prompt' is in the data
being sent back, seems to be causing the cmd to freak...
------------------------------
Date: Thu, 13 Mar 2003 12:43:43 +0100
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: Uninitialised variable - no it isn't!
Message-Id: <pan.2003.03.13.11.35.42.829852@kamelfreund.de>
Tore Aursand wrote at Thu, 13 Mar 2003 00:14:02 +0100:
> On Wed, 12 Mar 2003 21:49:55 +0000, Stephen Patterson wrote:
>> if ($url->scheme() eq 'ftp') {
>>
>> This gives me Use of uninitialized value in string eq at
>> lib/DBIx/TextSearch.pm line 314. (the line with the if statement), but
>> all the print statements above display the correct (defined) values of
>> $url and $uri.
>
> It's the _return value_ of the 'scheme()' method which is undefined. If
> you try to do 'print $uri->scheme()' you will notice that you can't print
> undefined values. :)
The reason for the undefined value is also explained in the documentation
to the URI module:
$uri->scheme( [$new_scheme] )
This method sets and returns the scheme part of the
$uri. If the $uri is relative, then $uri->scheme
returns "undef". If called with an argument, it will
update the scheme of $uri, possibly changing the class
of $uri, and return the old scheme value. The method
croaks if the new scheme name is illegal; scheme names
must begin with a letter and must consist of only US-
ASCII letters, numbers, and a few special marks: ".",
"+", "-". This restriction effectively means that
scheme have to be passed unescaped. Passing an
undefined argument to the scheme method will make the
URI relative (if possible).
I would guess the used $uri is relative.
Cheerio,
Janek
------------------------------
Date: Thu, 13 Mar 2003 05:23:29 GMT
From: Vincent Granville <vincentg@datashaping.com>
Subject: War against spam
Message-Id: <3E701113.327FF5B8@datashaping.com>
http://www.datashaping.com/internet.shtml
What do you think of this idea?
------------------------------
Date: Thu, 13 Mar 2003 05:39:31 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: War against spam
Message-Id: <3e701910.18106197@news.erols.com>
Vincent Granville <vincentg@datashaping.com> wrote:
: http://www.datashaping.com/internet.shtml
: What do you think of this idea?
What's it got to do with Perl?
Asking content-free questions just to get people to look at your site
is spamming, Vincent Granville, Ph.D., Strategy Architect.
Irony.
------------------------------
Date: 13 Mar 2003 10:20:38 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: War against spam
Message-Id: <b4pm1m$bit$2@mamenchi.zrz.TU-Berlin.DE>
Vincent Granville <vincentg@datashaping.com> wrote in comp.lang.perl.misc:
> http://www.datashaping.com/internet.shtml
> What do you think of this idea?
What idea? Plugging your own web site by spamming Usenet with disingenuous
questions about it? The idea is old, and its practice is insulting.
Anno
------------------------------
Date: Thu, 13 Mar 2003 06:12:44 +0000
From: Sharon Grant <peakpeek@purethought.com>
Subject: Re: what is current user from .htaccess?
Message-Id: <3b707vcvmff419t2lqo0pc2o56rh83ccii@4ax.com>
On Thu, 13 Mar 2003 03:22:18 +0100, in comp.lang.perl.misc, "Tore Aursand" <tore@aursand.no> wrote:
>On Wed, 12 Mar 2003 17:29:09 -0800, Paul wrote:
>> On a similar note, is there a way to expire that session so that they
>> must log in again?
>
>AFAIK, no. Maybe you're able to do this by using some Apache module, but
>I don't think so; The authentication is cached in the client's user agent
>(ie. browser), so you're not able to deal with it from the server
A CGI script can send a 401 status header, which should make
the browser popup the authentication dialogue box. Assuming the
user does not re-enter the same credentials, some browsers will
then "forget" the credentials. Unfortunately, some browsers will
remember the authentication credentials even if the user presses
the "Cancel" button in the authentication dialogue box, so the
user will still have access to the protected resource without
having to re-enter authentication credentials
The only technique I have been able to use to simulate "logout"
is to have a dummy entry in the user/password file. For example,
create an entry with user name 'logout' and blank password. Code
the application so that user 'logout' has no privileges, and then
instruct the users to enter 'logout' in the User name and leave
the password blank. If the users do this, the browser will
replace their normal authentication credentials with the
unprivileged 'logout' user credentials
One disadvantage of this is that the instruction to enter
'logout' and a blank password in the authentication dialogue box
is counter-intuitive. Many users will be confused
--
Sharon
------------------------------
Date: Thu, 13 Mar 2003 08:01:51 +0000
From: Chris Lowth <dont@want.spam>
Subject: Re: what is current user from .htaccess?
Message-Id: <iXWba.28$iZ5.24@newsfep3-gui.server.ntli.net>
Tony Curtis wrote:
>> On a similar note, is there a way to expire that session
>> so that they must log in again?
>
> Nope, cached authentication information (if any) is under
> the control of the user agent (browser) and is
> (hopefully!) sandboxed against any remote access. And
> it's, as you noted, authentication, not a login session.
But on the other hand - yes! Many ways to do this using cookies and locally
persisted data. The CGI::Session module gives a nice front end to this.
Note that as has been said, this is "session management" rather than
"authentication", but you can easily roll your own authentication using
HTML forms and cookie-based sessions. Dont use the .htpasswd logic in this
case because you cant log someone out that way.
Chris
--
Real address: chris at lowth dot sea oh em.
For free GPL e-mail virus blockade ...
http://protector.sourceforge.net
------------------------------
Date: Thu, 13 Mar 2003 20:24:02 +1100
From: "Tintin" <me@privacy.net>
Subject: What's wrong with the Perl docs
Message-Id: <b4pini$21mr4q$1@ID-172104.news.dfncis.de>
Anyone seen http://clueless.justsomeguy.com/
Anyone agree with any of his points?
------------------------------
Date: 13 Mar 2003 09:55:40 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: What's wrong with the Perl docs
Message-Id: <b4pkis$bit$1@mamenchi.zrz.TU-Berlin.DE>
Tintin <me@privacy.net> wrote in comp.lang.perl.misc:
> Anyone seen http://clueless.justsomeguy.com/
>
> Anyone agree with any of his points?
Yes, I agree with the "clueless" part :)
More seriously, it is easy to come up with a list of deficiencies.
I guess most of us could name another three or five in addition to
the fifteen listed on that page. The question is, who is going to
do the work. Patches speak louder...
Anno
------------------------------
Date: 13 Mar 2003 10:27:48 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: What's wrong with the Perl docs
Message-Id: <b4pmf4$gnb$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Tintin:
> Anyone seen http://clueless.justsomeguy.com/
>
> Anyone agree with any of his points?
It's the same stuff that gets re-hashed over and over again that it
starts hurting. This year's German Perl Workshop also featured a talk on
this topic with no useful conclusions that could be made from it. People
should stop pointing out the obvious or - even worse - coming up with
seemingly clever concepts that look good on paper but are never to be
met in real life.
I agree with Anno: There are too many spotting deficiencies and too few
correcting them.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Thu, 13 Mar 2003 13:50:37 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: What's wrong with the Perl docs
Message-Id: <3e7087e1.2943802053@news.cis.dfn.de>
On Thu, 13 Mar 2003 20:24:02 +1100, "Tintin"
<me@privacy.net> wrote:
>>Anyone seen http://clueless.justsomeguy.com/
>>
>>Anyone agree with any of his points?
Let's see:
>Nowhere to easily get ones hands on the latest version
Not true. Dead easy.
>References and tutorials are still mixed up
Not true. Tutorials clearly marked as such in index.
>Index should be improved
Works for me. Suggestions for improvements?
>Foreign Language variations are unlikely to be kept up to date
What does that mean? Unicode support finally got
through in 5.8. What is Foreign Language variation?
Perl in kanji?
>Code examples should follow the Perl style guide
Examples?
>Lack of central quality control
brian d foy handles that I believe, but he needs
suggestions more concrete than this whining.
>Hard to understand for beginners
Perl is a programming language! Not a
rubber chewtoy. It is among the easiest
languages possible for a beginner to use
and understand.
>Some functions documented by saying "works like it does in C"
Which ones? That is a bug, if true.
>Not all functions have examples
Which ones? That is a bug, if true.
>One has to use perlbug to report bugs
And that is in what way worse than having no way
at all? You prefer to pray for abugfixes. What's
wrong with perlbug anyway? (I haven't used it).
>Hard to get patched versions of the docs for old versions of perl
What's a patched version? Why use old versions of perl?
>Some not intuitively arranged (regexes in perlop)
Strange. And here I thought they were in perlre
and perlrequick and perlretut.
>Perldoc tool should be improved
Works fine for me. Improve it if you want. An
imporvement for me would be if FAQ entries were
linked to keywords that do not occur in the
heading itself, but are commonly used.
For example if the keyword 'delete' as in
perldoc -q delete were linked to perldoc -f unlink
(for deleting files) as well as to entries about deleting
hash keys, deleting lines and clobberiing read-only files.
.
>No effective search engine
Works fine for me, but a little unsophisticated.
>Some FAQ entries are too complicated, leading to 'cargo cult code'
Examples? What I dislike is the lack of 'my' for
proper scoping and the lack of check and die
or warn for system calls.
--
Regards, Helgi Briem
helgi AT decode DOT is
------------------------------
Date: 13 Mar 2003 08:43:58 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: XS, SWIG? Accessing C API easily
Message-Id: <b4pgce$9p2$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Martien Verbruggen:
> On 12 Mar 2003 06:23:41 GMT,
> Tassilo v. Parseval <tassilo.parseval@post.rwth-aachen.de> wrote:
[ h2xs -x header.h ]
>> I tried it once with a not so complex C header and C::Scan
>> (which is used for parsing the C code) bailed out quite horribly. Ever
>> since that I refrained from any attempts to have it done for me
>> automatically and instead wrote my own proper XSUBS which is guaranteed
>> to always work.
>
> You might want to give the latest versions of this stuff a try. Quite
> some work has gone into improving them between 5.6 and 5.8.
Hmmh, there are _some_ improvements, I think. I just let h2xs eat
through zlib.h and it did in fact produce a complete .xs file. But there
are serious problems. Obviously it doesn't know how to handle variable
argument lists in function signatures. This one turned out to be
uncompilable:
int
gzprintf(file, arg1, ...)
gzFile file
const char * format arg1
Worse, I don't even know what h2xs meant to write here.
*scratching my head*
> However, you are right, there will be instances where problems occur.
One seems to be the use of very odd typemaps. For
int
compress(dest, destLen, source, sourceLen)
Bytef * dest
uLongf * destLen
const Bytef * source
uLong sourceLen
it uses T_OPAQUEPTR (for destLen). From the description in
ext/XS/Typemap/Typemap.xs I can only assume that I need to use some sort
of pack()/unpack() thing to handle it. If doing the XS properly for this
function, it would have to look like
char *
compress(source)
char * source
All the other three parameters could easily be calculated within the
XSUB. Naturally, h2xs can't know that.
Well, even if I have to admit that 'h2xs -x' now seems to work (to some
extent) I find it scarier than doing it all manually. :-) I wonder
whether any module in the wild (on CPAN) has been build with -x.
> Which is why my suggestion is to allow the butt-ugly interface
> internally, and write a pure-perl wrapper module that does the
> necessary translations. You'd still need some knowledge of XS and
> internals, but not nearly as much as when implementing it all in XS.
> There are many more ways for making mistakes in XS than there are in
> Perl, and the errors can result in much, much uglier bugs
Uggh. I made some brief tests and was not able to make any of the
auto-generated XSUBS run from Perl without a segfault. Probably because
I was so compelled by their ugliness (I did not expect that much of it).
>> Oh, I think I have to study Inline::C once more or otherwise I'll never
>> understand why people think it's superiour and easier than XS.
>
> My main use for Inline::C has been to create some higher-performance
> inline code for programs.
Ah, right. Inline::C can be used from ordinary programs. Not sure how or
if this can be done with XS. I think it requires a module.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
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 4703
***************************************