[13825] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1235 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Oct 31 02:05:32 1999

Date: Sun, 31 Oct 1999 00:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <941353508-v9-i1235@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 31 Oct 1999     Volume: 9 Number: 1235

Today's topics:
        cgi on netscape <shalikas@americasm01.nt.com>
    Re: Drop the last item from the Environment string (CGI (J. Moreno)
        help with Text:ParseWords <yordestine@earthlink.net>
    Re: help with Text:ParseWords <slanning@bu.edu>
    Re: help with Text:ParseWords <skilchen@swissonline.ch>
    Re: How can I show a page-visitor his IP on my homepage <jkuhnert@bellatlantic.net>
    Re: How can I show a page-visitor his IP on my homepage <bokler_1@hiwaay.net>
        How exactly do I start creating a CGI with PERL <hacker65@cybertech.com.sg>
    Re: How exactly do I start creating a CGI with PERL <slanning@bu.edu>
    Re: How exactly do I start creating a CGI with PERL (Bill Moseley)
        looking for perl2c compiler <goldberg@goldsoft.com>
    Re: looking for perl2c compiler <slanning@bu.edu>
    Re: Perl script to compile C program. KernelKlink@webtv.net
    Re: Reading a file backwards? (Peter J. Kernan)
    Re: Telnet Question (Martien Verbruggen)
    Re: use heredoc to assign var? <sun_tong@geocities.com>
    Re: What's an elegant way to populate an array with met <kbandes@home.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 30 Oct 1999 21:33:49 -0400
From: "Kashyap, Shalini [SKY:BA12:EXCH]" <shalikas@americasm01.nt.com>
Subject: cgi on netscape
Message-Id: <381B9C7D.13B7E1C9@americasm01.nt.com>

Hi, I have developed a webpage using perl that creates a
form with table rows.  The problem is each row has about 6 select boxes
and when there are more than 7 rows in the table, my netscape
window freezes. 

Does anyone know why this may happen?  It seems my hard disk
cache is fine, and adjusting the memory cache doesn't make oh so
much difference.  When I lower the resolution of my monitor it works.

Does anyone know how I can fix this problem from within the program?
The program itself is only about 500 lines.

Thanks alot!!


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

Date: Sat, 30 Oct 1999 23:23:08 -0400
From: planb@newsreaders.com (J. Moreno)
Subject: Re: Drop the last item from the Environment string (CGI)
Message-Id: <1e0igps.1yigmsqwczm0iN%planb@newsreaders.com>

Larry Rosler <lr@hpl.hp.com> wrote:
> > > --
> 
> I wonder where my sigdash blank went -- it's there at the end as I post
> this.

The Windows version of OE 5 doesn't remove the sig like it should, and
Wyzelli isn't removing it by hand as he should.

Broken program, broken user...nothing to do with you.

-- 
John Moreno


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

Date: Sat, 30 Oct 1999 22:48:00 -0500
From: "Troy Lachinski" <yordestine@earthlink.net>
Subject: help with Text:ParseWords
Message-Id: <7vge61$ofc$1@fir.prod.itd.earthlink.net>

For starters I am a newbie, but I have read the FAQ (perlfaq4) that covered
this topic, I have also read every post from this newsgroup since the 19th
(hoping the same topic would be covered).  I am sure I just do not
understand the way that Text:ParseWords is supposed to work.

This is my only trouble:

After reading a line from a file into $_ I perform the following split
function....

($memory_location_counter, $plu_number, $shift_type, $plu_descriptor,
$price1,
$preset, $print_red, $inactive, $negative, $tax1, $tax2, $tax3, $tax4,
$non_add,
$print_receipt, $print_journal, $print_kp, $print_display, $discount,
$promo,
$memo, $cond_table_or_cond_chain, $condiment, $compulse_shift_type_1,
$compulse_shift_type_2, $compulse_shift_type_3, $special_item_stock, $scale,
$auto_grill, $coupon1, $coupon2, $coupon3, $printer_group, $video_group,
$video_color, $cond_table_or_chain, $piece_count, $recipe, $product_mix1,
$product_mix2, $subgroup, $kitchen_grill_group, $linked_plu, $tare, $MLU,
$deposit) = split(/,/);

This works great except the fact that some of the fields have comma's in
then. So I know that I need to use

use Text::ParseWords;
@new = quotewords(",", 0, $text);

but I can't figure out how to do this...

I have tried MANY things including:

use Text::ParseWords;
@new = quotewords(",",0,$_);

$new[0] = $memory_location_counter;
$new[1] = $plu_number;
$new[2] = $shift_type;
etc...

but this does not seem to put any values into $new[0] and also no values
into $memory_location_counter.

I think that I am using the quotewords command wrong because the program
worked swell before I changed it (except for the fact that many records were
messed up due to the ","'s).

Thanks in advance for any help that might be given.

And I apologize in advance if I am not following the correct protocol with
this post.





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

Date: 31 Oct 1999 01:41:20 -0400
From: Scott Lanning <slanning@bu.edu>
Subject: Re: help with Text:ParseWords
Message-Id: <kusogdgw0hr.fsf@charm.bu.edu>

"Troy Lachinski" <yordestine@earthlink.net> writes:
> This works great except the fact that some of the fields have comma's in
> then. So I know that I need to use
> 
> use Text::ParseWords;
> @new = quotewords(",", 0, $text);

I don't understand how it can work if your fields contain
commas and also your field delimiters are commas..

foo,bar,baz

Would that be 1, 2, or 3 fields???

-- 
"If lightning is the anger of the gods, the gods are concerned mostly
with trees." --Lao Tse


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

Date: Sun, 31 Oct 1999 05:54:18 GMT
From: "Samuel Kilchenmann" <skilchen@swissonline.ch>
Subject: Re: help with Text:ParseWords
Message-Id: <eQQS3.27734$m4.99998680@news.magma.ca>

Troy Lachinski <yordestine@earthlink.net> wrote in message
news:7vge61$ofc$1@fir.prod.itd.earthlink.net...
> This is my only trouble:
>
> After reading a line from a file into $_ I perform the following
> split function....
>
> ($memory_location_counter, $plu_number, $shift_type, $plu_descriptor,
> $price1, $preset, $print_red, $inactive, $negative, $tax1, $tax2, $tax3, $tax4,
> $non_add, $print_receipt, $print_journal, $print_kp, $print_display, $discount, $promo,
> $memo, $cond_table_or_cond_chain, $condiment, $compulse_shift_type_1,
> $compulse_shift_type_2, $compulse_shift_type_3, $special_item_stock, $scale,
> $auto_grill, $coupon1, $coupon2, $coupon3, $printer_group,$video_group,
> $video_color, $cond_table_or_chain, $piece_count, $recipe, $product_mix1,
> $product_mix2, $subgroup, $kitchen_grill_group, $linked_plu, $tare, $MLU,
> $deposit) = split(/,/);
>
[sorry i was too lazy to adjust the line length]
>
> I have tried MANY things including:
>
> use Text::ParseWords;
> @new = quotewords(",",0,$_);
>
> $new[0] = $memory_location_counter;
> $new[1] = $plu_number;
> $new[2] = $shift_type;
> etc...
>
You are close, but the assignments are exactly "the wrong way".
$memory_location_counter = $new[0];
etc...
would be much better.
You could also replace "split(/,/);" in the long statement above with
quotewords(",", 0, $_);
or with
parse_line(",", 0, $_);
(which is essentially the same, except that parsewords accepts a list
of strings, and parse_line only a single string.)

My usual recommendation is to use the module Text::CSV_XS instead
because what Text::ParseWords parses is not what is commonly called
the CSV format (where quotes in quoted fields are not escaped with \
as Text::ParseWords assumes, but simply doubled and CSV fields can
contain multiline values). Try sômething like:

#!/wherever/perl -w
use strict;
use Text::CSV_XS;

my $csv = Text::CSV_XS->new({ binary => 1 });

my $buffer  = "";
my $success = undef;

while(<>) {
  $buffer .= $_;
  $success = $csv->parse($buffer);
  if ($success) {
    my($your, $long, $list, $of, $variables) = $csv->fields();
    $buffer = "";
    # do whatever you want with the variables
    print "$your, $long, $list, $of, $variables", "\n";
  }
}
if (not $success) {
  my $err = $csv->error_input();
  print "parse CSV failed at:\n", $err, "\n";
}





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

Date: Sun, 31 Oct 1999 01:10:24 GMT
From: "G. Jesse Kuhnert" <jkuhnert@bellatlantic.net>
Subject: Re: How can I show a page-visitor his IP on my homepage ?
Message-Id: <381B9685.D2FD0783@bellatlantic.net>

I'm not sure how the proxy server's work, but I guess that the only way
I know of getting an environment I.P. address is by putting:(Although I
think this may be the incorrect hash key, but you can screw around with
it by printing out all the keys yourself...)

$ip=$ENV{'HOSTNAME'};

In your code....The CGI will have to generate this for you, kind of like
this:
---------------------------------------------
#!/usr/local/bin/perl

$ip=$ENV{'HOSTNAME'};

print "Content-type:  text/html\n\n";

print"Your IP address is: $ip";


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

Name this file <whateveryouwant>.pl and put it in your cgi-bin, then
call it from your browser via http://<hostname>/cgi-bin/<filename> to
see if it works...Hope this helps








Gerhard Landauf wrote:
> 
> Hello !
> 
> Obviously this problem cannot be managed in (pure) Java.
> 
> So, can anyone of you experts tell me how thet can be done using
> Perl/CGI ?
> 
> The specific problem is:
> 
> I'd like to show a visitor on my homepage from which IP (host address)
> he is logging in. Don't need any routine for saving this information or
> anything like that, just showing the IP to the visitor *himself*.
> 
> E.g. on my homepage a visitor then should read:
> 
> "... you are connecting from 245.0.10.45" or anything like that.
> 
> Does anyone of you know of a quick recipe for my problem and can also
> tell me, how I could integrate the data from that CGI file in the HTML
> code of the homepage ?
> 
> Thank you so much !
> 
> Greetings from Vienna,
> Gerhard
> 
> Gerhard Landauf (Vienna/AUSTRIA) mailto:landauf@inode.at
> --
> phone (GSM): +43676 4139765
> RSA/2048 ID: 6D094CC9 - FP: 2670 3D21 61B7 96C9  B57C 3AA8 3827 0F24
> DSS/4096 ID: B3B51660 - FP: 7065 2B70 7927 5A9D 8282  8197 6327 235D B3B5 1660


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

Date: Sun, 31 Oct 1999 01:33:59 -0500
From: James Moore <bokler_1@hiwaay.net>
Subject: Re: How can I show a page-visitor his IP on my homepage ?
Message-Id: <OdIbOFUVETQ0+l+4K03yc=owoFtN@4ax.com>

One way is to use the remote_addr() function in CGI.pm. The following
line in your CGI script should do it:

print "You came from ", $q->remote_addr();

Be sure you declare in your CGI script that you're going to use CGI.pm
with a statement like:

use CGI qw/:all/;

Another way is to use Server Side Includes (aka server parsed html).
The following, when inserted into an html file will display the
visitor's IP address. 

<p><!--#echo var="REMOTE_ADDR"--></p>

You should check with your system admin (or whoever it is that
configures your webserver) to see if SSI is enabled (if not, the above
will not work). Depending on how your wbserver is configured you may
also need to use an "shtml" file extension instead of "html", or
"htm", and if the webserver's hosted under Unix the file may have to
be chmod'd to be executable. Again, your system admin should be able
to answer these questions. 

To learn more about SSI, try your favorite search engine. Matt Kruse
has a pretty good tutorial on SSI at
http://mkruse.netexpress.net/info/ssi/

Good Luck~

On 30 Oct 1999 19:01:21 -0500, abigail@delanet.com (Abigail) wrote
(before flying off on her broom):

>Gerhard Landauf (landauf@teleweb.at) wrote on MMCCLI September MCMXCIII
>in <URL:news:38206753.48099682@news.telekabel.at>:
>;; 
>;; Obviously this problem cannot be managed in (pure) Java.
>
>Eh? How so? Java's inability to print?
>
>;; So, can anyone of you experts tell me how thet can be done using
>;; Perl/CGI ?
>;; 
>;; The specific problem is:
>;; 
>;; I'd like to show a visitor on my homepage from which IP (host address)
>;; he is logging in. Don't need any routine for saving this information or
>;; anything like that, just showing the IP to the visitor *himself*.
>
>Ah, yes, very useful information. As if the user doesn't already know
>that himself.
>
><offtopic>
>You cannot do that. All you can find out is the IP address of the
>last proxy the request came through.
>
>To find out the latter, check the CGI specification - which is not
>the topic of this newsgroup.
></offtopic>
>
>;; E.g. on my homepage a visitor then should read:
>;; 
>;; "... you are connecting from 245.0.10.45" or anything like that.
>;; 
>;; Does anyone of you know of a quick recipe for my problem and can also
>;; tell me, how I could integrate the data from that CGI file in the HTML
>;; code of the homepage ?
>
>print "<p>245.0.10.45";
>
>For more questions, go to an HTML newsgroup - HTML is not the topic of
>this newsgroup.
>
>
>
>Abigail



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

Date: Sun, 31 Oct 1999 10:00:58 +0800
From: "Zeus" <hacker65@cybertech.com.sg>
Subject: How exactly do I start creating a CGI with PERL
Message-Id: <7vg89s$453$1@clematis.singnet.com.sg>

What programs do I need to start programming with PERL ? My Host has a UNIX
system with perl ready but How do I create my own CGI script ?






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

Date: 31 Oct 1999 01:31:29 -0400
From: Scott Lanning <slanning@bu.edu>
Subject: Re: How exactly do I start creating a CGI with PERL
Message-Id: <kusu2n8w0y6.fsf@charm.bu.edu>

"Zeus" <hacker65@cybertech.com.sg> writes:
> What programs do I need to start programming with PERL ? My Host
> has a UNIX system with perl ready but How do I create my own
> CGI script ?

READ the FAQ
READ comp.infosystems.www.authoring.cgi
READ the gazillions of webpages on CGI
READ the gazillions of books on CGI with Perl

GAZILLIONS!!!!!

-- 
"I'm going to have fun telling you about this absurdity, because I
find it delightful." --Richard Feynman


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

Date: Sat, 30 Oct 1999 22:29:44 -0700
From: moseley@best.com (Bill Moseley)
Subject: Re: How exactly do I start creating a CGI with PERL
Message-Id: <MPG.128573a32adf49f698982b@nntp1.ba.best.com>

Zeus (hacker65@cybertech.com.sg) seems to say...
> What programs do I need to start programming with PERL ? My Host has a UNIX
> system with perl ready but How do I create my own CGI script ?

If you have a specific program you need then it's just easier to ask 
someone here to write it for you.

Otherwise, I'd consider searching the web.  I've heard about these 
search engine things that find things for you.  Cool, I think.  I was 
also at a bookstore the other day and saw some books on the Web and CGI.  
Frankly, I couldn't believe it.  Do people actually still read books?

There's also all these FACKS things I've seen around that answer common 
questions.

If you are on a UNIX host already and it has P.E.R.L installed then you 
are half way there.  Now you need some disk space, and permission from 
the system admin to run CGI scripts.  Most ISPs have some help web pages 
on running CGI programs that help you get started.

Don't forget to type 'perldoc CGI' at your UNIX prompt.  That's a really 
important "module" that people often recommend.

Good luck,

-- 
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.


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

Date: Sun, 31 Oct 1999 02:21:47 GMT
From: "Bernie Goldberg" <goldberg@goldsoft.com>
Subject: looking for perl2c compiler
Message-Id: <%INS3.18837$At1.82976@news1.rdc2.on.home.com>

I am looking for a perl2c compiler. I did my due diligence with search
engines to no avail.

CPAN had no information either.

I am posting this on the chance that someone may be able to steer me in some
good direction. Does anyone know of any perl2c compiler at this time? Any
help would be greatly appreciated.

Regards

Bernie




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

Date: 31 Oct 1999 01:35:18 -0400
From: Scott Lanning <slanning@bu.edu>
Subject: Re: looking for perl2c compiler
Message-Id: <kusr9icw0rt.fsf@charm.bu.edu>

"Bernie Goldberg" <goldberg@goldsoft.com> writes:
> I am looking for a perl2c compiler. I did my due diligence with search
> engines to no avail.
> 
> CPAN had no information either.

Lies! Hideous LIES!!!

I found it from CPAN in less than a minute......
(and note that i'm a dimwit)

-- 
qualification: I'm a dimwit according to someone who emailed me


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

Date: Sat, 30 Oct 1999 23:59:45 -0400 (EDT)
From: KernelKlink@webtv.net
Subject: Re: Perl script to compile C program.
Message-Id: <14829-381BBEB1-43@storefull-211.iap.bryant.webtv.net>

(Jonathan=A0Stowe) wrote:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D 
I think that it might be more appropriate to read the RFD that was
posted in that newsgroup and then act appropriately - I for one would
like to see a group to which we could point MySQL users. I would suggest
that encouraging people to post into a probably *inappropriate* group is
either trolling or an attempt to manipulate the newsgroup creation
process.  Of course there are also mailing lists that deal with MySQL.
/J\ 
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D

Mr Stowe,

First, this is a Perl newsgroup and you should refrain from making it a
soapbox from which to pontificate to us as to what you "think" about
this or that in the realm of net etiquette.

Sending me an email would have been much more appropriate.

Second, if you can find a copy of comp.databases RFD's that show me to
be at fault, then please send me a link or email. The only descriptions
I could find on appropriate comp.databases posting material is in the
name itself (comp.databases is rather generic isn't it). Also, Baylor
University in Texas describes appropriate postings for comp.databases:
"Database and data management issues and theory". Sounds like MySQL
might fall under that category, doesn't it?

Third, you used the terms "trolling" and "manipulate" in regards to a
"probably inappropriate group". Did you say "PROBABLY"? You should have
checked out the RFD's yourself and been sure before you made such
irresponsible remarks in a public forum.



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

Date: 31 Oct 1999 04:54:32 GMT
From: pete@theory2.phys.cwru.edu (Peter J. Kernan)
Subject: Re: Reading a file backwards?
Message-Id: <slrn81nis7.k6g.pete@theory2.phys.cwru.edu>

On 30 Oct 1999 10:27:42 -0000, Jonathan Stowe <gellyfish@gellyfish.com> wrote:
 .=open(REV,"tac $file |" ) || die "Couldnt fork for tac - $!\n";
 .=while(<REV>)
 .={
 .=  print;
 .=}
 .=close(REV) || die "Problem with tac - $?\n";
 .=
 .=But of course that is silly ...

not silly at all, hilarious. too bad tac isn't standard Unix. i
thought the name was a joke, but my linux box has it (AIX not, solaris
not), so i decided to play a little (gnu assisted) golf.

print +($_ = `tac $file` or die$!);

-- 
  Pete


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

Date: 31 Oct 1999 05:34:33 GMT
From: mgjv@wobbie.heliotrope.home (Martien Verbruggen)
Subject: Re: Telnet Question
Message-Id: <slrn81nle4.qu5.mgjv@wobbie.heliotrope.home>

On Sat, 30 Oct 1999 23:49:33 GMT,
	G. Jesse Kuhnert <jkuhnert@bellatlantic.net> wrote:

[question about installing Net::Telnet in own directory somewhere]

> I know you guys hate newbie questions, but please feel pity for a humble

We don't hate newbie questions. We just don't like people who come here
to beg for solutions without being prepared to do any owrk themselves,
or people who talk about stuff that is totally unrelated to Perl. In
general, if someone who is new to Perl shows that he or she has done
whatever they can to get to where they want to be, but simply get stuck,
you'll find that we don't have any trouble answering at all.

> little Perl beginner. I have read the FAQ's/man-pages/etc....It's not

Have you also read the part of Perl FAQ 8 that talks about how you can
keep your own module directory? And the questions around that one? Thos
should be exactly what you are looking for.

The following ones should be interesting:

# perldoc perlfaq8
      How do I install a CPAN module?
      How do I keep my own module/library directory?
	  How do I add the directory my program lives in to the
	  module/library search path?
	  How do I add a directory to my include path at runtime?

Most of these would have shown up with a 

# perldoc -q module

or, slightly less verbose:

# perldoc -q module | grep =head

> like I haven't tried to solve the problem myself. I'm just not
> experienced enough in Perl to write my own socket connection to a remote
> Telnet host yet...

No need to write raw sockets stuff. In this case it would be too much
work anyway :)

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Make it idiot proof and someone will
Commercial Dynamics Pty. Ltd.   | make a better idiot.
NSW, Australia                  | 


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

Date: Sat, 30 Oct 1999 21:09:22 -0400
From: * Tong * <sun_tong@geocities.com>
Subject: Re: use heredoc to assign var?
Message-Id: <381B96C2.8E79E574@geocities.com>

: Can I use heredoc to assign a bunck of txt to a varible? 

Thanks Eric!

perl -e '
$var=<<"EOF";
bla bla bla
EOF
print "$var";
'

-- Tong
Anti-spam: remove underscore to reply.
Welcome to my homepage http://maxpages.com/suntong
  - All free contribution & collection
  - freeware &  music from the heavens


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

Date: Sun, 31 Oct 1999 03:06:33 GMT
From: Kenneth Bandes <kbandes@home.com>
Subject: Re: What's an elegant way to populate an array with method refs?
Message-Id: <381BB23D.C372DD2A@home.com>

duane powell wrote:
> What's an elegant way to populate an array with method refs?
[...]
> sub someMethod {
>  my $self = shift;
> }
> 
> sub someOtherMethod {
>  my $self = shift;
> }
> 
> sub getMethods {
>  my $self = shift;
>  $self->{MY_METHODS}   = undef;
>  push @{ $self->{MY_METHODS} }, \$self->someMethod();
>  push @{ $self->{MY_METHODS} }, \$self->someOtherMethod();

You don't need the -> to get the reference.  A method in Perl is just 
a subroutine.  Try
  $self->{MY_METHODS} = [\&someMethod, \&someOtherMethod];

Ken Bandes


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

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 V9 Issue 1235
**************************************


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