[6283] in Perl-Users-Digest
Perl-Users Digest, Issue: 905 Volume: 7
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 6 11:08:24 1997
Date: Thu, 6 Feb 97 07:00:26 -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 Thu, 6 Feb 1997 Volume: 7 Number: 905
Today's topics:
Re: <Newbie>Incorporating a JavaScript into a Perl scri (Mike Stok)
Calling C from Perl5.001 (Stephen Guidon)
checking existance HTML-pages and webserver (Eddy De Clercq)
Re: Compiling perl _as_ a shared library? <tchrist@mox.perl.com>
Re: Compiling strings at runtime <tchrist@mox.perl.com>
Re: Division and Rounding <tchrist@mox.perl.com>
Re: Fast list search <tchrist@mox.perl.com>
Re: filehandles in recursive calls <rra@cs.stanford.edu>
Re: filehandles in recursive calls <tchrist@mox.perl.com>
Re: FTP Client (Nathan V. Patwardhan)
GUIs in NT/95 <bap1002@hermes.cam.ac.uk>
Re: GUIs in NT/95 (Nathan V. Patwardhan)
hget.pl, chat2.pl and socket.ph problems (Eddy De Clercq)
Re: How to do this using perl? (Bennett Todd)
Re: How to do this using perl? (Bennett Todd)
Re: How to do this using perl? <tchrist@mox.perl.com>
Re: Interfacing existing C library to OO perl module (Steffen Beyer)
Re: Maximum to size of string? <rra@cs.stanford.edu>
Re: Maximum to size of string? <tchrist@mox.perl.com>
Modem/Serial Communication NT--Problem/Help <tejo_carlos@jpmorgan.com>
Re: Newbie questions <e8726057@student.tuwien.ac.at>
Newbie: Compiling Perl (ScottRassbach)
PERL + OLE rseshadr@trilogy-cnslt.com
perl 4.036 for IRIX 6.4 <bobmusa@ti.com>
Re: Perl regexes are *not* greedy (was Pattern Matching <tchrist@mox.perl.com>
Ping through Netscape on NT (Thomas M. Blanchard)
Re: Ping through Netscape on NT (Nathan V. Patwardhan)
Re: printf and % (Mike Stok)
Re: printf and % (Tad McClellan)
Re: script to mirror http site (Charlie Stross)
Re: Setuid Issues <s.farooqi@cummins.com>
Re: Using exec-Why won't this work? (Nathan V. Patwardhan)
Re: UUencoding (Neil Bowers)
Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 6 Feb 1997 11:56:08 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: <Newbie>Incorporating a JavaScript into a Perl script????
Message-Id: <5dcgso$9ku@news-central.tiac.net>
In article <32F94D1E.4C9F@its2ez.com>, It's 2 EZ Sales <ed@its2ez.com> wrote:
>I have a Perl script that generates a web page by using commands, like
>print "Content-type: text/html\n\n";
>print "<HEAD>\n";
>I also have a separate javascript that works well on my normal HTML
>page. The javascript looks like
><script language = "JavaScript">
>function Add(form, Action){
> var Add="";
>Now I want to add the JavaScript to the page that is generated by the
>Perl script. I am concerned that Perl will get confused by all the
>reserved syntax needed for the JavaScript. I doubt that
>print "var Add="";\n";
>is going to work (is it?).
There is the issue of " inside a double quoted string, perl has some
useful generalised quoting mechanisms, including
qq{}
where {} are the opening and closing quotes *but* you're allowed to have
properly balanced sets of {} in the string which don't count as quotes.
qq means double quoted context exists between the delimiters, q would give
single quoted context.
>Is there a way that I can add this JavaScript into my Perl script, so
>that the page generated by the Perl script incorporates the JavaScript?
Perl really doesn't care that much about the contents of a string once
it's done interpolation (if necessary) If you don't care about the number
of whitespace bytes sent to the browser you can say stuff like
print qq{<script language = "JavaScript">
function Add(form, Action){
var Add="";
}
</script>
};
or:
$script = qq{<script language = "JavaScript">
function Add(form, Action){
var Add="";
}
</script>
};
$script =~ s/\s+/ /g;
print "$script\n";
In both cases I have made sure that the literal {} are "legal" in the
string, you can interpolate singleton quote characters using variables if
you like. Doing something as brutal as the whitespace squishing above may
change your JavaScript, you might want somethinh that just kills leading
spaces on each line like $script =~ s/^\s+//mg;
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: Thu, 06 Feb 1997 11:08:36 GMT
From: scg@Physics.DCU.IE (Stephen Guidon)
Subject: Calling C from Perl5.001
Message-Id: <9702061109.AA26086@ruby.OCE.ORST.EDU>
A slight twist on a common question.
I know that to call C code from a perl script you should use 'perlembed'.
I tried that but it did not work. I can't remember the exact error but it
appears that I was missing 'perlembed'.
The perl I am using is version 5.001 which came with the slackware
distribution. What I need to know is, can you call C code using 'perlembed'
with version 5.001 (i.e is it my distribution that is screwed) or is it
only possible with v5.003.
(if possible cc me a copy of your reply)
Thanks
Steve.
------------------------------
Date: Thu, 06 Feb 1997 14:27:44 GMT
From: Eddy.DeClercq@coi.be (Eddy De Clercq)
Subject: checking existance HTML-pages and webserver
Message-Id: <32f9ea3c.23128026@news.bru.tfi.be>
Hi,
Does anyone has a program that checks if a webserver and/or a
HTML-page still exists on a remote server.
I've tried hget, but I always get
chat'open(www.coi.be,80): Protocol not supported
Yours thankfully,
Eddy De Clercq
COI NV
+32 16 39 38 76
Eddy.DeClercq@coi.be
------------------------------
Date: 6 Feb 1997 14:08:46 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Compiling perl _as_ a shared library?
Message-Id: <5dcole$pf8$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
austin@visi.net writes:
: What would be nice is if you could dump the code resulting
:from the compile stage of the interpreter and then just load that for
:each instance. That should cut down on the perl's usual slow startup.
:Anyone know if you can do this?
You can do this with the perl compiler. It's not so much a gain
as you think. Compile time isn't much. Here's a 5,000 line perl
script getting compiled on a sparc classic:
wraeththu% time perl -c ~/scripts/plum
/homes/tchrist/scripts/plum syntax OK
4.670u 0.660s 0:05.92 90.0% 0+871k 1+0io 0pf+0w
That's a about one second per thousand lines, which isn't too
shabby.
And here it is on a 200-Mhz Pentium Pro running Linux:
jhereg% time perl -c ~/scripts/plum
/home/tchrist/scripts/plum syntax OK
0.350u 0.020s 0:00.39 94.8% 0+0k 0+0io 190pf+0w
Now we're down to about 14,000 lines per second. Hard to complain.
: What would be even better would be a pre-forked http server
:with perl built into it, so it could load and run these dumped images
:without forking.
You need modperl for Apache, or the Fast::CGI stuff. The former method
compiles in the perl CGI programming into apache using an embedded version
of perl, while the latter method creates persistent CGI daemons.
:
: If this is a heavily used program, I would definitely look at
:re-writing it directly in C rather than using a translator. Perl may
:be faster for development, but for a heavily used application, you pay
:for that savings 1000 times over in resources and reliability.
Um, perl will be *more* reliable than C, which you pay for via resources.
Consider the data-tracking mode of tainting, automatic memory allocation
and deallocation, and mutable data typing, just to name a few. C doesn't
have these, and it hampers its reliability.
--tom
--
Tom Christiansen Perl Consultant, Gamer, Hiker tchrist@mox.perl.com
All language designers are arrogant. Goes with the territory... :-)
--Larry Wall in <1991Jul13.010945.19157@netlabs.com
------------------------------
Date: 6 Feb 1997 13:59:06 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Compiling strings at runtime
Message-Id: <5dco3a$p7r$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
davidsen@tmr.com (bill davidsen) writes:
:I have a program which reads in rather a lot of strings and uses
:them to search some text. This is being rather painfully slow, and
:I'd like to speed it. However, I don't see a good way to do the
:equivalent of /str/o using a string read in at runtime. I can't
:practically have a copy of the program for each set of match
:strings, nor do I want the confusion of having a program write
:another program and then run it.
:
:Is there a way I'm missing which will do the compile at runtime,
:like regcomp, and save the pattern?
Well, not exactly. You can use /o for some things, but it's something
that needs better language support. I've a hack-around of what's missing,
but it's not pretty. There was a Devel::Regexp module once, but it was
never really well documented nor very used.
Here's an example of the odd workaround for building up a match function
that matches any or all of a list of words against $_:
sub _bm_build {
my $condition = shift;
my @regex = @_; # this MUST not be local(); need my()
my $expr = join $condition => map { "m/\$regex[$_]/o" } (0..$#regex);
my $match_func = eval "sub { $expr }";
die if $@; # propagate @_; this shouldn't happen!
return $match_func;
}
sub bm_and { _bm_build('&&', @_) }
sub bm_or { _bm_build('||', @_) }
$f1 = bm_and qw{
xterm
(?i)window
};
$f2 = bm_or qw{
\b[Ff]ree\b
\bBSD\B
(?i)sys(tem)?\s*[V5]\b
};
# feed me /etc/termcap, prolly
while ( <> ) {
print "1: $_" if &$f1;
print "2: $_" if &$f2;
}
##############################################################
# For a really fun time, explain why this also works: :-)
##############################################################
*f1 = bm_and qw{
xterm
(?i)window
};
*f2 = bm_or qw{
\b[Ff]ree\b
\bBSD\B
(?i)sys(tem)?\s*[V5]\b
};
# feed me /etc/termcap, prolly
while ( <> ) {
print "1: $_" if f1();
print "2: $_" if f2();
}
##############################################################
# Hm... this doesn't find syntax errors until you call it!!
# Maybe it should be either
# return scalar (&$match_func, $match_func);
# or
# return eval { &$match_func, 1 } && $match_func;
# or
# return eval { &$match_func, 1 } ? $match_func : die;
# depending on how spectacular a failure one wants, and when
##############################################################
__END__
--
Tom Christiansen Perl Consultant, Gamer, Hiker tchrist@mox.perl.com
"I think I'll side with the pissheads on this one." --Larry Wall
------------------------------
Date: 6 Feb 1997 14:22:03 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Division and Rounding
Message-Id: <5dcpeb$pmo$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
"Jeff Thistle" <jthistle@cancom.net> writes:
:I've been programming in Perl for about 1 1/2 years and consider myself
:quite competent in figuring out solutions to my own problems BUT.... I have
:always encountered difficulty with division and rounding. I have found it
:very difficult (almost impossible) to divide two numbers and end up with a
:manageable floating point as an answer (ie. a couple of decimal places).
Is there something inadequate about perl faq 4.13, which reads, "Does perl
have a round function?"? Do you have an aversion to printf() or sprintf()?
--tom
--
Tom Christiansen Perl Consultant, Gamer, Hiker tchrist@mox.perl.com
"The road to hell is paved with melting snowballs."
--Larry Wall in <1992Jul2.222039.26476@netlabs.com>
------------------------------
Date: 6 Feb 1997 14:14:56 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Fast list search
Message-Id: <5dcp10$ph2$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
"James Jardine" <jjardine@global.co.za> writes:
:Is there a fast built-in command which will tell me if a string is in a
:list?
I think we should add a new perl built-in called faq(). For example,
faq("string in list") might return:
5.5) How can I tell whether an array contains a certain element?
--tom
--
Tom Christiansen Perl Consultant, Gamer, Hiker tchrist@mox.perl.com
echo "ICK, NOTHING WORKED!!! You may have to diddle the includes.";;
--Larry Wall in Configure from the perl distribution
------------------------------
Date: 06 Feb 1997 04:40:51 -0800
From: Russ Allbery <rra@cs.stanford.edu>
To: "Samir Grover" <sgrover@elizacorp.com>
Subject: Re: filehandles in recursive calls
Message-Id: <qum6806ds4s.fsf@cyclone.stanford.edu>
[ Posted and mailed. ]
Samir Grover <sgrover@elizacorp.com> writes:
> When doCommandFile is called second time with another file name to be
> opened, DOES "perl" closes the foo.cmd, if yes how to preserve its
> filehandle.
This is because, if you look at the code, you haven't localized COMFILE,
so each recursive call uses the same filehandle, which is considered a
global variable.
> sub doCommandFile {
> local($fname);
> $fname = $_[0];
> open(COMFILE, "$fname") or die "Can't open '$fname'\n";
> while ($x = <COMFILE>)
> {
> if ($something)
> {
> ...
> } elsif ($x = $something)
> {
> @data = split(" ", $x);
> &doCommandFile($data[1]);
> } elsif ($something)
> {
> ...
> }
> }
> } # End of Routine
There are a couple of good ways in which this can be handled. The most
straightforward given your existing code is probably to localize the
filehandle by inserting:
local (*COMFILE);
into the beginning of the routine. Another approach (which I actually
prefer) is to use the FileHandle module (or IO::File with more recent
versions of Perl) and do something like:
use FileHandle; # use IO::File preferred as of 5.004
sub doCommandFile {
my ($fname) = @_;
my $fh = new FileHandle $fname or die "cannot open $fname";
while (defined ($x = <$fh>)) {
...
}
}
--
Russ Allbery (rra@cs.stanford.edu) <URL:http://www.eyrie.org/~eagle/>
------------------------------
Date: 6 Feb 1997 14:19:11 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: filehandles in recursive calls
Message-Id: <5dcp8v$pml$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
"Samir Grover" <sgrover@elizacorp.com> writes:
:
:sub doCommandFile {
: local($fname);
: $fname = $_[0];
: open(COMFILE, "$fname") or die "Can't open '$fname'\n";
: while ($x = <COMFILE>) {
: if ($something) {
: ...
: } elsif ($x = $something) {
: @data = split(" ", $x);
: &doCommandFile($data[1]);
: } elsif ($something) {
: ...
: }
: }
:} # End of Routine
Don't you think you'd better localize *COMFILE in your function
rather than stepping on a global? Was there something in FAQ 5.25
that you didn't understand? You could also go the OO route and
make new FileHandle thingies each time.
--tom
--
Tom Christiansen Perl Consultant, Gamer, Hiker tchrist@mox.perl.com
I'm TRYING to be a back end! - --Andrew Hume
------------------------------
Date: 6 Feb 1997 13:51:55 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: FTP Client
Message-Id: <5dcnlr$39p@fridge-nf0.shore.net>
A MAGIC STORE (max@amagicstore.com) wrote:
: I've programmed a couple of scripts in Perl, I've uploaded them to my
: server (UNIX) but they are not working. My server said that there is a
: ^M (new line) at the end of each line. I'm using Win95 Notepad.
If you're using Emacs on your Unix box, you can do a replace-string
to replace the ^M with a carriage return (or nothing for that matter).
Otherwise, you can substitute \015 for whatever. HTH!
--
Nathan V. Patwardhan
nvp@shore.net
"Hello, good citizen. I'm Batman.
Would you like to be my assistant?
Would you like to ride with me?
Would you like to ride with Batman?"
------------------------------
Date: Thu, 06 Feb 1997 13:33:00 +0000
From: Bruce Pagram <bap1002@hermes.cam.ac.uk>
Subject: GUIs in NT/95
Message-Id: <32F9DD8C.4ED2@hermes.cam.ac.uk>
What's the best way of giving a Perl app a GUI under NT/95? I want to do
something a little bit more interactive than plain shelling out from VB.
Bruce
------------------------------
Date: 6 Feb 1997 14:07:05 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: GUIs in NT/95
Message-Id: <5dcoi9$39p@fridge-nf0.shore.net>
Bruce Pagram (bap1002@hermes.cam.ac.uk) wrote:
: What's the best way of giving a Perl app a GUI under NT/95? I want to do
: something a little bit more interactive than plain shelling out from VB.
There is not a pTk port for Windows NT to my knowledge.
--
Nathan V. Patwardhan
nvp@shore.net
"Hello, good citizen. I'm Batman.
Would you like to be my assistant?
Would you like to ride with me?
Would you like to ride with Batman?"
------------------------------
Date: Thu, 06 Feb 1997 14:26:12 GMT
From: Eddy.DeClercq@coi.be (Eddy De Clercq)
Subject: hget.pl, chat2.pl and socket.ph problems
Message-Id: <32f9e9c1.23004678@news.bru.tfi.be>
Hi,
I try to use hget, which calls chat2.pl.
Chat2.pl has an include socket.ph, which I didn't have (why?).
I managed to download it somewhere and also downloaded a other
chat2.pl, without this include.
When I try to run
hget http://www.coi.be
I always get the folowing error message from chat2.pl
chat'open(www.coi.be,80): Protocol not supported
Does anyone has a clue or idea?
Yours thankfully,
Eddy De Clercq
COI NV
Eddy.DeClercq@coi.be
+32 16 39 38 76
------------------------------
Date: Thu, 6 Feb 1997 12:47:54 GMT
From: bet@nospam.interactive.net (Bennett Todd)
Subject: Re: How to do this using perl?
Message-Id: <slrn5fjknp.b67.bet@onyx.interactive.net>
On Tue, 4 Feb 1997 20:22:08 -0600, Tad McClellan <tadmc@flash.net> wrote:
>I thought it was a CP/M megablunder, wasn't it?
Huh? DOS 1.0 was a dead ripoff of CP/M, but the subdirectories, with their
backslashes, were in 2.0, and I never saw anything like that in CP/M; it used
instead numbered areas or some such thing. This is purely and solely
Microsoft. Interestingly, 2.0 and a few versions after included an internal,
undocumented "switchar" setting, which could be used to make command.com use
"-" for options and "/" for paths. They dropped that out, but they kept
support at the syscall level for "/" paths, even if command.com could no
longer be asked to handle them.
But happily, all this is ancient history; anybody with half a clue runs Linux
or FreeBSD or NetBSD or OpenBSD or .... If someone has having problems with
Microsoft software let 'em enjoy their problems, they are paying enough for
the privilege of having them.
-Bennett
------------------------------
Date: Thu, 6 Feb 1997 12:53:34 GMT
From: bet@nospam.interactive.net (Bennett Todd)
Subject: Re: How to do this using perl?
Message-Id: <slrn5fjl2d.b67.bet@onyx.interactive.net>
On 3 Feb 1997 22:30:27 GMT, Samir Grover <sgrover@elizacorp.com> wrote:
>@data = split("\", "c:\speech\work");
Not good. Backslash is the escape character within string literals in many
Unix tools --- including Perl. So it needs doubling.
>I want to split "c:\speech\work" into array of "c:", "speech" and "work".
>
>"\" is creating a problem for perl compiler.
Well, you could write
@data = split /\\/, "c:\\speech\\work";
but you'd be better off working with the routines in File::Basename; they
provide logical-level pathname parsing operators that are portable from OS to
OS.
-Bennett
------------------------------
Date: 6 Feb 1997 13:54:36 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: How to do this using perl?
Message-Id: <5dcnqs$p1t$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
abigail@ny.fnx.com writes:
:++ @elements = split( m#/#, "c:/speech/work" );
:++ Yes, the real slashes work just fine in pathnames.
:++
:
:What's the problem with:
:
: @data = split /\\/, 'cl:\speech\work';
:Seems to work for me.
Try passing that path in as a regexp:
$path = 'cl:\speech\work';
if ($file =~ /^$path/) { ... }
I'm just really tired all the confusion and brokenness caused by the
idiotic backslashes as a separator when all the world (well, C and Unix
and all the derivatives of these) uses them as escape characters. I'm
tired of seeing "\foo\bar\nooobie" from people who don't understand why
it doesn't work.
So I espouse using *nothing* but slashes for the separater. Ever. It
works on the dumb systems, too, so there's no need to get all confused
by using the stoopid backslashes in a way that's bound to haunt you.
--tom
--
Tom Christiansen Perl Consultant, Gamer, Hiker tchrist@mox.perl.com
Hey, I had to let awk be better at *something*... :-)
--Larry Wall in <1991Nov7.200504.25280@netlabs.com>1
------------------------------
Date: 6 Feb 1997 07:18:03 GMT
From: sb@sdm.de (Steffen Beyer)
Subject: Re: Interfacing existing C library to OO perl module
Message-Id: <5dc0jb$d2k@sunti1.sdm.de>
[mailed && posted]
In article <8ju3ntrgje.fsf@nynexst.com>,
Tom Fawcett (fawcett@nynexst.com) wrote:
> I'm working with a C library that is implicitly object oriented. Every
> function takes a CONTEXT argument which is a pointer to a large C structure
> containing contextual data. I'm writing an XS interface module for the
> library.
> Instead of a translating the function interface literally, I'd prefer
> to make the Perl module object-oriented. I've gone through perlxs,
> perlxstut, perlapi and perlguts, and unless I missed something there's
> no discussion of this. Can someone point me to an example of a
> Perl<->C object-oriented interface?
My module "Set::IntegerFast" does this.
You can find it on CPAN (for a list of CPAN ftp sites near you, see "The
Perl 5 Module List" in comp.lang.perl.modules, or direct your browser to
http://www.perl.com/CPAN/modules/by-module/Set/Set-IntegerFast-3.2.tar.gz
directly) under
CPAN/authors/id/STBEY/Set-IntegerFast-3.2.tar.gz
or
CPAN/modules/by-category/06_Data_Type_Utilities/Set/Set-IntegerFast-3.2.tar.gz
or
CPAN/modules/by-module/Set/Set-IntegerFast-3.2.tar.gz
The module handles all arguments passed to it itself, not via a typemap,
which makes things much easier in an OO context.
(For instance, if you want $set = Set::IntegerFast->new(200); as well as
$newset = $set->new(500); to work properly, this is a must!)
> Thanks,
> -Tom
Hope this helps.
Yours,
--
|s |d &|m | Steffen Beyer <sb@sdm.de> (+49 89) 63812-244 fax -150
| | | | software design & management GmbH & Co. KG
| | | | Thomas-Dehler-Str. 27, 81737 Munich, Germany.
------------------------------
Date: 06 Feb 1997 03:57:13 -0800
From: Russ Allbery <rra@cs.stanford.edu>
To: boekhold@elektron.et.tudelft.nl (M.Boekhold)
Subject: Re: Maximum to size of string?
Message-Id: <qumafpidu5i.fsf@cyclone.stanford.edu>
[ Posted and mailed. ]
M Boekhold <boekhold@elektron.et.tudelft.nl> writes:
> Is there a limit to the size of a string in Perl5? I have a cgi-0script
> that now chokes. It uses *really* large strings (I put an entire
> HTML-table into a string, which makes it easy for me to work with
> template-files for the html-output). It looks to me as if mytable just
> doesn't fit into the string anymore, it is broken of somewhere right in
> the middle.
The only limit to the size of Perl strings is the size of your computer's
memory. String size shouldn't be the problem here.
> It also may have something to do with the regex-stuff, since I do
> something like: $line =~ s/TABLE/$table/, or even with print (print
> $line).
Neither of these should have a problem with long strings either. Have you
tried printing out the string at each stage to see where things break?
> This is with perl 5.003_07 with suid security patch on a BSDI/2.1
> system.
You're using a development release of Perl, and the development releases
tend to have things randomly break which are then fixed in the next
release since they aren't intended to be stable. If you're going to use
development releases, you should probably stay current (the latest is
_25); otherwise, try going back to straight 5.003 and see if that works
better.
--
Russ Allbery (rra@cs.stanford.edu) <URL:http://www.eyrie.org/~eagle/>
------------------------------
Date: 6 Feb 1997 14:11:42 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Maximum to size of string?
Message-Id: <5dcoqv$pfe$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Tom Phoenix <rootbeer@teleport.com> writes:
:On 5 Feb 1997, M.Boekhold wrote something like:
:
:> Is there a limit to the size of a string in Perl?
:
:Yes. You can't have one larger than your available memory.
^
^
^ virtual memory.
--tom
--
Tom Christiansen Perl Consultant, Gamer, Hiker tchrist@mox.perl.com
"SPARC" is "CRAPS" backwards --Rob Pike
------------------------------
Date: Thu, 06 Feb 1997 07:40:46 -0500
From: Carlos Tejo <tejo_carlos@jpmorgan.com>
Subject: Modem/Serial Communication NT--Problem/Help
Message-Id: <32F9D14E.2F24@jpmorgan.com>
I'm trying to write a script that communicates with a modem.
Here's a code snippet:
$port="COM1";
#`mode com1:9600,n,8,1`; #Do I need to do this?
#print "I just set mode\n";
open(GANDALF,"+>COM1")||die "Can't open $port\n";
print "I just opened the serial port\n";
print GANDALF "AT\r"; #tried \n also
print "I just printed to the serial port\n";
$output=read GANDALF,$readbuf,80; #not sure if this is right way!!!
# sleep 6; #Tried to introduce some waiting
print "I just read from the serial port\n";
print $output; # to see how many characters came back
I'm not sure what the right way is to receive messages from
the serial port. The above way is not working. $output is zero.
What am I doing wrong? Eventually I want to write a script
that communicates with our modem pool and I will need to parse
a variety of output from the pool manager. While we're at it, how
can I send a CTRL-BREAK to the serial port? Thanks in advance.
Carlos
------------------------------
Date: Thu, 06 Feb 1997 15:03:21 +0100
From: Klaus Johannes Rusch <e8726057@student.tuwien.ac.at>
Subject: Re: Newbie questions
Message-Id: <32F9E4A9.23F9@student.tuwien.ac.at>
Chris Raettig ['Scooby'] wrote:
> 1) How can I make the output of my Perl program appear at the bottom of a HTML
> file. I have written a counter program which outputs text. I don't think this is
> classed actually as a CGI script, or is it?
Well, include it at the bottom of your HTML source as server side
include.
> 2) Is there a function that would return the number of lines in a text file?
lines = 0;
lines++ while(<FILE>);
> 3) What is the best way of seeding the random number generator? Doing it via
> time seems to lead to similar results if the numbers are taken in a very short
> time period.
Perhaps a combination of time and pid might be more random, unless you
run many threads under the same process.
Klaus Johannes Rusch
--
e8726057@student.tuwien.ac.at, KlausRusch@atmedia.net
http://www.atmedia.net/KlausRusch/
------------------------------
Date: Thu, 06 Feb 97 08:22:00 CST
From: ScottR@ssec.wisc.edu (ScottRassbach)
Subject: Newbie: Compiling Perl
Message-Id: <32F9DB2D@msmail.ssec.wisc.edu>
I have written a perl script/program (my terminology is vague). I am
wondering how I can make it so that I can call it from my HTML file, i guess
make it executable or whatever (I know I have to have it in the cgi-bin
directory). I've looked on my man pages and in FAQs, and I can't find this
small piece of information.
If you can a) tell me how to do it or b) tell me where to look it would be a
great help. Please feel free to deluge me with email on this simple
problem.
A little knowledge is a dangerous thing. :-)
Thanks.
-Scott Rassbach
scottr@ssec.wisc.edu
------------------------------
Date: Thu, 06 Feb 1997 08:01:11 -0600
From: rseshadr@trilogy-cnslt.com
Subject: PERL + OLE
Message-Id: <855235981.30785@dejanews.com>
Dear Experts,
I'm currently using Perl script to start a SAS OLE server session. My
problem is everytime when I issue a Perl script it starts a NEW SAS OLE
session. I'm trying to use "GETOBJECTS" function to solve this problem but
the syntax in not working in PERL! Any ideas/suggestions would be grealty
appreciated. Thanks in advance.
-Raj
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Thu, 06 Feb 1997 08:33:46 -0600
From: Bob Musa <bobmusa@ti.com>
Subject: perl 4.036 for IRIX 6.4
Message-Id: <32F9EBCA.309F@ti.com>
Does anyone know where I can get the perl binary to run on the IRIX 6.4
OS? I am looking for perl 4.036.
Thanks,
Bobmusa@ti.com
------------------------------
Date: 6 Feb 1997 13:46:10 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Perl regexes are *not* greedy (was Pattern Matching Question)
Message-Id: <5dcnb2$p1r$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
mike@stok.co.uk writes:
:In article <E54yH3.EnB@drnews.dr.lucent.com>,
:You might feel happier if you check out Jeffrey Friedl's Mastering Regular
:Expressions book which has illuminated several nooks & crannies in perl's
:handling or regexes (amongst other languages...)
Now we just need a book to illuminate perl's crooks and nannies. :-)
--tom
--
Tom Christiansen Perl Consultant, Gamer, Hiker tchrist@mox.perl.com
Hey, I had to let awk be better at *something*... :-)
--Larry Wall in <1991Nov7.200504.25280@netlabs.com>1
------------------------------
Date: Thu, 06 Feb 1997 12:58:02 GMT
From: tmblanchard@mar.lmco.com (Thomas M. Blanchard)
Subject: Ping through Netscape on NT
Message-Id: <32f9d3cb.132762625@butch.lmsc.lockheed.com>
Can anybody help with how to make "Ping" work through Netscape on NT
systems using Perl? I'm familiar with CGI, Perl, etc., and use both
Purveyor and MS IIS web servers on NT systems.
I'd like to try to use "Ping" so that the replies are reflected back
in HTML. I've tried simply re-directing the NT Ping replies to a text
file, and then allowing Netscape to access the text file, but it
doesn't work.
How do I use "Ping" within a Perl script, so that I can write the
replies to a HTML file on the fly?
Tom Blanchard tmblanchard@mar.lmco.com
Lockheed Martin Aeronautical Systems
Facilities Engineering
Marietta, GA 30063
------------------------------
Date: 6 Feb 1997 14:06:30 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Ping through Netscape on NT
Message-Id: <5dcoh6$39p@fridge-nf0.shore.net>
Thomas M. Blanchard (tmblanchard@mar.lmco.com) wrote:
: How do I use "Ping" within a Perl script, so that I can write the
: replies to a HTML file on the fly?
Server-side includes, which makes this a server question, not a Perl
question. :-) You might find answers in comp.infosystems.www.servers.misc.
In terms of the Perl part, do:
$pingvar = `/usr/etc/ping hostname`;
print("Ping response from host: $pingvar\n");
--
Nathan V. Patwardhan
nvp@shore.net
"Hello, good citizen. I'm Batman.
Would you like to be my assistant?
Would you like to ride with me?
Would you like to ride with Batman?"
------------------------------
Date: 6 Feb 1997 12:11:03 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: printf and %
Message-Id: <5dchon$ahj@news-central.tiac.net>
In article <01bc140b$196e8340$1b4281ce@davekris>,
David & Kristen <drwill@loginet.com> wrote:
>I'm trying to format the output of a calculated percentage.
>
>I can do:
> printf MYFILE "Answer is %3.2f \n", $variable
>
>But what I really want is the output to look like this:
> Answer is 100.00 %
You might try
$variable = 100;
printf MYFILE "Answer is %3.2f %%\n", $variable;
one use of the \ escaping is when perl is processing double quoteds
strings as it compiles the program, so the \n gets turned into (say) a
newline, and an escape like \% just gets turned into %
Your C library documentation should mention that one of the conversion
characters allowed after a % in a format string is:
[...]
5. A character that indicates the type of conversion to be applied, as
follows:
% Performs no conversion. Prints a % (percent sign).
[...]
according to my Digital Unix box.
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: Thu, 6 Feb 1997 06:17:38 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: printf and %
Message-Id: <25icd5.rk.ln@localhost>
David & Kristen (drwill@loginet.com) wrote:
: I'm trying to format the output of a calculated percentage.
: I can do:
: printf MYFILE "Answer is %3.2f \n", $variable
: But what I really want is the output to look like this:
: Answer is 100.00 %
: with the % sign after it. Obviously, printf thinks I'm trying to format
: something when I put the % sign after it so it's not working. So I try
^
"%" is a kind of escape in format strings.
: prefixing the % sign with a backslash intending for PERL to understand I
: literally want a "%". But it still doesn't work.
^^^^^^^^^^^^^^^^^^^
So you need to escape the escape (but the escape is % not \ )
: Any suggestions? Please e-mail!
printf MYFILE "Answer is %3.2f %%\n", $variable;
# ^^
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Thu, 6 Feb 1997 12:34:18 -0000
From: charlie@antipope.org (Charlie Stross)
Subject: Re: script to mirror http site
Message-Id: <MPG.d63e025f7cc3824989681@news.demon.co.uk>
In article <kuwayama-ya02408000R0502971023420001@news.acns.nwu.edu>,
kuwayama@nwu.edu says...
> Hi all, does anyone know what the most efficient way to mirror a web server
> via a perl script would be? I'd appreciate any help.
Look on CPAN for LWP (Lib-WWW Perl). Any version greater than 5.0 will
do. Note that you need Perl 5 to use it.
Among other things, LWP includes some demo scripts, including one
-- LWP-RGET -- that will recursively mirror a website.
Caveat: LWP-RGET (at least, the last version I tried) dumps all the
retrieved files into the same directory. However, modifying it to
build a directory tree mirroring that on the server is a fairly easy
exercise.
-- Charlie Stross
------------------------------
Date: Thu, 06 Feb 1997 09:39:40 -0500
From: Suheb Farooqi <s.farooqi@cummins.com>
Subject: Re: Setuid Issues
Message-Id: <32F9ED2C.466B@cummins.com>
Tom Phoenix wrote:
>
> I believe you'll need to disable autoloading in CGI.pm. There should be
> instructions near the beginning of that file on how to do that. If you
> can't find them, you may need to get a more recent version of CGI.pm.
>
> If you have further error messages from Perl, be sure to see what perldiag
> has to say about them. Hope this helps!
Thanx for your reply, I got it to work by disabling autoloading.
However, is there a way to make work SelfLoader work with setuid
scripts.
Without Autoloader, the script will take longer to run.
-suheb
------------------------------
Date: 6 Feb 1997 14:03:56 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Using exec-Why won't this work?
Message-Id: <5dcocc$39p@fridge-nf0.shore.net>
D.M. Johnson (ez045864@peseta.ucdavis.edu) wrote:
: #!/pkg/bin/perl
: $pass = "couctrx";
: print "This prints out fine\n";
: exec "echo $pass | spell > temp";
Why aren't you returning errors?
$pass = 'couctrx';
open(PIPE, "echo $pass |spell > temp |") || die("NO: $!\n");
chop($var = <PIPE>);
close(PIPE);
If I'm correct, spell returns the word if it's not spelled correctly,
or nothing otherwise. Yes, this is correct. When I do: $pass = 'dog';
(or some other common word), temp is empty. When I set $pass to an
unknown word, like 'fdjasdrspir' spell fails, the file is populated.
You can open the file:
$file = 'temp';
open(FILE, "$file")
|| die("Nada: $!\n");
chop($line = <FILE>);
close(FILE);
print("LINE: $line\n");
--
Nathan V. Patwardhan
nvp@shore.net
"Hello, good citizen. I'm Batman.
Would you like to be my assistant?
Would you like to ride with me?
Would you like to ride with Batman?"
------------------------------
Date: Thu, 6 Feb 1997 14:45:53 GMT
From: neilb@cre.canon.co.uk (Neil Bowers)
Subject: Re: UUencoding
Message-Id: <E56roH.7H7@canon.co.uk>
Matteo Pelati <pelatimtt@poboxes.com> wrote:
: I'm looking for a perl module that allow me to read and write uuencoded
: text strings?
There is a Convert::UU module on CPAN:
http://perl.org/CPAN/modules/by-authors/id/ANDK/Convert-UU-0.02.readme
http://perl.org/CPAN/modules/by-authors/id/ANDK/Convert-UU-0.02.tar.gz
The man page starts out:
NAME
Convert::UU, uuencode, uudecode - Perl module for uuencode
and uudecode
SYNOPSIS
use Convert::UU qw(uudecode uuencode);
$encoded_string = uuencode($string,[$filename],[$mode]);
($string,$filename,$mode) = uudecode($string);
$string = uudecode($string); # in scalar context
neilb
--
At least even the the UNIX implementations that I hate, it didn't appear that
the designers were totally insane with a vindictive streak.
-- Mike Chowla, on Windows NT
------------------------------
Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Jan 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.
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 V7 Issue 905
*************************************