[7695] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1321 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 14 23:08:31 1997

Date: Fri, 14 Nov 97 20:00:22 -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           Fri, 14 Nov 1997     Volume: 8 Number: 1321

Today's topics:
     Re: changing text to upper case <hollosi@sbcm.com>
     Re: changing text to upper case <kelvin@pubgroup.com>
     Re: changing text to upper case (Terry Michael Fletcher - PCD ~)
     Closures as first-class methods? (John L. Daschbach)
     Re: CPAN confusion (William R. Ward)
     Re: Debugger (Casper K. Clausen)
     Debugging CGI programs <navidk@cats.ucsc.edu>
     Re: Debugging CGI programs <zenin@best.com>
     Re: Deleting Cookies (need some help ASAP) (Michael Morrison)
     Easily using databases - am I reinventing a wheel? (Peter J. Schoenster)
     Re: Easily using databases - am I reinventing a wheel? <zenin@best.com>
     Re: How To Test if number is ODD or EVEN? <kelvin@pubgroup.com>
     Re: How To Test if number is ODD or EVEN? (Terry Michael Fletcher - PCD ~)
     Re: How To Test if number is ODD or EVEN? <$_=qq!fearless\@NOSPAMio.com!;y/[A-Z]//d>
     Re: How To Test if number is ODD or EVEN? <$_=qq!fearless\@NOSPAMio.com!;y/[A-Z]//d>
     Re: How To Test if number is ODD or EVEN? (Casper K. Clausen)
     Intermediate Message <jim.blackwell@gsfc.nasa.gov>
     Re: JavaScript document.write from Perl script (Michael Morrison)
     Re: Matching a literal "interrobang" ?? (Tad McClellan)
     Re: Matching a literal "interrobang" ?? (John Moreno)
     Re: Multi-line substitution (adding newlines and global (Eric Bohlman)
     Newbie Q. How to flush print output mid-script? <webmaster@visionary-western.co.uk>
     Re: Newbie Q. How to flush print output mid-script? (Mike Stok)
     Re: numeric format, commas, etc, like picture (Eric Bohlman)
     Re: regexp cruncher in perl. Please help. (Tad McClellan)
     Socket.so problem under Solaris 2.5.1 <oscarc@imsa.edu>
     Stop CGI program when STOP button in WebBrouser is down <pgs2041@hansol.co.kr>
     Testing CGI's? (Cavykid)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 14 Nov 1997 23:07:14 GMT
From: Jozsef Hollosi <hollosi@sbcm.com>
To: Debra Clark <dclark@rogers.wave.ca>
Subject: Re: changing text to upper case
Message-Id: <EJns85.54L@nonexistent.com>

Debra Clark wrote:
> 
> When I try to change "test" into upper case...
> 
> $mm = "test"; print "input is $mm\n"; $nn = uc $mm; print "result is
> $nn\n";
> 
> I get this error message:

You probably have Perl4 instead of Perl5, which doesn't have the uc
function. Either upgrade to Perl5 or use something like:
$nn =~ tr/a-z/A-Z/;

Jozsef


------------------------------

Date: Fri, 14 Nov 1997 18:19:45 -0600
From: "Kelvin D. Olson" <kelvin@pubgroup.com>
To: Debra Clark <dclark@rogers.wave.ca>
Subject: Re: changing text to upper case
Message-Id: <346CEAA1.41C6@pubgroup.com>

Debra Clark wrote:
> 
> When I try to change "test" into upper case...
> 
> $mm = "test"; print "input is $mm\n"; $nn = uc $mm; print "result is
> $nn\n";
> 

Here's what I tried... and it worked:

#!/usr/sbin/perl -w
$mm=<STDIN>;
$mm=uc($mm);
print "result in upper case is $mm";


I run it, and then type something in lower case, like the word "test"
and hit [Enter]

The program gives me
the result in upper case is TEST

I'm guessing it's just the parens in line 3.

KDO


------------------------------

Date: 15 Nov 1997 00:00:23 GMT
From: tfletche@pcocd2.intel.com (Terry Michael Fletcher - PCD ~)
To: dclark@rogers.wave.ca
Subject: Re: changing text to upper case
Message-Id: <64iomn$qlc$2@news.fm.intel.com>

Debra Clark (dclark@rogers.wave.ca) so eloquently and verbosely pontificated:
> When I try to change "test" into upper case...
> 
> $mm = "test"; print "input is $mm\n"; $nn = uc $mm; print "result is
> $nn\n";

looks fine, but...

> I get this error message:

because you are using perl5 syntax on a perl4 binary.  type "perl -v" to
see what i mean.  you need to get perl5.  i could explain further but im
sure Tom will follow up with his standard "perl4 is dead..." response. :)

