[6857] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 482 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 15 14:17:41 1997

Date: Thu, 15 May 97 11:00:35 -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           Thu, 15 May 1997     Volume: 8 Number: 482

Today's topics:
     Re: A perl routine to fetch an url (Clay Irving)
     Re: A perl routine to fetch an url <dean@tbone.biol.sc.edu>
     Re: A perl routine to fetch an url <Jan.Krynicky@st.ms.mff.cuni.cz>
     Re: Beta Testers for PMS <friedman@uci.edu>
     Re: Bug report: Perl dumps core on funny split (era eriksson)
     Cant get Perl up and running ddean@aracnet.net
     Re: CGI Environment vars (Kyzer)
     Re: Graphs <mike@soft-tek.com>
     Is it allowed to change Config.pm? (Honza Pazdziora)
     Re: List of List Question I think (assigning LOTS of va (Martin Cohen)
     Re: ls vs. readdir (Mike Stok)
     Re: ls vs. readdir (Honza Pazdziora)
     Re: Need help on Oraperl !!! (Lyndon VanWagner)
     Oops! That should have been FORMAT. <chapman@techctr.buddcompany.com>
     Opening files in Word from Perl (Mike Torrence)
     Perl (filter newlines & replace with space) <labah@algonet.se>
     Re: Perl (filter newlines & replace with space) (Mike Stok)
     Re: Perl (filter newlines & replace with space) (A. Deckers)
     Re: Perl (filter newlines & replace with space) (Honza Pazdziora)
     Re: PERL script autoresponder problems...please take a  (Chipmunk)
     Problem: File uploading (Kalimar)
     Problem: Multi-User Program waiting for results (Kalimar)
     Q:Redirecting STDIN back to STDIN <areeves@bnr.ca>
     Recognizing Type of Data Base (Martin Cohen)
     Re: running ftp in a Perl script. (Kyzer)
     Re: running ftp in a Perl script. (Bob Shair)
     Simulate unix/linux mail on PC? <labah@algonet.se>
     Re: Top of the page format problem (Chipmunk)
     Re: Tough replacement problem (Chipmunk)
     Using Perl as a script engine <hhowe@trgnet.com>
     Xforms4Perl-0.7 crash ()
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 15 May 1997 10:08:52 -0400
From: clay@panix.com (Clay Irving)
Subject: Re: A perl routine to fetch an url
Message-Id: <5lf5dk$1cd@panix.com>

In <5lehfp$d9p@nntp.hut.fi> mara@0.0.0.0 (mara) writes:

>Do you remember any well documented examples of simple and
>sophisticated URL checking?

This is an example of a basic, simple no-frills URL checker:

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

use LWP::Simple;
use LWP::UserAgent;

$url = "http://www.perl.com";

$ua = new LWP::UserAgent;
$ua->agent("$0/0.1");

$req = new HTTP::Request 'GET', $url;
$req->header('Accept' => 'text/html');

# send request
$res = $ua->request($req);

# check the outcome
if ($res->is_success) {
  print "The link <$url> is ok.\n";
} else {
  print "<$url>\n";
  print "  " . $res->code . " " . $res->message  . "\n\n";
}

The output is:

 The link <http://www.perl.com> is ok.

If you change the URL to http://www.perlly-gates.com, the output is:

 <http://www.perlly-gates.com>
    500 Can't resolv address for www.perlly-gates.com

-- 
Clay Irving                                        See the happy moron,
clay@panix.com                                     He doesn't give a damn,
http://www.panix.com/~clay                         I wish I were a moron,
                                                   My God! Perhaps I am!


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

Date: 15 May 1997 12:40:57 -0400
From: Dean Pentcheff <dean@tbone.biol.sc.edu>
Subject: Re: A perl routine to fetch an url
Message-Id: <m13eroofhi.fsf@nauplius.psc.sc.edu>

mara@0.0.0.0 (mara) writes:
> Thanks for your pointer. I checked the CPAN archive and there are
> indeed
> a lot of related modules. But perhaps a little too many :-) 
> Do you remember any well documented examples of simple and
> sophisticated
> URL checking?

Just in case you missed it, I've appended Clay's response - it's what
I would have said.  Be sure to check the LWP documentation for a range
of examples (simple to complex).  The LWP package gives you a very
sophisticated set of ways to snuffle at WWW sites.  The LWP::Simple
routines give you very simple ways of doing basic retrievals or URL
checks without retrieving the whole contents.  If and when you want
finer control, the other modules within the set give you more
capability.

Have fun!

-Dean
P.S. As you may notice from the reference line at the top of the
message, your news posting program is putting in a bad return email
address for you - you might want to see if that could be fixed.
-- 
N. Dean Pentcheff   <pentcheff@acm.org>   WWW: http://tbone.biol.sc.edu/~dean/
Biological Sciences, Univ. of South Carolina, Columbia SC 29208 (803-777-3936)
PGP ID=768/22A1A015 Keyprint=2D 53 87 53 72 4A F2 83  A0 BF CB C0 D1 0E 76 C0 
Get PGP keys and information with the command: "finger dean@tbone.biol.sc.edu"

