[9988] in Perl-Users-Digest
Perl-Users Digest, Issue: 3581 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Aug 29 00:03:48 1998
Date: Fri, 28 Aug 98 21:00:20 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 28 Aug 1998 Volume: 8 Number: 3581
Today's topics:
Re: Accessing NIS info from perl? <garry@NOSPAM.america.net>
Re: Accessing NIS info from perl? <garry@NOSPAM.america.net>
Announcing grepmail 1.3 <dwc3q@mamba.cs.virginia.edu>
Re: Another backslash question <rootbeer@teleport.com>
can not send email with perl, this module, that module (Michael Wang)
Re: can not send email with perl, this module, that mod <rootbeer@teleport.com>
Re: CGI Form Refresh <maryesme@localaccess.com>
Doing `open (FH,"<&STDIN")' with FileHandles? <dwc3q@mamba.cs.virginia.edu>
Re: Function Prototypes and Missing Arguments <dwc3q@mamba.cs.virginia.edu>
Re: Help with date script' <rootbeer@teleport.com>
How do I compare the contents of two files... <andyw@interserv.com>
installing modules in user defined dir - Actuve Perl dturley@pobox.com
Re: installing modules in user defined dir - Actuve Per (Nathan V. Patwardhan)
Re: Is this how it's supposed to be? <rootbeer@teleport.com>
Re: mod_perl configuration (brian d foy)
output in shell, but not in browser? <dan@bns.com>
Re: output in shell, but not in browser? <rootbeer@teleport.com>
Re: Perl Cookbook, does anyone have it? (Owen Cook)
Re: removing ^M when writing to file <rootbeer@teleport.com>
Re: simple variable manipulation (Larry Rosler)
Re: simple variable manipulation <prw@evolving.com>
Re: simple variable manipulation <prw@evolving.com>
Re: simple variable manipulation <prw@evolving.com>
Re: simple variable manipulation (Larry Rosler)
Re: simple variable manipulation <r28629@email.sps.mot.com>
Sybperl, ct_lib module: checking connection <tegelert@gol.com>
thank you (mt) <cattle@hknet.com>
Re: Where to put my perl-scripts? <rootbeer@teleport.com>
Re: XS with win32 Perl (Brian Jepson)
Re: Y2K Date Support <ljz@asfast.com>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 29 Aug 1998 02:41:43 GMT
From: Garry Williams <garry@NOSPAM.america.net>
Subject: Re: Accessing NIS info from perl?
Message-Id: <35E76AAA.AEAC59F0@NOSPAM.america.net>
Tony Curtis wrote:
>
> Re: Accessing NIS info from perl?, wwwuea
> <wwwuea@my-dejanews.com> said:
>
> wwwuea> Hi, Is it possible to do NIS lookups from within
> wwwuea> perl, without using system()?
>
> How about the Net::NIS module, available on CPAN?
...
If you're only interested in the passwd records and, if you're using
Solaris, the getpw* functions are defined as being able to retrieve NIS+
data:
man getpwent
...
Entries can come from any of the sources for passwd speci-
fied in the /etc/nsswitch.conf file (see nsswitch.conf(4)).
Perl implements these functions directly. Other operating systems may
not behave the same way.
-Garry Williams
> Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
> Liechtensteinstrasse 22, A-1090 Wien, | <URI:http://www.vcpc.univie.ac.at/>
> "You see? You see? Your stupid minds! | private email:
> Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>
------------------------------
Date: Sat, 29 Aug 1998 02:42:44 GMT
From: Garry Williams <garry@NOSPAM.america.net>
Subject: Re: Accessing NIS info from perl?
Message-Id: <35E76AE7.7FCB223D@america.net>
Tony Curtis wrote:
>
> Re: Accessing NIS info from perl?, wwwuea
> <wwwuea@my-dejanews.com> said:
>
> wwwuea> Hi, Is it possible to do NIS lookups from within
> wwwuea> perl, without using system()?
>
> How about the Net::NIS module, available on CPAN?
...
If you're only interested in the passwd records and, if you're using
Solaris, the getpw* functions are defined as being able to retrieve NIS+
data:
man getpwent
...
Entries can come from any of the sources for passwd speci-
fied in the /etc/nsswitch.conf file (see nsswitch.conf(4)).
Perl implements these functions directly. Other operating systems may
not behave the same way.
-Garry Williams
> Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
> Liechtensteinstrasse 22, A-1090 Wien, | <URI:http://www.vcpc.univie.ac.at/>
> "You see? You see? Your stupid minds! | private email:
> Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>
------------------------------
Date: Fri, 28 Aug 1998 22:54:53 -0400
From: David Coppit <dwc3q@mamba.cs.virginia.edu>
Subject: Announcing grepmail 1.3
Message-Id: <Pine.SOL.3.96.980828224743.9973A-100000@mamba.cs.virginia.edu>
I humbly offer my meager programming output to the world:
grepmail 1.3: Search email archives for patterns, in the spirit of grep.
Outputs full email messages.
http://www.cs.virginia.edu/~dwc3q/code/index.html
---------------------------------------
usage: grepmail [-vi] [-d "datespec"] <expr> <files...>
-i Ignore case in the search expression
-v Output emails that don't match the expression
Date specifications must be of the form of:
a date like "today", "1st thursday in June 1992", "05/10/93",
"12:30 Dec 12th 1880", "8:00pm december tenth",
OR "before", "after", or "since", followed by a date as defined above,
OR "between <date> and <date>", where <date> is defined as above.
You can also pipe to grepmail.
---------------------------------------
Here are a few examples:
Get all email that you mailed yesterday
- grepmail -d "yesterday" . sent-mail
Get all email that you mailed before the first thursday in June 1998 that
pertains to research:
- grepmail -d "before 1st thursday in June 1992" research sent-mail
Get all email you received since 8/20/98 that wasn't about research,
ignoring case:
- grepmail -i -d "since 8/20/98" -v research saved-mail
Get all email about research but not about software:
- grepmail research saved-mail | grepmail -v software
grepmail supports gzip'ed files, -i, and -v. Unfortunately, the packages
it uses slow the code's startup a bit. Please report any bugs,
modifications, or suggestions.
Thanks,
David
_________________________________________________________________________
David Coppit - Graduate Student coppit@cs.virginia.edu
The University of Virginia http://www.cs.virginia.edu/~dwc3q
"For I am a Bear of Very Little Brain,
and long words Bother me" - Winnie the Pooh
------------------------------
Date: Sat, 29 Aug 1998 01:40:40 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Another backslash question
Message-Id: <Pine.GSO.4.02A.9808281837030.14973-100000@user2.teleport.com>
On 28 Aug 1998, Doug wrote:
> I get this error:
>
> /www.whatever.com\/: trailing \ in regexp at ./new.pl line 7.
>
> With this code:
>
> 5: $fqdn="www.whatever.com\\";
> 6: $machine_names[1]="www.whoever.com\\";
> 7: if(grep(/$fqdn/, @machine_names))
Yep, that's a trailing backslash. If you want a literal backslash in Perl,
always use two. In this case, I think you want to use quotemeta (or,
equivalently, \Q) on $fqdn, since you don't mean for '.' to match any
character but newline, do you?
And maybe you want to anchor your pattern as well?
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 29 Aug 1998 01:42:30 GMT
From: mwang@tech.cicg.ml.com (Michael Wang)
Subject: can not send email with perl, this module, that module
Message-Id: <6s7ma6$geb$1@news.ml.com>
OK, I want to send email using Perl.
FAQ#9 - > Mail::Internet -> Net::Domain -> Data::Dumper.
I managed to have all modules installed, but it still complains.
Can you kindly tell me why?
Why sending email in Perl is such a pain? Why should I install
modules after modules in order to send email?
In Korn shell, it is just
mailx -s "subject" user << EOF
message
body
EOF
Thank you.
[mwangrs][16:20][/home/mwang/PERL]cat sendmail.pl
#!/usr/local/bin/perl
use Mail::Internet;
use Mail::Header;
# say which mail host to use
$ENV{SMTPHOSTS} = 'tech.cicg.ml.com';
# create headers
$header = new Mail::Header;
$header->add('From', 'mwang@tech.cicg.ml.com');
$header->add('Subject', 'Testing');
$header->add('To', 'mwang@ml.com');
# create body
$body = 'This is a test, ignore';
# create mail object
$mail = new Mail::Internet(undef, Header => $header, Body => \[$body]);
# send it
$mail->smtpsend or die;
[mwangrs][16:20][/home/mwang/PERL]perl sendmail.pl
Not an ARRAY reference at /usr/local/lib/perl5/site_perl/Mail/Internet.pm
line 193.
--
unix programs: niftp (non-interactive recursive ftp), hide (hide command args),
submit (replace nohup), etc from ftp://ftp.mindspring.com/users/mwang/unix-prog
Michael Wang, mwang@ml.com, Merrill Lynch, World Financial Center, 212-449-4414
------------------------------
Date: Sat, 29 Aug 1998 01:52:55 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: can not send email with perl, this module, that module
Message-Id: <Pine.GSO.4.02A.9808281846430.14973-100000@user2.teleport.com>
On 28 Aug 1998, Michael Wang wrote:
> I managed to have all modules installed, but it still complains.
> Can you kindly tell me why?
If perl is giving you a message you don't understand, you should find what
the perldiag manpage says about the message.
> Why sending email in Perl is such a pain?
I don't think it's such a pain. Maybe you're not doing it right. :-)
> Why should I install modules after modules in order to send email?
Some recommend a method which doesn't require additional modules. I'd
explain it, but this newsgroup has already seen too much discussion of the
two different ways of sending mail. Search your favorite Usenet archive
for the discussions about using Net::SMTP and sendmail.
> In Korn shell, it is just
> mailx -s "subject" user << EOF
> message
> body
> EOF
If you want Korn shell, you know where to find it. Of course, you may find
that there are some security ramifications involved with mailx, but that's
beyond the scope of this newsgroup.
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 28 Aug 1998 20:11:07 -0700
From: Mark Lybrand <maryesme@localaccess.com>
Subject: Re: CGI Form Refresh
Message-Id: <35E7714B.5F3F@localaccess.com>
Art Martinez wrote:
>
> Ashley Latham wrote:
> >
> > Hi,
> >
> > I have a form set up that calls a perl script. After data is entered the
> > script checks the data, adds it to the database and returns a html page
> > stating the data has been added or there was an error in the data entry.
> >
> > All this works fine.
> >
> > On some browsers when I hit the browser back button I can see the form with
> > all the information I have entered as it was just before I hit the submit
> > button. This is good in that if an error has been made with the data entry
> > the entire form doesn't need to be re-entered, only the fields that are
> > wrong.
>
> The best way to handle this is when an error has occured and the user
> must go back and correct something, push them the form again with all
> the correct fields filled out. That way you dont have to rely on
> browser settings and all the fields will be filled ou and you can put
> the blurb about an error occuring at the to of that page.
>
> art
Exactly. You could have a separate "submit" button that goes back.
Using CGI.pm, the form elements all have "sticky" values, so you can
pass values back and forth quite easily.
Mark :)
------------------------------
Date: Fri, 28 Aug 1998 22:26:22 -0400
From: David Coppit <dwc3q@mamba.cs.virginia.edu>
Subject: Doing `open (FH,"<&STDIN")' with FileHandles?
Message-Id: <Pine.SOL.3.96.980828222125.9549A-100000@mamba.cs.virginia.edu>
I'm using a library function (read_mbox from Mail::Utils) which expects a
scalar string, which is then used to open a file like so:
my $fd = FileHandle->new($file,"r") || die "cannot open '$file': $!\n";
$file is the string passed as an argument.
I wanted to use STDIN so that my script could act as a filter, so I
thought, why not use "<&STDIN" as the file name? Well, it didn't work. I
have to admit I'm not familiar with the use of OO FileHandles, or passing
the standard streams around either.
Any help would be appreciated. I've tried scoping STDIN with main::, and
have tried variants of *STDIN, *STDIN{IO}, etc.
Thanks,
David
_________________________________________________________________________
David Coppit - Graduate Student coppit@cs.virginia.edu
The University of Virginia http://www.cs.virginia.edu/~dwc3q
"For I am a Bear of Very Little Brain,
and long words Bother me" - Winnie the Pooh
------------------------------
Date: Fri, 28 Aug 1998 22:05:52 -0400
From: David Coppit <dwc3q@mamba.cs.virginia.edu>
To: Josh Kortbein <kortbein@iastate.edu>
Subject: Re: Function Prototypes and Missing Arguments
Message-Id: <Pine.SOL.3.96.980828220345.6013A-100000@mamba.cs.virginia.edu>
On 28 Aug 1998, Josh Kortbein wrote:
> What about passing undef or some other pleasing value for an unused
> argument?
Well, the hash, for example, is %opts from the command line. I guess I
could conditional code to make it pass undef if the user doesn't supply
arguments, but I'm trying to have that sort of special case logic
encapsulated by the function.
Thanks though,
David
_________________________________________________________________________
David Coppit - Graduate Student coppit@cs.virginia.edu
The University of Virginia http://www.cs.virginia.edu/~dwc3q
"For I am a Bear of Very Little Brain,
and long words Bother me" - Winnie the Pooh
------------------------------
Date: Sat, 29 Aug 1998 01:33:34 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Help with date script'
Message-Id: <Pine.GSO.4.02A.9808281831300.14973-100000@user2.teleport.com>
On 28 Aug 1998, Shane Stout wrote:
> Subject: Help with date script'
Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.
http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post
> I have to write a script that determines the date and then calculates
> the next days date in the form Month dayofmonth, year. I am using the
> conversion function localtime, but if I do I have to also script a
> solution to trap the ends of each month.
No, you simply have to pass localtime the proper parameter. Hope this
helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 28 Aug 1998 20:50:45 -0500
From: Andrew Whitcroft <andyw@interserv.com>
Subject: How do I compare the contents of two files...
Message-Id: <6s7mhr$bpa@newsops.execpc.com>
Hi All --
I am the sys admin for 52 Unix boxes, and I needed a better way to track
filesystems which were getting too full. So, I have a script to
accumulate
the output from a "df -lk" command, sort it, and display a formatted
results.
Now I want to take it one step further, I want to compare the last time
file
to the current results, and have the script show me the differances that
meet
the following parameters: the filesystem is > 79% full, and has changed
more
than 10% from the last time I polled the machines.
I am still kind of new to Perl programming, and what better way to learn
than
having a project to work on. But, this little problem has me stumped, so
I am
hoping you can get me pointed in the right direction.
Thanks in advance,
Andy.
n9kws@yahoo.com
------------------------------
Date: Sat, 29 Aug 1998 00:55:28 GMT
From: dturley@pobox.com
Subject: installing modules in user defined dir - Actuve Perl
Message-Id: <6s7ji0$sqn$1@nnrp1.dejanews.com>
I asked this a few weeks ago with no reponses. Now that people have had the
pleasure (?) of playing with AS's perl 5.005 for a bit longer, I'll ask again.
Is there a way to install modules in "another" directory. I've tried:
perl makefile.pl PREFIX=c:\myModDir
and the modules still get installed in the AS site directory.
Am I attempting the impossible, or just doing something wrong? (Let's just
assume that I must use windows for this task.)
Cheers,
david
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Sat, 29 Aug 1998 02:06:48 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: installing modules in user defined dir - Actuve Perl
Message-Id: <YmJF1.41$tN.431346@shore>
dturley@pobox.com wrote:
: perl makefile.pl PREFIX=c:\myModDir
: and the modules still get installed in the AS site directory.
Weird. Have you tried:
perl Makefile.PL PREFIX=c:/whatever
or
perl Makefile.PL PREFIX=/whatever
?
Just curious.
--
Nate Patwardhan|root@localhost
"Fortunately, I prefer to believe that we're all really just trapped in a
P.K. Dick book laced with Lovecraft, and this awful Terror Out of Cambridge
shall by the light of day evaporate, leaving nothing but good intentions in
its stead." Tom Christiansen in <6k02ha$hq6$3@csnews.cs.colorado.edu>
------------------------------
Date: Sat, 29 Aug 1998 01:25:04 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Is this how it's supposed to be?
Message-Id: <Pine.GSO.4.02A.9808281814050.14973-100000@user2.teleport.com>
On Fri, 28 Aug 1998 webmuse@my-dejanews.com wrote:
> Subject: Is this how it's supposed to be?
Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.
http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post
> Using version 5.004_69 built for MSWin32-x86. Is
> this a bug in perl, a bug in THIS build of perl, or
> not a bug at all?
Of course, that's an experimental version, and an old one at that. If
you're choosing to use that, you should be prepared to provide your own
answers. :-)
> I had a file that needed to be read in and variables interpolated.
> my ($who, $what) = ("Jill", "hill");
> s/\$([A-Za-z_]\w*)/${$1}/ge;
You're doing a soft reference there. Maybe the FAQ's entry on this should
be clearer about that. Soft references can't find my() variables, of
course.
Of course, if you use a hash instead of a soft reference, you can do this
sort of thing with no trouble. And safer and faster, besides!
my %subs = (
who => 'Jill',
what => 'hill',
);
s/\$([A-Za-z_]\w*)/$subs{$1}/g; # or whatever...
There's also Text::Template. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 28 Aug 1998 21:19:52 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: mod_perl configuration
Message-Id: <comdog-ya02408000R2808982119520001@news.panix.com>
Keywords: from just another new york perl hacker
In article <6s72au$7gi$1@nnrp1.dejanews.com>, marad@usa.net posted:
>After many hassles, I successfully complied Apache 1.3.1 for Linux with
>mod_perl, but I still can't seem to get it to actually run scripts. Instead,
>it just displays the script. I have searched the newsgroups and FAQs over and
>over, but nothing seems to work. My srm.conf looks like this:
>AddHandler cgi-script .cgi #Do I need this line? Is it in the way?
i have this commented out in my config, but that doesn't mean anything.
my servers don't allow executable content outside of designated
directories.
>Alias /perl/ /usr/apache/share/perl/
><Location /perl>
>SetHandler perl-script
>PerlHandler Apache::Registry
>Options ExecCGI
></Location>
my configuration looks very similar to yours (Stronghold is a little
different than Apache for configuration). i know this is a stupid
question, but have you reloaded the server so that the new
configuration takes affect? that bites me a couple times a week :)
good luck :)
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers needs volunteers! <URL:http://www.pm.org/to-do.html>
------------------------------
Date: Fri, 28 Aug 1998 18:42:48 -0700
From: "Dan Bassett" <dan@bns.com>
Subject: output in shell, but not in browser?
Message-Id: <35e75f93.0@news1.starnetinc.com>
I seem to be having a strange problem with outputing to a browser.
When running the attached script via Telnet, it outputs the information
from the program on the screen. However, when I run the same script
from a browser, the output is just blank.
But what's really strange is that when I replace "socklink" with "whois"
and "variable1 variable2" with a domain name, it runs the whois command
and successfully outputs to the browser.
Does any one know why this would occur and what I need to do to correct it?
Thanks,
Dan
dan@bns.com
begin 666 socklink.cgi
M(R$O=7-R+V)I;B]P97)L-0T*#0H-"B1S;V-K;&EN:U]C;60@/2 B<V]C:VQI
M;FLB.PT*#0HD<W1R:6YG(#T@(G9A<FEA8FQE,2!V87)I86)L93(B.PT*#0I
M<F5S=6QT(#U@)'-O8VML:6YK7V-M9" D<W1R:6YG8#L-"@T*<')I;G0@*")#
M;VYT96YT+51Y<&4Z=&5X="]H=&UL7&Y<;B(I.PT*#0IP<FEN=" \/$5/33L-
M"CQH=&UL/@T*/'!R93X-"D!R97-U;'0-"CPO<')E/@T*/"]H=&UL/@T*14]-
$#0H-"@``
`
end
------------------------------
Date: Sat, 29 Aug 1998 02:36:43 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: output in shell, but not in browser?
Message-Id: <Pine.GSO.4.02A.9808281935070.14973-100000@user2.teleport.com>
On Fri, 28 Aug 1998, Dan Bassett wrote:
> When running the attached script via Telnet, it outputs the information
> from the program on the screen.
So, the problem isn't in Perl.
> However, when I run the same script
> from a browser, the output is just blank.
Maybe the problem is in your browser. Or it could be in your server, your
use of the CGI interface, or in one of the other things you didn't
mention. In any case, the docs, FAQs, and newsgroups about those things
should be helpful.
Also, hen you're having trouble with a CGI program in Perl, you should
first look at the please-don't-be-offended-by-the-name Idiot's Guide to
solving such problems. It's available on CPAN.
http://www.perl.com/CPAN/
http://www.perl.org/CPAN/
http://www.perl.org/CPAN/doc/FAQs/cgi/idiots-guide.html
http://www.perl.org/CPAN/doc/manual/html/pod/
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 29 Aug 1998 01:44:39 GMT
From: rcook@pcug.org.au (Owen Cook)
Subject: Re: Perl Cookbook, does anyone have it?
Message-Id: <35e83428.805397@newshost.pcug.org.au>
On Wed, 26 Aug 1998 19:14:05 GMT, ptimmins@netserv.unmc.edu (Patrick
Timmins) wrote:
>>doesn't
>> seem to have reached Georgia yet.
>It's not in Omaha yet either,
Guess it will never get to Australia
--
Owen
------------------------------
Date: Sat, 29 Aug 1998 01:29:01 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: removing ^M when writing to file
Message-Id: <Pine.GSO.4.02A.9808281827090.14973-100000@user2.teleport.com>
On 28 Aug 1998, Antti-Jussi Korjonen wrote:
> My problem are the ^M's. How can I get rid of them?
Try one of the functions in perlfunc or the operators in perlop. I'd
probably choose tr/// or chop or chomp, depending upon the situation. Hope
this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 28 Aug 1998 16:54:20 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: simple variable manipulation
Message-Id: <MPG.1050e30b5d47360298977a@nntp.hpl.hp.com>
In article <35E73904.44F21C32@email.sps.mot.com> on Fri, 28 Aug 1998
18:11:00 -0500, Tk Soh <r28629@email.sps.mot.com> says...
> Paul Worthington wrote:
>
> > How do I get Perl to recognize those
> > three "pieces" I've lined up next to each other as the
> > variable $d20 and have Perl give me the value of $d20?
>
> Try this:
>
> $d20 = 'Acrobat';
> $Acrobat = 1; # put something into $Acrobat
> $sub = 20;
>
> eval '$Acrobat = $d'.$sub;
>
> print $Acrobat; # output: Acrobat
#!/usr/local/bin/perl -w
use Benchmark;
$d20 = 'Acrobat';
$Acrobat = 1;
$sub = 20;
timethese (1 << (shift || 0), {
Eval => sub { eval '$Acrobat = $d' . $sub },
String => sub { $Acrobat = ${"d$sub"} },
} );
Benchmark: timing 16384 iterations of Eval, String...
Eval: 9 secs ( 5.61 usr 0.05 sys = 5.66 cpu)
String: 1 secs ( 0.43 usr 0.00 sys = 0.43 cpu)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 28 Aug 1998 17:52:31 -0600
From: Paul Worthington <prw@evolving.com>
Subject: Re: simple variable manipulation
Message-Id: <35E742BE.F642CA0B@evolving.com>
> print eval '$d'.$sub;
Thanks for your response! But that didn't do it. I think maybe I could
express the problem better:
I've got a variable $d20. I don't know what its value is.
I've got another variable $sub. I know its value is 20.
How can I combine "$" and "d" and "$sub" such that I can
'print' whatever that combination is and get the value of
$d20?
I'm putting together three "pieces", and to us humans, they
look like "$d20". How do I get Perl to recognize those
three "pieces" I've lined up next to each other as the
variable $d20 and have Perl give me the value of $d20?
Thanks!
Paul Worthington
------------------------------
Date: Fri, 28 Aug 1998 17:50:14 -0600
From: Paul Worthington <prw@evolving.com>
Subject: Re: simple variable manipulation
Message-Id: <35E74235.6AE53961@evolving.com>
> ${"d$sub"}
>
> But are you sure you really want to use symbolic references instead of
a
> hash?
That didn't quite work for me...
And I think maybe I'm not expressing the problem the right way, so
let me try again:
I've got a variable $d20. I don't know what its value is.
I've got another variable $sub. I know its value is 20.
How can I combine "$" and "d" and "$sub" such that I can
'print' whatever that combination is and get the value of
$d20?
I'm putting together three "pieces", and to us humans, they
look like "$d20". How do I get Perl to recognize those
three "pieces" I've lined up next to each other as the
variable $d20 and have Perl give me the value of $d20?
Thanks!
Paul Worthington
------------------------------
Date: Fri, 28 Aug 1998 18:04:31 -0600
From: Paul Worthington <prw@evolving.com>
Subject: Re: simple variable manipulation
Message-Id: <35E7458E.951EFC3D@evolving.com>
Tk Soh wrote:
> Paul Worthington wrote:
>
> > How do I get Perl to recognize those
> > three "pieces" I've lined up next to each other as the
> > variable $d20 and have Perl give me the value of $d20?
>
> Try this:
>
> $d20 = 'Acrobat';
> $Acrobat = 1; # put something into $Acrobat
> $sub = 20;
>
> eval '$Acrobat = $d'.$sub;
>
> print $Acrobat; # output: Acrobat
>
> -TK-
Here's what I tried:
$d20 = 'BLAH';
$sub = 20;
$foo = 1;
eval '$foo = $d'.$sub;
print $foo;
And I got nothing. I really appreciate your suggestion,
though. Any other ideas on how to make this work?
Paul Worthington
prw@evolving.com
------------------------------
Date: Fri, 28 Aug 1998 17:14:23 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: simple variable manipulation
Message-Id: <MPG.1050e7b7a3b4bbb098977b@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy mailed.]
In article <35E74235.6AE53961@evolving.com> on Fri, 28 Aug 1998 17:50:14
-0600, Paul Worthington <prw@evolving.com> says...
> > ${"d$sub"}
> >
> > But are you sure you really want to use symbolic references instead of
> a
> > hash?
>
> That didn't quite work for me...
...
Use ${"d$sub"} as I suggested, but chomp the new-line off $sub first. It
will work. I guarantee it!
Then think about using a hash. Someone else showed you how.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 27 Aug 1998 21:49:30 -0500
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: simple variable manipulation
Message-Id: <35E61AB9.A736530F@email.sps.mot.com>
Paul Worthington wrote:
> Here's what I tried:
>
> $d20 = 'BLAH';
> $sub = 20;
> $foo = 1;
> eval '$foo = $d'.$sub;
> print $foo;
>
> And I got nothing. I really appreciate your suggestion,
> though. Any other ideas on how to make this work?
Hmm.. I am a little confused here. I duplicated your code and tried it on my
system, but I did get 'BLAH' on my screen. Larry's code worked too, only much
faster (>20 times on my Sun-system).
I'm not sure what version of Perl you are using, or even if these codes would
behave differently on older version of Perl - I was lucky enough to begin my
perl adventure with revision 5.003. Maybe other folks could have a answer for
you. Good luck.
-TK-
------------------------------
Date: Sat, 29 Aug 1998 03:10:47 GMT
From: Tom Tegeler <tegelert@gol.com>
Subject: Sybperl, ct_lib module: checking connection
Message-Id: <35E76C22.62A7538C@gol.com>
After I connect to sybase using sybperl ct_lib ct_connect subroutine, I
want to periocially check the connection to see if I am still connected
and talking to the sybase server. Anybody have a suggestion of how this
could be done?
Thanks,
Tom T.
------------------------------
Date: Sat, 29 Aug 1998 11:19:05 +0800
From: Cattle <cattle@hknet.com>
Subject: thank you (mt)
Message-Id: <35E77329.E52F3447@hknet.com>
------------------------------
Date: Sat, 29 Aug 1998 01:45:28 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Where to put my perl-scripts?
Message-Id: <Pine.GSO.4.02A.9808281841330.14973-100000@user2.teleport.com>
On Fri, 28 Aug 1998, Florian Arndt wrote:
> Do you know a place to put my scripts?
On disk somewhere? :-)
> Any free cgi-provider (perhaps included in homepage)?
If you're looking for ISPs, perhaps you should use your favorite reference
site; Yahoo has a large list. But any sysadmin who lets J. Random
Programmer install scripts on a webserver isn't smart enough to be trusted
with anything so important as being a sysadmin. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 29 Aug 1998 00:10:05 GMT
From: bjepson@ids.net (Brian Jepson)
Subject: Re: XS with win32 Perl
Message-Id: <slrn6uehon.529.bjepson@gelvis.ids.net>
On Fri, 28 Aug 1998 16:45:38 +0100, Jeff Kiser <jeffk@synplicity.com> wrote:
>I am having problems writing my own extensions with XS and the latest
>ActivePerl (5.005). Even trying the simple "Hello world" example in
>perlxstut.html gives me the same problem. The message I am getting is:
>
>C:\Perl\5.005\lib\MSWin32-x86-object\CORE\perl.h(1232) : error C2644:
>basis class 'CPerlObj' for pointer to member has not been defined
>
>Does anyone know a solution to this? In the perl.h header file, it
>mentioned that you must link the perlX.lib library to define this class
>but I don't have this library anywhere on my machine. Do you have to
>build the Perl yourself to get this file and, if so, is the source code
>to the new ActivePerl available anywhere on ActiveState's website?
>Thanks for any help.
>
I was able to build a simple extension, but for some reason, the Makefile
could not find PerlCRT.lib, which is kind of weird. Being lazy, I copied
PerlCRT.lib from c:\perl\5.00502\bin\MSWin32-x86-object into the same
directory as my extension source, and it compiles fine.
You can find the source code at:
http://users.ids.net/~bjepson/HelloWorld-0.10.tar.gz
http://users.ids.net/~bjepson/HelloWorld-0.10.zip
Here are the steps I took:
# Extract the archive.
C:\> cd HelloWorld-0.10
C:\HelloWorld-0.10> copy c:\perl\5.00502\bin\MSWin32-x86-object\PerlCRT.lib
C:\HelloWorld-0.10> perl Makefile.PL
C:\HelloWorld-0.10> nmake
C:\HelloWorld-0.10> perl hello.pl
Hope this helps,
--
Brian Jepson * (bjepson@ids.net) * http://users.ids.net/~bjepson
Choosy mothers choose to chew Chew-Z
------------------------------
Date: 28 Aug 1998 23:25:01 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: Y2K Date Support
Message-Id: <lt90k831wy.fsf@asfast.com>
No.unsoiliciteds@dead.end (Norman UNsoliciteds) writes:
> In article <6s59lr$1kf$1@marina.cinenet.net>, cberry@cinenet.net (Craig
> Berry) wrote:
> > As a result of sloppy math and historical research by Dennis
> > the Little, our calendar has no year zero,
>
> so what happened 1,998 years ago? why are we counting from such a
> relatively recent date and not from the dawn of the eistence of the earth?
> Granted the _exact_ dates of the death (and birth for that matter) of
> Christ is none are lost somewhere between the heresay of what went into
> writing the bible several hundreds of years after the events it describes,
> and the addtional months added by the roman emperors to the callendar and
> the decision to revise the callendar in the middle ages however a zero
> year there is (appromimateit may be).
I'm not sure I follow. Here's a section of the sequence of years that
took place a couple millenia ago:
... 3 B.C. 2 B.C. 1 B.C. 1 A.D. 2 A.D. 3 A.D. ...
Note the absence of year zero. This has nothing to do with the lack
of precise knowledge about the date of the birth of Christ. The date
system was specifically designed without a year numbered zero.
This is no doubt what Craig Berry was referring to, although I'm not
sure about the "sloppy math" part having anything to do with the
absence of a zero year. The Roman number system did not have the
concept of zero as an actual number. The number zero was introduced
many centuries after the calendar was adopted ... it came to Europe
during the Middle Ages by way of the Islamic countries of the Middle
East and North Africa, and its adoption involved a huge philosophical
leap on the part of many Europeans.
Therefore, it would have been natural to start numbering years with 1
at the time the calendar was adopted, and I'm pretty sure that this is
the main reason for a 1 B.C. and a 1 A.D. with no year zero in
between.
> [ ... ]
>
> Not that this information will change the question of Perl being Y2K or not
Agreed. But some people might find it interesting or illuminating.
--
Lloyd Zusman ljz@asfast.com
perl -e '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
$t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
$x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x\n"'
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 3581
**************************************