> # syntax error in file F:\OBBRP\TESTUC.PL at line 3, next 2 tokens "uc
> $mm"
> # Execution of F:\OBBRP\TESTUC.PL aborted due to compilation errors.

> If anyone knows what I'm doing wrong, please e-mail me.  Thanks.

ok, but most people will expect you to read the followups to your own
article.

-- 
#!/usr/local/bin/perl -w- tfletche@pcocd2.intel.com
sleep 1;$"=(time-$^T)<<1;$SIG{ALRM}=sub{print};${q$_$}=join"",
map{chr(hex)}split/(..)/,"4a75737420";alarm$";<>;s y(\0\w){4}.
?yreverse q brehtonabyex;alarm$";<>;for(;length>4;chop){}tr&to
an&empti&;alarm$";<>;s@$_@reverse',ret'.q csaw c@e;alarm$";<>;



------------------------------

Date: 14 Nov 1997 16:08:31 -0800
From: d3h486@wd19518.emsl.pnl.gov (John L. Daschbach)
Subject: Closures as first-class methods?
Message-Id: <m367pv9fy8.fsf@wd19518.emsl.pnl.gov>


Is there a way in Perl to write a closure as a first class method?  By
this I mean it appears that the current implementation of closures
requires an explicit indirection operator to evaluate the function.  

The question is general, but my particular case arises from parsing
lines out of a file.  Right now I use methods of the form:

sub title {
  my($self) = shift;

  return($self->simple_field('title','T'));
}
#
sub simple_field {
  my($self) = shift;
  my($fkey) = shift;
  my($refkey) = shift;

  unless ( $#{$self->{$fkey}} > 0) {
    $self->parse_simple_field($refkey,$fkey);
  }
  return(join('',@{$self->{$fkey}}));
}
#
sub parse_simple_field {
  my($self) = shift;
  my($refkey) = shift;
  my($fkey) = shift;
  my($searchkey);

  $searchkey = "^\\%$refkey\\s*(\\S.*)";
  foreach (@{$self->{currec}} ) {
    if ( /$searchkey/ ) {
      push(@{$self->{$fkey}},$1);
    }
  }
}

Where there will be a large number of methods akin to 'title'.  One
could write these as closures, thus making the regex expressions
static, which should in principle speed up parsing a great deal.
However the calling syntax changes so that at least the top level
methods must be called indirectly.

Am I missing something?

-John


------------------------------

Date: 14 Nov 1997 15:49:39 -0800
From: hermit@cats.ucsc.edu (William R. Ward)
Subject: Re: CPAN confusion
Message-Id: <waavhxv2fzf.fsf@ese.UCSC.EDU>

mgjv@comdyn.com.au (Martien Verbruggen) writes:
> In article <waa67pw1846.fsf@ese.ucsc.edu>,
> 	hermit@cats.ucsc.edu (William R. Ward) writes:
> > What version of Perl is that?  I get "Can't locate CPAN.pm in @INC."
> > when I try that.
> 
> perl 5.004_04 of course :)
> 
> CPAN should be included with recent versions of perl. I would install
> the newest if I were you, or if that is not possible, download CPAN.pm,
> from CPAN :)

Well at work I can't install the newest as our large development
project is using 5.003 for the production system.  I have been
suggesting that it's time to consider upgrading, though.  Probably in
6 months or a year we'll be upgraded.  In the meantime I don't want to
get in the habit of using 5.004's cool new features, so I haven't
upgraded my home system.  Though with the recent news I saw on
linux-alert about the buffer overruns in suidperl, I think I will
anyway.

> > Also, does that work through SOCKS or do you have to use a
> > protocol-specific proxy?
> 
> As far as I know, it uses LWP to connect, meaning (AFAIK) that it's
> standard HTTP proxy forwarding (or FTP proxy forwarding). No Socks
> connections needed. 

