[11090] in Perl-Users-Digest
Perl-Users Digest, Issue: 4690 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 19 14:17:33 1999
Date: Tue, 19 Jan 99 11:00:23 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 19 Jan 1999 Volume: 8 Number: 4690
Today's topics:
Re: "Back button" in CGI script <upsetter@ziplink.net>
Re: Binary and Hex number conversion (Abigail)
Re: Calculate next [mon..sun]day (Randal L. Schwartz)
Re: Calculate next [mon..sun]day (M.J.T. Guy)
Can I manipulate Win apps using Perl? mere_mortal@my-dejanews.com
Re: CC via email (Was Re: "Back button" in CGI script) (Mike Bristow)
Re: Changing elements in a text file (Abigail)
Re: Ext files w/var int (Tad McClellan)
f (Decision Systems Inc)
Re: f <spam@dikkelul.com>
Re: File Handle Elements as numeric values (Abigail)
Re: foreach dilemma (Greg Ward)
Re: How to best process a large CGI form? (Abigail)
Re: How to determine time? (Greg Ward)
Re: How to determine time? (Abigail)
Re: How to link image in Perl script ? (Abigail)
Re: Including a CGI script in a Web Page <supernet@mail.telepac.pt>
joining lines from file and sending to array <hamptonk@bible.org>
Re: joining lines from file and sending to array <henk@crash.nu>
Re: launching perl scripts from windows explorer (Abigail)
New to perl - trying to FTP <abc@abc.com>
Objects and Code Structure... <phraktyl@home.com>
Re: package context in evals/subrefs (M.J.T. Guy)
Re: Perl 5.005_2 fails op/pack test 9 on DEC OSF1 (Donald L. Nash)
Re: perl Help ptimmins@netserv.unmc.edu
Re: Perl problem :(Offline mode... (Abigail)
Re: problem with: use module; (Tad McClellan)
Re: Questions about cookies (Greg Ward)
Re: Sys::Syslog problem (Greg Ward)
Re: Using GetOptions? (Bob Waltenspiel)
Using Perl OLE to convert Excel xls to txt <jay.frase@boeing.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 19 Jan 1999 18:05:32 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: "Back button" in CGI script
Message-Id: <MP3p2.647$z71.139930@news.shore.net>
Steve Linberg <linberg@literacy.upenn.edu> wrote:
: And if I turn off javascript in my browser for security reasons? If I use
: Lynx, or any of dozens of other browsers that don't support Javascript?
: Then you have a dead link which says "Go back" and doesn't do anything,
: confusing your visitors.
Anyone who uses Lynx, or bothers to turn off JavaScript, is probably not
going to be seriously confused by a broken "go back" button. I don't use
JS-enabled "back" buttons myself, but realistically, it's still going to
work for *most* WWW users. If that's good enough for your purposes, have
at it.
--Art
--
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: 19 Jan 1999 17:00:57 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Binary and Hex number conversion
Message-Id: <782do9$pp$1@client2.news.psi.net>
Mark Nold (markn_nospam_@mincom.com) wrote on MCMLXVII September MCMXCIII
in <URL:news:780n9g$p40$1@pithy.mincom.oz.au>:
&& Hi i want to easily convert fractional binary numbers to decimal.
FAQ
Abigail
--
perl -e '$_ = q *4a75737420616e6f74686572205065726c204861636b65720a*;
for ($*=******;$**=******;$**=******) {$**=*******s*..*qq}
print chr 0x$& and q
qq}*excess********}'
------------------------------
Date: 19 Jan 1999 10:05:16 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Calculate next [mon..sun]day
Message-Id: <m11zkrp28z.fsf@halfdome.holdit.com>
>>>>> "Mike" == Mike Bristow <mike@fat.dotat.at> writes:
>> $time = time;
>> $today = (localtime($time))[6];
>> $tomorrow = (localtime($time + 24*60*60))[6];
Mike> Some days have leap seconds.
Not according to Unix time. :)
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 19 Jan 1999 18:08:29 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Calculate next [mon..sun]day
Message-Id: <782hmt$gqk$1@pegasus.csx.cam.ac.uk>
Mike Bristow <mike@fat.dotat.at> wrote:
>
>Some days have leap seconds.
No. The time() value does not include leap seconds.
But there are other things wrong with that posting - see my other reply.
Mike Guy
------------------------------
Date: Tue, 19 Jan 1999 18:15:09 GMT
From: mere_mortal@my-dejanews.com
Subject: Can I manipulate Win apps using Perl?
Message-Id: <782i32$bo8$1@nnrp1.dejanews.com>
I am about to start the scripting journey...
I have to implement a script that needs to manipulate Windows apps to make
them output files. Can I use Perl to manipulate these apps? For example, can
I launch WINFOO.EXE, make WINFOO save a document, then close WINFOO?
If Perl can't do this, is there another free scripting language (TCL, Python)
that can?
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 19 Jan 1999 18:36:55 GMT
From: mike@fat.dotat.at (Mike Bristow)
Subject: Re: CC via email (Was Re: "Back button" in CGI script)
Message-Id: <slrn7a9k67.1da.mike@lindt.fat.dotat.at>
On the vexed question of CCing followups via email.
On Tue, 19 Jan 1999 08:32:03 -0800, Larry Rosler <lr@hpl.hp.com> wrote:
>I agree. Refusal to do so as a matter of policy is a fascistic response
>to a polite and reasonable request. I often CC the response on my
>own, unless requested not to -- it gets to the questioner much faster, as
>a rule.
I, personally, find this irritating.
Unless I notice that it's an email copy, I will often reply to the email
and then get a sense of deja vu when reading the newsgroup.
--
"...Unix, MS-DOS, and Windows NT (also known as the Good, the Bad, and
the Ugly)."
-- Matt Welsh
------------------------------
Date: 19 Jan 1999 17:05:17 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Changing elements in a text file
Message-Id: <782e0d$pp$2@client2.news.psi.net>
Artoo (r2-d2@REMOVEbigfoot.com) wrote on MCMLXVII September MCMXCIII in
<URL:news:781oap$f4d$1@plug.news.pipex.net>:
--
-- How can you make perl just edit the file and replace 1234 with 5678. Is it
-- possible or do you have to bring in the file as an array and s/// the value
-- and then right the info back to the file? I'm dealing with large files that
-- will use unnecessary processor power to write the entire file each time it
-- is changed.
If your replacement is as long as what it replaces, look up open() & seek().
Abigail
--
perl -wleprint -eqq-@{[ -eqw+ -eJust -eanother -ePerl -eHacker -e+]}-
------------------------------
Date: Tue, 19 Jan 1999 11:58:30 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Ext files w/var int
Message-Id: <64h287.pmg.ln@magna.metronet.com>
Chad Lawson (cdlawson@xnet.com) wrote:
: I am looking for a way to have an external data file contain (among other
: things) variables, and then when the file is read, the variables be
: evaluated.
Perl FAQ, part 4:
"How can I expand variables in text strings?"
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 19 Jan 1999 17:51:29 GMT
From: dsi@smart.net (Decision Systems Inc)
Subject: f
Message-Id: <782gn1$55$2@news.smart.net>
Keywords: parameter switch
What is the best way to pass switches or parameters to my perl script from
the command line?
Thanks
Horst
------------------------------
Date: Tue, 19 Jan 1999 19:25:12 +0100
From: "Willem" <spam@dikkelul.com>
Subject: Re: f
Message-Id: <782isn$p1q$1@dinkel.civ.utwente.nl>
Decision Systems Inc wrote in message <782gn1$55$2@news.smart.net>...
>What is the best way to pass switches or parameters to my perl script from
>the command line?
_Are_ their multiple ways? AFAIK, you can only use @ARGV to read cmdline
arguments.
------------------------------
Date: 19 Jan 1999 17:06:20 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: File Handle Elements as numeric values
Message-Id: <782e2c$pp$3@client2.news.psi.net>
Artoo (r2-d2@REMOVEbigfoot.com) wrote on MCMLXVII September MCMXCIII in
<URL:news:781oik$f93$1@plug.news.pipex.net>:
//
// How can the file handle read any of the values from the array created as
// their numeric value so they can be manipulated numerically, rather than as
// text values which can not be manipulated numerically.
Please learn Perl.
Abigail
--
perl -wle\$_=\<\<EOT\;y/\\\\n/\ /\;print\; -eJust -eanother -ePerl -eHacker -eEOT
------------------------------
Date: 19 Jan 1999 18:20:22 GMT
From: gward@thrak.cnri.reston.va.us (Greg Ward)
Subject: Re: foreach dilemma
Message-Id: <782id6$455$1@news0-alterdial.uu.net>
Rich Grise <off-duty@entheosengineering.com> wrote:
> When I have a foreach loop going through a file
> one line at a a time, and match something that
> breaks the loop, then does the next foreach on
> the same list pick up where the last one left
> off, or start from the top again? (I want to
> capture the lines between a certain "From"
> address and the ensuing "end of message" line
> in an In.mbx file).
You don't necessarily have to use a foreach loop, or a couple of 'em
ganged together, for this. Perl's range operator ('..'), combined with
grep, will often do the trick. For example, let's say you want to split
up a Unix-style "mbox" file, where the start of each message is marked
by "\nFrom " (ie. the word "From" at the start of a line, followed by a
space -- also, the line before "From" should be blank except at the
beginning of the file... I'll ignore that detail). Here's some code
that sets the situation up:
$text = <<TEXT;
junk
blah
From foo@bar.com
Header: ...
Header: ...
Body body body body
From ...
TEXT
@lines = split ("\n", $text);
Now let's say you want to pull out lines from "From foo@bar.com" to the
next "From" line. This is a snap with 'grep' and '..':
@my_lines = grep (/^From foo\@bar\.com/ .. /^From /, @lines);
Pop some cruft off the end, and you have what you wanted. Presumably
you'll have to tweak the boundary conditions a bit for your problem, but
you get the idea.
'man perlop' and search for "Range operator" for details. I find that
the range operator in a scalar context is one of those things that seem
utterly deep and mysterious until you have a working example in front of
you, in which case the (formerly) cryptic explanation in the man page
makes perfect sense.
Greg
--
Greg Ward - software developer gward@cnri.reston.va.us
Corporation for National Research Initiatives
1895 Preston White Drive voice: +1-703-620-8990 x287
Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913
------------------------------
Date: 19 Jan 1999 17:09:18 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: How to best process a large CGI form?
Message-Id: <782e7u$pp$4@client2.news.psi.net>
jlatifi@tsicable.com (jlatifi@tsicable.com) wrote on MCMLXVII September
MCMXCIII in <URL:news:36a3fd90.19105872@corp.supernews.com>:
%% I have a large form, (many similar form objects), that I need to put
%% into arrays. I will then check for null, and mail away non-null
%% variables. How can I do this without explicitly loading each object
%% into the arrays?
You lost me here. You have your "objects" (whatever they are) which
you need to put into arrays (you don't explain why). Then you ask
how you can do that without "loading" (?) each object into the arrays.
Could you tell me how I can shovel sand into a wheelbarrow, without
shoveling sand into a wheelbarrow?
Abigail
--
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))
------------------------------
Date: 19 Jan 1999 18:29:29 GMT
From: gward@thrak.cnri.reston.va.us (Greg Ward)
Subject: Re: How to determine time?
Message-Id: <782iu9$455$4@news0-alterdial.uu.net>
info@netstyle.nl <info@netstyle.nl> wrote:
> I would like to know how to put the time in a string variable.
> I know this:
>
> $tim= time;
>
> but this gives me the epoch-relative time and I do not want that.
> How to let $tim have the folowing content i.e.
> 19-01-1999/8.05PM
So far everyone has mentioned localtime and gmtime, which are available
whenever Perl is. The POSIX module, however, supplies an extremely
useful function from the C library: strftime. This lets you format a
time/date just about any way you'd please, without mucking around with
the list returned by localtime (or gmtime). Verrrry convenient.
'perldoc POSIX' for a little bit of information 'man 3 strftime' on most
Unix systems for the gory details.
Of course, this is only guaranteed to be there on POSIX-compliant systems.
Greg
--
Greg Ward - software developer gward@cnri.reston.va.us
Corporation for National Research Initiatives
1895 Preston White Drive voice: +1-703-620-8990 x287
Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913
------------------------------
Date: 19 Jan 1999 17:10:07 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: How to determine time?
Message-Id: <782e9f$pp$5@client2.news.psi.net>
info@netstyle.nl (info@netstyle.nl) wrote on MCMLXVII September MCMXCIII
in <URL:news:7820h8$rfl$1@nnrp1.dejanews.com>:
__
__ I would like to know how to put the time in a string variable.
localtime
Abigail
--
perl -MNet::Dict -we '(Net::Dict -> new (server => "dict.org")
-> define ("foldoc", "perl")) [0] -> print'
------------------------------
Date: 19 Jan 1999 17:11:17 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: How to link image in Perl script ?
Message-Id: <782ebl$pp$6@client2.news.psi.net>
Alex (ex5316@netvigator.com) wrote on MCMLXVII September MCMXCIII in
<URL:news:36A40398.72BC8D06@netvigator.com>:
"" However, I cannot run this script. Error appear.
"" Please tell me how to do this.
Make error go away. Then run script.
Abigail
--
perl -e '$a = q 94a75737420616e6f74686572205065726c204861636b65720a9 and
${qq$\x5F$} = q 97265646f9 and s g..g;
qq e\x63\x68\x72\x20\x30\x78$&eggee;
{eval if $a =~ s e..eqq qprint chr 0x$& and \x71\x20\x71\x71qeexcess}'
------------------------------
Date: Tue, 19 Jan 1999 18:22:39 -0000
From: "Cristovao Morgado" <supernet@mail.telepac.pt>
Subject: Re: Including a CGI script in a Web Page
Message-Id: <782ibu$8dp$1@duke.telepac.pt>
use:
<!--#virtual file="/cgi-local/weather/weather.cgi?Augusta&ME"-->
jgalenski@my-dejanews.com escreveu na mensagem
<77rm72$l2q$1@nnrp1.dejanews.com>...
>I'm trying to include a CGI script in a web page (HTML) via the exec sever
>side include. If my script does not require any inputs, it works ok.
>However, if I have to pass in inputs, it fails. Here's a sample of what
I'm
>trying to do:
>
><!-- test.shtml -->
><html><body bgcolor="#123456">
>This is a test
><p>
><!--#exec cgi="/cgi-local/weather/weather.cgi?Augusta&ME"-->
></body></html>
>
>When 'test.shtml' is accessed, it should run 'weather.cgi' using 'Augusta'
>and 'ME' as the inputs.
>
>Any ideas how to do this?
>
>Thanks,
>-John Galenski (johng@mathworks.com)
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 19 Jan 1999 18:20:42 GMT
From: Hampton Keathley <hamptonk@bible.org>
Subject: joining lines from file and sending to array
Message-Id: <36A4CB61.944FA77E@bible.org>
Hello again,
I've read all my perl books on arrays and still can't figure this out...
so I'm turning to the experts.
I'm trying to read in an html file with lines like this:
<div2 type=title><head>Here's the text<BR>
here's some more text<BR>
and some more text.
I want to remove the "<BR>\n" at the end of each line that has <BR>'s
and make one long line so that it looks like this:
<div2 type=title><head>Here's the text<lb>here's some more text<lb>and
some more text.
Then I want to send the entire file with the joined lines to an array so
I can process it some more.
After I do all my searches and replaces, then I'll split it into two
arrays (body and footnotes) and do separate things to those arrays.
Why doesn't this work?
while (<INFILE>){
$line = $_;
while ($line =~ /\<BR\>\n/){ #this section just puts me in
$line =~ s/\<BR\>\n/<lb>/; #an endless loop
$newline = <INFILE>; #and I don't know why
$line = $line.$newline;
}
push @array1, $line; #Send entire file with joined lines to array
}
for (@array1){ #process the array
#do my $_ =~ s///g; stuff here
}
#now split @array1 into @body and @footnotes arrays
#Yogish and Tad gave me this and it works with while (<>) but not an
array
#should I use "for (@array1){ "? I tried but it only put the body text
in @body
#but put the whole file in @notes
for (@array1) {
last if /<P><A NAME="P/;
push @body, $;
}
push @notes, $_;
for (@array1) {
push @notes, $_;
}
print OUTFILE (@body);
print NOTEFILE (@notes);
close (NOTEFILE);
close (OUTFILE);
close (INFILE);
Thanks,
Hampton
------------------------------
Date: Tue, 19 Jan 1999 19:35:48 +0100
From: "Henk Slaaf" <henk@crash.nu>
Subject: Re: joining lines from file and sending to array
Message-Id: <782jgj$s24$1@dinkel.civ.utwente.nl>
I don't see what could be wrong about your program, however, it's not very
efficient.
Maybe you could try this?
@array = <INFILE>;
for $line (@ARRAY) {
$line =~ s/\<BR\>\n/\<lb\>/i;
#do other stuff
}
Also, some part of your program _is_ incorrect:
----------------------
while (blabla) (
[snip]
$line = $line.$newline;
}
push @array1, $line; #Send entire file with joined lines to array
}
for (@array1){ #process the array
----------------------
Don't you get an array with just one element that way?
------------------------------
Date: 19 Jan 1999 17:14:29 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: launching perl scripts from windows explorer
Message-Id: <782ehl$pp$7@client2.news.psi.net>
Roger S Reynolds (rsr@rogerware.com) wrote on MCMLXVII September MCMXCIII
in <URL:news:V6Qo2.235$jp4.1864@news14.ispnews.com>:
~~
~~ Now, say that I want to launch this script from the windows explorer
~~ somehow.
How to configure your browser isn't a perl question.
Go away.
Abigail
--
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
"\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
"\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'
------------------------------
Date: Tue, 19 Jan 1999 18:54:40 -0000
From: "Richard Gordon" <abc@abc.com>
Subject: New to perl - trying to FTP
Message-Id: <782kco$bsf$1@plutonium.btinternet.com>
I am trying to use the ftp.pl package supplied with my perl distribution to
get a list of files on an ftp server. Everything seems to work ok but I
cannot work out how to get the list of files returned into an list(or even
find out how the list of files get returned).
I am new to perl I would appreciate any help.
I am using the ftp.pl package rather than the Net:FTP as I could not get the
later to install.
------
#!/usr/bin/perl
require 'ftp.pl' ;
#ftp'debug(1) ;
(ftp'open( ("127.0.0.1", "21", "1", "2") ) == 1) || die "cannot open\n" ;
(ftp'login( ("anonymous", "xxx\@123.com") ) == 1) || die "cannot login\n" ;
(ftp'cwd( "/swr/isp/sb") == 1) || die "cannot change directory\n" ;
(ftp'dir_open() == 1) || die "cannot open directory" ;
(ftp'dir_close() == 1) || die "cannot close directory" ;
ftp'close ;
-----
Thanks in advance
Richard Gordon
------------------------------
Date: Tue, 19 Jan 1999 18:52:50 GMT
From: Wyatt Draggoo <phraktyl@home.com>
Subject: Objects and Code Structure...
Message-Id: <36A4C7AF.4607@home.com>
I am trying to make a very modular system admin type of client/server
tool and am not sure how to organize it. Actually, I think I know how
to organize it functionally, but I'm not sure how the object inheritance
tree is going to work. Here are my modules so far: (Names have been
changed to protect the guilty. :)
bin/main
He is a very small script that will
check a few things and then load up
and init the appropriate objects as
per any command line switches.
lib/Main.pm
Base object. Has methods used both
by the client and config methods of
the program. The Main objects just
provide a container to hold all the
other modules in place. He reads a
modules.conf (or somesuch) file and
initializes each added object.
lib/Main/Client.pm
He starts any Client methods in the
added Modules.
lib/Main/Config.pm
Meant to be a base class that holds
configuration methods.
lib/Main/Config/CLI.pm
This is a Command Line Interface to
Config.pm. He will pass args to my
other modules:
-M<module> [module specific args]
lib/Main/Config/GUI.pm
Graphical User Interface. Also for
Config.pm. He will basically bring
up an empty notebook, and give each
module a page.
modules/Mod1.pm
Base class for first module.
modules/Mod1/Client.pm
Client system for Mod1.
modules/Mod1/Config.pm
Base config class for Mod1.
modules/Mod1/Config/CLI.pm
CLI for Mod1.
modules/Mod1/Config/GUI.pm
GUI for Mod1.
lib/GUI_lib.pm
GUI code that all modules should be
using.
Whew!
Now, with all that said and done, I am not sure what needs to have an
ISA relationship with everything else. Here are my thoughts:
1) Both Client.pm and Config.pm are instances of their respective base
classes - Main and Mod1.
2) Both CLI.pm and GUI.pm are instances of their respective Config
classes.
But beyond that, things get muddy.
Should I wait to initialize the modules until after I find out how the
program is going to run? (Instead of Main.pm initializing Mod1.pm,
should Main/Config/GUI.pm initialize Mod1/Config/GUI.pm?)
If Main.pm has attributes and methods that I need all the added modules
to use, should the added modules 'be' (ISA) a Main object? Or - if I
wait according to the last question - should Mod1/Config/GUI.pm 'be' a
Main/Config/GUI.pm?
I know this is probably very unclear - that is why I'm asking here. :)
If you have any more questions, please ask. I just want to figure this
out!
Wyatt
------------------------------
Date: 19 Jan 1999 18:34:07 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: package context in evals/subrefs
Message-Id: <782j6v$i5s$1@pegasus.csx.cam.ac.uk>
Brad Fitzpatrick <bradfitz@bradfitz.com> wrote:
>How can I control what package context evals and anonymous sub references
>run in when executed from somewhere else? I'm sucking in foreign code to be
>executed within the current program but I want to have it run in its own
>namespace, instead of walking all over my existing program.
For eval(), the package currently in scope defines the namespace used.
So since package directives are lexically scoped, you can write
{ package ForeignCode; eval $sucked_in_code };
or
eval "package ForeignCode; $sucked_in_code";
Mike Guy
------------------------------
Date: Tue, 19 Jan 1999 12:13:51 -0600
From: D.Nash@utexas.edu (Donald L. Nash)
Subject: Re: Perl 5.005_2 fails op/pack test 9 on DEC OSF1
Message-Id: <D.Nash-1901991213510001@bubba.ots.utexas.edu>
In article <77vvst$3n5$1@pegasus.csx.cam.ac.uk>, mjtg@cus.cam.ac.uk
(M.J.T. Guy) wrote:
>What does
>
> perl -wle 'print unpack "H*", pack("I", 0xFFFFFFFF)'
>
>produce for you? I get 'ffffffff'.
I get ffffffff as well.
>It'd also be interesting to know what the output from `perl -V' says,
>in particular the lines which for me say
intsize=4, longsize=8, ptrsize=8, doublesize=8
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
alignbytes=8, usemymalloc=y, prototype=define
>This has no relevance to the above problem.
Yeah, well, it was a shot in the dark.
--
Donald L. Nash, <D.Nash@utexas.edu>, PGP Key ID: 0x689DA021
The University of Texas System Office of Telecommunication Services
------------------------------
Date: Tue, 19 Jan 1999 17:45:56 GMT
From: ptimmins@netserv.unmc.edu
Subject: Re: perl Help
Message-Id: <782gch$a3j$1@nnrp1.dejanews.com>
In article <slrn7a7qfp.1uc.sholden@pgrad.cs.usyd.edu.au>,
sholden@cs.usyd.edu.au (Sam Holden) wrote:
> Well that 'obviously' made me actually check since nothing is ever 'obvious'
waaaaaaaaaaaaaaah!
> when dealing with stupidly complex (for the situation) data structures...
good recovery!
> And I came to the conclusion that I would just use substr, as the FAQ says,
> as my answer said, as everyone elses answer said... What if I have to access
> the characters a lot you ask... well I'd still use substr :
[snip the benchmarking that totally missed the obvious point I was making]
The only reason for using the 'stupidly complex' 'reference crap' is to
store the information for later use in the program. That's obvious. If the
original poster doesn't need the information elsewhere, then there would be
no need to do this. That's obvious.
To me, it sounded like he might have to get at the information at some other
point in the program:
> I need to find a way to return a certain character of a string, counting from
> the beginning
> ie: string = 'abcd', character 1 of string = 'a', 2='b', etc
" string2 = 'efgh', character 1 of string2 = 'e', 2='f', etc, etc "
seemed like a natural progression to me, so I gave him a more complex
data structure to track all the info. You're right, he probably didn't need
this, but if he didn't, then he asked a FAQ (or a variation on a FAQ), as
you stated. I just gave him the benefit of the doubt.
Really, I was thinking he had a top-secret mission to decode secret
messages about the Clinton impeachment trial:
$row = 0;
while (<DATA>) {
chomp;
$chr[$row]{string} = $_;
@tmp = split //;
for ($i=0; $i<@tmp; $i++) {
$chr[$row]{char}[$i] = $tmp[$i];
}
$row++;
}
@secret = qw(09 197 181 73 98 102 69 183 32 119 120 286 88 35 59 42 74 261
86 151 22 267 59 104 95 10 33 224 47 108 192 200 305 47 09 197 181 73 98
102 69 183 32 119 120 286 88 35 175 50 25 77 146 133 97 16 00 203
09 203 90 106 281);
foreach (@secret) {
($c, $r) = /(.*)(.)/;
push @message, $chr[$r]{char}[$c];
}
print @message,"\n";
__DATA__
mary had a little lamb,
it's fleece was red as roses.
the rain in spain falls
mainly on the senate-chamber.
the sheep's in the meadow
the cow's in the tobacco field.
jack be nimble, jack be quick,
jack jumps into the waiting limo.
if you're happy and you know it,
I've got a lovely bunch of coconuts.
zulu roger able dancer bomber
latern wedding jackal victor tiger
Obviously!
Patrick Timmins
$monger{Omaha}[0]
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 19 Jan 1999 18:07:37 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Perl problem :(Offline mode...
Message-Id: <782hl9$1kd$2@client2.news.psi.net>
Andrew Fry (andrewf@beausys.demon.co.uk) wrote on MCMLXVII September
MCMXCIII in <URL:news:NxesJHAhhHp2Ew6i@beausys.demon.co.uk>:
..
.. However, it is reporting the following message...
.. (offline mode : please give name=value pairs via STDIN)
.. (... or something like that) and then waiting for some
.. reply.
.. Why is it doing this ? And what is offline mode ?
Did you read the man page?
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'
------------------------------
Date: Tue, 19 Jan 1999 11:54:13 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: problem with: use module;
Message-Id: <5sg287.mjg.ln@magna.metronet.com>
Julien 'Jay' Tane (jtane@etu.info.unicaen.fr) wrote:
: I have a problem with use module;
: But it doesn't work with the modules that are in directory where the
: main script is.
The location of the module is not the problem.
The problem is the _contents_ of your Module.pm.
: when I try : perl mainfile.pl
: it stops the compilation and prints:
: Module.pm did not return a true value at mainfile.pl
: And I a not the only one to whom that happened.
^^^^^^^^^^^^^^^^^^^^
So the answer is very likely to have been included in the
documentation that is shipped with perl.
Messages that perl might issue are documented in the
'perldiag.pod' man page:
------------------
=item %s did not return a true value
(F) A required (or used) file must return a true value to indicate that
it compiled correctly and ran its initialization code correctly. It's
traditional to end such a file with a "1;", though any true value would
do. See L<perlfunc/require>.
------------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 19 Jan 1999 18:23:06 GMT
From: gward@thrak.cnri.reston.va.us (Greg Ward)
Subject: Re: Questions about cookies
Message-Id: <782iia$455$2@news0-alterdial.uu.net>
John <jdebay@NOSPAMearthlink.net> wrote:
> I have a page where I set a number of cookies from JavaScript. I then want
> to read these cookies when a seperate form is submitted. The script that
> handles the form can't seem to see the cookies. I try to read the
> HTTP_COOKIES (or whatever it is) envoronment variable, but it doesn't
> contain any data. These cookies do exist when I check through JavaScript,
> though. Is there something I'm doing wrong? Is there something special I
> have to do to get them sent to the script? The books I have are no help.
> Thanks to anyone who has any advice.
What does this have to do with Perl? Post your web programming
questions somewhere in the comp.infosystems.www.* hierarchy; this
newsgroup is for Perl questions.
Greg
--
Greg Ward - software developer gward@cnri.reston.va.us
Corporation for National Research Initiatives
1895 Preston White Drive voice: +1-703-620-8990 x287
Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913
------------------------------
Date: 19 Jan 1999 18:24:27 GMT
From: gward@thrak.cnri.reston.va.us (Greg Ward)
Subject: Re: Sys::Syslog problem
Message-Id: <782ikr$455$3@news0-alterdial.uu.net>
Benjamin <bench@surfshop.net.ph> wrote:
> why is that perl complains:
>
> Can't locate stdarg.ph in @INC (did you run h2ph?) (@INC contains:
> /usr/lib/perl5/i386-linux/5.00404 /usr/lib/perl5
> /usr/lib/perl5/site_perl/i386-linux /usr/lib/perl5/site_perl .) at
> /usr/lib/perl5/i386-linux/5.00404/sys/syslog.ph line 160.
> BEGIN failed--compilation aborted at syslog line 3.
You (or your sysadmin, whoever) probably didn't run 'h2ph' after
installing Perl. If you go back and look at the INSTALL file included
in the Perl source distribution, you'll see this little note right at
the very top:
# You may also wish to add these:
(cd /usr/include && h2ph *.h sys/*.h)
(installhtml --help)
(cd pod && make tex && <process the latex files>)
You want to run the first of these.
Greg
--
Greg Ward - software developer gward@cnri.reston.va.us
Corporation for National Research Initiatives
1895 Preston White Drive voice: +1-703-620-8990 x287
Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913
------------------------------
Date: 19 Jan 1999 18:33:08 GMT
From: bobw@sr.hp.com (Bob Waltenspiel)
Subject: Re: Using GetOptions?
Message-Id: <782j54$gn6@canyon.sr.hp.com>
Ronald J Kimball (rjk@linguist.dartmouth.edu) wrote:
: Which O'Reilly books are you looking at, exactly?
: Programming Perl, 2nd ed., page 447:
This is exactly what I wanted. I overlooked this paragraph. Thanks
for pointing it out to me.
-Bob
--
Bob Waltenspiel
HP Microwave Instruments Division | phone: (707) 577-3091
web page: http://web.sr.hp.com/~bobw | e-mail: bob_waltenspiel@hp.com
------------------------------
Date: Tue, 19 Jan 1999 18:24:52 GMT
From: Jay Frase <jay.frase@boeing.com>
Subject: Using Perl OLE to convert Excel xls to txt
Message-Id: <36A4CDF4.8C75567D@boeing.com>
Has anyone had success in converting an Excel spreadsheet to text using the OLE
extensions to Perl? If so, can you give me an example?
--
Thanks,
Jay Frase
Boeing -- PC Hardware Technologies
Admin for http://pchelp.ca.boeing.com (intranet)
http://home1.gte.net/frasej/ (internet - Reef pictures)
------------------------------
Date: 12 Dec 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 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 4690
**************************************