[22481] in Perl-Users-Digest
Perl-Users Digest, Issue: 4702 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 13 00:05:46 2003
Date: Wed, 12 Mar 2003 21: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 Wed, 12 Mar 2003 Volume: 10 Number: 4702
Today's topics:
Re: building perl crashes my linux system at "strtoul() <mgjv@tradingpost.com.au>
Re: Can I use Net::FTP get() to get directly into a per <tony_curtis32@yahoo.com>
Re: Can I use Net::FTP get() to get directly into a per (Bryan Castillo)
comma delimited s/r (david)
Re: comma delimited s/r <tore@aursand.no>
Re: comma delimited s/r <bwalton@rochester.rr.com>
Re: comma delimited s/r <mgjv@tradingpost.com.au>
Re: comma delimited s/r <krahnj@acm.org>
Re: Grabbing module name on the fly <grazz@nyc.rr.com>
Re: Grabbing module name on the fly <noreply@gunnar.cc>
handling multiple reponses from a Net::Telnet session? (Beeblebrox)
How to get an (almost) absolute path <brian.bygland@garbage.boeing.com>
Re: How to get an (almost) absolute path <tore@aursand.no>
http cgi and perl <member17678@dbforums.com>
Re: Need Help : Passing Parameters to Functions (KP)
Re: Need Help : Passing Parameters to Functions <glex_nospam@qwest.net>
Re: new Perl feature request: call into shared libs <hpa@zytor.com>
Re: new Perl feature request: call into shared libs (Bryan Castillo)
Re: new Perl feature request: call into shared libs <no.spam@gknw.de>
Re: panic error (Smiles)
Re: Perl Auto Form Filler <peakpeek@purethought.com>
Question about the filehandle example in the perl FAQ <oxmard.Rules@ab.ab>
Re: Question about the filehandle example in the perl F <bwalton@rochester.rr.com>
Re: Question about the filehandle example in the perl F (Gary Cottreau)
Test failures (Orville R. Weyrich, Jr.)
Re: Test failures <mgjv@tradingpost.com.au>
Re: Uninitialised variable - no it isn't! <tore@aursand.no>
what is current user from .htaccess? (Paul)
Re: what is current user from .htaccess? <tony_curtis32@yahoo.com>
Re: what is current user from .htaccess? <tore@aursand.no>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 13 Mar 2003 01:23:30 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: building perl crashes my linux system at "strtoul() found"
Message-Id: <slrnb6vnch.79p.mgjv@verbruggen.comdyn.com.au>
[comp.lang.c removed. This has absolutely no business there]
On Wed, 12 Mar 2003 21:46:15 GMT,
David <thunderbolt01@netscape.net> wrote:
> joe dekk wrote:
>> Hi
>>
>> I am building perl on a new system (because
>> red linux perl is not "shared" and I need
>> it "shared" so that I can use plperl
>> with postgresql which requires that
>> perl be such)
Are you saying that the Perl that ships with Redhat is not built with
a shared libperl.so?
# /usr/bin/perl -V | grep libperl=
libc=/lib/libc-2.2.92.so, so=so, useshrplib=true, libperl=libperl.so
It is. Or is "red linux perl" something else?
Even with a perl with a static libperl.a, Postgres support isn't a
problem. I doubt very much that you really need to do what you think
you need to do. I am pretty sure that the last time I looked at this
(about a year ago) I could get plperl work happily on RH linux, and I
was using my own Perl, which doesn't have a shared libperl.
For access to postgres from Perl: If you indeed have Redhat, and it's
a recent version, it has an RPM called
postgresql-perl-7.2.2-1.i386.rpm which you should be able to use. Or
even better, use DBI (perl-DBD-Pg-1.13-5.i386.rpm and
perl-DBI-1.30-1.i386.rpm).
>> Any way cpu duron 950MHz and motherboard MSI
>> ms6378 are brand new. With stock kernel
>> the system crashes when ./Configure
>> is checking "memcpy" or something like that.
That, to me, sounds like you have an issue with your hardware, or
maybe with your OS installation. Crashes like that, under normal
circumstances, should not be caused by a simple user process like this.
> For Perl-5.8.0 you would use:
>
> ./configure.gnu --prefix=/usr
> make
> make install
I generally use
$ sh Configure --prefix=/opt/perl-$version --Uinstallusrbinperl -des
$ make test
$ make install
and I never have problems with that. I never liked using that
new-fangled GNU configure stuff for Perl.
Oh, and I wouldn't install Perl in /usr on Redhat. Leave the one that
redhat distributes where it is. If you want to use another one, put it
in /usr/local, or /opt, and make sure your path is set up correctly.
Martien
--
|
Martien Verbruggen | The world is complex; sendmail.cf reflects
Trading Post Australia | this.
|
------------------------------
Date: Wed, 12 Mar 2003 17:05:21 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Can I use Net::FTP get() to get directly into a perl variable
Message-Id: <87d6kwtccu.fsf@limey.hpcc.uh.edu>
>> On 12 Mar 2003 14:22:11 -0800,
>> desprague@yahoo.com (Doug Sprague) said:
> I'm trying to figure a way to use the get() method of
> Net::FTP to be able to get() a file from a remote host
> and stuff it directly into a perl variable for
> processing.
> Figure there may be some way to do this with open()
> using a pipe and then using the filehandle from the open
> for the get() LOCAL_FILE argument.
I suggest using LWP::Simple instead to get() the remote
data.
"perldoc lwpcook" for more.
hth
t
------------------------------
Date: 12 Mar 2003 19:01:30 -0800
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: Can I use Net::FTP get() to get directly into a perl variable
Message-Id: <1bff1830.0303121901.9d66517@posting.google.com>
desprague@yahoo.com (Doug Sprague) wrote in message news:<6648fadd.0303121422.7c8c0d83@posting.google.com>...
> I'm trying to figure a way to use the get() method of
> Net::FTP to be able to get() a file from a remote host and
> stuff it directly into a perl variable for processing.
>
> Figure there may be some way to do this with open() using
> a pipe and then using the filehandle from the open for the
> get() LOCAL_FILE argument.
You can use the retr method to get a Net::FTP::dataconn object for a
file. This is usually the socket (the file is being transferred
over). You can read from this and append it into a variable. You can
do cool things like apply filters directly to the data stream. I used
the retr and sto methods to transfer files to and from systems
applying compression on the fly.
>
> Thanks,
> Doug
------------------------------
Date: 12 Mar 2003 17:31:01 -0800
From: dwlepage@yahoo.com (david)
Subject: comma delimited s/r
Message-Id: <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?
Thanks,
------------------------------
Date: Thu, 13 Mar 2003 03:22:18 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: comma delimited s/r
Message-Id: <pan.2003.03.13.02.17.08.477753@aursand.no>
On Wed, 12 Mar 2003 17:31:01 -0800, david wrote:
> What is the best way to do a s/r on a comma delimited file?
When hearing 'comma delimited', I automatically think of the Text::CSV
module. So should you. :)
> 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)
Totally untested:
my @separate = ();
while ( <DATA> ) {
my @fields = split( /\Q,\E/ );
if ( $fields[3] =~ m,^S/N:, ) {
( $fields[1], $fields[3] ) = ( $fields[3], $fields[1] );
push( @separate, join(',', @fields) );
}
}
open( FILE, ">output.csv" ) || die "Couldn't open file; $!\n";
print FILE "@separate\n";
close( FILE );
Don't know if I got the part about writing the data to a file, but I hope
the example above is to some help.
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: Thu, 13 Mar 2003 02:46:48 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: comma delimited s/r
Message-Id: <3E6FF106.5070304@rochester.rr.com>
david wrote:
> What is the best way to do a s/r on a comma delimited file? What I
...
> Any suggestions? I am currently saving value 1 and 2 to arrays and
...
Modules are your friend. Try looking at ones whose names contain CSV.
Maybe Text::CSV, for example. Even if your data is known for sure to
not contain any quoted commas, it is still a good way to go.
You might also consider DBI with DBD::CSV if your data file looks like a
database table, as it appears it does.
--
Bob Walton
------------------------------
Date: Thu, 13 Mar 2003 03:16:56 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: comma delimited s/r
Message-Id: <slrnb6vu17.79p.mgjv@verbruggen.comdyn.com.au>
On 12 Mar 2003 17:31:01 -0800,
david <dwlepage@yahoo.com> wrote:
> What is the best way to do a s/r on a comma delimited file? What I
What's a s/r? Search and replace?
> 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.
The best way? I don't know...
You could use DBD::CSV or DBD::AnyData. You could use Text::CSV. You
could parse it yourself and do stuff.
The rest of the question is answered by reading the answer to the
frequently asked question (in the Perl FAQ, section 5) with the title
"How do I change one line in a file/delete a line in a file/insert a
line in the middle of a file/append to the beginning of a file?"
(although DBD::CSV and DBD::AnyData would probably do all that work
for you)
> 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)
So.... Where does that bit that looks like a date come from suddenly?
I am simply going to ignore it, because I have no way of making it up.
> 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?
Assuming you're not using the DBD modules, I would
open the input file A
open a temporary output file B
open another output file C
for each line in the input file
split the line into fields (with split(), Text::CSV)
if $field[3] matches
print B line with $field[3] in second place
print C $field[1],$field[3]
else
print B original line
remove original file
rename temp file to original file
With the DBD modules, it'll look very different.
Post some code, and we'l be happy to be of more assistance.
Martien
--
|
Martien Verbruggen | Begin at the beginning and go on till you
Trading Post Australia | come to the end; then stop.
|
------------------------------
Date: Thu, 13 Mar 2003 03:46:16 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: comma delimited s/r
Message-Id: <3E6FFEF5.B71E1866@acm.org>
david wrote:
>
> 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, -lane'BEGIN{$,=",";open(F,">file")||die$!}
if($F[3]=~/^S\/N:/){print F@F[1,3];$F[1]=$F[3];print@F}else{print}' yourfile.txt
John
--
use Perl;
program
fulfillment
------------------------------
Date: Wed, 12 Mar 2003 17:00:56 GMT
From: Steve Grazzini <grazz@nyc.rr.com>
Subject: Re: Grabbing module name on the fly
Message-Id: <cJJba.3105$Em1.113450@twister.nyc.rr.com>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> Anno Siegel wrote:
>> Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in comp.lang.perl.misc:
>>>
>>>- Is there any significantly better solution?
>>
>> I don't know about better, but you can do run-time exportation. Prepare
>> the additional module as an Exporter as usual
>>
>> [snip]
>>
>> In the regular module, do
>>
>> require "$INC[0]/extras/$mod";
>> Something->import( 'extras') if Something->can( 'import');
> -----^^^^^^^^^
>
> That presupposes that you know the package name in advance...
FYI, you can use a variable for the package name:
$something = "Foo";
require "$something.pm";
$something->import("extras");
--
Steve
perldoc -qa.j | perl -lpe '($_)=m("(.*)")'
------------------------------
Date: Thu, 13 Mar 2003 01:45:56 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Grabbing module name on the fly
Message-Id: <b4okb4$20h8l4$1@ID-184292.news.dfncis.de>
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.
Thanks for the tip, Steve.
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 12 Mar 2003 16:06:56 -0800
From: sl1433@hotmail.com (Beeblebrox)
Subject: handling multiple reponses from a Net::Telnet session?
Message-Id: <c976cb73.0303121606.34dceb20@posting.google.com>
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.
Your help/examples are greatly appreciated.
------------------------------
Date: Thu, 13 Mar 2003 00:04:20 GMT
From: Brian Bygland <brian.bygland@garbage.boeing.com>
Subject: How to get an (almost) absolute path
Message-Id: <3E6FCB04.9780C787@garbage.boeing.com>
I'm on UNIX. I need to resolve a relative path to an absolute path with one
unusual condition.
Given that I'm in the directory:
/s/users/me/bin
and do an ls giving:
lrwxrwxr-x 1 me sys 50 Feb 12 16:23 tools -> /s/users/me/bin/tools_3
drwxrwxr-x 7 me dev 96 Feb 12 16:17 tools_3
(Note the linked subdirectory.) tool_3 has two subdirectories: wrappers and
common. I run the script:
/s/users/me/bin/tools/wrappers/foo.pl
In it I need to refer to a module in the common subdirectory and I need its
absolute path, BUT I need that path in the linked form,
i.e. /s/users/me/bin/tools/common. I do not want that path
as: /s/users/me/bin/tools_3/common.
I've tried Cwd::abs_path() but it returns the path that I don't want.
Is there a way to convert "../common" to "/s/users/me/bin/tools/common"
instead of "/s/users/me/bin/tools_3/common"?
Brian Bygland
------------------------------
Date: Thu, 13 Mar 2003 03:22:18 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: How to get an (almost) absolute path
Message-Id: <pan.2003.03.13.02.01.39.580090@aursand.no>
On Thu, 13 Mar 2003 00:04:20 +0000, Brian Bygland wrote:
> I'm on UNIX. I need to resolve a relative path to an absolute path with
> one unusual condition.
> [...]
I really don't know if this helps you, but have you tried 'File::Spec' in
addition to 'Cwd'?
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: Thu, 13 Mar 2003 00:12:37 +0000
From: Mario542 <member17678@dbforums.com>
Subject: http cgi and perl
Message-Id: <2636569.1047514357@dbforums.com>
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??
Here is the perl script.
#!c:\perl\bin\perl.exe -wT
# Get the input for POST method
read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'});
#Split the name-value pairs
($name,$value)=split(/=/,$buffer);
# Substitute special character to its original character
$value=~ tr/+/ /;
$value=~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
use DBI ;
use CGI ;
CGI::ReadParse ();
$dbName ="DBI:ODBC:";
$user="";
$passwd="";
$statement = "update settopinfo set pinset='0' where
serialnumber='$value' " ;
$dbh = DBI->connect($dbName, $user, $passwd) || die "$DBI::errstr";
$cursor = $dbh->prepare($statement) || die "$DBI::errstr";
$cursor->execute();
#------print the return HTML------------------
#print the MIME type
print"Content-type: text/html\n\n";
#print the HTML body
print"<html>\n";
print "<head><title></title></head>\n";
print "<body>\n";
print "<body bgcolor=#C0C0C0>\n";
print "<BR>\n";
print "<body><center><h1></h1>\n";
print "<HR>\n";
print "<body><center><h2>PIN</h2>\n";
print "<HR>\n";
print "<BR>\n";
print "<BR>\n";
print "<BR>\n";
print "<h2>The : ";
print "<h1><u> $value\n";
print "</body></html>\n";
print "<BR>\n";
print "<BR>\n";
print "<BR>\n";
print "<BR>\n";
print "<BR>\n";
print "<BR>\n";
print "<HR>\n";
exit;
--
Posted via http://dbforums.com
------------------------------
Date: 12 Mar 2003 15:56:05 -0800
From: snazystyl@hotmail.com (KP)
Subject: Re: Need Help : Passing Parameters to Functions
Message-Id: <dc2b0830.0303121556.b9b0734@posting.google.com>
There is over 470 lines so I'm only posting a chunk. Removed quit a
bit. Bascially shows what globals I'm using and how I'm calling the
Sub's below.
use Warnings;
use Strict;
use File::Find;
use File::Basename;
use Win32::OLE;
my $g_wttdllpath = "\\system32\\wttlogcm.dll";
my $g_systemdrivepath = "\\";
my $g_xmlfilepath = "\\system32\\Restore\\filelist.xml";
my $g_newfilepath = "\\Stuff\\Test\\list.txt";
#Main
FirstSub();
SecondSub();
ThirdSub();
#End Main
sub FirstSub
{
my $filelistexts;
my $fileinfo;
my $FileList;
if (exists $ENV{'SYSTEMROOT'})
{
my $xmlfile = $ENV{"SYSTEMROOT"}.$g_xmlfilepath;
open (FILE, $xmlfile) || die;
while ($fileinfo = <FILE> )
{
if ($fileinfo =~ /.*<EXTENSIONS>.*/)
{
while ($filelistexts = <FILE>)
{
if ($filelistexts =~ /<REC>(.*)<\/REC>/)
{
$FileList = $FileList .';'. $1;
}
}last;
}
}
}
else
{
die;
}
}
sub SecondSub
{
my $extleftover;
my $NotFoundList;
my @SystemList = split/;/, $SystemList;
foreach $extleftover (@SystemList)
{
unless ($FileList =~ m/.*;\Q$extleftover\E;.*/)
{
$NotFoundList = $NotFoundList .$extleftover.';';
}
}
}
Please allow me to revert to my previous problem.
In FirstSub $FileList is present but in the Second Sub it is not. This
then returns a Error because it's not in the SecondSub. How would I
pass $filelist to the SecondSub so that it can be used there as well.
Reason being is that ThirdSub() which is not shown it requires both
$filelist and $NotFoundList to be there and tries to do a diff between
the two and puts that into a list which also then needs to passed then
to a 4th sub.
I have been reading up on Passing Parameters to Functions. But I'm
just not getting it. Any help would be greatly appreciated.
Thanks to all of you who responded.
------------------------------
Date: Wed, 12 Mar 2003 18:43:12 -0600
From: Jeff D Gleixner <glex_nospam@qwest.net>
Subject: Re: Need Help : Passing Parameters to Functions
Message-Id: <3sQba.3270$PQ2.136981@news.uswest.net>
KP wrote:
> #Main
> FirstSub();
>
> SecondSub();
>
> ThirdSub();
> #End Main
>
> sub FirstSub
> {
> my $filelistexts;
> my $fileinfo;
> my $FileList;
> [...]
> $FileList = $FileList .';'. $1;
> }
>
> sub SecondSub
> {
> my $extleftover;
> my $NotFoundList;
> my @SystemList = split/;/, $SystemList;
>
> foreach $extleftover (@SystemList)
> {
> unless ($FileList =~ m/.*;\Q$extleftover\E;.*/)
> {
> $NotFoundList = $NotFoundList .$extleftover.';';
> }
> }
> }
>
> Please allow me to revert to my previous problem.
>
> In FirstSub $FileList is present but in the Second Sub it is not. This
> then returns a Error because it's not in the SecondSub. How would I
> pass $filelist to the SecondSub so that it can be used there as well.
>
> Reason being is that ThirdSub() which is not shown it requires both
> $filelist and $NotFoundList to be there and tries to do a diff between
> the two and puts that into a list which also then needs to passed then
> to a 4th sub.
>
> I have been reading up on Passing Parameters to Functions. But I'm
> just not getting it. Any help would be greatly appreciated.
>
> Thanks to all of you who responded.
The reason it fails is because you declared them 'my', meaning they'll
only be around until the end of the block. Do the same thing you're doing
for $SystemList in FirstSub.
You're probably best off declaring them, using 'my', before you call
FirstSub(), essentially making them global to your script. You'll need
to remove your current declarations.
my $var;
FirstSub();
SecondSub();
sub FirstSub
{
$var='in First';
}
sub SecondSub
{
print $var, "\n";
}
If you truly want to pass things, you'll need FirstSub to return the value
and you'd pass that to SecondSub, which could return a value.
my $var = FirstSub();
my $nextVar= SecondSub($var);
# now $var='in First' and $nextVar='in second'
sub FirstSub
{
return 'in First';
}
sub SecondSub
{
my $passedIn = shift;
print $var, "\n"; #works, because it's in the same scope
print $passedIn, "\n"; #works,it's only known in SecondSub() though
return 'in second';
}
------------------------------
Date: 12 Mar 2003 16:27:07 -0800
From: "H. Peter Anvin" <hpa@zytor.com>
Subject: Re: new Perl feature request: call into shared libs
Message-Id: <b4oj8r$5pu$1@cesium.transmeta.com>
Followup to: <b4gcqk$1vgq$1@agate.berkeley.edu>
By author: Ilya Zakharevich <nospam-abuse@ilyaz.org>
In newsgroup: comp.lang.asm.x86
>
> Of course, if you know that a particular register is preserved during
> the call, then there is the place to store the number of arguments so
> it survives during the call, and one can adjust ESP accordingly. And
> I see that even with -fomit-frame-pointer gcc is doing
>
> popl %ebx
> popl %esi
> popl %edi
> popl %ebp
> ret
>
> so it preserves 4 registers (including EBP you used). Is it a
> universally accepted ABI on all x86-hosted OSes and all compilers? If
> yes, then indeed this particular problem is not a problem.
>
The 32-bit cdecl/stdcall ABI on i386 is that arguments are passed on
the stack, and the four registers above are preserved.
-hpa
--
<hpa@transmeta.com> at work, <hpa@zytor.com> in private!
"Unix gives you enough rope to shoot yourself in the foot."
Architectures needed: ia64 m68k mips64 ppc ppc64 s390 s390x sh v850 x86-64
------------------------------
Date: 12 Mar 2003 16:36:04 -0800
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: new Perl feature request: call into shared libs
Message-Id: <1bff1830.0303121636.5ae73e22@posting.google.com>
Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote in message news:<b4lqai$q3r$1@agate.berkeley.edu>...
> [A complimentary Cc of this posting was sent to
> Matt Taylor
> <para@tampabay.rr.com>], who wrote in article <vacba.19122$Xu4.533273@twister.tampabay.rr.com>:
>
> > Default convention (__cdecl) is the same. Windows system libraries are
> > compiled with __stdcall convention which is different. The following code
> > should suffice for any convention except a register-parameter scheme:
>
> 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? I don't see
why you would try to satisfy all schemes with one function. If the
user would be interested in using a module like this, they should know
the calling convention and signature of the function they are calling.
They just may not want to write XS code. Perhaps, its just for
testing a C library. I've been looking at then C::DynaLib module, it
is suppose to work on multiple OS's supporting more than one
convention (including an interesting one called hack30 - not really a
convention but a trick to try and accomodate most of them). (I don't
have a clue what the convention is on SPARC). Anyway, the module
takes a convention type as a parameter. You could write something
that works for regparam (or regparm? - Is this similar to Borland's
fastcall, does it add any decoration to the symbol name?) and put it
in with this module.
> The call will be transparent for functions with up to 3 arguments; to
> call __regparam__(3) functions with more than 3 arguments one would
> need to move the first 3 arguments to the end of the list.
>
> Not convenient, but at least it would be *possible* to call functions
> with most usual the calling conventions.
>
> > mov [ecx], eax
> >
> > ; If 64-bit return value, also do next line
> > ; mov [ecx+4], edx
>
> I think it is convenient to make this unconditional; let the caller
> worry about what to do with retval[1]...
>
> Thanks,
> Ilya
------------------------------
Date: Thu, 13 Mar 2003 05:12:44 +0100
From: Guenter <no.spam@gknw.de>
Subject: Re: new Perl feature request: call into shared libs
Message-Id: <3E70053C.6080103@gknw.de>
Hi Bryan,
thank you very much for pointing to this! I didnt know of this module...
I will give it a try next weekend on Linux...
thanks, Guenter.
Bryan Castillo schrieb:
> I just noticed that there is a module C::DynaLib on CPAN. I was able
> to use it under Linux. (Of course I already did too much work in this
> thread, looking at assembly, and blabbering about calling
> conventions).
>
> It seems to support cdecl among other conventions, plus some
> capability to turn perl sub-refs to C-callbacks. All along I thought
> you would have to use assembly, and this module uses the alloca
> function, to allocate space on the stack.
>
>
> Here is a short example.
>
> my $call;
> my $so = "./test_1.so";
> my $libref = DynaLoader::dl_load_file($so, 1);
>
> $call = C::DynaLib::DeclareSub({
> ptr => DynaLoader::dl_find_symbol($libref, "call_v_v"),
> return => 0
> });
> $call->(1, 2);
>
> $call = C::DynaLib::DeclareSub({
> ptr => DynaLoader::dl_find_symbol($libref, "call_i_ii"),
> return => "i",
> args => ["i", "i"]
> });
> $call->(1, 2);
>
> $call = C::DynaLib::DeclareSub({
> ptr => DynaLoader::dl_find_symbol($libref, "call_i_dd"),
> return => "i",
> args => ["d", "d"]
> });
> $call->(3.14, 2.14);
------------------------------
Date: 12 Mar 2003 15:10:08 -0800
From: smileypete2@yahoo.com (Smiles)
Subject: Re: panic error
Message-Id: <63ccfece.0303121510.5d3affeb@posting.google.com>
I'm not exactly at liberty to say because of my work place :) but I
can list a pile of modules that I'm using.
LWP::UserAgent
HTML::TokeParser
URI::URL
DATA::Serializer
threads
threads:shared
Thread::Queue
SDBM_File
Thread::Use
The error seems to appear at random points in the execution and it
take several hours to appear. I don't run out of memory space or hard
drive so that eliminates possible hardware failures. Also I have a
constant number of threads running, so the problem is not number of
threads. This is the only error I'm getting...all 20 letters or
so.... no warnings, no seg faults.
I am currently testing it on a Linux box (single proc so it'll take
longer) to see if I fare any better.
smiles
------------------------------
Date: Thu, 13 Mar 2003 00:50:07 +0000
From: Sharon Grant <peakpeek@purethought.com>
Subject: Re: Perl Auto Form Filler
Message-Id: <srkv6vspm81p623e344rsrs8r56ls9vvto@4ax.com>
On Thu, 13 Mar 2003 01:50:19 +0800, in comp.lang.perl.misc, <tester@aol.com> wrote:
>I have a lot of forms to fill online. Most of them have the same format:
>Name, Address, Phone etc. I have programmed a Perl program to "post" those,
>however because all the fields are not done on 1 page-- (such as fill name
>on page one then click submit then fill address on page 2 then submit then
>address on page 3) All info are saved as cookie in my local machine.
>
>I am wonder if the cookie_jar thing in Perl can save the cookie and pass the
>cookie to the next page it visit.
>
>Can anyone give me an example of save and reuse the cookie
There is an example here:
http://tinyurl.com/7d9x
The code posted there is specific to the cpso site, but it
includes the cookie_jar example you are asking about
The cookie is extracted from the first page and saved using
extract_cookies() and is then sent to subsequent pages using
add_cookie_header()
--
Sharon
------------------------------
Date: Wed, 12 Mar 2003 17:37:08 -0600
From: "Peter Shankey" <oxmard.Rules@ab.ab>
Subject: Question about the filehandle example in the perl FAQ
Message-Id: <hcqcncHSZvs0WfKjXTWcqA@comcast.com>
With the help of the FAQ I have:
my @FHArray = ();
local *FH;
open (FH,"c:/t/d1/oratab") || die "Could not open $!";
$FHArray[0] = *FH;
my $fh = $FHArray[0];
while(<$fh>){
print $_;
}
close($fh);
this does work, the file is printed out. However if I use the line:
while(<$FHArray[0]>)
instead of:
while(<$fh>)
it does not. I am not understanding this when
my @array = ();
$array[0] = 1;
my $i = $array[0];
print ($array[0],$i);
prints the same value. I think it is I am missing some fact about typeglobs.
I have read the perldocs on typeglobs, but I am still missing something.
Please give me some food for thought as I would like to understand this
stuff rather than type it mindlessly out
Thank you
Pete
------------------------------
Date: Thu, 13 Mar 2003 02:35:32 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Question about the filehandle example in the perl FAQ
Message-Id: <3E6FEE62.9050207@rochester.rr.com>
Peter Shankey wrote:
...
> while(<$fh>){
...
> this does work, the file is printed out. However if I use the line:
> while(<$FHArray[0]>)
> instead of:
> while(<$fh>)
> it does not. I am not understanding this when
...
> Pete
...
It is the "angle bracket" I/O operator's behavior which is tripping you
up. Check out:
perldoc perlop
where it says:
"If what's within the angle brackets is neither a filehandle nor a
simple scalar variable containing a filehandle name, typeglob, or
typeglob reference, it is interpreted as a filename pattern to be
globbed, and either a list of filenames or the next filename in the list
is returned, depending on context. This distinction is determined on
syntactic grounds alone. That means <$x> is always a readline() from an
indirect handle, but <$hash{key}> is always a glob(). That's because $x
is a simple scalar variable, but $hash{key} is not--it's a hash element."
In your case, <$FHArray[0]> is attempting to glob filenames which match
the filename pattern $FHArray[0], whereas:
$fh=$FHArray[0];
... <$fh> ...
would have worked in the sense that it would have read from the stored
filehandle.
--
Bob Walton
------------------------------
Date: 12 Mar 2003 19:30:45 -0800
From: frodobaggins_2@yahoo.co.uk (Gary Cottreau)
Subject: Re: Question about the filehandle example in the perl FAQ
Message-Id: <c8cf02de.0303121930.7b73470a@posting.google.com>
"Peter Shankey" <oxmard.Rules@ab.ab> wrote in message news:<hcqcncHSZvs0WfKjXTWcqA@comcast.com>...
> With the help of the FAQ I have:
> my @FHArray = ();
> local *FH;
> open (FH,"c:/t/d1/oratab") || die "Could not open $!";
> $FHArray[0] = *FH;
> my $fh = $FHArray[0];
> while(<$fh>){
> print $_;
> }
> close($fh);
>
> this does work, the file is printed out. However if I use the line:
> while(<$FHArray[0]>)
> instead of:
> while(<$fh>)
> it does not. I am not understanding this when
> my @array = ();
> $array[0] = 1;
> my $i = $array[0];
> print ($array[0],$i);
> prints the same value. I think it is I am missing some fact about typeglobs.
> I have read the perldocs on typeglobs, but I am still missing something.
> Please give me some food for thought as I would like to understand this
> stuff rather than type it mindlessly out
>
> Thank you
> Pete
Try putting FH in the while statement like: while (<FH>) and see how
it goes.
I look at opening a file as a mass of information. The block
statements like while or foreach, work through them as some kind of
whole unit. But you have a choice, you can take the info and break it
into an array or hash with a little coding (i.e. regex, split).
Good luck and good coding.
Gary
------------------------------
Date: 12 Mar 2003 19:25:47 -0800
From: orville@weyrich.com (Orville R. Weyrich, Jr.)
Subject: Test failures
Message-Id: <f0496a69.0303121925.4815cb57@posting.google.com>
I tried to build perl 5.8.0 on Linux slackware kernel 2.2.6 using gcc
2.7.2.3 and had the following regression test errors:
18/68591 subtests failed, 99.68% okay.
ok
Failed Test Stat Wstat Total Fail Failed List of
Failed
-------------------------------------------------------------------------------
../ext/Time/HiRes/HiRes.t 1 256 25 14 56.00% 12-25
../lib/AutoSplit.t 3 768 58 3 5.17% 3 26 30
../lib/ExtUtils/t/Manifest.t 2 512 33 2 6.06% 18 26
../lib/ExtUtils/t/basic.t 1 256 17 1 5.88% 14
../lib/File/Find/t/find.t 188 186 98.94% 3-188
../lib/File/Find/t/taint.t 5 1280 45 5 11.11% 23 25
43-45
../lib/h2xs.t 7 1792 113 7 6.19% 3-4 35 54
73 88 107
43 tests and 408 subtests skipped.
Are these problems I should worry about that prevent me from
installing perl 5.8.0? Are they problems worth trying to fix (or
since this is an old Linux box, is it not worthwhile to try to resolve
the problems?)
TIA
orville@weyrich.com
------------------------------
Date: Thu, 13 Mar 2003 03:39:07 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Test failures
Message-Id: <slrnb6vvar.79p.mgjv@verbruggen.comdyn.com.au>
On 12 Mar 2003 19:25:47 -0800,
Orville R. Weyrich, Jr. <orville@weyrich.com> wrote:
> I tried to build perl 5.8.0 on Linux slackware kernel 2.2.6 using gcc
> 2.7.2.3 and had the following regression test errors:
>
> 18/68591 subtests failed, 99.68% okay.
> ok
> Failed Test Stat Wstat Total Fail Failed List of
> Failed
> -------------------------------------------------------------------------------
> ../ext/Time/HiRes/HiRes.t 1 256 25 14 56.00% 12-25
> ../lib/AutoSplit.t 3 768 58 3 5.17% 3 26 30
> ../lib/ExtUtils/t/Manifest.t 2 512 33 2 6.06% 18 26
> ../lib/ExtUtils/t/basic.t 1 256 17 1 5.88% 14
> ../lib/File/Find/t/find.t 188 186 98.94% 3-188
> ../lib/File/Find/t/taint.t 5 1280 45 5 11.11% 23 25
> 43-45
> ../lib/h2xs.t 7 1792 113 7 6.19% 3-4 35 54
> 73 88 107
> 43 tests and 408 subtests skipped.
>
> Are these problems I should worry about that prevent me from
> installing perl 5.8.0? Are they problems worth trying to fix (or
> since this is an old Linux box, is it not worthwhile to try to resolve
> the problems?)
I would definitely worry about those failures. The fact that most of
the find and many others fail, and definitely shouldn't means that you
have some odd problem somewhere. Whether it's related to your compiler
or your libraries I can't tell. You should probably find out why they
are failing, and see how you can prevent it.
How did you configure Perl?
Martien
--
|
Martien Verbruggen | True seekers can always find something to
Trading Post Australia | believe in.
|
------------------------------
Date: Thu, 13 Mar 2003 00:14:02 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: Uninitialised variable - no it isn't!
Message-Id: <pan.2003.03.12.22.52.37.212518@aursand.no>
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. :)
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: 12 Mar 2003 17:29:09 -0800
From: prempel@paradata.com (Paul)
Subject: what is current user from .htaccess?
Message-Id: <9d7b3d0.0303121729.7b95d126@posting.google.com>
I have a perl cgi program that requires user authentication via the
apache .htaccess file. Is there a CPAN module or some sort of tool i
can use to detect what user name the user was authenticated with? On
a similar note, is there a way to expire that session so that they
must log in again?
Thanks for you help!
Paul
------------------------------
Date: Wed, 12 Mar 2003 19:39:17 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: what is current user from .htaccess?
Message-Id: <87u1e8doze.fsf@limey.hpcc.uh.edu>
>> On 12 Mar 2003 17:29:09 -0800,
>> prempel@paradata.com (Paul) said:
Hi,
> I have a perl cgi program that requires user
> authentication via the apache .htaccess file. Is there
> a CPAN module or some sort of tool i can use to detect
> what user name the user was authenticated with?
perldoc CGI
remote_user ()
Return the authorization/verification name used for
user verification, if this script is protected.
Should come your perl install.
> 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.
(This 2nd question leads us off-topic for clpm.)
hth
t
------------------------------
Date: Thu, 13 Mar 2003 03:22:18 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: what is current user from .htaccess?
Message-Id: <pan.2003.03.13.02.05.25.328352@aursand.no>
On Wed, 12 Mar 2003 17:29:09 -0800, Paul wrote:
> I have a perl cgi program that requires user authentication via the
> apache .htaccess file. Is there a CPAN module or some sort of tool i
> can use to detect what user name the user was authenticated with?
Yes. If you're using the 'CGI.pm' module, which you _should_ use, there
is a method called 'remote_user()';
my $username = $cgi->remote_user();
Eventually, you can read the environment variable 'REMOTE_USER' directly;
my $username = $ENV{'REMOTE_USER'} || '';
> 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.
--
Tore Aursand <tore@aursand.no>
------------------------------
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 4702
***************************************