[7343] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 968 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 3 13:07:32 1997

Date: Wed, 3 Sep 97 10:00:26 -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           Wed, 3 Sep 1997     Volume: 8 Number: 968

Today's topics:
     "Odd number of elements in hash list": So? (Doug Claar)
     Re: "Odd number of elements in hash list": So? (Brian Wheeler)
     Re: Anyone else seeing this core dump in perl5.004_03 o (Greg Bacon)
     Array Question about fast method of comparisons <dlorenso@afai.com>
     Communication between computer, modem and Videorecorder <verschue@esat.kuleuven.ac.be>
     Re: Communication between computer, modem and Videoreco (Brian Wheeler)
     Re: Complex map problem (Bennett Todd)
     Re: duplicate problems.. (Matti Kinnunen)
     Dynmical pattern problem <slateff@netway.at.Please.remove.this.I.really.hate.spam>
     Re: gethostbyaddr or some such... (David Efflandt)
     Re: Help with Perl hooks on INN 1.5.1, please <merlyn@stonehenge.com>
     Re: Help with perl script jmisiris@hotmail.com
     Re: Help! cron&perl ! (Will Morse)
     IS there a 'strlen' in Perl? (Jun Zhuang)
     Re: NET::NNTP Woes <blb@fedex.com>
     Pattern Matching with Arrays (Tracy Bednar)
     Patternmatching with arrays (Robert)
     Perl Help (:F:F&a*:-7)
     Printing two variables on alternate lines? (Phil Davey)
     Re: Pushing output in CGI (David Efflandt)
     Query Strings & CGI's (The Infamous BooBoo Q. Earp.)
     Re: Script on input to perl arrays wanted - Newbie lear (Tad McClellan)
     Re: shell command "more" (William Wue(2xP)elma(2xN))
     Re: Time warp - Perl 4 question <bsugars@sunpub.com>
     Re: Trivial(?) readdir question (M.J.T. Guy)
     Re: using unix commands for missing libwww module (David Efflandt)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 3 Sep 1997 00:59:14 GMT
From: dclaar@hp.cNoSPAm (Doug Claar)
Subject: "Odd number of elements in hash list": So?
Message-Id: <5uicp2$rt4$1@ocean.cup.hp.com>

With -w and strict turned on, perl 5.004 warns me that I have an
"Odd number of elements in hash list". Why does it care, and should
I care? Seems like a fairly useless error message, in that--if there
is a reason that this is bad, it certainly doesn't tell you what it
is, and if it isn't, why print it?

==Doug Claar


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

Date: 3 Sep 1997 16:24:30 GMT
From: bdwheele@indiana.edu (Brian Wheeler)
Subject: Re: "Odd number of elements in hash list": So?
Message-Id: <5uk2vu$52m$1@dismay.ucs.indiana.edu>

In article <5uicp2$rt4$1@ocean.cup.hp.com>,
	dclaar@hp.cNoSPAm (Doug Claar) writes:
>With -w and strict turned on, perl 5.004 warns me that I have an
>"Odd number of elements in hash list". Why does it care, and should
>I care? Seems like a fairly useless error message, in that--if there
>is a reason that this is bad, it certainly doesn't tell you what it
>is, and if it isn't, why print it?
>
>==Doug Claar

Sounds like the list you're assigning to a hash has an odd number of elements,
which means that the final key has no value assigned to it.
i.e.:
	%myhash=('key1'=>1,'key2'=>3,'key3'); 
would trigger this message. 

Not a useless error message at all:  you're doing something wrong and its
telling you that it may cause problems.
  

-- 
Brian Wheeler
bdwheele@indiana.edu


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