=========================================================================
>From: clay@panix.com (Clay Irving)
Subject: Re: A perl routine to fetch an url
Newsgroups: comp.lang.perl.misc
Date: 15 May 1997 10:08:52 -0400
Organization: PANIX Public Access Internet and Unix, NYC
Path: sc.edu!cpk-news-feed4.bbnplanet.com!cpk-news-hub1.bbnplanet.com!cam-news-hub1.bbnplanet.com!news.bbnplanet.com!panix!news.panix.com!not-for-mail
Lines: 45
Distribution: inet
Message-ID: <5lf5dk$1cd@panix.com>
References: <5lbrh2$dde@nntp.hut.fi>    <m1k9l2f53n.fsf@nauplius.psc.sc.edu> <5lehfp$d9p@nntp.hut.fi>
NNTP-Posting-Host: panix.com

In <5lehfp$d9p@nntp.hut.fi> mara@0.0.0.0 (mara) writes:

>Do you remember any well documented examples of simple and
>sophisticated URL checking?

This is an example of a basic, simple no-frills URL checker:

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

use LWP::Simple;
use LWP::UserAgent;

$url = "http://www.perl.com";

$ua = new LWP::UserAgent;
$ua->agent("$0/0.1");

$req = new HTTP::Request 'GET', $url;
$req->header('Accept' => 'text/html');

# send request
$res = $ua->request($req);

# check the outcome
if ($res->is_success) {
  print "The link <$url> is ok.\n";
} else {
  print "<$url>\n";
  print "  " . $res->code . " " . $res->message  . "\n\n";
}

The output is:

 The link <http://www.perl.com> is ok.

If you change the URL to http://www.perlly-gates.com, the output is:

 <http://www.perlly-gates.com>
    500 Can't resolv address for www.perlly-gates.com

-- 
Clay Irving                                        See the happy moron,
clay@panix.com                                     He doesn't give a damn,
http://www.panix.com/~clay                         I wish I were a moron,


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

Date: Thu, 15 May 1997 18:52:02 -0700
From: Jan Krynicky <Jan.Krynicky@st.ms.mff.cuni.cz>
To: Clay Irving <clay@panix.com>
Subject: Re: A perl routine to fetch an url
Message-Id: <337BBDC2.677E@st.ms.mff.cuni.cz>

Clay Irving wrote:
> 
> In <5lehfp$d9p@nntp.hut.fi> mara@0.0.0.0 (mara) writes:
> 
> >Do you remember any well documented examples of simple and
> >sophisticated URL checking?
> 
> This is an example of a basic, simple no-frills URL checker:
> 
> #!/usr/local/bin/perl -w
> 
> use LWP::Simple;
> use LWP::UserAgent;
> 
> $url = "http://www.perl.com";
> 
> $ua = new LWP::UserAgent;
> $ua->agent("$0/0.1");
> 
> $req = new HTTP::Request 'GET', $url;

probably 'HEAD' would be better than 'GET'

 $req = new HTTP::Request 'GET', $url;

just to preserve the bandwith.


> $req->header('Accept' => 'text/html');
> 
> # send request
> $res = $ua->request($req);
> 
> # check the outcome
> if ($res->is_success) {
>   print "The link <$url> is ok.\n";
> } else {
>   print "<$url>\n";
>   print "  " . $res->code . " " . $res->message  . "\n\n";
> }
> 
> The output is:
> 
>  The link <http://www.perl.com> is ok.
> 
> If you change the URL to http://www.perlly-gates.com, the output is:
> 
>  <http://www.perlly-gates.com>
>     500 Can't resolv address for www.perlly-gates.com
> 
> --
> Clay Irving

Jenda


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

Date: 15 May 1997 16:58:19 GMT
From: "Eric D. Friedman" <friedman@uci.edu>
Subject: Re: Beta Testers for PMS
Message-Id: <5lffbb$1us@news.service.uci.edu>

[mailed, posted]

In article <01bc60ac$64001660$138fd4c7@Garcia.huron.net>,
Stephen Hill <buck@huron.net> wrote:
>Beta testers Needed for my messaging system, It is all written in perl.
>
>http://www.huron.net/~buck/bbs
>
>Please check it out and report any bugs that you may come across to me at
>buck@huron.net.

Stephen,

