[7142] in Perl-Users-Digest
Perl-Users Digest, Issue: 767 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 24 06:17:44 1997
Date: Thu, 24 Jul 97 03:00:28 -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 Thu, 24 Jul 1997 Volume: 8 Number: 767
Today's topics:
Re: alarm (mis) function??? <bkyan@mindcast.com>
Re: Arrays, FILEHANDLES, and Efficiency <clark@s3i.com>
Date to Number function? (Scott Card)
Help requested on Telnet program jtstepni@socs.uts.edu.au
Re: HELP: Innocuous return stmt yields errors (M.J.T. Guy)
how to download <wongmeik@iscs.nus.edu.sg>
How to include perl header files? <schattev@imb-jena.de>
Re: How to s/TARGET_TEXT/&Subroutine;/gi; (Simon Hyde)
Re: How to s/TARGET_TEXT/&Subroutine;/gi; (Clay Shirky)
Re: How to set precision <rootbeer@teleport.com>
Re: Looking for a routine to trim white space (like VB <rootbeer@teleport.com>
Re: Matching lowercase in regexp? (Tad McClellan)
Re: Newbie: Backtracking with regexp <rootbeer@teleport.com>
Re: Newbie: Backtracking with regexp <kvan@diku.dk>
Re: problem searching w/ string ridden with metachars. <sfairey@adc.metrica.co.uk>
Re: Problems Installing Libnet Bundle <Unix> (Danny Aldham)
Re: prototyping subroutines...not working (Terry Michael Fletcher - PCD ~)
Re: Q: empty elements in arrays (Tony Bass)
Re: Q: perl ver of fflush(STDOUT) <mark@tstonramp.com>
Question: MacPerl & "require" <mxu@eecs.ukans.edu>
Re: read last line without reading previous lines, how? (Bob Wilkinson)
Re: read last line without reading previous lines, how? <rootbeer@teleport.com>
Re: rlogin with Perl (Matthew H. Gerlach)
Seeking object enlightenment (Neil Kandalgaonkar)
Re: Some problem! <sfairey@adc.metrica.co.uk>
Re: stdout problem <rootbeer@teleport.com>
telling 1/1000 of a second <kin@wco.com>
test <mxu@eecs.ukans.edu>
TeX::DVI::Parse module (Honza Pazdziora)
Trees (Guido Wimmel)
Re: Trees <sfairey@adc.metrica.co.uk>
trying to get parameters from web browser <mikec@dlpco.com>
Re: unpack suitability <rootbeer@teleport.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 24 Jul 1997 01:21:02 -0700
From: Benjamin Kyan <bkyan@mindcast.com>
To: Bob Mariotti <bobm@cunix.com>
Subject: Re: alarm (mis) function???
Message-Id: <33D7106E.4116FB0D@mindcast.com>
Bob Mariotti wrote:
>
> We have several perl5 modules that use backtics to execute a c program
> which works quite well. However, there are times when the c program
> cannot complete (due to i/o timeout). We therefore implemented the
> alarm function and detected the interrupt signal to impose and handle
> this potential time-out situation. We tested it thoroughly from the
> command line and it functions perfectly based on the state of the c
> program.
>
> But, when we attempt to use it via the server (FastTrack 2.01c) is
> ALWAYS interrupts IMMEDIATELY and gives NO signal of alarm.
>
> Without changing ANYTHING we execute the SAME module from the command
> line and it WORKS!
>
> Any ideas????
I have used alarm() successfully with Apache and NS
Communications Server, so I don't think it is an inherent
problem with the fact that it is being used as a CGI,
unless it is something specific to how FastTrack handles
CGI's. Perhaps you should illustrate the code fragment
you are trying to use?
--
Best Regards,
Benjamin Kyan
bkyan@mindcast.com
========================== ======================== ==============
Clickstream Communications 9101 W. Sahara, #105-183 T 404.685.0852
(website) www.mindcast.com Las Vegas, Nevada 89117 F 404.685.0853
========================== ======================== ==============
------------------------------
Date: 23 Jul 1997 12:12:41 -0400
From: Clark Dorman <clark@s3i.com>
Subject: Re: Arrays, FILEHANDLES, and Efficiency
Message-Id: <d204prbly.fsf@s3i.com>
preed@psd.k12.co.us (J. Paul Reed) writes:
> I need to modify one line of a large file that has a format somewhat
> similar to /etc/passwd (i.e. fields separated by a separator character,
> one entry per line).
>
> I need to have the functionality of changing one line. Is there anyway to
> do this?
While Perl is an excellent hammer, not every problem is a nail. Have
you considered using sed? Of course, you can use perl in a sed-like
way. Let's say that we need to change all the XCreateBitmapFromData
to YADA. There are various ways to do this. I'm using the tk tar
file. You could do:
sed 's/XCreateBitmapFromData/YADA/' tk4.2p2.tar > temp.dat
or the perl-ish way to do this would be:
perl -p -i.bak -e "s/XCreateBitmapFromData/YADA/" tk4.2p2.tar
(but remember that tk...tar gets changed). Both of these are faster
than doing it in a real perl script:
#!/home/dorman/bin/perl -w
use Benchmark;
$filename = "tk4.2p2.tar";
$outputfile = "temp.dat";
$filename = "tk4.2p2.tar";
$outputfile = "temp.dat";
timethese (20, {
'readin' => ' open(FN, $filename);
if (-e $outputfile) {
unlink $outputfile;
}
open( OP, ">$outputfile");
while (<FN>) {
s/XCreateBitmapFromData/YADA/;
print OP "$_";
}
close( OP );
close( FN );',
'usesed' => 'if (-e $outputfile) {
unlink $outputfile;
}
system("sed \'s/XCreateBitmapFromData/YADA/\' $filename > $outputfile" );'
} );
> Currently, I do this:
>
> 1. Open file, read it into an array, one entry per line.
> 2. Find what I want, modify it in the array.
> 3. Write the entire array back out to the file.
>
> But, this is memory and processor intensive and then people have to wait
> for this function to end before they can add entries to that file.
But, this is always going to be the case, isn't it? I really don't
understand file locking that well, but if one person is trying to
modify the file and another person is trying to do something to the
file, then somebody has to wait.
> Is there some kind of cool open() statment I can use to tell perl to both
> read in the file and write to it at the same time. I've looked in the perl
> faqs, specifically the "How do I" section and didn't find anything
> helpful.
In a perl script, you can include the -p and -i flags. See the
perlrun page, under the section on -i.
--
Clark Dorman "Evolution is cleverer than you are."
http://cns-web.bu.edu/pub/dorman/D.html -Francis Crick
------------------------------
Date: Thu, 24 Jul 1997 02:38:59 GMT
From: ils@pipcom.com (Scott Card)
Subject: Date to Number function?
Message-Id: <33d6c006.5805297@news.pipcom.com>
Is there a perl date to number function that converts the date to a
number of days from a specific date (ie Jan 1, 1980)
Thanks.
------------------------------
Date: Thu, 24 Jul 1997 11:13:42 +1000
From: jtstepni@socs.uts.edu.au
Subject: Help requested on Telnet program
Message-Id: <33D6AC46.6918@socs.uts.edu.au>
Hi,
I am writing a program to telnet to variuos routers and perform small
tasks on them. I assume it would be good to use chat2.pl, but I do not
know how to interface with it.
I need to telnet to a specified ip address and port number and send
login prompts, passwords, and exec commands - these vary for different
routers as well as the login/password prompts so I would need to expect
different responses.
Any help on this subject would be greatly appreciated
Thankyou
Joe Stepniewski <jtstepni@socs.uts.edu.au>
------------------------------
Date: 24 Jul 1997 08:05:36 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: HELP: Innocuous return stmt yields errors
Message-Id: <5r72cg$98g@lyra.csx.cam.ac.uk>
tbrannon <tbrannon@nunki.usc.edu> wrote:
>sub count_spikes {
> my ($spike_ct,$i);
> $spike_ct = 0;
> for ($i=0; $i< nelem($Persync::current_piddle); ++$i) {
> if spike_at($i) {
> ++$spike_ct;
> }
> }
> return($spike_ct);
>}
>
>yields the following errs:
>
> DB<2> use Persync
>Global symbol "spike_ct" requires explicit package name at /felix/terry/scripts/perl/Persync.pm line 204, <IN> chunk 2.
[snip]
When I run that, I get errors
syntax error at - line 6, near "if spike_at"
Global symbol "spike_ct" requires explicit package name at - line 10.
The first error is because that "if" should read
if (spike_at($i)) {
After syntax errors involving incorrect brackets, Perl tends to get
confused about scopes of lexicals, not entirely surprisingly. This is
the cause of the second error.
In cases like this, if you can explain some but not all of your compiler
errors, fix the ones you understand and try again.
Mike Guy
------------------------------
Date: 23 Jul 1997 14:09:19 GMT
From: Wong Mei Kwan <wongmeik@iscs.nus.edu.sg>
Subject: how to download
Message-Id: <5r53af$dp3@nuscc.nus.sg>
Hi!
This perl script which I need to write require the downloading of a file
from the server. Could someone please enlighten me on how to go about
doing it?
How to use ftp in cgi-perl?
I am using a WinNT server.
Thanks
Regards
MK
------------------------------
Date: Thu, 24 Jul 1997 09:29:50 +0200
From: Ruben Schattevoy <schattev@imb-jena.de>
Subject: How to include perl header files?
Message-Id: <33D7046E.3A83@imb-jena.de>
Hi,
is there another way than using the C preprocessor (which I apparently
cannot use in combination with a #!/usr/local/bin/perl line) to include
perl header files into perl code? I mean some more Perl-like
construction like require("header.pm") or use "header.pm". I get it
working with this construction:
>cat main.pl
#!/usr/local/bin/perl -w
#
use strict;
use header();
use vars qw( $test );
#
printf("test = %s\n",$test);
#
>cat header.pm
#!/usr/local/bin/perl -w
#
$test = "abc";
#
1;
But I have to use "use vars qw( $test );" which is not very comfortable
since I have to keep this statement up-to-date in all files which
include my header file. Acctually this is what I wanted to avoid by
setting up a header file!
Thanks,
Ruben
--
Ruben Schattevoy
Institut fuer Molekulare Biotechnologie,
Beutenbergstrasse 11,
07745 Jena,
Germany
------------------------------
Date: Sun, 20 Jul 1997 09:32:10 GMT
From: shyde@poboxes.com (Simon Hyde)
Subject: Re: How to s/TARGET_TEXT/&Subroutine;/gi;
Message-Id: <33d3d9db.8611901@news>
On 19 Jul 1997 20:41:24 -0400, clays@panix.com (Clay Shirky) wrote:
@I am running a search-and-replace function on an HTML file like so:
@
@for (@File) {
@ if (/(TARGET_TEXT)/i) {
@
@ &sub_to_generate_unique_variable;
@ s/$1/$unique_variable/g;
@ }
@}
@
@This leaves me the non-HTML-ish assumption that subsequent occurences
@of TARGET_TEXT are separated by at least one \n.
@
@I would much rather do something like
@
@ $unique_variable = sub { BLOCK };
@ s/TARGET_TEXT/$unique_variable/gi;
@
@if I could get each replacement, even with two on a single line, to
@re-evaluate $unique_variable.
@
@Alternatively, I could also
@
@ s/TARGET_TEXT/&sub_to_generate_unique_variable;/gi;
@
@if the sub routine returns the value of the unique variable into the
@replacement position, but I cannot get either of these methods to work.
@
you can use the /e operator to "Evaluate the right side as an expression." therefore
it will retrieve the return level of the function and place that as the replacements, ie:
s/TARGET_TEXT/&sub_to_generate_unique_variable/egi;
For more info on this and other operators take a look at the s/// section of the perlop
manpage
(http://www.perl.com/perl/nmanual/pod/perlop.html#item_s_PATERN_REPLACEMENT_egimosx).
------------------------------
Date: 20 Jul 1997 08:47:57 -0400
From: clays@panix.com (Clay Shirky)
Subject: Re: How to s/TARGET_TEXT/&Subroutine;/gi;
Message-Id: <5qt1dt$hvo@panix2.panix.com>
>> if (/(TARGET_TEXT)/i) {
>Do you have that literal text in that pattern match? Or is it a different
>pattern than you're showing us here? You may be able to do this more
>efficiently with index than with a pattern.
>> &sub_to_generate_unique_variable;
>> s/$1/$unique_variable/g;
>I don't like that substitution. (You're compiling a new pattern for each
>substitution, and you know just what text it should match already.
The answer to both of these is that "TARGET_TEXT" is a place holder
for a general class of matches, where non-CGI aware coders might be
placing the target text in the file in all sorts of different
configurations, potentially differing in each occurrence:
Imagine matching "<TARGET_TEXT><Target Text><TARGET
TEXT>"
> ... Worse,
>it might do something you really don't want if the text from $1 has
>metacharacters in it!) You should probably re-write this loop with s///eg.
Yes, which is what I did.
>And it may also be that you've made the assumption that each occurrence of
>TARGET_TEXT was contained on one line. (That may be a valid assumption,
>for that matter.)
You're right, its not a valid (e.g. HTMLish) assumption, so I switched
$/=">"; to match on close-tag chars.
>> s/TARGET_TEXT/&sub_to_generate_unique_variable;/gi;
>That one looks pretty close, but you'll want the /e modifier. Hope
>this helps!
Got it - many thanks
--
Clay Shirky
------------------------------
Date: Wed, 23 Jul 1997 19:48:49 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Jennifer & Nathan Hammontree <agnet@3rivers.net>
Subject: Re: How to set precision
Message-Id: <Pine.GSO.3.96.970723194757.9621C-100000@kelly.teleport.com>
On 23 Jul 1997, Jennifer & Nathan Hammontree wrote:
> I can't seem to find a function to set decimal precessions. Is there a
> Perl function for this, or does someone have one I can use?
Perl normally uses your system's default for double-precision floating
point numbers. If you want something different, you may want to use the
Math::BigFloat module. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 22 Jul 1997 07:19:58 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Benjamin Kyan <bkyan@mindcast.com>
Subject: Re: Looking for a routine to trim white space (like VB trim$)
Message-Id: <Pine.GSO.3.96.970722071735.19892D-100000@kelly.teleport.com>
On Mon, 21 Jul 1997, Benjamin Kyan wrote:
> > $stripped = $unstripped;
> > $stripped =~ s/^\s+//;
> > $stripped =~ s/\s+$//;
>
> ...and if you really need to do it in one pass:
>
> ($stripped = $unstripped) =~ s/^\s|\s$//g;
Besides being less efficient and harder to read, that also fails to trim
multiple leading or trailing whitespace characters. Oops! :-)
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 23 Jul 1997 07:10:42 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Matching lowercase in regexp?
Message-Id: <2cs4r5.up.ln@localhost>
Jason H. Elbaum (jhelbaum@holly.mr) wrote:
: Here's a short, simple one that I've been unable to find in
: the perl docs:
from the perlre man page:
---------------
Because patterns are processed as double quoted strings, the following
also work:
\t tab (HT, TAB)
\n newline (LF, NL)
\r return (CR)
\f form feed (FF)
\a alarm (bell) (BEL)
\e escape (think troff) (ESC)
\033 octal char (think of a PDP-11)
\x1B hex char
\c[ control char
\l lowercase next char (think vi)
\u uppercase next char (think vi)
...
---------------
: Is there a regexp meta-character which will match only an uppercase
: or only a lowercase letter? Or should I use [A-Z] and [a-z]?
: I would have thought the latter not to be recommended due to
: potential locale issues.
---------------
#! /usr/bin/perl -w
$_ = 'Jason H. Elbaum';
print "matched upper case surname\n" if /\uelbaum/;
---------------
: Thanks,
You're welcome.
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Wed, 23 Jul 1997 15:26:10 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Ronald L. Parker" <ron@farmworks.com>
Subject: Re: Newbie: Backtracking with regexp
Message-Id: <Pine.GSO.3.96.970723151749.19613E-100000@kelly.teleport.com>
On Wed, 23 Jul 1997, Ronald L. Parker wrote:
> On Wed, 23 Jul 1997 08:30:03 -0700, Tom Phoenix
> <rootbeer@teleport.com> wrote:
>
> > ($chunk) = m{
> > ^ # Starting at the top
>
> Is this strictly necessary? Won't .* start as early as possible
> anyway?
Well, the difference between a pattern match which starts with /^.* and
one which starts /.* is interesting. As you probably guessed, they match
the exact same things. But what happens when the match fails? If you don't
have an anchor, the RE engine might decide that it should "bump along" to
the next position and try again. That could take a very long time before
the engine finally gives up.
As it happens, Perl's engine is clever enough that it would have added an
anchor internally if I hadn't done that. But I put it in for completeness.
(Jeffrey Friedl's Hip Owls book has a good discussion of this and many
related matters.)
> > .* # as much stuff as possible, so that
> > # we skip all previous entries
> > ( # Memory 1 -> $chunk
> > <entry>
> > .*? # minimal match - don't overrun
>
> Surprise! You don't actually need the minimal match! You've already
> selected the last possible <entry> before the <url> you need.
Yes, but this should be more efficient. Rather than using a grabby .* to
zip to the end of the string and back up (perhaps backing up thousands of
characters) I start at the beginning and go forward (probably stepping
only a few dozen characters.) Once again, the match is the same, though.
> > <url>
> > \Qhttp://www.perl.com/\E # or whatever
> > </url>
> > .*? # minimal match - don't overrun
> > </entry>
> > )
> > }x;
>
> Another thing I noticed about this solution is that it finds the LAST
> matching entry rather than the first one as would have been found by
> the expressions the original poster attempted, had they worked as
> intended. I don't know if this is a problem.
It may be. I may have said that this was intended only if you know that
the URL appears only once.
> >...but trying to do this in just one expression may not be the best way.
> >You could probably do better by breaking up the text into chunks, with
> >each chunk being one <entry>...</entry>. Or, you could do this.
> >
> > ($pre, $match, $post) = m{
> > (^.*) # pre
> > (\Qhttp://www.perl.com\E) # match
> > (.*?</entry>) # post
> > }x;
> > $pre =~ s#^.*(?=<entry>)##; # Strip previous entries
> > $entry = "$pre$match$post"
>
> I like this. Do you know if it's more or less efficient than
> splitting it up into chunks as you suggested?
Probably depends upon the data. But you could benchmark it, I suppose.
> As written, though, this will give a false match if the desired url
> appears in another entry, outside of the <url>...</url> markers.
True. I probably should have put those markers in.
> You could make this method work to find the first match by changing
> the first .* to .*?
I believe that that would work. Have fun with it.
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 23 Jul 1997 16:26:16 +0200
From: Kvan <kvan@diku.dk>
Subject: Re: Newbie: Backtracking with regexp
Message-Id: <Pine.HPP.3.95.970723162201.11467B-100000@skade.diku.dk>
On 23 Jul 1997, Stefan Berglund wrote:
> m#(<entry>.*?<url>$url</url>.*?</entry>)#
> m#(<entry>.*?(?!</entry>)<url>$url</url>.*?</entry>)#
>
> Neither of these work.
Not in the way you'd like, no.
> Both regexps return (in $1) the same thing, starting with the very first <entry>
> and upto the </entry> in the correct block.
Both regexps contain exactly the same thing in the outermost set of
parentheses (which is what's put in $1). If you wanted to extract the
urls into $1, you should use
m#<entry>.*?(<url>$url</url>).*?</entry>#
(or move the parentheses inside the <url> tags if you don't want those
included).
Regards,
Kvan.
-------Casper Kvan Clausen------ | 'Ah, Warmark, everything that passes
---------<kvan@diku.dk>--------- | unattempted is impossible.'
'kvan' on pbmserv@eiss.erols.com |
http://www.diku.dk/students/kvan | - Lord Mhoram, Son of Variol.
------------------------------
Date: Thu, 24 Jul 1997 10:19:02 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: dcd@k12-dev.arc.nasa.gov
Subject: Re: problem searching w/ string ridden with metachars.
Message-Id: <33D71E05.A13EFE17@adc.metrica.co.uk>
dcd@k12-dev.arc.nasa.gov wrote:
> The snippet of code below is supposed to search through the text from
> an
> html file (in $data), for a search string ($search_string) of more
> html
> text. Previously I had the problem that the spacing of the text in
> $search_string was different than when it appeared in $data. I had
> several helpful suggestions and fixed the problem by saying
> $search_string =~ s/\s/\\s+/g; and $data =~ s/$search_string/$text/g;
>
> It struck me that there were probably tons of other meta characters
> that could appear in $search_string, and so I added some lines to
> backslash them out. But the resulting code below, which by my
> estimations
> should work, doesn't. If anyone could figure out why and explain it
> to
> me, I'd be very grateful.
>
> Thanks,
> David
> --------------------
> $data=join("",<DATA>);
> $text='THIS WAS THE HEADER!!'; #test replacement text
>
> $search_string = '<p>
> <center>
> <a href="/neuron/credits.html"><img border=0
> src="/neuron/images/credits.gif"></a>
> </center><p>
> '; #multi-line search string
>
> $search_string =~ s/^\s+//; #kill leading /
> $search_string =~ s/\s+$//; # / trailing white space
> $search_string =~ s/\s/\\s+/g; #collapse white space.
> $search_string =~ s/\\(?!s\+)/\\\\/g; #quote non-used backslashes
>
> $search_string =~ s/([^\\\w])/\\$1/g; #quote non-'/' metachars
>
> print "Search string is:!!$search_string!!\n";
> <stdin>;
> $data =~ s/$search_string/$text/gi;
> print $data;
>
> __DATA__
>
> <p>
> <center>
> <a href="/neuron/credits.html"><img border=0
> src="/neuron/images/credits.gif"></a>
> </center><p>
>
> <map name="neuron">
> <AREA SHAPE=rect COORDS="3,95, 85,117" HREF="/neuron">
> <AREA SHAPE=rect COORDS="98,96, 158,117"
> HREF="/cgi-bin/neuron/survey.pl">
> <AREA SHAPE=rect COORDS="166,96, 243,117"
> HREF="/cgi-bin/neuron/postcard.pl">
> <AREA SHAPE=rect COORDS="258,96, 344,117"
> HREF="/cgi-bin/neuron/neuron-wais.pl">
> <AREA SHAPE=rect COORDS="358,96, 420,117"
> HREF="/neuron/overview.html">
> <AREA SHAPE=rect COORDS="431,95, 502,118" HREF="/">
> <AREA SHAPE=default HREF="/neuron">
> </map>
> </body>
> </html>
>
> -------------------==== Posted via Deja News
> ====-----------------------
> http://www.dejanews.com/ Search, Read, Post to Usenet
Sorry but I haven't really looked at your code but from the sounds of
it you want to be using the quotemeta() function ( see perlfunc manpage
) it will deal with any meta-characters present in your search string.
Simon
------------------------------
Date: 23 Jul 1997 19:39:59 -0700
From: danny@lennon.postino.com (Danny Aldham)
Subject: Re: Problems Installing Libnet Bundle <Unix>
Message-Id: <5r6f9v$g9v$1@lennon.postino.com>
Paul Berry (pwlberry@nortel.ca) wrote:
: After typing the "perl Makefile.PL" command the following error is displayed.
: Can't locate IO/File.pm in @INC at Makefile.PL line 70.
: BEGIN failed--compilation aborted at Makefile.PL line 70.
You are on unix, right, so try:
#find / -name IO -print
#perl -e 'print @INC' ;
and see how the outputs compare.
--
Danny Aldham SCO Ace , MCSE , JAPH , DAD
I don't need to hide my e-mail address, I broke my sendmail.
------------------------------
Date: 22 Jul 1997 21:09:03 GMT
From: tfletche@pcocd2.intel.com (Terry Michael Fletcher - PCD ~)
Subject: Re: prototyping subroutines...not working
Message-Id: <5r37hf$173$1@news.fm.intel.com>
Terry Michael Fletcher - PCD ~ (tfletche@pcocd2.intel.com) wrote:
: I have been trying to get a subroutine call to work without giving it an
: empty argument, namely, to do this:
:
: sub this {
: print "finally!";
: }
:
: this;
: __END__
oops.... i have to correct myself here. the sub declaration is made in a
library that is required at the beginning of the perl file in question.
however it still does not work without giving it and empty paren argument,
or prepending an ampersand, like this:
this(); # or
&this;
it does work when predeclaring the subroutine at the top of the file, but
not when requiring it from another file. i have also tried declaring
inside the library file:
package main;
sub this () {...}
which still does not work. any insight on empty calls to subroutines
declared outside the scope of the main package?
sorry about the misleading first post.
--
"Give me ambiguity or give me something else."
______ ______ _ _
(_) | (_) | | | | |
| _ ,_ ,_ _|_ | | _ _|_ __ | | _ ,_
_ ||/ / | / | | | / | ||/ |/ | / |/ \ |/ / |
(_/ |__/ |_/ |_/ \_/|/ (_/ |__/|__/|_/\___/| |_/|__/ |_/
*+*+*+*+*+*+*+*+*+*+*+* /| *+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*
\| tfletche@pcocd2.intel.com
*+*+*+*+*+ Views expressed...not INTeL's...yadda yadda yadda.... *+*+*+*+*+*
------------------------------
Date: 23 Jul 1997 15:27:26 +0100
From: aeb@brains.cartoon.bt.co.uk (Tony Bass)
Subject: Re: Q: empty elements in arrays
Message-Id: <5r54ce$r3d$1@brains.cartoon.bt.co.uk>
>From article <33D5F444.C26@astro.estec.esa.nl>, by Uwe Lammers <Uwe.Lammers@astro.estec.esa.nl>:
> Hi,
> looking for the most efficient way to determine whether a string array
> contains empty entries, i.e.,
> ('1', '2', '3') -> no
> ('1', '2', '', '3') -> yes
if (grep(!length, LIST)) ...
Tony Bass
--
# A E Bass Tel: (01473) 645305
# MLB 3/19, BT Laboratories e-mail: aeb@saltfarm.bt.co.uk
# Martlesham Heath, Ipswich, Suffolk, IP5 7RE DO NOT e-mail to From: line
# Opinions are my own
------------------------------
Date: Wed, 23 Jul 1997 03:28:54 -0700
From: "Mark J. Schaal" <mark@tstonramp.com>
Subject: Re: Q: perl ver of fflush(STDOUT)
Message-Id: <33D5DCE6.71BA@tstonramp.com>
Eric Heft wrote:
>
> Hello,
> I'm trying to do something like this. I've tried the method
> outlined in the FAQ but can't seem to get it to work :( Heres
> the general loop structure.
>
> print "Processing :";
> for (@list)
> {
> print ".";
> ## Want to flush the buffer here.
> slowly_process($_);
> }
> print "Done!\n";
>
Funny, that's not what my copy of the FAQ has. :)
$|=1 sets the current default output filehandle to
autoflush. You could set this at the top of your
script. If for some reason you don't always want the
output to autoflush, you could do
$|=1; print "."; $|=0;
(You might want to spend a little more time on the FAQ
explanation next time.)
Hope this helps,
mark
--
Mark J. Schaal TST On Ramp Sysadmin mark@tstonramp.com
------------------------------
Date: Wed, 23 Jul 1997 21:11:26 -0500
From: Mousheng Xu <mxu@eecs.ukans.edu>
Subject: Question: MacPerl & "require"
Message-Id: <33D6B9CE.2781@eecs.ukans.edu>
In UNIX perl, if you want to include a perl file called "common.cgi",
you write
require("common.cgi");
Everything is OK. But in MacPerl, I always get an error message
'common.cgi' did not return a true value.
Any help will be highly appreciated.
Thanks in advance.
m.xu
------------------------------
Date: Wed, 23 Jul 1997 14:30:33 +0100
From: b.wilkinson@pindar.co.uk (Bob Wilkinson)
Subject: Re: read last line without reading previous lines, how?
Message-Id: <b.wilkinson-2307971430330001@ip57-york.pindar.co.uk>
In article <5qnrki$jfd$1@news.rwth-aachen.de>,
jarausch@numa1.igpm.rwth-aachen.de (Helmut Jarausch) wrote:
> In article <5qjj3s$11$1@coranto.ucs.mun.ca>, chuan@engr.mun.ca (Chuan
Wang) writes:
> |> Hi,
> |>
> |> I wonder how to reading the last line of a text file, without going through
> |> the previous lines. Thanks.
>
> Look up the man pages for 'seek', there is a mode to seek to the end of
a file.
> --
> Helmut Jarausch
> Lehrstuhl f. Numerische Mathematik
> Institute of Technology, RWTH Aachen
> D 52056 Aachen, Germany
or use
system "tail","-1",$file; # or some such variant
Bob
--
.sig file on holiday
------------------------------
Date: Wed, 23 Jul 1997 07:51:29 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Jeff Wilson <jwilson@ic.ac.uk>
Subject: Re: read last line without reading previous lines, how?
Message-Id: <Pine.GSO.3.96.970723074820.14902B-100000@kelly.teleport.com>
On 23 Jul 1997, Jeff Wilson wrote:
> Subject: Re: read last line without reading previous lines, how?
>
> Try ...
>
> open(TXT,"<textfile");
> @fred=<TXT>;
> print @fred[$#fred],"\n";
That doesn't read the last line without reading previous lines. You should
always check the return value from open(). Also, the last element of @fred
should be referenced as $fred[-1] . Thanks for trying!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 23 Jul 1997 14:22:05 GMT
From: gerlach@netcom.com (Matthew H. Gerlach)
Subject: Re: rlogin with Perl
Message-Id: <gerlachEDrzwu.85@netcom.com>
In article <33D4F3EC.4ECA@ncsa.uiuc.edu> bethazzi@ncsa.uiuc.edu writes:
>Hello,
>
>I need to write a script to log into 30 different accounts and do
>something to all of them. The password for all 30 accounts is the
>same. At the beginning of the script, the password will be entered by
>STDIN.
>
Check out Comm.pl, it has examples of just what want except that it is
using telnet instead of rlogin. You should be able to use either, provided
you are using a relatively popular UNIX variant.
Matthew
------------------------------
Date: 24 Jul 1997 07:28:54 GMT
From: neil@domingo.concordia.ca (Neil Kandalgaonkar)
Subject: Seeking object enlightenment
Message-Id: <5r707m$v89$1@newsflash.concordia.ca>
I'm a reasonably smart person, and have programmed perl for $, but I
am having difficulty understanding objects.
I've seen some general books on objects (for instance, of the C++ variety)
suggesting that objects cannot be explained, that enlightenment comes only
after years of fumbling in the dark. I can't believe that this is true. I
don't need to be spoon-fed, but that sounds like a big cop-out on the
author's part.
Part of what I don't understand about objects is that defining them and
using them always seems so redundant. It looks inefficient on paper. Maybe
if I had more understanding of what the computer was doing behind the
scenes, it would make more sense? I just don't get what's so fundamentally
wonderful about defining a series of objects with properties, rather than
making a HoL and a few subroutines. In day-to-day life, how useful are
things like polymorphism?
I stumbled onto Randal's object intro
(http://www.stonehenge.com/merlyn/UnixReview/col13.html), which helped me
more than any other tutorial has. (BTW, the de-referencing tutorial was
killer. Thanks, Randal!) However, the concepts of package and bless still
don't mean much to me.
I own Programming Perl 2nd edition. Would Learning Perl be any use to me?
How about the new Advanced Perl? Other books?
--
Neil Kandalgaonkar CUG web weaver http://cug.concordia.ca/~neil
neil@cug.concordia.ca Current moon phase: look outside
------------------------------
Date: Thu, 24 Jul 1997 10:01:16 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Some problem!
Message-Id: <33D719DB.AEF61370@adc.metrica.co.uk>
Tom Phoenix wrote:
> On Wed, 23 Jul 1997, nick wrote:
>
> > I've installed PerlIS and Perl 5 on my windows NT 4.0 and tried to
> run a
> > very simple script:
> >
> > foreach (%ENV){
> > print "The Env Variable $_ value is \"$ENV($_)\"\n";
> > }
>
> You probably want this sort of thing instead.
>
> print map { "$_: $ENV{$_}\n" } sort keys %ENV;
Nice, and simple ( I love one liners ) but using for() is quicker ( only
just ) which I didn't think it would be. Although map() appears to be a
variant of a for() loop I imagine its a case of trial and error to see
where it is quicker and what it's better at, I haven't really used map()
much; I probably will more often now.
Simon 'always looking for the fastest way to do things' F
------------------------------
Date: Wed, 23 Jul 1997 20:52:59 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Ken Sato <ksato@mda.ca>
Subject: Re: stdout problem
Message-Id: <Pine.GSO.3.96.970723205000.9621I-100000@kelly.teleport.com>
On Wed, 23 Jul 1997, Ken Sato wrote:
> I am invoking a Perl script from a Java application using the exec()
> call but I can't seem to get the stdout back in Java.
Could this be a Java problem?
> Simple Print commands get
> routed back fine through the DataInputStream ,
So, you can print output, and Java gets it?
> but for example:
>
> $output = `lpq -S prnServerName -P prnName`;
> print $output;
>
> does not print back in Java.
Maybe there's nothing to print. Try this, and see what Java gets.
$output = `lpq -S prnServerName -P prnName`;
print "Status: $?. The output was: $output";
It may be that lpq is producing no output. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 23 Jul 1997 14:25:21 -0700
From: Kenneth Kin Lum <kin@wco.com>
Subject: telling 1/1000 of a second
Message-Id: <33D676C1.D2DEA63F@wco.com>
There seems to be no function that tells the current time
accurate to 1/1000 of a second in perl? Is there any workaround?
Or, what if I just want to count the time it takes for the
program to run, also accurate to 1/1000 of a second in perl?
times() seems to tell number of seconds only.
------------------------------
Date: Wed, 23 Jul 1997 21:08:00 -0500
From: Mousheng Xu <mxu@eecs.ukans.edu>
Subject: test
Message-Id: <33D6B900.167E@eecs.ukans.edu>
xzccx
------------------------------
Date: 20 Jul 1997 15:51:00 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: TeX::DVI::Parse module
Message-Id: <5qtc54$1nl$1@nadine.teleport.com>
Hallo, I have uploaded to PAUSE TeX::DVI::Parse module, the original
location (before it gets to CPAN to authors/id/JANPAZ) is
http://www.fi.muni.cz/~adelton/perl/TeX-DVI-Parse-0.02.tar.gz
Here is a piece from man page:
TeX::DVI::Parse recognizes all commands from the DVI file and
for each command found it calls method of appropriate name, if
defined in the class.
As an example there is class TeX::DVI::Print coming in this
file, so you can do
use TeX::DVI::Parse;
my $dvi_parse = new TeX::DVI::Print("test.dvi");
$dvi_parse->parse();
and get listing of DVI's content printed in (hopefully)
readable form.
I will be glad to hear any comments, or any bug reports.
Since I did not write many parsers in my life, the approach might be
bad, so if you can comment on the programming style, I will be happy
to read. What I am curious most is the use of unpack for traversing
through the file, and also reading the file with $/ undef.
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
I can take or leave it if I please
------------------------------------------------------------------------
------------------------------
Date: 23 Jul 1997 20:03:25 GMT
From: wimmel@Informatik.TU-Muenchen.DE (Guido Wimmel)
Subject: Trees
Message-Id: <5r5o2d$28h@sunsystem5.informatik.tu-muenchen.de>
Hi all,
I want to use Perl to read a document that has got
a tree structure (record-types with subtypes, sub-
subtypes etc.). Can anyone point me to an example
how to represent this structure in Perl (I haven't
found anything about that in the FAQ).
What I'd like would be to read in the document and
then have a 'node' that has some attributes and a
list of its immediate successors, which are nodes
as well. And it should be possible to add/delete
nodes, iterate through the tree etc. I suppose
this should be possible with lists containing lists,
but I'd be happy if anyone has done it already and
can show me how.
Thanks in advance,
--
Guido Wimmel (wimmel@informatik.tu-muenchen.de)
------------------------------
Date: Thu, 24 Jul 1997 10:14:49 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: Guido Wimmel <wimmel@Informatik.TU-Muenchen.DE>
Subject: Re: Trees
Message-Id: <33D71D09.26920CA5@adc.metrica.co.uk>
Guido Wimmel wrote:
> Hi all,
>
> I want to use Perl to read a document that has got
> a tree structure (record-types with subtypes, sub-
> subtypes etc.). Can anyone point me to an example
> how to represent this structure in Perl (I haven't
> found anything about that in the FAQ).
> What I'd like would be to read in the document and
> then have a 'node' that has some attributes and a
> list of its immediate successors, which are nodes
> as well. And it should be possible to add/delete
> nodes, iterate through the tree etc. I suppose
> this should be possible with lists containing lists,
> but I'd be happy if anyone has done it already and
> can show me how.
>
> Thanks in advance,
> --
> Guido Wimmel (wimmel@informatik.tu-muenchen.de)
Personally I would use a hash of hashes, I did something similar to
generate a large hash tree which represented a directory structure. Look
at the perllol man page for further details. If you are still having
trouble ( say building the tree ) then shout.
Simon
------------------------------
Date: 23 Jul 1997 21:09:13 GMT
From: "Mike Cloppert" <mikec@dlpco.com>
Subject: trying to get parameters from web browser
Message-Id: <01bc97ab$c4b72530$058d48ce@mikec>
I'm sure this is a trivial question, but how can I pass a parameter to a
perl script as a hyperlink, and how can I then grab it inside the perl
script? I have no problems using the &GetOptions("Domain=s" => \$DOMAIN);
procedure from Getopt::Long when calling the script from the command line,
but I'm not sure how to implement this so that I can pass a parameter from
an HTML file, ex:
<a href="../cgi-bin/test.pl --Domain=mydomain">
At least, that's how I'd do it following the command line method, but I'm
sure that this isn't correct.
Any help would be greatly appreciated. Thanks
m
- - - - - - - - - - - - - - - - - - - - - - - - - -
Mike Cloppert mikec@dlpco.com
Internet Development/ http://www.dlpco.com/
Software Support Engineer
DLP Technologies, Inc.
SCO Premier Service & Support
------------------------------
Date: Wed, 23 Jul 1997 20:48:42 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: bob king <bking@dimensional.com>
Subject: Re: unpack suitability
Message-Id: <Pine.GSO.3.96.970723204504.9621H-100000@kelly.teleport.com>
On Wed, 23 Jul 1997, bob king wrote:
> I am attempting to read a string of 450 hex
> chars of length 4 and get the decimal numbers.
Do you mean that you want this? Hope this helps!
@numbers = unpack "n*", pack "H*", $hex_string;
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 767
*************************************