Date: 3 Sep 1997 15:20:50 GMT
From: gbacon@adtran.com (Greg Bacon)
To: lvirden@cas.org
Subject: Re: Anyone else seeing this core dump in perl5.004_03 on solaris 2.5.1 [Was: Re: Compiling perl5.004.01 on solaris 2.5.1
Message-Id: <5ujv8i$8cs$1@info.uah.edu>

[Posted and mailed]

In article <5u6k4r$fq1$1@cas.org>,
	lvirden@cas.org writes:
: I am seeing peculiar behavior in perl ever since installing the
: latest version.
: 
: $ perl -MCPAN -e shell
:  
: cpan shell -- CPAN exploration and modules installation (v1.29)
: ReadLine support enabled
:  
: cpan> r
: Segmentation Fault(coredump)

[snip backtrace]

: Summary of my perl5 (5.0 patchlevel 4 subversion 3) configuration:
:   Platform:
:     osname=solaris, osvers=2.5.1, archname=sun4-solaris

Works fine for me on

    SunOS carol 5.5.1 Generic sun4m sparc SUNW,SPARCstation-5

Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: 3 Sep 1997 16:23:19 GMT
From: "D. Dante Lorenso" <dlorenso@afai.com>
Subject: Array Question about fast method of comparisons
Message-Id: <01bcb885$90122280$3a151ecf@dns1.afai.com>


I have two arrays:

	@array1 = qw|3 4 5 16 24 1 43 42 31 23 56|;
	@array2 = qw|4 5 6 2 1 43 31 23 56 18 27 69|;

and I would like to do a comparison of these two arrays and receive output
of three arrays that contain the following information:

	@out1 = qw|3 16 24 42|;		# Contains all the items in Array 1 but NOT in
array 2
	@out2 = qw|4 5 1 43 31 23 56|;	# Contains all the items that are in BOTH
Array1 and Array2
	@out3 = qw|6 2 18 27 69|;	# Contains all the items in Array 2 but NOT in
array 1

What is the most efficient algorithm to use in order to send two arrays and
return three with the conditions listed?  

Dante
dlorenso@afai.com



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

Date: 03 Sep 1997 17:38:29 +0200
From: Laurent Verschueren <verschue@esat.kuleuven.ac.be>
Subject: Communication between computer, modem and Videorecorder with socket
Message-Id: <wr0oh6al85m.fsf@esat.kuleuven.ac.be>

	Hello,

	We are trying to send and receive data to and from a Vcr to a UNIX-alpha 
workstation, using a TCP-IP-modem, with its own internet adress.  

	We used two sockets for communication,  

	 use Socket;

defined all things to get a connection, which actually succeeds, we use TCP, 
have a server "plex2" and a port 4000 :

	$remote="plex2";	
	$port=4000;
	$iaddr=inet_aton($remote);
	
	$paddr= sockaddr_in($port, $iaddr);
	
	$sock=socket(TOPLEX,PF_INET,SOCK_STREAM,6); 
	$sock=socket(FROMPLEX,PF_INET,SOCK_STREAM,6);

	connect(TOPLEX,$paddr);
	connect(FROMPLEX,$paddr);

	select (TOPLEX); $| = 1; to set the buffering off

Now we can print to our vcr commands : e.g. play is hexadecimal 0x3a,...
And we get a status byte back then : 0x0a.

	print TOPLEX (0x3a); to play
	if (-z FROMPLEX) {print STDOUT "FROMPLEX IS EMPTY\n";}
	else ($status =  <FROMPLEX>);

The problem is that we don't get any action, except when we send much info 
(strings for example, the recorder begings to do strange things).

Before, we used a program which sent data to our vcr with a C++ socket. 
This went fully with the same protocol...

	Thanks in advance for your help,



	S. DESMET


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

Date: 3 Sep 1997 16:34:53 GMT
From: bdwheele@indiana.edu (Brian Wheeler)
Subject: Re: Communication between computer, modem and Videorecorder with socket
Message-Id: <5uk3jd$52m$2@dismay.ucs.indiana.edu>


In article <wr0oh6al85m.fsf@esat.kuleuven.ac.be>,
	Laurent Verschueren <verschue@esat.kuleuven.ac.be> writes:
>
>	print TOPLEX (0x3a); to play
>	if (-z FROMPLEX) {print STDOUT "FROMPLEX IS EMPTY\n";}
>	else ($status =  <FROMPLEX>);
>
>The problem is that we don't get any action, except when we send much info 
>(strings for example, the recorder begings to do strange things).

	when you print 0x3a you get: "58".  Is this what you want?  Probably
not, or you'd just write "58" :)   So, if you're wanting to print a byte with
value 0x3a, you can do it like this:
	print chr(0x3a);

Make sure that you're autoflushing this socket, to send the single byte (via
select TOPLEX; $|=1; select STDOUT;).  Also, if you're expecting one byte
back, you'd probably want to use a read() instead of <>, because <> reads a
single line of text.  

>Before, we used a program which sent data to our vcr with a C++ socket. 
>This went fully with the same protocol...

	What kind of VCR is this?  It sounds pretty cool....