Well since SOCKS is the only kind of proxy available to me at work,
that doesn't help me much there.  (Is there any way to use SOCKS in
Perl besides SOCKSifying the Perl binary?)  It would be possible from
my home system, though.  I'll install CPAN.pm there and see what
happens.

--Bill.

-- 
William R Ward          Bay View Consulting   http://www.bayview.com/~hermit/
hermit@bayview.com     1803 Mission St. #339        voicemail +1 408/479-4072
hermit@cats.ucsc.edu  Santa Cruz CA 95060 USA           pager +1 408/458-8862


------------------------------

Date: 14 Nov 1997 14:24:07 +0100
From: ckc@hobbes.ejoper.dmi.min.dk (Casper K. Clausen)
Subject: Re: Debugger
Message-Id: <wvpyb2r38y0.fsf@hobbes.ejoper.dmi.min.dk>

rqy1319@is4.nyu.edu (Ryuji Yokoyama) writes:

> I appreciate people who replied me, but I still don't understand how
> to use the debugger.  I read perldebug man, but this document is too
> poor for me.  Please some body teach me.  How to watch variables and
> how to trace the program step by step.

You know, the first time I tried the perl debugger, I got something
like this:

,-----
| ckc@hobbes > perl -d ~/src/Perl/whoison.pl --noloop
| 	  
| Loading DB routines from perl5db.pl version 1.01
| Emacs support available.
| 	  
| Enter h or `h h' for help.
| 	  
| main::(/home/ckc/src/Perl/whoison.pl:8):
| 8:      unless (GetOptions("width=i", "update=i", "h|help:s", "loop!")) {
|   DB<1> 
`-----

"Hmmm," I thought, "wonder how you get it to work."

Then, just for the hell of it, I tried reading the output. And lo and
behold! The ouput told me to 'Enter h or `h h' for help'. Suspicious,
but feeling adventurous, I tried doing just that, and got nice info on
stepping, tracing and all sorts of things.

HTH,
Kvan.

-- 
-------Casper Kvan Clausen------ | 'Ah, Warmark, everything that passes
----------<ckc@dmi.dk>---------- |  unattempted is impossible.'
           Lokal  544            |   
I do not speak for DMI, just me. |        - Lord Mhoram, Son of Variol.      


------------------------------

Date: Fri, 14 Nov 1997 15:50:56 -0800
From: Navid S Kamali <navidk@cats.ucsc.edu>
Subject: Debugging CGI programs
Message-Id: <Pine.SUN.3.91.971114154736.6217D-100000@cobweb.UCSC.EDU>

Hi I'm fairly new to Perl.
I was wondering how i can print the value of variable into standard 
output instead of into a web page. My perl programs uses cgi.
I want to be able to do something like:
print $variable;  (for debugging purposes)
How do i get around this? How do i print the value into the xterm after 
the %

Thanks for your help in advance. 
***** Please respond to navidk@cats.ucsc.edu *************************


------------------------------

Date: 15 Nov 1997 01:27:07 GMT
From: Zenin <zenin@best.com>
Subject: Re: Debugging CGI programs
Message-Id: <879557391.477280@thrush.omix.com>

Navid S Kamali <navidk@cats.ucsc.edu> wrote:
: Hi I'm fairly new to Perl.
: I was wondering how i can print the value of variable into standard 
: output instead of into a web page. My perl programs uses cgi.
: I want to be able to do something like:
: print $variable;  (for debugging purposes)
: How do i get around this? How do i print the value into the xterm after 
: the %

	Get and install the CGI module.  Then run
		perldoc CGI::Carp
	Look for the references about saving debug info to a file.

-- 
-Zenin
 zenin@best.com


------------------------------

Date: 15 Nov 1997 01:45:36 GMT
From: mmorrison@vnet.ibm.com (Michael Morrison)
Subject: Re: Deleting Cookies (need some help ASAP)
Message-Id: <64ius0$okg$3@sjnews.sanjose.ibm.com>