Has it occured to you that `PMS' might not be the greatest name for
your system?  That particular acronym is already in widespread use....

-- 
Eric D. Friedman
friedman@uci.edu


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

Date: Thu, 15 May 1997 11:36:40 +0300 (EET DST)
From: reriksso@cc.helsinki.fi (era eriksson)
Subject: Re: Bug report: Perl dumps core on funny split
Message-Id: <199705150836.LAA30715@kontti.Helsinki.FI>

On Thu, 15 May 1997 10:23:08 +0200,
domo@slipper.ip.lu (Dominic Dunlop) wrote:
 > [ A copy of this message has been posted to the newsgroup ]
 > [     comp.lang.perl.misc                                 ]

Ditto. 

 > era eriksson <reriksso@cc.helsinki.fi> wrote:
 >> Here's a working script:
 >> 
 >> $ echo foo | perl -ne 'split /\s*,\s*/'
 >> foo
 >> 
 >> Here's one that dumps core:
 > [with perl5.001m on SunOS and 5.003 on Alpha OSF/1 4.0]
 >> 
 >> $ echo foo | perl -ne 'split /\s*(,\s*)?/'
 >> Segmentation fault (core dumped)
 > I can't reproduce this, either on 5.003 or on really really really
 > soon-to-be-released 5.004 'gamma' (both on MachTen 4.0.3).  Somebody
 > running 5.004 on an Alpha needs to see if the problem is present or gone
 > on that platform.

For the record, some machines I tested this on only display the
"Segmentation fault" when tried interactively (i.e. if you start up
only the Perl part of the pipeline and type in some input manually)
but they do dump core (if coredumps enabled) even without the error
message. This was the case, for example, under Linux 2.0.21 with Perl
5.003.

 >> The manual page doesn't tell you where to send bug reports so I
 >> figured ...
 > Well, actually, the information's on the 5.003 perl man page (derived

Silly me, I only looked in the 5.001 manual. Sorry for this slip.

/* era */

-- 
Defin-i-t-e-ly. Sep-a-r-a-te. Gram-m-a-r.  <http://www.iki.fi/~era/>
 * Enjoy receiving spam? Register at <http://www.iki.fi/~era/spam.html>


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

Date: Thu, 15 May 1997 12:41:43 -0400
From: ddean@aracnet.net
Subject: Cant get Perl up and running
Message-Id: <337B3CC7.5042@bart.kenan.com>

HI

I've just installed perl on a Unix box.  For some reason it installed it
in /opt/perl5 instead of /usr/local/bin/perl5.  Anyway, the installation
went fine but when I try to run a script is tells me that it cannot
execute the file.  

Can anyone tell me what is the matter with this tiny script

#!/opt/perl5

print"hello";
exit(0);

I'm new to this stuff so be gentle


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

Date: 15 May 1997 15:20:19 GMT
From: junkmail@sysc.abdn.ac.uk (Kyzer)
Subject: Re: CGI Environment vars
Message-Id: <5lf9jj$jp1@info.abdn.ac.uk>

Mads Toftum, while smelling of fish, wrote:
: >Can some1 pls give me a pointer to a list of environment variables
: >used in CGI? Thanks.

: Try this small CGI-script:
[snip]

Try this smaller script (tmtowtdi, yk :)
#!/bin/sh
set;exit

and yes, this thread has nothing to do with perl.

--
Stuart 'Kyzer' Caie - Kyzer/CSG |undergraduate of Aberdeen University |100%
http://www.abdn.ac.uk/~u13sac   |My opinions aren't those of Aberdeen |Amiga -
kyzer@4u.net kyzer@hotmail.com  |University or AUCC, thankfully.***** |always!

-- 
Random sig of the day:
"Slightly less safe than joining the mile high club bareback with a junkie
whore in a plane flying over a war zone with three engines on fire, a pissed
up pilot and Carlos the Jackal sitting RIGHT BEHIND YOU" - MK3 advert.


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

Date: Thu, 15 May 1997 11:02:51 -0500
From: Mike Christensen <mike@soft-tek.com>
To: GOD4GOLF <god4golf@aol.com>
Subject: Re: Graphs
Message-Id: <337B33AB.4A3B@soft-tek.com>

GOD4GOLF wrote:
> 
> Hi All :
> 
>    looking for a Perl Library to do Graphs(Bar charts) .....
> does anyone know if there is such a thing ?
> 
> thanks
> god4golf@aol.com

Please take a look at GRAFSMAN from Soft-tek International, Inc.

We have a "live" demonstration on our website, using GRAFSMAN w/Perl.

http://www.soft-tek.com

Please let me know if I can be of further assistance,


Mike Christensen
Soft-tek International, Inc.
1999 N. Amidon, Wichita, KS  67203
316 838 7200(v)  --  316 838 3789(f)
mailto:mike@soft-tek.com
http://www.soft-tek.com


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

Date: Thu, 15 May 1997 14:32:29 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Is it allowed to change Config.pm?
Message-Id: <adelton.863706749@aisa.fi.muni.cz>


Hallo,

>From man pages and READMEs I realize that Config.pm holds the
content of the config.sh from the compile time. Is this file read
only or can I change some of the variables and change the behaviour
of my Perl instalation? For example, can I change the value of
startperl? Or the location of archlib files?

I know that the Config.pm is used when compiling new modules. I would
sometimes need to compile the module on a machine where the directory
layout of perl is different and then just install it on another
computer. Or, when upgrading to 5.004, I need to keep the 5.003
instalation running until all necessary modules are in the new
directory tree and then just change my /usr/bin/perl. To do this, I
would either need to specify the startperl as
/packages/run/perl-5.004/bin/perl and later change it, or run all
perl Makefile.PL's with absolute path to perl binary. But I fear that
during the installation the scripts might fall back to use the old
/usr/bin/perl and install to the old directory tree, if I just left
the startperl pointing to /usr/bin.

Thanks for any suggestion.

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: 15 May 97 08:29:24 GMT
From: mcohen@arl.mil (Martin Cohen)
Subject: Re: List of List Question I think (assigning LOTS of variables.)
Message-Id: <337AC964.5E20@arl.mil>

Hunter L. Brown wrote:
[edited]
- I have conducted a survey (web page survey). Now, it's time to process
- the data. I have collected it all, split it up, everything is dandy I
- can print out things the way I want.
- 
- NOW, I need to make some variables for each question return value so I
- can process percentages and statistics, etc.
- 
- How can I assign these variables without typing them all out?
[deleted script that doesn't work]
--
- HUNTER L. BROWN    | Web Information Developer
-                    | FUJITSU SOFTWARE CORPORATION
- mailto:hunter@fsc.fujitsu.com
- http://www.fsc.fujitsu.com/~hlbrown

I couldn't follow exactly what you were trying to do, but it looks
like you will have much better luck using associative arrays rather
than indexed ones.  Look up "hashes" in any book on perl (or assoc-
iative arrays" in a book on awk).  Basically, you can "name" your
variable at run time, using the question text for example.

	$quest{$text} = $othertext;
	...
	for $q (keys %quest) {# use $q and  $quest{$q} here
	}

-- 
Martin Cohen - AMSAA-North - Custom House Rm 800 Phila PA 19106-2976


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

Date: 15 May 1997 14:37:53 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: ls vs. readdir
Message-Id: <5lf741$ant@news-central.tiac.net>

In article <Pine.SUN.3.91.970515095220.22311B-100000@aisun6.ai.uga.edu>,
David Jennings [MSAI] <djenning@aisun6.ai.uga.edu> wrote:
>I recently wrote a small script for cleaning up some directories, and I 
>used the backticked UNIX command ls to get filenames.  I am curious: is 
>using the backticked command more or less computationally expensive than 
>using the built-in Perl commands opendir and readdir?

It's likely to be more expensive overall to use `ls` as you spawn a
process to do the work, whereas

  while (defined ($entry = readdir (DIRHANDLE)) {
    process it
  }

allows you to just have one directory entry in memory at a time as opposed
to having the (potentially large) output from ls buffered up and then
processed.

If you're making use of shell globbing to match wildcards then it's
possible to use perl's pattern matching if you're working in a single
directory, but if you're saying @files = `ls foo/f*/d*/*.dat` then the
coding could get complex (so you either hunt down a globbing module that
doesn't spawn a shell or leave it to the shell as opposed to doing "hard"
work yourself :-)

Also using readdir avoids problems with file/directory names which comtain
whitespace which can confuse the shell.

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@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: Thu, 15 May 1997 15:01:23 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: ls vs. readdir
Message-Id: <adelton.863708483@aisa.fi.muni.cz>

"David Jennings [MSAI]" <djenning@aisun6.ai.uga.edu> writes:

> I recently wrote a small script for cleaning up some directories, and I 
> used the backticked UNIX command ls to get filenames.  I am curious: is 
> using the backticked command more or less computationally expensive than 
> using the built-in Perl commands opendir and readdir?

When you use opendir and readdir, you do not fork another process and
also do not use external programs that somebody might have erased or
so.

> It seems like you can make Perl as much like or unlike conventional shell 
> programming as you please.  Neat, I guess.

I think opendir is better when you seek efficient and reliable
solution, `ls` when you need easy solution. You can use Perl as
a powerfull shell but it usually deserves more than that.

Hope this helps.

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: Wed, 14 May 1997 18:56:09 GMT
From: lvanwagn@lcp.com (Lyndon VanWagner)
Subject: Re: Need help on Oraperl !!!
Message-Id: <3379e62d.16119826@tppinternet.roc.tlp.com>

On 14 May 1997 15:09:50 GMT, etltsln@etlxd30.ericsson.se ( Thomas
Lachlan XMS x4206 ) wrote:

>pdemeyer@cri.univ-lr.fr wrote:
>: Hi !
>
>: Where can I get detailed help on oraperl ???
>
>: Or maybe someone of you already had the problem :
>: my function ora_login doesn't work with the new version of Oracle database,  
>: version 7.3.2.2, I don't even get any error message...
>: What happens ??
>
>: Thanks for your help.
>
>: -------------------------------
>: Patrice
>: pdemeyer@cri.univ-lr.fr
>
>Hello Patrice,
>	I've recently installed Oracle 7.3.2.2, DBI and Oraperl.
>	It works fine. In order to use the ora_login function
>	I think you need to install sql*net and have the TNS
>	listener up and running. Above and beyond this rather
>	vague and unhelpful information I can be of little 
>	assistance.
>				Sorry
>
>				Yours Tom Lachlan etltsln@etlxdmx.ericsson.se

Tom,

Would you mind answering a perl5 newbie question?
I've had perl running with static linking for some time, but recently
changed to dynamic linking and added the Wais.pm module.  This seems
to work fine, but now I'm trying to add the DBI and DBD::Oracle
modules, but am having problems.

I'm using perl5.003_07, Wais-2.203, DBI-0.81, DBD-Oracle-0.44 on
Solaris2.4, sun4c sparc, Oracle 7.3.2.3.  Also using GNU c/c++ and ld.
Perl5 seems to build and test fine.  I've even tested some XS stuff.  
The Wais.pm build seems okay, although I can't connect thru the
firewall to the outside world...

Following the README file, I untarr-ed DBI-0.81 into my gnu source
area, and successfully ran 'perl Makefile.PL; make', but when running
'make test' I get the following error while building test.pl:
'Can't locate object method "autoflush" via package "IO::Handle" at
blib/lib/DBI.pm line 394'

Any ideas what can be causing this?

I've untarr-ed DBI-0.81 and DBD-Oracle-0.44 into my per5.003_07/ext
directory, just like I did for Wais.pm, and added 'DBI Oracle' to the
dynamic_ext, extensions, and known_extensions macros in config.sh.
However, when I run:
	cd perl5.003_07; sh ./Configure -des -Dcc=gcc

What am I doing wrong?  I haven't found a FAQ set for adding modules,
does one exist?  The perl installations don't seem to be as well
documented as INN was...

Thanks for whatever assistance you can provide.  BTW, what is the real
module name for DBD::Oracle?  Sorry, but I'm new to perl.

--Lyndon


================================================================
Lyndon C. VanWagner                 Senior Systems Administrator
Thomson Legal Publishing            phone:  716.546.5530 x3523
50 Broad Street                     fax:    716.327.2633
Rochester, NY 14694                 email:  lvanwagn@lcp.com
================================================================
Excuse me, but why does God need a starship?
================================================================



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

Date: Thu, 15 May 1997 10:34:29 -0400
From: Harold Todd Chapman <chapman@techctr.buddcompany.com>
Subject: Oops! That should have been FORMAT.
Message-Id: <27A7D8F1707F3CEF.86C120E54D8B3602.2689C1A4914D5865@library-proxy.airnews.net>

I have the following format:
 
format =
GRID@>>>>>>>>>>>        @<<<<<<<@<<<<<<<@<<<<<<<
$node,                  $x,     $y,     $z
 .
 
The x/y/z vars are floating point numbers. I want them right next to
each other but FORMAT seems to insist that there be a space. How can
I prevent this.
 
Thanks.


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

Date: Thu, 15 May 1997 17:40:30 GMT
From: mst@fadavis.com (Mike Torrence)
Subject: Opening files in Word from Perl
Message-Id: <337b49be.12018865@news.idt.net>

I'm attempting to open a series of files up in Word and save them out
in another format. I have tried (very unsuccessfully) to open files
via OLE. All I seem to be able to do is launch the application, I
cannot get it to respond to anything else.

Here's where I get stuck:

# Set the file list array
@files = grep -T, map "$ARGV[0]\\$_", readdir INPUT_DIR;

# Initiate OLE to launch Word
$application = CreateObject OLE 'Word.Application' || die $!;
$application->{'Visible'}=1; 

# open all files in the directory
while (@files[$count] ne ""){
    ????? now what ?????
}

I want to be able to call each of the files in the @files array up in
Word.

Any help would be appreciated.
-----------------------------------------------------
The preceding does not necessarily reflect my
employer's opinion. Nor does it necessarily reflect
my opinion all of the time.
-----------------------------------------------------
Mike Torrence
mst@fadavis.com
mtorrenc@waterw.com
F.A. Davis
-----------------------------------------------------


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

Date: Thu, 15 May 1997 16:27:42 +0200
From: Jonas Thvrnvall <labah@algonet.se>
Subject: Perl (filter newlines & replace with space)
Message-Id: <337B1D5E.6BEA@algonet.se>

Hello!
I wonder if someone could tell me how to filterout newlines and replace
with space, the message is submitted from a form comments field.
I've tried with this code but it does'nt seeme to work.
   $value =~ tr/\n/ /;
Should  i replace \n with hexcode or what? 

Jonas T


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

Date: 15 May 1997 14:42:48 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Perl (filter newlines & replace with space)
Message-Id: <5lf7d8$avk@news-central.tiac.net>

In article <337B1D5E.6BEA@algonet.se>,
Jonas Thvrnvall  <labah@algonet.se> wrote:
>Hello!
>I wonder if someone could tell me how to filterout newlines and replace
>with space, the message is submitted from a form comments field.
>I've tried with this code but it does'nt seeme to work.
>   $value =~ tr/\n/ /;
>Should  i replace \n with hexcode or what? 

Maybe the \n are \r, as that seems to work OK for me:

  DB<1> $value = "foo\nbar\nbaz"

  DB<2> X value
$value = 'foo
bar
baz'
  DB<3> $value =~ tr/\n/ /

  DB<4> X value
$value = 'foo bar baz'

so you might want to see what's really in $value at the start.

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@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: 15 May 1997 15:16:37 GMT
From: I-hate-cyber-promo@man.ac.uk (A. Deckers)
Subject: Re: Perl (filter newlines & replace with space)
Message-Id: <slrn5nma6l.mvk.I-hate-cyber-promo@news.rediris.es>

In comp.lang.perl.misc,
	labah@algonet.se wrote:
>Hello!
>I wonder if someone could tell me how to filterout newlines and replace
>with space, the message is submitted from a form comments field.

 $value =~ s/\n/ /;

Similarly:

 perl -pi.bak -e 's/\n/ /' file

HTH,

Alain

-- 
Perl information: <URL:http://www.perl.com/perl/>
    Perl archive: <URL:http://www.perl.com/CPAN/>
        Perl FAQ: <URL:http://www.perl.com/CPAN/doc/FAQs/FAQ/>
>>>>>>>>>>>>> NB: comp.lang.perl.misc is NOT a CGI group <<<<<<<<<<<<<<


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

Date: Thu, 15 May 1997 16:07:27 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Perl (filter newlines & replace with space)
Message-Id: <adelton.863712447@aisa.fi.muni.cz>

Jonas Thvrnvall <labah@algonet.se> writes:

> Hello!
> I wonder if someone could tell me how to filterout newlines and replace
> with space, the message is submitted from a form comments field.
> I've tried with this code but it does'nt seeme to work.
>    $value =~ tr/\n/ /;
> Should  i replace \n with hexcode or what? 

It works for me. What version of perl are you using? Can you send
a little complete script -- maybe the problem is somewhere else. You
can put hexcode in but then it might not me platform independent.

Hope this helps.

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: 15 May 1997 16:10:54 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: PERL script autoresponder problems...please take a look.
Message-Id: <5lfcie$urg$2@dartvax.dartmouth.edu>

In article <5l7fek$7fo2@cirrus.pyramid.net>
c9@pyramid.net (K. Hawkins) writes:

> if ($remote_mail eq '1' && $FORM{'username'} && $FORM{'perad' eq '1'})

Do you mean to key your hash table on a string comparison?  I think
('perad' eq '1') will evaluate to false consistently.  :-)
Perhaps you meant to say:
  if ($remote_mail eq '1' && $FORM{'username'} && $FORM{'perad'} eq
'1')

Chipmunk


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

Date: Thu, 15 May 1997 14:44:36 GMT
From: georg.seipler@studbox.uni-stuttgart.de (Kalimar)
Subject: Problem: File uploading
Message-Id: <337b213e.755212@news.uni-stuttgart.de>

Hey you able programmers out there ...

Solution preferably in Perl :-)

Here's another problem of mine:
I need to be able to upload a file to the server from the client side.
That is: the user gives a filename in a directory accessable to him
to a form which will upload the given file to the server where it will
be checked and processed.
The purpose is to enable the user to upload HTML files and images
without having to resort to FTP directly - this way the files can be
checked at once, catching the user in an Q&A loop and letting him
go only if all data is verified ...
(with FTP this is a procedure with several steps involving the
webmaster directly in most cases)

How can it be done ?
(there is/was a netscape HTML feature for this which doesn't work
satisfying since it brings the serverside formbuffer to overflow
sooner or later ...)
What security problems do occur with this solution ?

Thanks for your help ...

Greetings,
Georg "Kalimar" Seipler
(georg.seipler@studbox.uni-stuttgart.de)



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

Date: Thu, 15 May 1997 14:44:04 GMT
From: georg.seipler@studbox.uni-stuttgart.de (Kalimar)
Subject: Problem: Multi-User Program waiting for results
Message-Id: <337b2107.700237@news.uni-stuttgart.de>

Hey you able programmers out there ...

Solution preferably in Perl :-)

I've got the following problem:
In a (sort of) multi-user game based on a server multiple "players"
send input via forms to a CGI-Script. So far so good.

Now the Script calculates its response from ALL the forms that have
been sent in (that is from all players participating in that
particular game). The server can/will only send its answer once
it's got all the input.

And there comes the problem:
Each client side waits for the answer, but some users or some
connections will be slower than others and after about 60 seconds
of waiting the client will assume a timeout.

How can the server push its information to the client once its ready ?
(the info is not composed of only an image - I've heard about that
feature already)
I want to avoid all users having to push the "reload" button
repeatedly which will send out their formdata again and again ...

How to do this ?
Do I have to come up with a seperate program using sockets ?
(I'd like to use no seperate programs which need to be downloaded)
Can this be done in JavaScript or Java (not much experience here) ?
Which solution would be the most elegant and workable ?

Thanks for any help ...

Greetings,
Georg "Kalimar" Seipler
(georg.seipler@studbox.uni-stuttgart.de)



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

Date: Thu, 15 May 1997 12:04:18 -0400
From: Adam Reeves <areeves@bnr.ca>
Subject: Q:Redirecting STDIN back to STDIN
Message-Id: <337B3402.996@bnr.ca>

This may sound like a dumb question, but...

After doing the following statements:

open(STDIN,  "<&Client") or die;
open(STDOUT, ">&Client") or die;

How do you redirect STDIN back to STDIN
and, likewise, STDOUT back to STDOUT?

Thanks in advanced!

Cheers,
Adam Reeves


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

Date: 15 May 97 07:53:14 GMT
From: mcohen@arl.mil (Martin Cohen)
Subject: Recognizing Type of Data Base
Message-Id: <337AC0EA.4D06@arl.mil>

Some time ago I posted a request for information on the existence
of a perl module for examining the files constituting a data base
with the objective of recognizing which DBMS it employed.  I also
guessed that there may be a set of entries for /etc/magic that
could be used.  So far, I haven't seen any response in clpm, but
the traffic is so heavy that I may have missed it.

I have looked in the excellent http://www.perl.org/CPAN/CPAN.html
listings of available modules (I really should have looked there first
but I'm still pretty new here.), and found several modules related to
DMBS, but they all seem to require knowing *which* DBMS you have.  If
I missed something, I hope someone will point me to it.  DBI looked
promising.

The problem seems like a valuable area for work.  Many people have
software that they did not write, and which uses a DBMS to hold their
data.  Usually the interfaces provided by the application program are
adequate, but sometimes something goes wrong, and you find yourself
recreating the data base from scratch -- or losing some useful data --
because of a glitch or user error.  If you knew what kind of DBMS was
used you could write a perl script that used the module for that DBMS,
and thus save your data.

One approach would be to extend your /etc/magic file to recognize the
index and data files used by various DBMS.  The other approach would
be a perl script that you could run in a directory, and which would
check each file and make an educated guess as to what DBMS was used,
and list the various types of file by name (filename extension on
some systems).

I guess the next step is to check dejanews -- I probably should have
done *that*, too, before posting.  Anyway, does anyone have any ideas
or suggestions?  Someone has likely already done the ground work by
listing the various DBMS formats; given that, I could try to develop
either the magic entries or the perl script myself (as soon as I
retire from my job:-).
-- 
Martin Cohen - AMSAA-North - Custom House Rm 800 Phila PA 19106-2976
mcohen@acm.org, mcohen@netaxs.com, mcohen@arl.mil, mcohen@river.iro.org


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

Date: 15 May 1997 15:17:21 GMT
From: junkmail@sysc.abdn.ac.uk (Kyzer)
Subject: Re: running ftp in a Perl script.
Message-Id: <5lf9e1$jp1@info.abdn.ac.uk>

Florence Kuan, while smelling of fish, wrote:
: I need to ftp a file from another server while running a Perl program. Does
: anyone know how I can pass arguments to the ftp program while running a
: Perl program? Is it possible for the Perl program to supply the user
: account name, password, and ftp commands to the ftp program so that the
: user does not have to enter anything.
: I am working on a Unix X-terminal.
: Thanx.

You could always use the Net::FTP module (I've just used it myself in a CGI
script) which gives you a direct connection to FTP servers, without faffing
about with the ftp command, which can differ on different machines.
The module Net::FTP and the docs for it are on CPAN http://www.perl.com/CPAN/
however this is a (crap) example of getting a file witht the ftp command.

open (FTP, "|/bin/ftp -n") || die "Can't open FTP command, $!\n";
print FTP <<"EOFTP";
open ftp.doc.ic.ac.uk
user anonymous -kyzer\@hotmail.com
cd /pub/aminet
asc
get README /tmp/myfile-$$
EOFTP
close FTP;
open (FILE, "</tmp/myfile-$$") || die "FTP didn't succeed";
@myfile=<FILE>;
close FILE;

print "here we are...\n";
print join('',@myfile);

--
Stuart 'Kyzer' Caie - Kyzer/CSG |undergraduate of Aberdeen University |100%
http://www.abdn.ac.uk/~u13sac   |My opinions aren't those of Aberdeen |Amiga -
kyzer@4u.net kyzer@hotmail.com  |University or AUCC, thankfully.***** |always!

-- 
Random sig of the day:
BEAU PEEP: This "Cow-man" comic of yours is riduiculous!
DENNIS: S'not!
BEAU: How is this "half-man, half-cow" supposed to catch criminals?
DENNIS: HE'S GOT LASER-BEAM UDDERS!



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

Date: 15 May 1997 17:05:50 GMT
From: rmshair@uiuc.edu (Bob Shair)
Subject: Re: running ftp in a Perl script.
Message-Id: <5lffpe$l9h@vixen.cso.uiuc.edu>

"Florence Kuan" <Florence=Kuan%Design%Eng=Sin@netgate.compaq.com> writes:

>I need to ftp a file from another server while running a Perl program. Does
>anyone know how I can pass arguments to the ftp program while running a
>Perl program? Is it possible for the Perl program to supply the user
>account name, password, and ftp commands to the ftp program so that the
>user does not have to enter anything.

I've done this two ways, based on whether I needed to capture the
output from ftp in my program or not.  According to the Camel book
(March 1992 edition, p163, "open" function) 
(You may not have an open command that pipes both in and out,
 though it's easy to build one using the pipe and fork commands).
I haven't needed to build one yet.

Case 1, very simple... just issue commands and let the output 
	flow across the console.
(Gets many files from a VSE/POWER mainframe... taking their names
 from the file "hostfilenames")

open (HNAMES, "hostfilenames");
open(FTP, "|ftp -ivn mainframe");
print FTP "user userid password\n";
while (<HNAMES>) {
    ($jobname,$jobno) = split(/ /,$_,3);
    print "getting $jobname.$jobno\n";
    print FTP "get \$\$LST.$jobname.0.$jobno batchrec/$jobname.$jobno\n";
    }
print FTP "quit\n";
close(FTP);

Case 2, FTP a file from systemA to systemB and examine the output
(this runs from a third system, since neither systemA nor systemB
 then had a decent perl implementation).

$then = time;
$F = `ftpboth $jobname.$class.$jobno $jobname.$jobno 2>&1`);
$elapsed = time - $then;
@F = split(/\n/,$F,20);
if (2 == grep(/226 Transfer complete/,@F)) {
    print "$jobname,$jobno successfully transferred\n";
    }
# since we're doing proxy ftp, we need two "transfer complete" messages
else { ...

where the "ftpboth" script is:
#!/bin/ksh
ftp -iv mainframe <<THE_END
proxy open mainframe2
proxy ascii
proxy get \$\$LST.$1 $2
quit
THE_END
-- 
Bob Shair                          Open Systems Consultant
1018 W. Springfield Avenue         rmshair@uiuc.edu
Champaign, IL 61821		   217/356-2684
< Not employed by or representing the University of Illinois >


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

Date: Thu, 15 May 1997 16:39:41 +0200
From: Jonas Thvrnvall <labah@algonet.se>
Subject: Simulate unix/linux mail on PC?
Message-Id: <337B202D.441A@algonet.se>

(I use Perl on pc)Is there any Pc program that will use same parameters
as the unix version of mail. I wan't to be able to check that
the user really submit his own mailadress before logon. If he get my
controllcode, he can use it to logon my chatserver.

I know i could do it directly against the real server but it would be
nice to simulate it on my own machine before i put it up!

Maybe there is no such program for pc?

Please mail me if you know the answer


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

Date: 15 May 1997 16:06:13 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: Top of the page format problem
Message-Id: <5lfc9l$urg$1@dartvax.dartmouth.edu>

In article <33789EDF.41C67EA6@cig.mot.com>
Ali Ranjbar <ranjbar@cig.mot.com> writes:

> I tried:
> write STDOUT_TOP;
> but it did not work. Did not print anything. I got the message
> Write on closed filehandle at final.pl line 25.

The top of page format is automatically printed whenever a new page is
needed.  STDOUT_TOP is a format, not a filehandle.  You should 'write
STDOUT;', not 'write STDOUT_TOP;'

Chipmunk


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

Date: 15 May 1997 16:21:56 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: Tough replacement problem
Message-Id: <5lfd74$urg$3@dartvax.dartmouth.edu>

In article <01bc60ed$d4adb200$391a56a0@hercules.ods.com>
"Hampton Keathley" <hamptonk@bible.org> writes:

> I have a file with lines that look like this:
> 
> text text text text <greek>agapv wuix</greek>
> 
> I need to search through a rather large file and search and replace various
> characters between the <greek> codes.
> 
> How do I grab only the text between the tags and then do a search and
> replace on only the "v" or the "x" that is within the <greek> tags and not
> mess up the v or x outside the tags?

One way to do it...

s#\(<greek\>)(.*?)\(</greek>)#$1.&do_greek($2).$3#eg

sub do_greek {
   # whatever you want to do to text within the <greek> tag
}

Chipmunk


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

Date: Thu, 15 May 1997 09:54:06 -0500
From: Harold Howe <hhowe@trgnet.com>
Subject: Using Perl as a script engine
Message-Id: <337B238E.7EB5@trgnet.com>

Howdy,

I need to add scripting ability for a windows program. The program tests
hardware on the PC, and the script would allow users to design their own
tests. I am considering using Perl as the script engine, while the
program would be written in C++.

Here's the question. When I run a script from my program, will the
script be able to call functions from the EXE? For example, if I code a
function that opens the CD tray using windows API calls, can the script
call my function if the user wants to open the CD from within the
script?

This is an elementary example. Maybe perl allows the user to open the CD
tray using perl commands directly, without any help from the Windows
API. However, there are more complex situations where we will need the
script to call functions provided in the EXE, or a DLL.

Harold


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

Date: 15 May 1997 14:29:30 GMT
From: fm0529@vulpius-atm.rz.uni-frankfurt.de ()
Subject: Xforms4Perl-0.7 crash
Message-Id: <5lf6ka$u5e$1@grapool30.rz.uni-frankfurt.de>

Hi all,
I compiled and installed Xforms4Perl-0.7 on a Sparc 10 SunOS 4.1.4,
perl5.003, xforms.0.86, gcc2.7.2 without any problems.
fdesign runs fine. perl runs fine.
When I try to run the demos in the DEMO directory
I get Bus error (core dumped). Thats all.
There was no error or warning at compiletime.
What can be wrong ?
Thanks in advance
Christian


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

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

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