-- 
Brian Wheeler
bdwheele@indiana.edu


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

Date: 3 Sep 1997 16:21:16 GMT
From: bet@network.rahul.net (Bennett Todd)
Subject: Re: Complex map problem
Message-Id: <slrn60r3jl.7tj.bet@waltz.rahul.net>


On Wed, 3 Sep 1997 23:11:24 +1000, Chris Phillips <cphillip@kerr.phys.utas.edu.au> wrote:
>I have just discovered the joys of the map function, but have run
>into a problem :-(
>
>Basically, I want the map function to skip a couple of the
>elements of the array in question. I cannot get it to work.

map _can_ be coerced into doing what you want, at least sometimes, but it's
hard because that's not what it's intended for.

Map returns the array that results from concatenating the expressions, which
result from evaluating the block once for each element of the input array.

What you're looking for is grep, which returns the array of those input
elements for which the expression evaluates to "true".

	testsub '*', grep {$_ ne 'b'} @a[0..2], '*';

(untested:-).

-Bennett


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

Date: 03 Sep 1997 18:51:21 +0300
From: matti@universe.pc.helsinki.fi (Matti Kinnunen)
Subject: Re: duplicate problems..
Message-Id: <lzlo1ev1ja.fsf@universe.pc.helsinki.fi>

In article <34060E28.F86@ein.ericsson.se> Zaheed Haque :

   1|acs|Digital Image Library|Texas Tech|33452
   4|acs|Digital Display|OMTEC Inc.|98292
   5|acs|Digital Image Library|SideShop|33452
   230|dcs|Optical Fiber|TTML|82920
   902|fcp|Network adapter|Cisco|01920
   123|fcp|Network adapter|Cisco|01920
   544|acs|Digital Image Library|Image Inc|33452

   If the third items are equal and and last item are equal than it's
   a duplicate so remove all but keep one.. It doesn't matter which one..

   Could someone help me with a snippit of perl code.. 

Not the code but the idea. Split lines at 1st |. Call the parts
$fst and $rest. Store them in a hash{$rest}=$fst

print the hash. That is loop over the keys and print 
value and key on the same line separated with a |.

You will get what you want.

HTH.

- matti --
 
-- 
* matti.kinnunen@helsinki.fi *
* http://universe.pc.helsinki.fi/~matti/contact.html *
* !!! +358-(0)40-593 50 91 but try first +358-(0)9-191 23978 *


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

Date: 2 Sep 1997 21:32:19 GMT
From: "Andreas SLATEFF" <slateff@netway.at.Please.remove.this.I.really.hate.spam>
Subject: Dynmical pattern problem
Message-Id: <01bcb7e7$bd349700$LocalHost@andreass>



Andreas SLATEFF <slateff@netway.at.Please.remove.this.I.really.hate.spam> wrote in
article <01bcb70b$97f57360$LocalHost@andreass>...
[...]
> A feature consists of dynamical s///-command, the patterns are references. It works
fine
> with all patterns, backreferences like \1 etc. 
> But with $1, $2 etc, it becomes quite difficult.
> 
> Here what I tried (I think, you can imagine my intention):
> 
> $e=$2;
> s/ ..any pattern.. /$e/;
> # fails at 1st line, because $2 is not defined...
> 
[...]
> Remember: I don't want hard-coded 
> 	s/.../$2/;
> I prefer it dynamically.

Because nobody has answered me so far, I found a brute force solution:

Print "s/.../$e/" in a temorary file and execute it with `perl ...`.
Ugly.

Isn't there any better solution?

Andreas


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

Date: Sat, 30 Aug 1997 17:53:16 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: gethostbyaddr or some such...
Message-Id: <34095cc9.15201557@flood.xnet.com>


mbudash@sonic.net (Michael Budash) wrote:

>If I have an IP address (e.g., mine right now: 208.201.224.62) and I'd
>like to get the actual host name (e.g., mine right now:
>d49.pm8.sonic.net), how would I do it in perl? Would I use perl's
>gethostbyaddr function? Anybody?
>
>Response by email as well as this newsgroup preferred - I'm kinda in a hurry!
>
>TIA,
>                _____________________________
>                       Michael Budash, Owner
>                     Michael Budash Consulting
>                           707-255-5371
>                   http://www.sonic.net/~mbudash
>                         mbudash@sonic.net
>                _____________________________

See "What I know about you?" on my home page.  The script shows you
how to resolve a host name in perl (if it can be resolved).

When I had this simple question with a not so simple answer, I was
glad I got a useful response other than RTFM.


David Efflandt/Elgin, IL USA
efflandt@xnet.com    http://www.xnet.com/~efflandt/


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

Date: 03 Sep 1997 08:42:25 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: "Eric D. Friedman" <friedman@uci.edu>
Subject: Re: Help with Perl hooks on INN 1.5.1, please
Message-Id: <8cafhuz9ni.fsf@gadget.cscaper.com>

>>>>> "Eric" == Eric D Friedman <friedman@uci.edu> writes:

Eric> In article <01bcb753$2df794a0$fc01fd0a@telsarlt.harmonic.com>,
Eric> Stan A. Rogge <srogge@telsarpc.harmonic.com> wrote:
Eric> <Perl 5 does not use dbmopen and dbmclose.  It uses tie and untie.  Also,
Eric> <you must define the type dbm you are using.  Here is an example:

Eric> So how come the new Llama book still uses 'em?  I'm confused.

Because dbmopen still works, it's a simpler interface, and there's no
reason to switch.  I *still* write code using that interface.  Just
like I still write code with open(FOO,">bar") even though an IO::File
gives me more flexibility.

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 363 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Wed, 03 Sep 1997 10:21:09 -0600
From: jmisiris@hotmail.com
Subject: Re: Help with perl script
Message-Id: <873299446.8293@dejanews.com>

In article <340BE6FA.30A0@icl.fi>,
  petri.backstrom@icl.fi wrote

>> Are file/directory permissions set so that the account
> your web server runs under can access every file it
> needs to?
>
> What's displayed if you run your script with
>
>    use strict;
>
> at the beginning of the file and -w on the command line
> (or on the "shebang" line; #/usr/bin/perl -w)?
>
> What does perl -v say on the command line about your
> Perl version?
>

Since my understanding how to configure the WebServer is
growing
I found out that the file I was creating (as an result of
executing
my cgi script) where in an directory with no read/write
access.
By setting the ExecCGI option in the webserver access conf
file
the script worked fine.

I also had to copy the cgi.pm file to the location where my
cgi script
was because neither:


use lib '/perl5/lib/CGI.pm';

OR

BEGIN {
       unshift(@INC,'/perl5/lib/CGI.pm');
      }
use CGI;

worked.

I'm using perl, version 5.002 beta3 with EMBED.

Thanks anyway.


Regards,
I. John Misiris

jmisiris@hotmail.com

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 3 Sep 1997 10:21:09 -0500
From: will@Starbase.NeoSoft.COM (Will Morse)
Subject: Re: Help! cron&perl !
Message-Id: <5ujv95$gtv$1@Starbase.NeoSoft.COM>



cron starts scripts with a pretty minimal path and ld_library_path.

To see what you would get, try executing a cron that has a script

-- #! /bin/sh
-- env 

Perhaps the easiest way to handle this is have the cron start a 
wrapper script that includes your .profile  (csh is obsolete, so you should
not still be using .cshrc or .login).  Your wrapper would look like

-- #! /bin/sh               (or maybe /bin/ksh or /usr/local/bin/bash)
-- . /home/me/.profile
-- my-perl-script

This should set your perl script in the same environment as your
command line.

It is also reasonably easy, and probably more efficient in computer 
resources depending on how often your script runs and wha environment
you actually need, to simply put the required PATH and LD_LIBRARY_PATH
etc. in the wrapper and not include your .profile, which probably has
a lot of defintions and environment set that are not useful to your perl
program.

Hard coding the PATH will fix path problems, but not necessarily
library linkage problems or other missing environment.

Hope this helps.

Will

In article <5uisn2$hir$1@oravannahka.Helsinki.FI>,
Tero Tuononen  <tuononen@cc.helsinki.fi> wrote:
>Hi there !
>
>I am having problems with the following structure:
>
>I have few perl scripts that work fine when executed from commandline
>and in proper directory. When I call these very same scripts from
>cron it does not work anymore. There is one script that is called from
>cron and then the script itself calls for more scripts when it generates
>proper commandlines to do some daily routines with daily changing files. All
>the stuff is located in the same directory but is there still a problem
>with paths or what ? The script cannot access some file that surely are
>in the same directory...it also has major difficulties copying result
>files to some subdirectories and so on. 
>
>I found some info about parameter %ENV{'path'} but maybe I was not
>able to use it right since nothing new happened. Could someone confirm
>the right way to use this command?
>
>Do I need to use absolute paths in every statement if I want to use
>my scripts from cron.
>
>I really need help with this one.
>
>thanks
>
>best wishes Tero


-- 
# Copyright 1997 Will Morse.  Internet repost/archive freely permitted.
# Hardcopy newspaper, magazine, etc. quoting requires permission.
# 
#      Gravity,                    #    Will Morse
#      not just a good idea,       #    Houston, Texas
#              it's the law.       #    will@starbase.neosoft.com
#
#   These are my views and do not necessarly reflect anyone else/
 =========================================================================
      By US Code Title 47, Sec.227(a)(2)(B), a computer/modem/printer
      meets the definition of a telephone fax machine. By Sec.227(b)
      (1)(C), it is unlawful to send any unsolicited advertisement to
      such equipment, punishable by action to recover actual monetary
      loss, or $500, whichever is greater, for EACH violation.
 =========================================================================



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

Date: 3 Sep 1997 16:31:53 GMT
From: jzhuang@ringer.cs.utsa.edu (Jun Zhuang)
Subject: IS there a 'strlen' in Perl?
Message-Id: <5uk3dp$b6g@ringer.cs.utsa.edu>


Is there a function like 'strlen()' in C in Perl5?
I just want to use it to count the chars in a char string.

--
Jun Zhuang                         |Jun Zhuang 
Department of Computer Science     |Department of Pharmacology
University of Texas                |UT Health Science Center
San Antonio, Texas                 |San Antonio, Texas
Email: jzhuang@ringer.utsa.edu     |Email: zhuang@uthscsa.edu
                                   |       jun@gcrdb.uthscsa.edu


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

Date: Wed, 03 Sep 1997 09:52:08 -0600
From: Bryan Blackburn <blb@fedex.com>
Subject: Re: NET::NNTP Woes
Message-Id: <340D87A8.4CE1@fedex.com>


For your line 97, try

   $nntp->post( $posting );

And I take it $posting is an array reference, as that's what is
expected.

Also, when you create $nntp, note that options follow the hostname in
the call to new, ie,

   $nntp = Net::NNTP->new( 'news.ilk.com', Debug => 1 );

If you turn on warnings (-w switch) Net::NNTP should complain about a
bad hostname of "Debug".  Finally, "use strict;" would complain about
Debug being a bare word.

Bryan
-----
Bryan Blackburn     <blb@rmi.net>


Bruce Hodo wrote:
> 
> I've been trying to use NET::NNTP.pm in perl, but I get the following
> error:
> 
> Can't call method "Net::NNTP::post" without a package or object
> reference at /export/home/getaway/site/cgi-bin/postnews.cgi line 97,
> <BODY> chunk 15.
> 
> Line 97 is:
>  $nntp->Net::NNTP::post($posting);
> 
> I've tried it with just "post($posting);", but it still doesn't work. In
> the beginning of my script, I have the following:
> 
> use Net::NNTP; # This is how the server I'm using set it up.
> $ENV{'NNTPSERVER'}="news.ilk.com";
> $nntp = Net::NNTP->new(Debug);
> 
> I figure I'm doing something stupid, but I can't figure out what! The
> documentation for NET::NNTP is ... well, "thin".
> 
> Any help would be appreciated.
> 
> --
>             Bruce Hodo - Webmaster, GetAwayNetwork, Inc.
> ==Providing vacation information services on the World Wide Web==
> For Villas, Resorts, Hotels, Air/Hotel Packages, Charter Airfares
> =============== Visit us at http://getawaynet.com ===============


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

Date: Wed, 3 Sep 1997 16:09:26 GMT
From: spectran@netcom.com (Tracy Bednar)
Subject: Pattern Matching with Arrays
Message-Id: <spectranEFxwvq.Gu8@netcom.com>

Hi, How about this
open (OLD, "$REAL") || die ("couldnt open file for reading");
while(<OLD>) {
 if(/\<!-- $TIME $ROOM --!\>/){
 print "HTML stuff here";
 }
}
close( OLD );

btw: I read that you shouldn't close files, Perl will do this for you???


perl -e 'print pack("c26", $=+14,85,83,84,32,65,78,
79,84,72,69,82,32,80,69,82,76,32,72,65,67,75,69,82,13,10);'


Hi, I'm very new to perl and have this problem.
I'm trying to do a script that takes a file (OLD) reads in to an
array, then if a line exists in that file I want it to display the
html. I'm sure this is a very easy thing, but I just can't get it to
work!

This is a the piece of the code that's the problem

open (OLD, "$REAL") || die ("couldnt open file for reading");
@search_array = <OLD>;
    while (<OLD>) {
   if ($search_array =~ "/<!-- $TIME $ROOM --!>/\n") {

print "content-type: text/html\n\n";
 print "<html><head><title>Occupied</title></head>\n";
 print "<body bgcolor=#ffcc99><center><font size=5 color=Maroon>Room
is already occupied</font>\n";
  print "</center></body></html>";

 close (OLD);   }



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

Date: Wed, 03 Sep 1997 15:20:37 GMT
From: colte@hem.passagen.se (Robert)
Subject: Patternmatching with arrays
Message-Id: <340d7780.3805570@news.hogia.net>

  
Hi, I'm very new to perl and have this problem.
I'm trying to do a script that takes a file (OLD) reads in to an
array, then if a line exists in that file I want it to display the
html. I'm sure this is a very easy thing, but I just can't get it to
work!

This is a the piece of the code that's the problem

open (OLD, "$REAL") || die ("couldnt open file for reading");
@search_array = <OLD>;
    while (<OLD>) {
   if ($search_array =~ "/<!-- $TIME $ROOM --!>/\n") { 

print "content-type: text/html\n\n";
 print "<html><head><title>Occupied</title></head>\n";
 print "<body bgcolor=#ffcc99><center><font size=5 color=Maroon>Room
is already occupied</font>\n";
  print "</center></body></html>"; 

 close (OLD);   } 
} 

Thanks

Robert



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

Date: 2 Sep 1997 10:26:39 GMT
From: cs_icm@uxmail.ust.hk (:F:F&a*:-7)
Subject: Perl Help
Message-Id: <5ugpkv$b2d@ustsu10.ust.hk>



--
 
  $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   Iu Chi Man, Kevin
  $$$$$$ z$*$$**"""$$$$"^**$$$"*$$$$$$   cs_icm@stu.ust.hk 
  $$$$$L." $$F .e  $$$P.ed$$$% d$*$$$$   cscmiu@ug.cs.ust.hk 
  $$$$$$*   3L " .$$$$bP*C"$$   .e$$$$   http://home.ust.hk/~cs_icm/
  $$$F   .d"$$.e$$$$$$$ .$ *F.$ $$$$$$    
  $$$$bP.$$ ... *$$$$""  . . "$ $$$$$$   
  $$$$$z$$F ""F 4$$$be $z* *$.  $$$$$$   +i)s;{?y,%C$#'o9L!C
  $$$$$$$$  $$F  $$$$L..z  eP".  "$$$$   7N(#15(|,:A+W7SBB!C
  $$$$$$$$L..e" z$$$$$$$".$ed$$$e..*$$   
  $$$$$$$$$$$$e$$$$$$$$$$$$$$$$$$$$$$$              
 
                                           .&______~*@*~______&.
                                         "w/%%%%%%%%%%%%%%%%%%%\w"       
                                           `Y""Y""Y"""""Y""Y""Y'         
                                        p-p_|__|__|_____|__|__|_q-q                 
                _______________________[EEEEM==M==MM===MM==M==MEEEE]


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

Date: 3 Sep 1997 15:59:31 GMT
From: pd@mole.bio.cam.ac.uk (Phil Davey)
Subject: Printing two variables on alternate lines?
Message-Id: <5uk1h3$msh$2@lyra.csx.cam.ac.uk>

Hi,

I have two variables containing multiple line text and I would like to
print them on alternate lines.

For example if $foo is:
xxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxx

and $bar is:
aaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaa

I would like to end up with:
xxxxxxxxxxxxxxxxxx
aaaaaaaaaaaaaaaaaa
xxxxxxxxxxxxxxxxxx
aaaaaaaaaaaaaaaaaa

Any ideas?
I've searched through DejaNews and looked through the man pages and FAQ
but I can't find anything which helps.

-- 
Phil 
[E-mail pd@mole.bio.cam.ac.uk]



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

Date: Sat, 30 Aug 1997 19:21:30 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Pushing output in CGI
Message-Id: <340a5e47.15583319@flood.xnet.com>

kchadha@hotmail.com wrote:

>Hi,
>
>This is a very simplied version of
>my program:
>
>$| = 1;
>
>for ($i=0;$i<5;$i++)
>{
>	sleep(5);
>	print "wait ";
>}
>
>Now the problem is that it prints all "wait wait wait"
>together instead of waiting 5 secs before each.
>
>Howvever, if I say print "wait <br>", it pushes
>the output every 5 secs.
>
>My questions is that can I avoid putting the
><br> or <p> and just get the output to
>print on the same line after every 5 secs-
>basically I need to prevent the buffering. I
>got suggestions to make it a nph- script, but that
>doesn't work.
>
>Please e-mail your replies to kchadha@hotmail.com
>
>
>Thanks !
>
>K.Chadha

Now that I look at it, the 'nph-' may only work for NCSA and Apache.
But the real problem is whether the browser displays anything before
it gets the whole page.  Apparently IE and other Mosaic browsers may
not, so an IE user may leave the site thinking it is broken if there
is a long pause with no apparent response.

Simply get a quicker ISP that is not choked uploading X-rated
material.


David Efflandt/Elgin, IL USA
efflandt@xnet.com    http://www.xnet.com/~efflandt/


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

Date: 1 Sep 97 22:29:48 -0500
From: 00mslantz@bsuvc.bsu.edu (The Infamous BooBoo Q. Earp.)
Subject: Query Strings & CGI's
Message-Id: <1997Sep1.222948.1@orion.bsuvc.bsu.edu>

I'm writing a PERL script which sends a lot of data to itself, which
it then interprets and then puts up a new screen.

Anyway, I had been having it use forms to send to itself:  it would
first interpret any data sent to it, then generate a page with a form
on it so that it could send itself more data.

However, in an attempt to streamline the application, I'm trying to
remove some of the form stuff and replace it with just URL's with the
query string tacked on the end.  Here's the format for my URL:
<a href=\"http://www.cs.bsu.edu/homepages/lancelot/cgi-bin/
  uclbbs.pl?choice=answer&qnum=q1\">

(the \'s before the "'s are to make the "'s literal)
      
Anyway, it's activating the cgi (uclbbs.pl), but the query string 
(choice=answer&qnum=q1) is not showing up at all.  I ran the version
that uses the forms, and it reads the query sting fine.  Is the CGI
not getting the query sting because I'm sending at as an anchor
instead of a form action?

basically, my question in a nutshell is:  
How do I send a query string via a normal URL?
And you get bonus points if you can tell me what I'm doing wrong.

Please mail me directly, I won't be checking this newsgroup.

Thank you for your help

Sincerely,
Scott Lantz
00mslantz@bsuvc.bsu.edu





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

Date: Wed, 3 Sep 1997 11:09:47 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Script on input to perl arrays wanted - Newbie learning
Message-Id: <b42ku5.7v3.ln@localhost>

Nathan Stanford (nathan@cyberservices.com) wrote:
: Do anyone have a simple script that will show me how to pull a address
: list
: and insert it into an array so I can do things with is....

: address file
: 23:123 anywhere st., anycity,state:324:888-555-1212
: 32:321 john rd.,acity,state:243:888-686-6868

: number:address:speeddial:phonenumber

: I want an array where -

: $number[0]              = the first number in the list
: $address[0]             = the first address in the list
: $speeddial[0]           = the first speeddial in the list
: $phonenumber[0]         = the first phonenumber in the list


: I am a newbie but learning fast I want to use : to seperate but would
: use
: other if I can some how make them work in excel  ex: if I use comma's
: then
: the comma's in the addresses would cause a problem what do you suggest
: about
: that as well?


colons will be fine.

----------------------
#!/usr/bin/perl -w

while (<DATA>) {
   chomp;
   ($number, $address, $speeddial, $phonenumber) = split /:/;
   push @number, $number;
   push @address, $address;
   push @speeddial, $speeddial;
   push @phonenumber, $phonenumber;
}

for ($i=0; $i<@number; $i++) {
   print "number: $number[$i]\n";
   print "address: $address[$i]\n";
   print "speeddial: $speeddial[$i]\n";
   print "phonenumber: $phonenumber[$i]\n";
   print "\n";
}

__DATA__
23:123 anywhere st., anycity,state:324:888-555-1212
32:321 john rd.,acity,state:243:888-686-6868
----------------------


: Do anyone use perl on NT?

Not me. I hear that some do though.


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


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

Date: Wed, 03 Sep 1997 16:03:03 GMT
From: williamw@rooster.igs.deleteTheRooster.net (William Wue(2xP)elma(2xN))
Subject: Re: shell command "more"
Message-Id: <340d88fa.10113501@news.igs.net>

On Mon, 01 Sep 1997 22:27:31 GMT, <gomar@mindless.com> (Marco Goetze)
wrote:

>
>On Thu, 21 Aug 1997 09:58:42 -0700, sabrina chan <schan@rice.edu>
>wrote:
>>This is probably a newbie question,
>
>It is. (SCNR ;)
>
>>I wrote a script that gathers various information into one file, and
>>then I want to output this file to the screen.  However, I can't
>>figure out how to output it in the style of the command "more", ie
>>stopping and asking for a key to be pressed when the screen is full.
>
>Why don't you _employ "more"_, i.e. pipe the output to it?  Of course
>it's more recommendable to use "less" (if available).
>

However, generally speaking, if you want to display n lines and then
stop and wait for user input, you can do something the following
(assuming an 80 x 25 screen, and that you've read your file into
@file):

$lines = 0;
foreach (@file) {
	$lines += int(length($_) / 80);
	$lines++ if (length($_) % 80 != 0);
	if ($lines > 24) {
		print("PRESS ENTER TO CONTINUE");
		<STDIN>;
		$lines -= 24;
	}
	print $_;
}

After all, not every Perl program is a non-interactive run-and-watch
UNIX script...


-------------------------
William Wue(2xP)elma(2xN)
Reply-To: williamw (at) igs (dot) net
--------------------------------------------------------------
It is pitch black. You are likely to receive spam from a grue.


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

Date: Wed, 03 Sep 1997 11:38:25 -0400
From: Benjamin Sugars <bsugars@sunpub.com>
Subject: Re: Time warp - Perl 4 question
Message-Id: <340D8471.7B47@sunpub.com>

George Menyhert wrote:

> I wrote a script using Perl 5.003.  It works great.  However, it is
> very complex and long (4500 lines).  The problem is that I have to
> move it back to Perl 4 to guarantee the widest range of acceptance.

I have a 2 Gig database that I have to move back to punch cards to
guarantee the widest range of acceptance :-)

Seriously, though, there really is no reason to restrict yourself to
Perl 4.  The simplest answer to your problems are to stick with Perl 5.

-Ben

--
Ben Sugars <bsugars@canoe.ca>
Senior Webmaster,
CANOE Canadian Online Explorer,
http://www.canoe.ca/


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

Date: 3 Sep 1997 15:09:37 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Trivial(?) readdir question
Message-Id: <5ujujh$5c9$1@lyra.csx.cam.ac.uk>

Marc Philips  <Marc.Philips@tvd.be> wrote:
>> > How likely is readdir to NOT return '.' and '..' as the first two
>> > directory entries when reading in a directory?
>
>On UNIX, a directory is created with two (sub)directory entries: "." and
>"..".
>
>Given that readdir reads the directory sequentially, I'd say that they
>will always be the first two entries returned and always in that order.

That isn't defined.   So only a masochist would assume it.


Mike Guy


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

Date: Sat, 30 Aug 1997 17:36:43 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: using unix commands for missing libwww module
Message-Id: <34085803.13979037@flood.xnet.com>

bob@cafemedia.com (Bob Maillet) wrote:

>
>Hi,
>
>I am trying to get the following snippet of code to work..  The server I
>am currently working on does not have the libwww module installed so I am
>using unix commands to read the data from a remote sight..then parse out
>that data.
>I still have to enter a newline command when the script is run and the
>data does not display..any ideas?
>
>Bob

I am not sure how to tell telnet what to do from a script, but you can
open a socket and get the web page directly.  I have assorted perl
scripts to GET or POST to web pages and my own little module that all
work without the LWP module (which I have not had a chance to read or
install in Linux yet).  See: http://www.xnet.com/~efflandt/pub/


David Efflandt/Elgin, IL USA
efflandt@xnet.com    http://www.xnet.com/~efflandt/


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

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

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