In <64fm4p$mfv@snews3.zippo.com>, "Jesse Retchko" <JesseR@HeadHunter.NET> writes:
>Hey Everyone,
>
>I'm running a site that a user has to log onto. Lately my users have started
>wanting a log off button. Does anyone out there know the code on how to
>delete a cookie using Perl? If you could e-mail any response you have one
>this article to JesseR@HeadHunter.NET that would be great!
>
>    Thanks,
>    Jesse Retchko
>    JesseR@HeadHunter.NET
>    Webmaster
>    HeadHunter.NET
>    http://www.HeadHunter.NET/
>
>

Why not let JavaScript delete the cookie?  Or change the way the cookie is created
to give it an expiration date and let the browser delete it for you?

See Bill Dortch's cookie functions: http://www.hidaho.com/cookies/cookie.txt


------------------------------

Date: Sat, 15 Nov 1997 01:45:34 GMT
From: pschon@baste.magibox.net (Peter J. Schoenster)
Subject: Easily using databases - am I reinventing a wheel?
Message-Id: <346cfc2a.13949658@news.magibox.net>

Hello,

I am working on a web application: a movie site:

http://www.germantownnews.com/movies

I have to make this simple for someone else to administer.  I do not
use mSQL or other types although I am looking at them. I find it much
easier to write my own dbm or flat-file databases. 

I finally found a way to very easily update, delete, modify  a
database.  All I need to do is set an entry in the dbm:

table = "name|adress|city|state"

like that.  Then my program will open the dbm, get the values for
table and then write forms for the rest of the entries in that dbm.
Works like a charm.

I can now just create a dbm from a form, add the table values and then
presto I have an easy way to modify anything.

But who knows,  Maybe I am spinning my wheels.  You can see it here:

http://www.germantownnews.com/cgi-bin/get_db.cgi

That program reads a directory where I have my database files: a
mixture of Berkley DBM and flat-files.  I have not done much with the
flat files.  This only works with files marked binary.  Just choose
one and then click on "Open this database".  I put the other submit
because I had to insert the table value in the dbm. If you are curious
you can see what that does.

The cgi programs have no idea what the names or how many names there
are in a dbm. It gets that from the table values and then creates the
forms.

This took me a couple of hours to do and I have already spent more
time than that on figuring out how to use the mSQL modules like I
want.

Here are what I consider some interesting things:

To get the names of the values:

sub get_headers {

	(@names)= split(/\|/,$DB{table});
	 foreach(@names) {
		 $c++;
		 $name = ${\$_};
		print "$c = $name\n";
		push(@table_names,$name);

	 }
}

	while(($key,$value) = each(%DB)) {
	$c='';
	next if $key eq "table";

my($tmovie,$tsubject,$tname,$temail,$tstreet,$tcity,$tstate,$tcountry,$tareacode,$tphone,$tcomments,$tuk,$tdate)
= split(/\|/,$value);
	(@vals) = split(/\|/,$value);
	print qq! <form method="post"
action="/cgi-bin/update_db.cgi">!;
	print <<END;
	<table border="1" width="60%">
	<tr><th align="left">Key</th><td><input type="hidden"
name="id" value="$key">$key</td></tr>
END
	foreach(@vals) {
	print qq! <tr><th align="left">$table_names[$c]</th><td><input
type="text" name="$table_names[$c]" value="$_" size="50"></td></tr>!;
	$c++;
}






When I need to update a dbm value I do this:


@keys = $q->param;
foreach $key (@keys) {
   #$myarray{$key}=$query->param($key};
	next if $key eq "file";
	next if $key eq "type";
	next if $key eq "id";
	$v = $q->param($key);
	$add_term .= "$v|";
}

$add_term =~ s/[|]+$//;

$DB{$id} = "$add_term";


I cheated on having to leave out file and type but I could have made
it completely anonymous.
















------------------------------

Date: 15 Nov 1997 02:37:38 GMT
From: Zenin <zenin@best.com>
Subject: Re: Easily using databases - am I reinventing a wheel?
Message-Id: <879561622.787677@thrush.omix.com>

Peter J. Schoenster <pschon@baste.magibox.net> wrote:
: I have to make this simple for someone else to administer.  I do not
: use mSQL or other types although I am looking at them. I find it much
: easier to write my own dbm or flat-file databases. 

	If multiple people could ever be using this at the same time,
	I **REALLY** hope you're locking your DBM and flat files.  See
	the DB_File man page for examples of locking DBM files.  To not
	lock on update could (will actually, it's just a matter of time)
	corrupt the file.  Same with flat files.

	The main advantages with a SQL database (IMHO) is misc column
	searches.  Right now you've got them all together as a pipe
	delimited string in a DBM file.  What this meens is that if you
	want to search on anything but the DBM key, you're reading the
	*entire* DBM file, and doing a split() on *every* row of data.
	If you want column substring searches (show me everything that
	column "name" starts with "rocky") it gets even worse.  You'll
	end up with a system that doesn't scale at _all_, since it will
	slow down at an exponential rate to the number of rows you add.

-- 
-Zenin
 zenin@best.com


------------------------------

Date: Fri, 14 Nov 1997 18:28:38 -0600
From: "Kelvin D. Olson" <kelvin@pubgroup.com>
Subject: Re: How To Test if number is ODD or EVEN?
Message-Id: <346CECB6.2781@pubgroup.com>

> >> 1) switch a value between 1 and 0.
> >>
> >>         $go = 1 - $go;
> >>         if ($go) { ... }
> >
> >Don't see how how this is supposed to help?!
> 
> You don't? Then I'll repeat a selected quote:
> 
> > I only want to run a bit of code every other pass.
> 
> I think this will work nicely, even if it doesn't check if a number is
> even or odd.

No kidding. If the point is SOLELY to do every-other, then the above
code makes a TON more sense than running a counter.


 ...ok, maybe only a few OUNCES more sense. But it's sure elegant in its
simplicity, that's for darn sure!


Now lemme see... I want to figure out if the counter has reached 12, so
I'll square it and see if the result is between 100 and 169... <g>

KDO


------------------------------

Date: 14 Nov 1997 23:47:30 GMT
From: tfletche@pcocd2.intel.com (Terry Michael Fletcher - PCD ~)
Subject: Re: How To Test if number is ODD or EVEN?
Message-Id: <64inui$qlc$1@news.fm.intel.com>

Jay Dixon (jay@dixonssurgical.co.uk) so eloquently and verbosely pontificated:
> 
> I want to test if a variable is Odd (or Even) - i.e. I only want to
> run a bit of code every other pass.  I have never come across this as
> a bit of code.

if you dont really need a counter (and hence testing for odd/even), and
you're just wanting to do something every other time through a loop, you
could make a toggle function:

$toggle = 0; # or '1'
your_loop_function (CONDITION) {
	# some stuff here
	[some stuff] if $toggle;
	$toggle ^= 1;	# XOR with self and '1' is an inverter
}

-- 
#!/usr/local/bin/perl -w- tfletche@pcocd2.intel.com
sleep 1;$"=(time-$^T)<<1;$SIG{ALRM}=sub{print};${q$_$}=join"",
map{chr(hex)}split/(..)/,"4a75737420";alarm$";<>;s y(\0\w){4}.
?yreverse q brehtonabyex;alarm$";<>;for(;length>4;chop){}tr&to
an&empti&;alarm$";<>;s@$_@reverse',ret'.q csaw c@e;alarm$";<>;


------------------------------

Date: Fri, 14 Nov 1997 17:04:03 -0800
From: "Creede Lambard" <$_=qq!fearless\@NOSPAMio.com!;y/[A-Z]//d>
Subject: Re: How To Test if number is ODD or EVEN?
Message-Id: <64isi8$jv7@news.microsoft.com>

Hmmmm . . . I squared the counter . . . it came up with 121 . . . must be
12. :D

Kelvin D. Olson wrote in message <346CECB6.2781@pubgroup.com>...

<snip, ah say, snip>

>
>Now lemme see... I want to figure out if the counter has reached 12, so
>I'll square it and see if the result is between 100 and 169... <g>
>
>KDO




------------------------------

Date: Fri, 14 Nov 1997 17:12:25 -0800
From: "Creede Lambard" <$_=qq!fearless\@NOSPAMio.com!;y/[A-Z]//d>
Subject: Re: How To Test if number is ODD or EVEN?
Message-Id: <64it1v$7la@news.microsoft.com>

You could also do this (at least it worked for me just now):

$toggle = (1==1)        # you could probably just say $toggle=1 but what fun
would that be? :D
while ($whatever) {    # do whatever you were going to do here
    # stuff happens;
    $toggle = !($toggle);
    }

Bart Lateur wrote in message <346c392b.702216@news.tornado.be>...
>jay@dixonssurgical.co.uk (Jay Dixon) wrote:
>
>>I want to test if a variable is Odd (or Even) - i.e. I only want to
>>run a bit of code every other pass.  I have never come across this as
>>a bit of code.
>
>Two ways.
>
>1) switch a value between 1 and 0.
>
> $go = 1 - $go;
> if ($go) { ... }
>
>2) do a binary and with the lowest bit
>
> if ($counter++ & 1) { ... }
>
>HTH,
>Bart.




