[12450] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6050 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 18 18:07:35 1999

Date: Fri, 18 Jun 99 15:01:29 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 18 Jun 1999     Volume: 8 Number: 6050

Today's topics:
    Re: odd autoincrement behavior ? (Bart Lateur)
        Perl Sockets <bill.lewis@corp.usa.net>
    Re: Printing compound variables (explanation) greg@dns.kode.net
    Re: Printing compound variables (explanation) <cassell@mail.cor.epa.gov>
        problems with eval (Christopher Grau)
    Re: Random Index?.... (Bart Lateur)
    Re: Random Index?.... <crt@highvision.com>
        Relocation error in Socket.so <zmievski@ispi.net>
    Re: Running Perl Simultaneously with another language.. (Cameron Laird)
    Re: Running Perl Simultaneously with another language.. <gbartels@xli.com>
        s/\s/ /g does not work for me... why??!! <unclelui@grin.net>
    Re: s/\s/ /g does not work for me... why??!! (Greg Bacon)
    Re: s/\s/ /g does not work for me... why??!! <jeffp@crusoe.net>
    Re: s/\s/ /g does not work for me... why??!! <unclelui@grin.net>
    Re: script to lookup phone number off website? <pnkflyd51@hotmail.com>
    Re: script to lookup phone number off website? <cassell@mail.cor.epa.gov>
    Re: win32 shortcut tool? (Jan Dubois)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Fri, 18 Jun 1999 20:25:15 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: odd autoincrement behavior ?
Message-Id: <3774aae2.11612188@news.skynet.be>

M.J.T. Guy wrote:

>That's only a syntax error in perl5.004_04 and earlier.   Bill's problem
>is an out of date Perl.

Yes, yes, rub it in. The latest MacPerl port is out of date. Sigh.
Matthias is far too busy right now, with his new life and all, to
quickly fix that.

	Bart.


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

Date: Fri, 18 Jun 1999 15:23:42 -0600
From: William Lewis <bill.lewis@corp.usa.net>
Subject: Perl Sockets
Message-Id: <376AB8DE.E2A6D1C8@corp.usa.net>

I have a perl client/server program that is very simple in nature.
I put this on one machine and it works fine, if I put it  on another
machine with the same perl version and installation is will not work.
When it attempts to create the socket it gives a Bad File Number error
and
in fact the clients cannot create sockets either.

I am using a Sun, with solaris 2.6, perl 5.005_02, and all the IO
modules.

has anyone seen this before?
-- 
Apocalypse Troll
email: ApocalypseTroll@usa.net
"Not Guilty."
	- Captain Lincoln Stern


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

Date: Fri, 18 Jun 1999 20:16:47 GMT
From: greg@dns.kode.net
Subject: Re: Printing compound variables (explanation)
Message-Id: <7ke9f4$rap$1@nnrp1.deja.com>



First off, if my post went through more than once, I appologize.  I'm
away from my normal news server and am forced to use dejanews, which was
going through some technical difficulties yesterday.

I received an email asking why I wanted to do be able to access compound
variables... (apparently symbolic references)

I work for an ISP and I am writing a CGI program that functions
basically as an e-commerse server.  It stores items for sale, and users
can browse through, search, etc. and select items to put in their
"shopping cart". Our customers want to use this software to sell things
from their web pages, which we host.  I'm a (pseudo)programmer, but I
don't know squat about html or web page design.  I wanted to separate
the html portion of the code into separate files so our webmaster can
modify them without messing with the CGI.  I wanted to be able to read
in a file such as:
_______________________________________________
<HTML><HEAD><TITLE>Parameters</TITLE></HEAD>
<BODY>
<H1><TT>Parameters</TT></H1>
<P>

<a
href="$cgiurl/$user/parameters.cgi?user=$user&command=change">View/Chang
e Options</a>
<P>

</BODY>
</HTML>
_________________________________________________________________

The variables named ($cgiurl, $user, etc) are already defined and have
values in the CGI.  But our webmaster doesn't know anything about Perl.
 We want him to be able to take the file above and "beautify" the html,
