[18131] in Perl-Users-Digest
Perl-Users Digest, Issue: 291 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 14 21:06:03 2001
Date: Wed, 14 Feb 2001 18:05:14 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <982202714-v10-i291@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 14 Feb 2001 Volume: 10 Number: 291
Today's topics:
Re: Call C Programs from Perl <Jonathan.L.Ericson@jpl.nasa.gov>
Re: Call C Programs from Perl <michaelk@jbase.com>
Re: calling clock ! <soso@open.net>
Re: calling clock ! <nowayandnohow@hotmail.com>
Re: CRC-32 in Perl (was: Strings and pointers in Perl?) <pdcawley@bofh.org.uk>
Re: DBI <crazzeto@hotmail.com>
Determining memory usage within Perl <terrence.brannon@oracle.com>
Re: Determining memory usage within Perl <comdog@panix.com>
Re: Determining memory usage within Perl <bwalton@rochester.rr.com>
Email Attachments - Help <teamzulu@teamzulu.com>
email script problem <bmccann@naisp.net>
Re: How to scan spaces from a string of characters? <ren.maddox@tivoli.com>
HTML generator <soso@open.net>
Re: HTML generator <bwalton@rochester.rr.com>
Re: Newbie: How do I make my home Win2k IIS system run <DavePerkins@bigfoot.com>
Re: no headers using CGI.pm <Jonathan.L.Ericson@jpl.nasa.gov>
Re: Proper sorting - alphanumeric values? <pobbard@hotresponse.com>
Re: Proper sorting - alphanumeric values? <ren.maddox@tivoli.com>
Re: Proper sorting - alphanumeric values? (Keith Calvert Ivey)
Re: Screen with - screen height <mischief@velma.motion.net>
Re: Screen with - screen height <jdb@ga.prestige.net>
Re: Smart truncating of text <godzilla@stomp.stomp.tokyo>
Re: using getc to input user response from keyboard <mischief@velma.motion.net>
Re: Using Modules <tony_curtis32@yahoo.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 14 Feb 2001 23:09:13 +0000
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: Call C Programs from Perl
Message-Id: <867l2suajq.fsf@jon_ericson.jpl.nasa.gov>
"Michael Krygowski" <michaelk@jbase.com> writes:
> I have a question around this subject, and simply it's; What's the best
> method? I've poured through all the docs and it appears that I have 3
> options, all of which have pluses and minuses (XS, SWIG and Inline). I need
> to make calls to some C code (for DB purposes- opening/reading/writing
> records to a specific DB) that have already been developed. So obviously I
> don't want to re-invent the wheel. I did not write the C code, so know
> nothing about it really (plus I'm not a C coder). My hope was to make calls
> directly to them, but according to the docs, I can't really do this without
> jumping through some minor hoops. I'm also assuming that the syscall
> function *only* works with the syscall.h file. Is this correct or can I
> include other ".h" files?
1) Would the DBI module suit your purposes better?
2) I haven't used SWIG, so I can't comment except to say that it looks
pretty slick. If you have any plans to use Tcl or Python, you should
look into it.
3) XS is what I currently use and it works well for me.
Unfortunately, it requires a fair amount of C knowledge - especially
the build process. h2xs does a good job of parsing *.h files and
building an XS wrapper, but you will need to do some tweaking to get
things working. The waters get real deep real fast.
4) I just started playing with Inline. It's not as cumbersome as h2xs
is, but I seems to require even _more_ understanding of C. Coding
with Inline *feels* like working with some sort of interpreted C,
because you are in an edit/run vs. an edit/build/run cycle. In other
words, you can focus on the language, rather than the build
process.
5) You are probably going to need to learn a little C no matter what
route you take.
Jon
------------------------------
Date: Wed, 14 Feb 2001 16:59:19 -0800
From: "Michael Krygowski" <michaelk@jbase.com>
Subject: Re: Call C Programs from Perl
Message-Id: <MXFi6.340$Vf.11841@typhoon.aracnet.com>
Jon,
Thanks for the insights. Very helpful. I'm not apposed to learning C, was
just hoping to crank out my module sooner, with more ease. :-) I've wanted
to learn it anyway, so will give me a good, if not difficult, first project.
Another couple of questions:
1) Where can I find some good docs on the DBI Module? I wasn't able to find
any. I could just be searching on the wrong key words.
2) If I understand the little bit that I have read, I can only do SQL calls
through the DBI. Is this correct? My hope was to build a module for our
database (where they can read/write/open directly) for our customers. Or
anybody who's using our database. Rather than doing SQL types of functions.
Plus I believe the DBI module is for the large scale DB's (i.e. Oracle,
Sysbase, etc) is this true? Or does it support all types that support SQL?
Thanks for all the help!
- Michael
"Jon Ericson" <Jonathan.L.Ericson@jpl.nasa.gov> wrote in message
news:867l2suajq.fsf@jon_ericson.jpl.nasa.gov...
> "Michael Krygowski" <michaelk@jbase.com> writes:
>
> > I have a question around this subject, and simply it's; What's the best
> > method? I've poured through all the docs and it appears that I have 3
> > options, all of which have pluses and minuses (XS, SWIG and Inline). I
need
> > to make calls to some C code (for DB purposes- opening/reading/writing
> > records to a specific DB) that have already been developed. So
obviously I
> > don't want to re-invent the wheel. I did not write the C code, so know
> > nothing about it really (plus I'm not a C coder). My hope was to make
calls
> > directly to them, but according to the docs, I can't really do this
without
> > jumping through some minor hoops. I'm also assuming that the syscall
> > function *only* works with the syscall.h file. Is this correct or can I
> > include other ".h" files?
>
> 1) Would the DBI module suit your purposes better?
>
> 2) I haven't used SWIG, so I can't comment except to say that it looks
> pretty slick. If you have any plans to use Tcl or Python, you should
> look into it.
>
> 3) XS is what I currently use and it works well for me.
> Unfortunately, it requires a fair amount of C knowledge - especially
> the build process. h2xs does a good job of parsing *.h files and
> building an XS wrapper, but you will need to do some tweaking to get
> things working. The waters get real deep real fast.
>
> 4) I just started playing with Inline. It's not as cumbersome as h2xs
> is, but I seems to require even _more_ understanding of C. Coding
> with Inline *feels* like working with some sort of interpreted C,
> because you are in an edit/run vs. an edit/build/run cycle. In other
> words, you can focus on the language, rather than the build
> process.
>
> 5) You are probably going to need to learn a little C no matter what
> route you take.
>
> Jon
------------------------------
Date: 14 Feb 2001 23:35:40 GMT
From: "Martijn Mulder" <soso@open.net>
Subject: Re: calling clock !
Message-Id: <01c096df$44af81c0$3ec3f1c3@default>
print "Time: ${\scalar localtime(time)}";
nowayandnohow <nowayandnohow@hotmail.com> wrote in article
<K8Ci6.21$is3.12330@typhoon2.ba-dsg.net>...
> How do i get the time from my NT server into my perl script ? And how do
i
> convert it to a value ?
>
> // Jo
>
>
>
------------------------------
Date: Thu, 15 Feb 2001 00:50:07 GMT
From: "nowayandnohow" <nowayandnohow@hotmail.com>
Subject: Re: calling clock !
Message-Id: <3JFi6.74$is3.99693@typhoon2.ba-dsg.net>
thanx :-)
------------------------------
Date: 14 Feb 2001 23:17:41 +0000
From: Piers Cawley <pdcawley@bofh.org.uk>
Subject: Re: CRC-32 in Perl (was: Strings and pointers in Perl?)
Message-Id: <m3r910dfca.fsf@iest.bofh.org.uk>
Frank van Wensveen <fw@lanvision.nl> writes:
> On Tue, 13 Feb 2001 21:44:45 GMT, tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
> wrote:
>
> [In answer to my question on strings and chars]
> > There is a few ways but you don't really say what it is you are doing to
> > the string so that influences things.
>
> Well, basically I'm trying to calculate the 32-bit CRC for a string.
Would I be right in thinking that for 32-bit CRC to work, you need to
pull the data off the string in 32-bit chunks?
If so:
foreach my $long_int (unpack 'N*', $string . "\0" x 3) {
...
}
I'm unfamiliar with the CRC-32 algorithm, but I'm assuming that the
block should be padded with nulls at the end to ensure that everything
gets included.
--
Piers
------------------------------
Date: Wed, 14 Feb 2001 18:45:18 -0800
From: "Carlo Razzeto" <crazzeto@hotmail.com>
Subject: Re: DBI
Message-Id: <96f59l$fva$1@walter.acs.nmu.edu>
Thank you, actually the perpouse of temp was to see if anything at all was
returned in an effort to keep the item ID's unique. There should only be one
item in that list ever.
Carlo
"Joe Schaefer" <joe+usenet@sunstarsys.com> wrote in message
news:m366icj2ri.fsf@mumonkan.sunstarsys.com...
> "Carlo Razzeto" <crazzeto@hotmail.com> writes:
>
> > if ($temp = $sth1->fetchrow_array())
>
> Since fetchrow_array returns a list, it might be better to
> reflect this in your code (unless you really mean for $temp to
> catch the last element in the list instead of the first. It's
> probably academic here, though.)
>
> if ( my ($temp) = $sth1->fetchrow_array )
>
> > {
> > $marker = 1;
> ^^
> my
> > while($marker != 0)
> > {
> > $sth->prepare ("select id from to_do where id = $marker");
> ^^^^
> You didn't define $sth, so it has no methods to call. Besides,
> you can't call prepare on a DBI::st object. prepare is
> a DBI::db method. (See below).
>
> Perhaps you meant to write
>
> my $sth = $dbh->prepare(...) or die $DBI::errstr;
>
> instead?
>
> > $sth->execute();
> >
> > if(!($temp = $sth->fetchrow_array()))
>
> Definitely academic here :)
>
> if (! my ($tmp) = $sth->fetchrow_array ) {
>
> [...]
>
> > I get an error informing me that prepare could not be located
> > via package DBI::st with in the while loop. I have used $sth for
> > a query before, is it neccessary to unset the previouse value (some
> > how) from $sth?
>
> If by this you mean:
>
> "$sth is used earlier in my code, so do I need to unset it first?
> Will that fix it?",
>
> then no. Reassigning it to another statement handler like
>
> $sth = $dbh->prepare("select a from A");
> $sth = $dbh->prepare("select b from B"); # replaces first handle
>
> will work fine. But you *should* be using "my" far more often than
> you appear to be. Strictures ("use strict;") and warnings (-w flag
> or "use warnings;" on 5.6) are also a good habit, in case you're not
> already using those.
>
> > In previouse programs I was albe to use $sth, $sth1 and $sth2, but if
> > I try $sth2 ($sth1 is also used in this program) I get "Can't call
> > method "prepare" on an undefined value". If anyone can offer insite it
> > would be appriciated.
>
> DBI really has a lot of packages that are associated with it, but
> the two chief ones are DBI::db and DBI::st. Respectively, they define
> the interfaces for _database_ handle (usually $dbh in your code) and
> _statement_ handle (usually $sth) objects. A typical sequence starts
> something like this:
>
> use DBI;
>
> my $dbh = DBI->connect( # returns a DBI::db object
> $dsn, $user, $passwd, {RaiseError => 1} );
>
> my $sth = $dbh->prepare($sql); # returns a DBI::st object
>
> $sth->execute( @params ); # tells backend database to run query
>
> ...
>
> Note that the database handler and statement handler are in different
> packages, so they have different methods available to them. You should
> not call "prepare" on a DBI::st object ($sth) any more than you should
> call "connect" on it. Ditto for trying to "execute" a DBI::db object
> (although there are shortcuts available). See the DBI and DBD::mysql
> documentation for details:
>
> % man DBI
> % man DBD::mysql
>
> HTH
> --
> Joe Schaefer "Language is the dress of thought."
> -- Samuel Johnson
------------------------------
Date: Wed, 14 Feb 2001 17:14:47 -0800
From: Terrence Monroe Brannon <terrence.brannon@oracle.com>
Subject: Determining memory usage within Perl
Message-Id: <3A8B2D87.25A1A086@oracle.com>
Is there some means within Perl to find the amount of memory that a
running Perl program has used thus far?
------------------------------
Date: Wed, 14 Feb 2001 17:51:16 -0800
From: brian d foy <comdog@panix.com>
Subject: Re: Determining memory usage within Perl
Message-Id: <comdog-E49293.17511614022001@news.panix.com>
In article <3A8B2D87.25A1A086@oracle.com>, Terrence Monroe Brannon
<terrence.brannon@oracle.com> wrote:
> Is there some means within Perl to find the amount of memory that a
> running Perl program has used thus far?
does it have to be from within Perl? there are many tools which
can do this for any process.
perhaps you are looking for something like what is described in
the perldebguts man page, though.
http://www.perldoc.com/perl5.6/pod/perldebguts.html
--
brian d foy <comdog@panix.com>
------------------------------
Date: Thu, 15 Feb 2001 01:45:51 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Determining memory usage within Perl
Message-Id: <3A8B3553.67EFC3D2@rochester.rr.com>
Terrence Monroe Brannon wrote:
>
> Is there some means within Perl to find the amount of memory that a
> running Perl program has used thus far?
You should use your OS's tools to see how much memory your Perl
program's process is using. What that tool is depends upon what your OS
is. Perl, so far as I know, doesn't have tools that give you stats on
its own memory usage. Generally, if memory usage is your main concern,
you would probably be better off running something other than Perl, like
maybe C. You can find a bit more info with:
perldoc -q memory
at your OS's command line prompt.
--
Bob Walton
------------------------------
Date: Wed, 14 Feb 2001 20:46:40 -0500
From: "TeamZulu HQ" <teamzulu@teamzulu.com>
Subject: Email Attachments - Help
Message-Id: <HtGi6.3544$D3.16688@tor-nn1.netcom.ca>
I am looking for an email attachment type script - Anybody ?
Please email me direct.
Thanks
____________________________________________________________________
Team Zulu Headquarters
Phone: 1-416-899-9642
visit: http://www.TeamZulu.com
** Ask us how we can make your Web Site come to life. Streaming Audio
is included in all our packages. **
_____________________________________________________________________
** CONFIDENTIALITY NOTICE **: This electronic mail is intended only for the
addressee listed. It is a legally privileged document and is exempt from
disclosure. If you are not the intended recipient or if this has been
delivered in error, you may not copy, distribute or disseminate this e-mail
or its attachments and are asked to please advise the sender immediately of
the transmission by email.
------------------------------
Date: Wed, 14 Feb 2001 18:21:42 -0800
From: "Brian McCann" <bmccann@naisp.net>
Subject: email script problem
Message-Id: <t8m4u5s8f68d5a@corp.supernews.com>
I cant' get this to work.
Even though jspbuild.txt has the word "ERROR" in it the script never
executes the The jspbuild failed on flyhalf. part of the script. on top of
that it keeps
looping sending emails the same amount as there are ERROR's in the
jspbuild.txt file unless
I put the last; in the else part of the code.
what am I missing?
tia
Brian
use warnings;
use strict;
use Net::SMTP;
open (FILE, "<c:/perl/perlscripts/jspbuild.txt") or die $!;
while(<FILE>) {
if (/ERROR/) {
my $server = 'mail.pactolus.com';
my $from_address = 'bui-@pactolus.com';
my $to_address = 'bmcc-@pactolus.com';
# If there's problems, turn on debugging output.
#$mailserv = Net::SMTP->new( $server. Debug => 1 );
my $mailserv = Net::SMTP->new( $server );
unless ( $mailserv ) {
die "Could not connect to server $server. $!\n";
}
my $subject = "Subject: The jspbuild failed on flyhalf.";
#my $msg = "This is a test build message";
$mailserv->mail( "$from_address\n" );
$mailserv->to( "$to_address\n" );
$mailserv->data();
$mailserv->datasend( "To: $to_address\n" );
#$mailserv->datasend( "Cc: $to_address\n" );
$mailserv->datasend( "$subject\n\n" );
#$mailserv->datasend( "$msg" );
open (FILE, "<c:/perl/perlscripts/jspbuild.txt") or die $!;
$mailserv->datasend( $_ ) while <FILE>;
#Close connection.
$mailserv->dataend();
$mailserv->quit();
print "Found ERROR\n";
last;
}else {
my $server = 'mail.pactolus.com';
my $from_address = 'bui-@flyhalf.pactolus.com';
my $to_address = 'bmcc-@pactolus.com';
# If there's problems, turn on debugging output.
#$mailserv = Net::SMTP->new( $server. Debug => 1 );
my $mailserv = Net::SMTP->new( $server );
unless ( $mailserv ) {
die "Could not connect to server $server. $!\n";
}
my $subject = "Subject: The jspbuild on flyhalf was successful.";
#my $msg = "This is a test build message";
$mailserv->mail( "$from_address\n" );
$mailserv->to( "$to_address\n" );
$mailserv->data();
$mailserv->datasend( "To: $to_address\n" );
$mailserv->datasend( "Cc: $to_address\n" );
$mailserv->datasend( "$subject\n\n" );
#$mailserv->datasend( "$msg" );
#Close connection.
$mailserv->dataend();
$mailserv->quit();
}
}
close FILE;
------------------------------
Date: 14 Feb 2001 17:32:44 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: How to scan spaces from a string of characters?
Message-Id: <m3bss4j0wz.fsf@dhcp11-177.support.tivoli.com>
"cindy" <cindyann@mbox3.singnet.com.sg> writes:
> I have tried wrap but it break it in the following way.
>
> Output:
> Line1 = "How are you today? Have you ta"
> Line2 = "ken lunch?"
>
> Input:
> How are you today? Have you taken lunch?
>
> Therefore, I need something to tell me that it break in a
> full words and not "ta" in the 1st line and "ken" in the 2nd line.
The Text::Wrap module that Anno suggested does exactly that. Here you
go:
#!/usr/bin/perl
use Text::Wrap;
$Text::Wrap::columns = 30;
print wrap("", "", "How are you today? Have you taken lunch?\n");
__END__
How does this not meet your needs?
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: 14 Feb 2001 23:31:12 GMT
From: "Martijn Mulder" <soso@open.net>
Subject: HTML generator
Message-Id: <01c096de$a53fc5a0$3ec3f1c3@default>
I am working on a Perl program to aid me in writing HTML documents. Where
can I find the fruit of similar efforts? Thanks, Martijn
------------------------------
Date: Thu, 15 Feb 2001 01:47:36 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: HTML generator
Message-Id: <3A8B35C4.2BE5E26@rochester.rr.com>
Martijn Mulder wrote:
>
> I am working on a Perl program to aid me in writing HTML documents. Where
> can I find the fruit of similar efforts? Thanks, Martijn
perldoc CGI
--
Bob Walton
------------------------------
Date: Wed, 14 Feb 2001 23:11:08 -0000
From: "DaveP" <DavePerkins@bigfoot.com>
Subject: Re: Newbie: How do I make my home Win2k IIS system run Perl scripts?
Message-Id: <96f394$cks$1@newsg2.svr.pol.co.uk>
Thanks, now running OK.
I'd overwritten the default program settings for .pl programs in my scripts
directory - it wasn't passing any parameters to perl.exe. (which is
important :-) )
Another small question if I may, since you obviously have experience of IIS.
My little perl program reads a line of text from the end of a text file and
then truncates the text file to effectively remove the last line. This
works fine on my commercial IIS web space, but on my system when I try to
open the test file with "+<file.txt" $! reports "Permission denied".
Checking the file.txt properties in IIS shows that it has Sript souce
access, Read and Write check boxes checked. I thought this would be enough
but it gives me "permission denied"
Any ideas? If not, I think it's time I done some swotting on IIS.
Thanks
David
------------------------------
Date: 14 Feb 2001 23:49:33 +0000
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: no headers using CGI.pm
Message-Id: <863ddgu8oi.fsf@jon_ericson.jpl.nasa.gov>
"Jeff Fletcher" <jeff_fletcher@pacbell.net> writes:
> My server uses MS IIS, so I've been told I need to prevent my scripts from
> sending a header. I've tried to use...
>
> use CGI qw(:standard -nph);
>
> and a few other suggested syntaxes I got here
> (http://stein.cshl.org/WWW/software/CGI/cgi_docs.html#nph) that supposedly
> do the same thing. Nothing seems to work.
You seem to be learning 1) perl, 2) CGI, 3) MS IIS configuration, and
4) Usenet, all at the same time. That would be a mistake. Focus on
one (or possibly two) until you are comfortable, then move on.
I don't know how to solve your problem because I haven't got a clue
what it *is*. What are your expected and actual outputs? Can you
show us a small piece of code that reproduces your problem? Are you
sure it's a Perl problem, not a MS IIS or CGI problem? Who told you
MS IIS requires this option and what do they say when you ask this
question? Have you talked to a co-worker about your problem?
Jon
------------------------------
Date: Wed, 14 Feb 2001 18:28:54 -0500
From: "Philip Obbard" <pobbard@hotresponse.com>
Subject: Re: Proper sorting - alphanumeric values?
Message-Id: <96f41a$kk6$1@taliesin.netcom.net.uk>
----- Original Message -----
From: "Ala Qumsieh"
Sent: Wednesday, February 14, 2001 3:29 PM
Subject: Re: Proper sorting - alphanumeric values?
> Your values seem suspiciously similar to hexadecimal numbers. Are they?
> If they are, then you can use the hex() function in your sort subroutine
> and sort numerically:
>
> my @tmp = sort { hex($a->{value}) <=> hex($b->{value}) } @array;
Thanks Ala, but nope, they aren't hexademical. It's more like version
numbers for an application release, e.g., "0.8a", "1.0", "1.0f", "2", etc.
I even tried this module,
http://search.cpan.org/doc/KJALB/SortVersions-1.1/Versions.pm, but so far it
doesn't seem up to sorting arrays of hashes.
--Philip
------------------------------
Date: 14 Feb 2001 17:44:50 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Proper sorting - alphanumeric values?
Message-Id: <m37l2sj0ct.fsf@dhcp11-177.support.tivoli.com>
"Philip Obbard" <pobbard@hotresponse.com> writes:
> My question is: Can I do a smarter sort of this? Can I mix pure numerics AND
> alphanumerics and get the numerics to sort correctly, or is that not
> possible? Is there a regex combo that might help?
Yes, you can do this.
The hard part is deciding exactly what the right order is, and then
determining a comparison routine that gives you what you want.
A quick first-pass is to use a numeric compare and then fall back on
an ascii compare. Any values that don't look like numbers will
compare as 0. This is possibly OK if all of your numeric-type values
are greater than 0, but gets problematic if some of them are equal to
or less than 0.
Anyway, start with using:
{ $a <=> $b or $a cmp $b }
as your comparison and go from there.
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Thu, 15 Feb 2001 00:18:26 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Proper sorting - alphanumeric values?
Message-Id: <3a8c1c8f.2419627@news.newsguy.com>
"Philip Obbard" <pobbard@hotresponse.com> wrote:
>I even tried this module,
>http://search.cpan.org/doc/KJALB/SortVersions-1.1/Versions.pm, but so far it
>doesn't seem up to sorting arrays of hashes.
What makes you think it's not up to it? I've rewritten your
program and it seems fine:
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
use Sort::Versions;
my @array = map { { value => $_ } }
qw( 1b e 1a 5 b 22 99 D 2 2f 0.8 C 1 10 );
print Dumper(\@array), "\n\n\n";
my @tmp = sort { versioncmp $a->{value}, $b->{value} }
@array;
print Dumper(\@tmp);
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
------------------------------
Date: Thu, 15 Feb 2001 00:19:52 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Screen with - screen height
Message-Id: <t8m858bem95gdd@corp.supernews.com>
Jeremia d. <jdb@ga.prestige.net> wrote:
> I do believe there is some java to do this. If i recollect the url I will post
> it
Please post it to a Java group. This is a Perl group. Please, when you post it
to the Java group, don't Jeopardy post.
> Bjoern Hoehrmann wrote:
>> * Carlo Vandecraen wrote in comp.lang.perl.misc:
>>
>> Thanks for multiposting this into our german Perl newsgroup.
This is called being fecetious. Don't multipost. Spam is bad.
Crosspost instead. Good newsreaders recognize crossposting.
>> >How can I check the screen width/height in a cgi script running on a
>> >webserver written in Perl?
First, find a webserver written in Perl. Second, write a CGI that runs with it.
Have the CGI reach through the monitor with a ruler and measure the screen.
This is almost as realistic as having an input/output stream measure the screen.
There are no CGI variables for screen size. The C in CGI stands for common.
There's not much need to know the exact screen size to make a highly
interoperable (common) script.
>> You can't.
>>
>> >I want to check the screen width/height for getting statistics for the user
>> >on the website?
>>
>> Maybe.
I dunno, do you? Is this really a question? The user probably knows. There are
these nifty things called forms that can take values the user enters. Of course,
this is CGI and not Perl.
[snipped two sigs]
It is rude to post quoted sig blocks.
Chris
--
Christopher E. Stith
Get real! This is a discussion group, not a helpdesk. You post
something, we discuss its implications. If the discussion happens to
answer a question you've asked, that's incidental. -- nobull, clp.misc
------------------------------
Date: Wed, 14 Feb 2001 23:42:04 GMT
From: "Jeremia d." <jdb@ga.prestige.net>
Subject: Re: Screen with - screen height
Message-Id: <3A8A7BFA.86D10FB4@ga.prestige.net>
Yes, I know this but i was just stating to maybe help with his perl related
question. Which seem's perl has no way. So I figured id mention the java I saw..
Chris Stith wrote:
> Jeremia d. <jdb@ga.prestige.net> wrote:
> > I do believe there is some java to do this. If i recollect the url I will post
> > it
>
> Please post it to a Java group. This is a Perl group. Please, when you post it
> to the Java group, don't Jeopardy post.
>
> > Bjoern Hoehrmann wrote:
>
> >> * Carlo Vandecraen wrote in comp.lang.perl.misc:
> >>
> >> Thanks for multiposting this into our german Perl newsgroup.
>
> This is called being fecetious. Don't multipost. Spam is bad.
> Crosspost instead. Good newsreaders recognize crossposting.
>
> >> >How can I check the screen width/height in a cgi script running on a
> >> >webserver written in Perl?
>
> First, find a webserver written in Perl. Second, write a CGI that runs with it.
> Have the CGI reach through the monitor with a ruler and measure the screen.
> This is almost as realistic as having an input/output stream measure the screen.
> There are no CGI variables for screen size. The C in CGI stands for common.
> There's not much need to know the exact screen size to make a highly
> interoperable (common) script.
>
> >> You can't.
> >>
> >> >I want to check the screen width/height for getting statistics for the user
> >> >on the website?
> >>
> >> Maybe.
>
> I dunno, do you? Is this really a question? The user probably knows. There are
> these nifty things called forms that can take values the user enters. Of course,
> this is CGI and not Perl.
>
> [snipped two sigs]
>
> It is rude to post quoted sig blocks.
>
> Chris
>
> --
> Christopher E. Stith
> Get real! This is a discussion group, not a helpdesk. You post
> something, we discuss its implications. If the discussion happens to
> answer a question you've asked, that's incidental. -- nobull, clp.misc
--
A little experience often upsets a lot of theory.
------------------------------
Date: Wed, 14 Feb 2001 16:26:09 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Smart truncating of text
Message-Id: <3A8B2221.5644FB7@stomp.stomp.tokyo>
Jesse James Jensen wrote:
> I have a bunch of strings containing English text that
> are from 15 to 400 characters long. If the text is too
> long, I want to truncate it and put in an ellipsis that
> links to the whole thing. I don't, however, want to
> truncate it if it's only a few words too long. Does
> this seem like a respectable solution? Is there a
> good way to keep this from choking on a well-placed
> 30-letter word?
> my $ellipsis = qq{<A HREF="script?show=$file">...</A>};
(snipped)
You have not stated your parameters clearly and concisely.
This article of yours does not provide information about
your database. It is unknown if you are working with a
multi-line database or working with single line strings.
A university student, such as yourself, should know
better than to not state precise and exact parameters.
This is most unacademic.
Below my signature you will find a test script which
exhibits some fundamental principles to accomplish
your given task. My presumption is you, as a university
student, assuming an instructor wouldn't write an article
like yours, my presumption is you have an ability to
manipulate numbers and have an ability to realize my
[footnote ..] additions represent page links, your
$ellipsis, or whatever is needed, added with some
easy-to-write Perl code.
Godzilla!
--
Kira, Professional Poker Player
http://la.znet.com/~callgirl/android/poker.cgi
Kira, Professional Blackjack Player
http://la.znet.com/~callgirl/android/blakjack.cgi
--
TEST SCRIPT:
____________
#!perl
print "Content-type: text/plain\n\n";
$count = 1;
@Array = (30 .. 40);
open (FILE, "test.txt");
while (<FILE>)
{
if ($_ eq "\n")
{ print $_; next; }
foreach $number (@Array)
{
if (length (substr ($_, 0, index ($_, " ", $number))) < 41)
{
$_ = substr ($_, 0, index ($_, " ", $number));
print "$_ [footnote: $count]\n";
$count++;
last;
}
}
}
close (FILE);
exit;
CONTENTS OF TEST.TXT:
_____________________
Now is the time for all obsessive Techno-Geeksters
to come to the aid of their lame brain glossy black
jack boot wearing cabal in impotent defense against
Godzilla and her onslaught of booger bombs, snot rockets,
slime grenades, slippery semantics and satirical commentaries.
It is also the time for obsessive Techno-Geeksters to
kneel and pray before their alter of Perl Perl God,
this formidable foe, Godzilla, does not use her ultimate
weapon of mind destruction, Socratic Irony.
PRINTED RESULTS:
________________
Now is the time for all obsessive [footnote: 1]
to come to the aid of their lame [footnote: 2]
jack boot wearing cabal in impotent [footnote: 3]
Godzilla and her onslaught of booger [footnote: 4]
slime grenades, slippery semantics [footnote: 5]
It is also the time for obsessive [footnote: 6]
kneel and pray before their alter [footnote: 7]
this formidable foe, Godzilla, [footnote: 8]
weapon of mind destruction, Socratic [footnote: 9]
------------------------------
Date: Wed, 14 Feb 2001 23:32:10 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: using getc to input user response from keyboard
Message-Id: <t8m5bqt9jrtp3d@corp.supernews.com>
Gus <gus@black.hole-in-the.net> wrote:
> Brad A. Gwinn <bradgwinn@hotmail.com> wrote:
>> I'm writing a script that requires a 'Y' or 'N' response from the user. I'm
>> using an "until" loop which checks the return from getc, but it also gets
>> the "\n" from hitting the Enter key, and the cursor drops a line in the
>> console window.
> Have you looked at Term::ReadKey ? It's designed to make doing exactly this
> a lot easier.
And it blocks, so it doesn't tie up the system in a wasteful loop!
The days of programming input with busy loops should have been over when
the days of single-user systems were over. I'd say, oh, about 1992 at the
latest on any system that comes to mind, save for embedded microcontrollers
and such.
There is a SysV way to get the terminal into raw mode and a BSD way to do
the same, both via system() calls, but Term::ReadKey (or Term::ReadLine) is
portable (even to non-Unixen I believe) and has other nice features as
well.
I suppose if you were really anti-module, you could play with sysread(),
but using the unbuffered sysread() and syswrite() are not for the faint
of heart. Using them mixed with buffered reads or writes on the same
file handle is reportaedly not for those with organic hearts. ;-)
Anyway, using sysread() is beyond the scope of this post, and is
left as an exercise.
Chris
--
Christopher E. Stith
Where there's a will, there's a lawyer.
------------------------------
Date: 14 Feb 2001 17:08:04 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Using Modules
Message-Id: <87hf1wn9rf.fsf@limey.hpcc.uh.edu>
>> On Wed, 14 Feb 2001 15:02:21 -0800,
>> "terminalsplash" <shino_korah@yahoo.com> said:
> HI I have a s1.pl script with the following code
> #!/usr/bin/perl package display; sub screenprint() {
> print "hello world"; } ##########ends here
> In another file i have s2.pl
> #!/usr/bin/perl require "s1.pl"; display::screenprint();
> What is wrong here? The compiler complains s1.pl didnot
> return a true value at s2.pl line 2.
See "perldoc -f require"
The file must return true as the last statement to
indicate successful execution of any initialization
code, so it's customary to end such a file with '1;'
unless you're sure it'll return true otherwise. But
it's better just to put the '1;', in case you add more
statements.
hth
t
--
The avalanche has already started.
It is too late for the pebbles to vote.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 291
**************************************