------------------------------

Date: 14 Nov 1997 15:30:25 +0100
From: ckc@hobbes.ejoper.dmi.min.dk (Casper K. Clausen)
Subject: Re: How To Test if number is ODD or EVEN?
Message-Id: <wvpwwib35vh.fsf@hobbes.ejoper.dmi.min.dk>

jay@dixonssurgical.co.uk (Jay Dixon) writes:

> I want to test if a variable is Odd (or Even) - i.e. I only want to
> run a bit of code every other pass.  I have never come across this as
> a bit of code.
> 
> if $counter == [????] print "stuff"; # as far as I can get!

Well, the perlop manpage might help you, if you know what you're
looking for. Doesn't sound like you do, though.

What you want is to use the modulo function, which returns the
division rest. Thus 20 modulo 3 equals 2, since 3 * 6 equals 18.

Expanding on this, we realize that any even number modulo 2 results in
a value of zero, and any odd number modulo 2 equals one.  If we now
use a statement modifier, we get, in plain english,

print stuff unless counter modulo 2 equals one.

This, fortunately, translates easily to Perl:

print "stuff" unless ($counter % 2);
                     ^------------^--- Redundant, but ease reading.

Of course, if you wanted it to print every 200th iteration, you'd
substitute 200 for the 2. I use this myself in a script which works on
very large files - every 200th line, it changes the icon title to the
line number. This lets me start the script, iconify, and follow along
very easily.

Regards,
Kvan.

-- 
-------Casper Kvan Clausen------ | 'Ah, Warmark, everything that passes
----------<ckc@dmi.dk>---------- |  unattempted is impossible.'
           Lokal  544            |   
I do not speak for DMI, just me. |        - Lord Mhoram, Son of Variol.      


------------------------------

Date: Fri, 14 Nov 1997 20:46:04 -0500
From: Jim Blackwell <jim.blackwell@gsfc.nasa.gov>
Subject: Intermediate Message
Message-Id: <346CFEDA.AE6EF526@gsfc.nasa.gov>

Hi all,

 a way to display an intermediate message that would come up on the
screen once a CGI FORM has been submitted and before its results come
back.

Something like

"One Moment Please"

Thanks,

Jim Blackwell



------------------------------

Date: 15 Nov 1997 01:36:40 GMT
From: mmorrison@vnet.ibm.com (Michael Morrison)
Subject: Re: JavaScript document.write from Perl script
Message-Id: <64iub8$okg$2@sjnews.sanjose.ibm.com>

In <Pine.GSO.3.96.971030081555.28125M-100000@usertest.teleport.com>, Tom Phoenix <rootbeer@teleport.com> writes:
>On 30 Oct 1997, Michael Morrison wrote:
>
>> I've been trying to issue JavaScript document.write() statements from a
>> Perl script, but without success. Can it be done?  If so how? 
>
>To Perl, any JavaScript statements are just data - strings, in particular. 
>To output a string, use print. If you can't get print to do what you want,
>see if you can make a small script (say, five lines) which shows the
>problem. Good luck!
>
>-- 
>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/
>              Ask me about Perl trainings!
>

Sorry for the long delay in reposting, but other work intervened ...

It seems that I can use JavaScript sucessfully in a Perl script _except_
if I enclose the JavaScript inside HTML comments (to hide the JavaScript
from non-JS browsers).

So something like:

print "<SCRIPT>";
 .. script stuff ...
print "</SCRIPT>;

works, but

print "<SCRIPT>";
print "<!--";
 .. script stuff ...