and let my CGI still be able to read it in and replace the variable
names with the appropriate values.

The short version of the response I got was "use a hash table".  I
hadn't though of that. (only been using Perl for 2 weeks)  But what I'm
probably going to do is have each file formatted like this:
________________________________________________________________

sub print_page {
print <<EndDATA;

<HTML>
<BODY>
Stuff here
</BODY>
</HTML>
EndData
}
______________________________________________________

And I'll just require the file and call the sub when I want to print
that page.

Hope that clears some things up.

Again, sorry about the multiple posts.  I'm not from AOL, really!

Greg Preston
greg@dns.kode.net




In article <376a6387@cs.colorado.edu>,
  tchrist@mox.perl.com (Tom Christiansen) wrote:
>      [courtesy cc of this posting mailed to cited author]
>
> In comp.lang.perl.misc, vectorcalculus@my-deja.com writes:
> :If I have this:
> :
> :$one = "text and stuff";
> :$two = '$one';
>
> Six times.  SIX FRICKING TIMES.   Have you no sense of
> proportion decency?  Who is this really?
>
> --tom
> --
>  PS/2 -- Half a computer
>  OS/2 -- Half an operating system
>  PS/2: Yesterday's hardware today. OS/2: Yesterday's software tomorrow
>


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Fri, 18 Jun 1999 14:50:36 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Printing compound variables (explanation)
Message-Id: <376ABF2C.8CAC5FDF@mail.cor.epa.gov>

greg@dns.kode.net wrote:
> [snip]

Okay.  Tom, Greg, etc...  Based on my survey (sample size 1)
100% say that the symbolic-reference-attempt is due to a lack
of exposure to programming techniques, rather than another
evil plan by M$ .  Shall we keep inquiring?

I was sort of expecting to hear that he got the syntax out
of one of Matt's Scripts.  :-)

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Fri, 18 Jun 1999 21:19:58 GMT
From: ScgrauP@Aucsd.eduM (Christopher Grau)
Subject: problems with eval
Message-Id: <376ab719.959956380@news>