print "// -->":
print </SCRIPT>";

does not work.  In fact, it looks like everything inside the comments <!-- --> is 
ignored by the browser.  But if I use the same code in an HTML file, it works
(with the comments and all).

Is this something I simply must live with?  Or is there a way around it?

I'm using Perl 4 under AIX.

TIA (and thanks to those who sent me private e-mail),

Michael


------------------------------

Date: Fri, 14 Nov 1997 17:06:56 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Matching a literal "interrobang" ??
Message-Id: <gili46.492.ln@localhost>

Pete Holsberg (pjh@mccc.edu) wrote:
: This is perl 5.004_01.

: I'm trying to match the following string (for subsequent
: replacement)

: /cgi-bin/htgrep.cgi/file=/AA/f97/msched.html&style=pre?AC106

: but I haven't been able to figure out how to make that "?"
: literal. I've tried "\?" but that didn't work.


That should work.

Can't tell why not, because you haven't included the code.

We like code here.


: Any suggestions?

Yes.

Post some buggy code and someone may be able to help fix said buggy code.


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


------------------------------

Date: Fri, 14 Nov 1997 21:52:40 -0500
From: phenix@interpath.com (John Moreno)
Subject: Re: Matching a literal "interrobang" ??
Message-Id: <199711141432209590550N@roxboro-173.interpath.net>

Pete Holsberg <pjh@mccc.edu> wrote:

] This is perl 5.004_01.
] 
] I'm trying to match the following string (for subsequent
] replacement)
] 
] /cgi-bin/htgrep.cgi/file=/AA/f97/msched.html&style=pre?AC106
] 
] but I haven't been able to figure out how to make that "?"
] literal. I've tried "\?" but that didn't work.

Well, it works for me.

$test ='/cgi-bin/htgrep.cgi/file=/AA/f97/msched.html&style=pre?AC106';
$test =~ m#(/cgi-bin/htgrep.cgi/file=/AA/f97/msched.html&style=pre\?AC106)#;
print  $1."\n";

gives 
/cgi-bin/htgrep.cgi/file=/AA/f97/msched.html&style=pre?AC106

-- 
John Moreno


------------------------------

Date: Fri, 14 Nov 1997 23:10:07 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Multi-line substitution (adding newlines and global replace)
Message-Id: <ebohlmanEJnsCv.3w2@netcom.com>

Steven Tolkin (steve.tolkin@fmr.com) wrote:
: I am having a hard time figuring out how to do a global replace that
: adds newlines, but not in front of an existing newline.  

[snip]

: s/(\. +)(?!\n)/$1\n/g;

This *will* match the string ".  \n" because it consists of a period, one 
or more spaces (in this case one space) followed by something other than 
a newline (in this case the other space).  The following works according 
to my tests:

s/(\. +)(?![ \n])/$1\n/g;




------------------------------

Date: Fri, 14 Nov 1997 11:45:47 +0000
From: John <webmaster@visionary-western.co.uk>
Subject: Newbie Q. How to flush print output mid-script?
Message-Id: <346C39EB.3E89@visionary-western.co.uk>

Hi All!

I have a dumb question. I have a script which replies to a simple web
site form submission. The chunk I'm having problems with is near the end
of the script and runs something like...

	print "...some html...\n";
	sleep (300);
	exit;

Question. Why does the script not return its html output to the browser
until 300 seconds are up? Presumably there's a command which could flush
the output before it starts to sleep? I've drawn a blank with the
manual, any help would be appreciated (grin).

Thanks in advance. 

John L


------------------------------

Date: 15 Nov 1997 01:58:43 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Newbie Q. How to flush print output mid-script?
Message-Id: <64ivkj$bqe@news-central.tiac.net>

In article <346C39EB.3E89@visionary-western.co.uk>,
John  <webmaster@visionary-western.co.uk> wrote:
>Hi All!
>
>I have a dumb question. I have a script which replies to a simple web
>site form submission. The chunk I'm having problems with is near the end
>of the script and runs something like...
>
>	print "...some html...\n";
>	sleep (300);
>	exit;
>
>Question. Why does the script not return its html output to the browser
>until 300 seconds are up? Presumably there's a command which could flush
>the output before it starts to sleep? I've drawn a blank with the
>manual, any help would be appreciated (grin).

You can say something like

  $| = 1;

at the beginning of the script which sets the currently selected file
handle (usually STDOUT) to flush after each print, but unless you've told
the web server that it shouldn't buffer up the script's output you might
find that the server buffers it up so that, for example, it can create an
accurate Content-length: header.  So you might want to look in your berb
server manual for instructions on how to have the server not buffer the
output (a couple of things to look for are nph- and non parsed headers.)

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@colltech.com                  |            Collective Technologies (work)


------------------------------

Date: Fri, 14 Nov 1997 23:12:42 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: numeric format, commas, etc, like picture
Message-Id: <ebohlmanEJnsH6.42x@netcom.com>

Rick Silterra (Enrico.Silterra@nortel.com) wrote:
: Are there any modules or code that deal with
: printing values with comma's in the right place,
: according to locale, using the right currency symbol?

William R Ward (hermit@bayview.com) has been talking about writing a 
Number::Format module and this sounds like something he'd want to 
include.  Why don't you drop him a note?



------------------------------

Date: Fri, 14 Nov 1997 17:15:48 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: regexp cruncher in perl. Please help.
Message-Id: <43mi46.7b2.ln@localhost>

Ravi Kumar (ravi@centtech.com) wrote:

: 	I have a bunch of multi-thousand line files containing lines
: which should be eliminated from a bunch of million line files. Obviously
: cannot use anything but perl

[snip]

: This is probably inefficient. It takes an hour or more on our most
: powerful machines. Is there a better way to do this? 
: What I think is since the number can be a regular expression, can I
: write a subroutine which creates a regular expression automatically?
: I can then use it to grep out lines from the data base.


Perl FAQ, part 6:

   "How do I efficiently match many regular expressions at once?"


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


------------------------------

Date: 15 Nov 1997 03:13:00 GMT
From: Oscar Cwajbaum <oscarc@imsa.edu>
Subject: Socket.so problem under Solaris 2.5.1
Message-Id: <64j3vs$nj3$1@java.imsa.edu>


After upgrading a Solaris 2.5.1 system from perl 5.004_03 to 5.004_04, I 
starting getting the following error message when using the Socket module:

Can't load '/usr/local/encap/perl500404/lib/sun4-solaris/5.00404/auto/Socket/
Socket.so' for module Socket: ld.so.1: /usr/local/bin/perl: fatal: relocation
error: file /usr/local/encap/perl500404/lib/sun4-solaris/5.00404/auto/
Socket/Socket.so: symbol __inet_ntoa: referenced symbol not found at 
/usr/local/encap/perl500404/lib/sun4-solaris/5.00404/DynaLoader.pm line 166.

If I replace the Socket.so file compiled during the 5.004_04 install with
the old Socket.so from 5.004_03, the error goes away. 

Any ideas?

Oscar Cwajbaum
oscarc@imsa.edu


------------------------------

Date: Sat, 15 Nov 1997 12:04:27 +0900
From: "9Z 1M<v" <pgs2041@hansol.co.kr>
Subject: Stop CGI program when STOP button in WebBrouser is downed
Message-Id: <346D113A.810126A3@hansol.co.kr>

I'm studying about CGI program.
But I have serious problem that CGI program written by PERL don't
stop when stop button is downed.

I use Netscape Communicator 4.04.
Any suggestions will be much appreciated.


#!/usr/local/bin/perl

use CGI;
$form = new CGI;

print $form->header;

print $form->start_html(
        -title=>'Raw Data Display'
        );

print "<BODY BGCOLOR=#ffffff>";

print "TEST PROGRAM<br>";

$i = 0;
while( $i < 3600 )
{
sleep( 1 );
        $i++;
}

print "</BODY>";
print $form->end_html;





------------------------------

Date: 15 Nov 1997 03:23:32 GMT
From: cavykid@aol.com (Cavykid)
Subject: Testing CGI's?
Message-Id: <19971115032300.WAA24858@ladder02.news.aol.com>

Does anyone here know a good place to test CGI's?  I have a CGI I made in
 MacPerl 5, and I cant figure out where to test it.  EMail me please!  Thanks!


------------------------------

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 1321
**************************************

home help back first fref pref prev next nref lref last post