I have had some difficulty using the eval function. Imagine that I
have a fairly complex perl script (with luck, this doesn't matter, and
I don't have to go into it). Basically, I am trying to execute code
that looks like this:

	eval "\$foo = \"bar\"";

However, this doesn't work in my complex script, $foo is never
assigned anything. Although it seems to work beautifully in a program
in which it is the only statement.

Now, if I execute it in this manner:

	eval "\$foo = \"bar\"";
	print "$foo\n";

It works just fine, $foo is assigned the string "bar" and the script
is happy.

Is there some sort of strange buffering thing that eval does? I'm at a
complete loss as to why this is happening.

Any help/clues/pointers would be much appreciated.

-chris


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

Date: Fri, 18 Jun 1999 20:09:11 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Random Index?....
Message-Id: <3772a527.10145471@news.skynet.be>

jennifer01@vei.net wrote:

>Hi!  I was wondering if anyone knew of a script(someone told me there
>was a perl one)that would allow me to have random index pages load.
>Meaning when the person hits reload, a whole new different index page
>would load.

That's not too difficult, provided that your server allows a CGI script
as an index page. Essentaially, what you do is:

	print "Content-type: text/html\n\n";
	open(HTML,"/local/directory/to/file.html"); # or die...
	while(<HTML>) {
		print;
	}

That's the whole script. It reads an existing HTML file, and outputs it
to the browser.

If you can get that to work, it's time for the newt step: pick a random
file. I could assume that you have 12 files, "index01.html" ...
"index12.html", in that directory, then you can randomly select one,
using

	$file = sprintf('index%02d.html', 1 + rand 12);

and open it with the line

	open(HTML,"/local/directory/to/$file"); # or die...

Or, alternatively, pick ANY file in that subdirectory:

	opendir(DIR,'/local/directory/to');
	@file = grep { /\.html$/ } readdir(DIR); # all html files
	closedir(DIR);
	$file = $file[rand @file]; # pick one

and you're ready to open and read that file.

	Bart.


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

Date: Fri, 18 Jun 1999 16:49:58 -0400
From: "Casey Tweten" <crt@highvision.com>
Subject: Re: Random Index?....
Message-Id: <7kebv6$5d71@news.icubed.com>

<jennifer01@vei.net> wrote in message
news:929734963.817.103@news.remarQ.com...
: Hi!  I was wondering if anyone knew of a script(someone told me there
: was a perl one)that would allow me to have random index pages load.
: Meaning when the person hits reload, a whole new different index page
: would load.  I saw it at http://starwars.com/episode-i/ and just am
: dying to know how they do that!  Ive tried in vain for a javascript
: for it but am not too sure on some of the details about it.  So i
: figured id try here as well since i was told it was more then likely a
: perl script.  Any help would be greatly appreciated!  Thanks!
:     Jen

It is possibly a Perl script, and I am sure that you are about to be flames
since this is completley off topic because you want a CGI, and that is a
whole nother (slew of) newsgroup(s).

But, for fun, this is one way to do that.  This implies that you will be
naming your indexes as follows:

index1.*(some ext: .htm .html .cgi .shtml .pl .asp .anything_else)
index2.*
etc...

#!/usr/local/bin/perl -w
use strict;
$|++;

use CGI qw(:standard);

my $dir = '/path/to_some/place';

sub die_gracefully {
    my $attempt = shift;
    print header,
    start_html,
            "Could not $attempt: $!\n",
    end_html;
    die;
}

opendir( DIR, $dir ) || die_gracefully('Open Directory');
my @indexes = grep( /^[index\d\.]/, readdir( DIR ) );
closedir( DIR );

print redirect( $indexes[rand @indexes] ) || die_gracefully('Open Index');

This is not tested, but it is peiced together from perlfaq4(the redirect)
and some comments about my bad error checking from previous posts, which are
archived at www.deja.com so you would be sent there, and CGI groups and some
other uncertain terms may be implied...

--
               +-----------------+
               | Casey R. Tweten |
+--------------+--------+--------+--------------+
| * KiskiNet ISP        | HighVision Associates |
| * HighVision Studio   | Web Developer         |
| * ISP-ProServices     | www.highvision.com    |
| * CityBuilder.com     | crt@highvision.com    |
+-----------------------+-----------------------+
|   <joke>This is 100% virus free code</joke>   |
+-----------------------------------------------+





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

Date: Fri, 18 Jun 1999 19:41:52 GMT
From: Andrey Zmievski <zmievski@ispi.net>
Subject: Relocation error in Socket.so
Message-Id: <7ke7dt$qgj$1@nnrp1.deja.com>

I've downloaded an application written in Perl today, but when it tried
to configure itself, an error was produced:

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

output of perl -V is:

  Platform:
    osname=solaris, osvers=2.7, archname=sun4-solaris
    uname='sunos thelonious.ispi.net 5.7 generic sun4u sparc
sunw,ultra-1 '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='gcc -B/usr/ccs/bin/ -B/usr/ccs/bin/', optimize='-O',
gccversion=egcs-2.91.66 19990314 (egcs-1.1.2 release)
    cppflags='-I/usr/local/include'
    ccflags ='-I/usr/local/include'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='gcc -B/usr/ccs/bin/ -B/usr/ccs/bin/', ldflags ='
-L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldl -lm -lc -lcrypt
    libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'


Characteristics of this binary (from libperl):
  Built under solaris
  Compiled at Jun 18 1999 14:25:56
  @INC:
    /usr/local/lib/perl5/5.00503/sun4-solaris
    /usr/local/lib/perl5/5.00503
    /usr/local/lib/perl5/site_perl/5.005/sun4-solaris
    /usr/local/lib/perl5/site_perl/5.005
    .

Why does this happen and how can I fix it?

Any help is appreciated,

-Andrey


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 18 Jun 1999 15:10:48 -0500
From: claird@Starbase.NeoSoft.COM (Cameron Laird)
Subject: Re: Running Perl Simultaneously with another language..
Message-Id: <7ke948$o2t$1@Starbase.NeoSoft.COM>

In article <7ke1o9$l5m$1@news1.bu.edu>, Chih-Hsin Wen <ccwen@bu.edu> wrote:
			.
			.
			.
>	  is really unimportant to the problem. I would like to be able to
>	  from my program create functions that will launch a perl interpreter
>	  that runs simultaneously. So that I can send commands to the
>	  interpreter from my program. I don't want to just be able to launch
>	  scripts, but be able to create variables at one time, and access
>	  them whenever I'd like. What my future plans are for this program to
>	  launch a perl interpreter and use a Tk interface to show a graphical
>	  real time simulation. So the program must be able to communicate
>	  constantly..
>
>	  Some Ideas I've had are to use named pipes or even internet Sockets
>	  but I'd like to keep things fairly simple. What  I'm also wondering is, is
>	  there a way to set perl in the backgroung to just wait for commands?
>	  Is this like debugging mode? Any help would be really appreciated.
			.
			.
			.
Yes, your plan is feasible.

I do a lot of this, though always using Tcl or Python
until now; I use Perl for many other things, and am
sure it can do this, too, but my own history simply
hasn't included this combination.

Named pipes are cool, but (internet) sockets are even
cooler, and, in my experience, do not add any complex-
ity with modern languages.  The advantage that sockets
give of being able to migrate the interpretive server
(or clients) around a network is a winner.
-- 

Cameron Laird           http://starbase.neosoft.com/~claird/home.html
claird@NeoSoft.com      +1 281 996 8546 FAX


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

Date: Fri, 18 Jun 1999 16:34:12 -0400
From: Greg Bartels <gbartels@xli.com>
Subject: Re: Running Perl Simultaneously with another language..
Message-Id: <376AAD44.30060CA2@xli.com>

if you get that working, _please_ let me know...
I'm doing verilog/VHDL simulations too,
and what you described would be pretty cool.

Greg


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

Date: Fri, 18 Jun 1999 13:39:03 -0700
From: "Luis F. Salas" <unclelui@grin.net>
Subject: s/\s/ /g does not work for me... why??!!
Message-Id: <376AAE66.1E97@grin.net>

Hello,

I am trying to write a CGI script where the user enters certain
info and the program appends it to a text file.

There are only 3 fields. Name, email and comments.

It works fine, as long as the comments are in one line.
But if I hit RETURN one or more times while entering the comments the
program crashes. Upon doing a cat on the file where the text gets
written, , I saw a ^M symbol at the end of each line.

I thought one way to try to go around this is by coding

$comments contains the comments (including the new line)

so, since \s   should contain blank space, \n, \t and \f  I wrote

$comments=~ s/\s/ /g;   ------->  replace by a simple blank space.

but that does not seems to work.

So, the basic question is, how do I get rid of the new line? or the ^M ?

If you care to look at it, the program is in:
http://heretic.mcs.csuhayward.edu/~lsalas/cgi-bin/myp4.cgi
enter 'guest' (no quotes) as login & password
                                                
choose VIEW guestbook

Thanks

Luis
unclelui@grin.net


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

Date: 18 Jun 1999 20:42:36 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: s/\s/ /g does not work for me... why??!!
Message-Id: <7keavs$rgd$1@info2.uah.edu>

In article <376AAE66.1E97@grin.net>,
	"Luis F. Salas" <unclelui@grin.net> writes:
: $comments=~ s/\s/ /g;   ------->  replace by a simple blank space.

    $comments =~ s/\s+/ /g;

Greg
-- 
Daphne:  Don't tell me that you've never used sex to get what you want 
Frasier: Men can't use sex to get what we want. Sex *IS* what we want.


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

Date: Fri, 18 Jun 1999 17:19:03 -0400
From: evil Japh <jeffp@crusoe.net>
Subject: Re: s/\s/ /g does not work for me... why??!!
Message-Id: <Pine.GSO.3.96.990618171714.3119F-100000@crusoe.crusoe.net>

[Email sent to Greg Bacon and Luis F. Salas as well]

On 18 Jun 1999, Greg Bacon wrote:
> : $comments=~ s/\s/ /g;   ------->  replace by a simple blank space.
>     $comments =~ s/\s+/ /g;

It is much more efficient to use the tr/// operator in this case, so you
may want to consider using:
	$comments =~ tr/\n\r\f\t / /s;

-- 
Jeff Pinyan (jeffp@crusoe.net)
www.crusoe.net/~jeffp

Crusoe Communications, Inc.
732-728-9800
www.crusoe.net



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

Date: Fri, 18 Jun 1999 14:38:51 -0700
From: "Luis F. Salas" <unclelui@grin.net>
To: evil Japh <jeffp@crusoe.net>
Subject: Re: s/\s/ /g does not work for me... why??!!
Message-Id: <376ABC6B.5366@grin.net>

Thanks, but neither one worked.

I made the change BEFORE sending them to the text file, and they
still show up  as

xxxxxx
yyyyy
zzzz

instead of xxx yyyyy zzzz as I need...

It is the RETURN character I awant to get rid of...
Sorry if I did not emphasized that earlier.

L.


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

Date: Fri, 18 Jun 1999 16:39:06 -0400
From: "AL" <pnkflyd51@hotmail.com>
Subject: Re: script to lookup phone number off website?
Message-Id: <7kears$nel$1@autumn.news.rcn.net>


David Cassell <cassell@mail.cor.epa.gov> wrote in message
news:376A9CAF.317DED7E@mail.cor.epa.gov...
> AL wrote:
> >
> > Darn, can't I be lazy?
> >
> > Tom Phoenix <rootbeer@redcat.com> wrote
> > [snip]
> > > If you're wishing merely to _find_ (as opposed to write) programs,
> > > this newsgroup may not be the best resource for you. There are many
> > > freeware and shareware archives which you can find by searching Yahoo
> > > or a similar service. Hope this helps!
>
> Yes, you can be lazy.  Laziness is a virtue for Perl programmers.
> In fact, it is defined (in the camel) as: "The quality that makes
> you go to great effort to reduce overall energy expenditure.  It
> makes you write labor-saving programs that other people will find
> useful, and document what you wrote so you don't have to answer
> so many questions about it..."
>
> Asking others to do your work *increases* overall energy
> expenditure.  That doesn't sound like the Perl definition of
> Laziness to me.  But using a labor-saving program like Yahoo!
> might be a step in that direction.
>
> HTH,
> David


In my defense, I did spend 15 minutes looking at CPAN before posting.  I
wasn't able to find an easy to read list of scripts/modules.

Al





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

Date: Fri, 18 Jun 1999 14:45:33 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
To: AL <pnkflyd51@hotmail.com>
Subject: Re: script to lookup phone number off website?
Message-Id: <376ABDFD.C80BDE2E@mail.cor.epa.gov>

[courtesy cc sent to poster]

AL wrote:
> In my defense, I did spend 15 minutes looking at CPAN before posting.  I
> wasn't able to find an easy to read list of scripts/modules.

Then check out this URL:
  http://theory.uwinnipeg.ca/search/cpan-search.html
It may be easier to find what you're looking for there, if it's in
CPAN.  If not, you may want to hit someplace like
  http://www.cgi.resourceindex.com/

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Fri, 18 Jun 1999 23:40:51 +0200
From: jan.dubois@ibm.net (Jan Dubois)
Subject: Re: win32 shortcut tool?
Message-Id: <376cb904.19163866@news3.ibm.net>

[mailed & posted]

Darrin Husmann <dthusma@netscape.net> wrote:

>attempting to run Aldo Calpini's win32::shrotcut tool.  Doing the
>install.bat, it returns :
>Can't locale NT.ph....
>I know about the h2ph (re: Cookbook pg.425), the issue I have is on my
>win95 box,
>there does NOT exist a header NT.h...so I submit to each of you:
>
>has anyone got this (or any other) shortcut tool working on win9X and
>NT?
>If so, how?

If you use ActivePerl, the module is either already included, or you can
install it using ppm (Win32::Shortcut is part of the libwin32 bundle).

-Jan


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 6050
**************************************

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