[7006] in Perl-Users-Digest
Perl-Users Digest, Issue: 631 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 18 16:18:05 1997
Date: Wed, 18 Jun 97 13:00:24 -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, 18 Jun 1997 Volume: 8 Number: 631
Today's topics:
"Cloning" a Perl install (no C compiler) <flannigan.robert@infoband.com>
Re: Another try <eike.grote@theo.phy.uni-bayreuth.de>
Re: appending two files into one? (Nathan V. Patwardhan)
Re: call perl script in c program? (Nathan V. Patwardhan)
Re: call perl script in c program? <usenet-tag@qz.little-neck.ny.us>
Re: Controlling "printf" Formatting from the Command Li (Mark O'Connell)
Re: DBM question <dean@tbone.biol.sc.edu>
Re: Debugging tutorial? (Michael Schuerig)
Fail to build Perl 5.004 on netbsd <joop@polder.ubc.kun.nl>
Form to Separate Perl Scrips (Darren VanWageningen)
Re: how can I write a long array? <sfairey@metrica.co.uk>
Re: how could I print or whatever a character one by on (kEQNql)
Re: how could I print or whatever a character one by on <sfairey@metrica.co.uk>
Re: How to get browser window size? (Nathan V. Patwardhan)
Re: Is there an easy way to send email in perl ? Using <mattias.lonnqvist@uidesign.se>
Re: LOG base 10 operator (Tung-chiang Yang)
Re: map feature request (Charles DeRykus)
mkdir <demirkol@sgs-server.Stanford.EDU>
Re: multiple white spaces <derek@netlink.co.uk>
Problems running xsubpp?? <joop@polder.ubc.kun.nl>
Scanning for Low & High ASCII in a text file ("Keith Christian")
Re: Sending e-mail using Perl for NT - don't wanna... g (Gerben Vos)
Re: Serial Communications <frank.gauthier@raba.com>
Re: Suppressing Echo to STDOUT? (Michael James Braunstein)
Traslate or other method? <david1@earthlink.net>
Re: unix mail in CGI-Script ? <sbarman@bdm.com>
Re: URL worthy strings in Perl (Bob)
What's wrong with my scripts??????? <ayafall@dartmouth.ccfne.ns.ca>
Re: What's wrong with my scripts??????? (Michael Fuhr)
When do I call srand? <Dskramer@concentric.net>
Re: When do I call srand? (Michael Fuhr)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 18 Jun 1997 14:04:07 -0600
From: Robert Flannigan <flannigan.robert@infoband.com>
Subject: "Cloning" a Perl install (no C compiler)
Message-Id: <866657638.20693@dejanews.com>
before I go about re-inventing the wheel, I was wondering if there was a
"canned" method for duplicating a specific Perl build to X number of
systems on a network (37 in my case).
we essentially have many SVR4 (NCR) unix systems spead around the country
that are at the same rev of OS and assorted libraries and system files.
I have built Perl cleanly on our "golden" lab system, but do not have a C
compiler installed on the production machines, and therefore cannot use
the recommended method of `sh Configure; make; etc.` to build on each
box. therefore my plan is to:
0) take a filesystem snapshot before building Perl on our "golden"
system. 1) run thru the standard Perl build on that system 2) take
another filesystem snapshot and then `diff` the before and after to get a
list of the files that were changed/added by the `make install` 3) create
a `cpio` archive of these files, and place it on an NFS mount. 4) execute
a `remsh cpio -icvdmul -I ` for each of the remote locations to
"install" Perl binaries, docs, libraries, modules, etc. on each remote
system.
is there a simpler method that I have yet to find on CPAN, FAQs, or the
other places I've been checking? is this method in any way "dangerous"
in that it would miss something? may thanks to the contributors to this
list for any feedback.
--rsf
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Wed, 18 Jun 1997 15:37:51 +0200
From: Eike Grote <eike.grote@theo.phy.uni-bayreuth.de>
Subject: Re: Another try
Message-Id: <33A7E4AF.167E@theo.phy.uni-bayreuth.de>
Hi,
Andreas Sliwka wrote:
>
> Hi,
> is someone out there to help me with something?
Yes, maybe ... But what's the problem ??? Is your code not running
(I didn't try it ...)? Is anything missing? Are you stuck in the
development? ...?
> Im trying to find an elegant way to combine HTML and Perl, i.e. mixing
> it up. I took a look at EmbedPerl and CGI.pm but both have drawbacks,
> the later is not intuitive enough for not-perl-hackers (p-- || !p), the
> other is (imho) to limited. So I tried to write a simple CGI-script,
> that gets the filename of a (so called) PetH file.
> this file is plain HTML but got two new tags: <PERL> and </PERL>
> Anything between them will be executed per eval, everything not between
> printed in doublequotes, so vars will be substituted. Example:
> I use the following script to overlook my httpd/icons directory:
>
[sample pseudo-html code]
>
> It's much more readable this way, I think.
> And now I'm calling for help, because I have no experience with Perl
> (which I use since three weeks) and I always like friendly criticism.
> Would anyone please be so nice? thanx, goff.
(see above) ;-)
Bye, Eike
P.S.: "Another try" isn't a very good subject at all ...
--
======================================================================
Eike Grote, Theoretical Physics IV, University of Bayreuth, Germany
----------------------------------------------------------------------
e-mail -> eike.grote@theo.phy.uni-bayreuth.de
WWW -> http://www.phy.uni-bayreuth.de/theo/tp4/members/grote.html
http://www.phy.uni-bayreuth.de/~btpa25/
======================================================================
------------------------------
Date: 18 Jun 1997 13:58:04 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: appending two files into one?
Message-Id: <5o8phc$gc@fridge-nf0.shore.net>
Magnus Bodin (Magnus.Bodin@tychonides.se) wrote:
: foreach $appfile (@ARGV) {
: open(TMP,$appfile);
Ouch.
perl -e 'while(<>) { print; }' filename filename >> out.txt
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: 18 Jun 1997 13:59:56 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: call perl script in c program?
Message-Id: <5o8pks$gc@fridge-nf0.shore.net>
Joe McCaughan (shiloh@best.com) wrote:
: Chun Xu (xuc@bayfront.org) wrote:
: : I have two cgi programs, one written in perl, another in c. Now, the c
: : prgram need to use a subroutine in that perl script? Is it possible to
man perlcall.
: You probably need to look at the comp.lang.c (or somesuch) newsgroup
: for this...
No. It's not 100% necessary since there's the perlcall manpage.
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: 18 Jun 1997 16:56:02 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: call perl script in c program?
Message-Id: <5o93v2$48t$1@news.netusa.net>
Joe McCaughan <shiloh@best.com> wrote:
> Chun Xu (xuc@bayfront.org) wrote:
> : I have two cgi programs, one written in perl, another in c. Now, the c
> : prgram need to use a subroutine in that perl script? Is it possible to
> : call a perl script in a c program? If so, how?
Yes. I've recently hacked procmail to be able to use perl for
regexps, for example. (Filtering with s/// will probably be next.)
> You probably need to look at the comp.lang.c (or somesuch) newsgroup
> for this...
Nope. But it most likely in the FAQ. (I've only read the regexp
section myself.)
> But I think the system() call should work. Something like:
> system("/path/to/perl/program.pl");
You could use system, or a fork/exec yourself, but the most interesting
solution can be had with perlembed. Consult that man page for some handy
code samples. Helped me a lot.
Elijah
------
free at last from procmail's broken regexps!
------------------------------
Date: 18 Jun 1997 18:28:08 GMT
From: oconnell@dg-rtp.dg.com (Mark O'Connell)
Subject: Re: Controlling "printf" Formatting from the Command Line
Message-Id: <5o99bo$c66@dg-rtp.dg.com>
Kevin M Simonson (simonson@skopen.dseg.ti.com) wrote:
: What I would like to do is write a "perl" script that varies the for-
: mat floating points are printed in, depending on what is entered on the
: command line.
:
: This is kind of what I want in "perl" except that I would also like to
: be able to control the number of decimal places that get printed. In par-
: ticular, what I would like is a "perl" script written such that if I were
: to execute "Space <length> <decimals> <float>", then what I would get would
: be a line with square brackets around the number field in which <float>
: would be displayed, have the number field be <length> long, have leading
: zeroes replaced by blanks, and have <decimals> decimals be displayed.
:
: For example, "Space 11 5 3.1415926535897932" would need to result in
:
: [ 3.14159]
:
: and "Space 17 14 3.1415926535897932" would need to result in
:
: [ 3.14159265358979]
How about just setting the printf() format field based on the arguments?
Something like
#! /usr/bin/perl
$format = "$ARGV[0].$ARGV[1]";
printf "Using %%$format" . "f to print $ARGV[2].\n";
printf "The number is -- [%$format" . "f]\n", $ARGV[2];
which gives
./moc.pl 11 5 3.1415926535897932
Using %11.5f to print 3.1415926535897932.
The number is -- [ 3.14159]
./moc.pl 11 8 3.1415926535897932
Using %11.8f to print 3.1415926535897932.
The number is -- [ 3.14159265]
./moc.pl 11 2 3.1415926535897932
Using %11.2f to print 3.1415926535897932.
The number is -- [ 3.14]
./moc.pl 8 2 3.1415926535897932
Using %8.2f to print 3.1415926535897932.
The number is -- [ 3.14]
------------------------------
Date: 18 Jun 1997 12:03:48 -0400
From: Dean Pentcheff <dean@tbone.biol.sc.edu>
Subject: Re: DBM question
Message-Id: <m17mfrrj8a.fsf@nauplius.psc.sc.edu>
Bob Wood <wood@ziplink.net> writes:
...
> I first tried tying a variable to an SDBM_File, and then discovered that
> my hashes weren't preserved. So I'm wondering how to handle this. I've
> seen MLDBM on CPAN, which sounds like it does what I want. Is this a
> good package to use? Or should I flatten my keys and try to stick with
> SDBM_File?
I've happily used MLDBM (which itself requires DataDumper) to do
similar things in the past - it works just fine. There may be other
solutions out there, but MLDBM worked for me...
-Dean
--
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"
------------------------------
Date: Wed, 18 Jun 1997 17:54:49 +0200
From: uzs90z@uni-bonn.de (Michael Schuerig)
Subject: Re: Debugging tutorial?
Message-Id: <19970618175449311371@rhrz-ts3-p3.rhrz.uni-bonn.de>
Chris Oke <coke@adrenalin.com> wrote:
> http://www.panix.com/clay/perl/ has a section on debugging.
Very good indeed. What I had in mind, though, was a tutorial on using
the debugger. Any recommendations?
Michael
---
Michael Schuerig Although condemned by moralist,
mailto:uzs90z@uni-bonn.de lying can have high survival-value.
http://www.uni-bonn.de/~uzs90z/ -Richard L. Gregory
------------------------------
Date: 18 Jun 1997 15:39:00 GMT
From: "Joop Jansen" <joop@polder.ubc.kun.nl>
Subject: Fail to build Perl 5.004 on netbsd
Message-Id: <01bc7bfd$c5d73910$2415ae83@beemster>
Hello,
I am trying to build per5.004 on a netbsd (Intel) architecture.
I am using g++ 2.7.2.2
I get the errors below.
Could not find any solutions in the hints.
Does anyone have a solution.
Thanks in advance,
Joop Jansen
joop@polder.ubc.kun.nl
perl.c:2618: parse error before `}'
perl.c: In function `void Perl_my_failure_exit()':
perl.c:2641: warning: `noreturn' function `Perl_my_failure_exit()' does
return
perl.c: In function `void my_exit_jump()':
perl.c:2645: new declaration `void my_exit_jump()'
perl.c:2617: ambiguates old declaration `int my_exit_jump()'
perl.c: In function `void my_exit_jump()':
perl.c:2652: warning: passing `int' to argument 1 of `fclose(__sFILE *)'
lacks a cast
perl.c:2653: warning: assignment to `int' from `__sFILE *' lacks a cast
perl.c:2655: warning: passing `int' to argument 1 of `unlink(char *)' lacks
a cast
perl.c:2656: `free' cannot be used as a function
perl.c:2657: warning: assignment to `int' from `char *' lacks a cast
perl.c:2663: warning: assignment to `sv **' from `long int' lacks a cast
perl.c:2663: warning: assignment to `int' from `cop *' lacks a cast
perl.c:2663: assignment to `int *' from `long int *'
perl.c:2663: warning: assignment to `int' from `pmop *' lacks a cast
perl.c:2667: base operand of `->' is not a pointer
perl.c:2667: base operand of `->' is not a pointer
perl.c:2667: `exit' cannot be used as a function
perl.c:2667: `fprintf' cannot be used as a function
perl.c:2667: `exit' cannot be used as a function
perl.c: At top level:
perl.c:66: warning: `void forbid_setid(char *)' declared `static' but never
defined
*** Error code 1
------------------------------
Date: 18 Jun 1997 19:02:49 GMT
From: dvanwage@tuns.ca (Darren VanWageningen)
Subject: Form to Separate Perl Scrips
Message-Id: <5o9bcp$hhp$1@News.Dal.Ca>
Hi all,
Here is the major problem. This might be suited for a html
newsgroup, but I figure I'd give it a shot here first.
I have html form for user input. Thats fine and dandy, so at the
end of the form, I have the submit, or Reset button, with submit going to
the script. So, thats great, fine and dandy. But, I was told to make a
modification of the form, so that the submit button turn into two
buttons, a yes/no type buttons. If they select Yes, it goes to the
original script. If they select no, it goes into a new html page, where
at the end they submit into the original script. So, essentially, the
first form 'goes' go the script, and it may also go into another html
form, which then heads into the same script.
So, I guess my big question is how this can be done. I have to
retain all the info from the first form in the second. I figure I can
pass the variables hidden into the next html page, but how I "do the
submit" NO button....What would be the code. Or is this even possible at all.
My origial plan was to just make a link button, but I don't know
if the variable would be passed into that page or not, and my tests
showed it did not work.
Thanks for your time, reply via email please.
--
***************************************************************************
* Darren VanWageningen *
* *
* dvanwage@tuns.ca *
* *
* http://www.tuns.ca/~dvanwage/eternal.html *
* *
* FSP: newton.ccs.tuns.ca Port 4303 *
***************************************************************************
------------------------------
Date: Wed, 18 Jun 1997 16:13:21 +0100
From: Simon Fairey <sfairey@metrica.co.uk>
To: mingtian@hotmail.com
Subject: Re: how can I write a long array?
Message-Id: <33A7FB11.6488@metrica.co.uk>
kEQNql wrote:
>
> >kEQNql wrote:
> >>
> >> question:
> >>
> >> @a=('a','b',...................
> >> 'c','d',.......,
> >> 'k','l',.........);
> >>
> >> that maybe wrong, right? what should I do then?
> >
> >Not sure if its just me but I don't have a clue what you are asking.
> >Try providing a bit more detail in your question pls a snippet of the
> >code in question is always a good idea. Otherwise go to www.perl.com and
> >follow the various links for documentation.
>
> Dear Simon
>
> Thanks! what I want to do is to implement a Chinese code converting
> betweeb Big5 and GB or vice versa, I get the C source so I need to know
> how should I convert it inot Perl style, as you might know Chinese characters
> are more than 13000(for Big5) so the array might be that long.
>
> Gil
The only limit to the size of an array in perl is the amount of memory
you have available. There was a thread a while back which went into
detail ( I think ) regarding this. In short you should not have a
problem.
Simon
------------------------------
Date: Wed, 18 Jun 1997 14:01:53 GMT
From: mingtian@hotmail.com (kEQNql)
Subject: Re: how could I print or whatever a character one by one from $string, not from @array?
Message-Id: <33ade9a1.14924866@usenet.kornet.nm.kr>
>kEQNql wrote:
>>
>> I would like to implement the following C routine into Perl.
>>
>> ch[] = "abcd....";
>> for (i=1;i<=size;i++)
>> {
>> c1 = ch[i];
>> if ( (c1 & 0x80 ) == 0x80 )
>> {
>> c2 = ch[i++];
>> printf("%c%c", c1 & 0x7F, c2 & 0x7F );
>> {
>> else
>> {
>> printf("%c", c1);
>> }
>>
>> Gil
>
>Not sure what you are doing with the hex values ( I am assuming its to
>do with handling the extended character set ) but the following will
>print $string one char at a time:
>
> $string = 'Simon says hows this?';
> print join( "\n", split( //, $string ) );
>
>Just split the string on nothing '//' and then do whatever
>you want with the resulting chars.
>
>Have fun
Dear Simon
Thank you~! my programme needs to get a character one by one
to manipulate, if the first letter in string is 8bit code(1xxx xxxx) then
get the second character from the string then hand the two letter
to some subroutine to convert it(Big5 or GB code) to (BG or Big5 code).
Gil
------------------------------
Date: Wed, 18 Jun 1997 16:23:27 +0100
From: Simon Fairey <sfairey@metrica.co.uk>
To: mingtian@hotmail.com
Subject: Re: how could I print or whatever a character one by one from $string, not from @array?
Message-Id: <33A7FD6E.773C@metrica.co.uk>
kEQNql wrote:
> Dear Simon
>
> Thank you~! my programme needs to get a character one by one
> to manipulate, if the first letter in string is 8bit code(1xxx xxxx) then
> get the second character from the string then hand the two letter
> to some subroutine to convert it(Big5 or GB code) to (BG or Big5 code).
>
> Gil
I don't have time to sort out the exact code but essentially it will be
the same as the c code.
i.e.
$string = "abcd....";
$looking_for_second_char = 0;
foreach $char ( split( //, $string ) ) {
if( $looking_for_second_char ) {
print the 2 chars together ( i.e $last_char and $char )
$looking_for_second_char = 0;
next;
}
if( $char is 8bit ) {
$last_char = $char;
$looking_for_second_char = 1;
next;
}
Otherwise print the character...
}
Simon
------------------------------
Date: 18 Jun 1997 14:02:29 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: How to get browser window size?
Message-Id: <5o8ppl$gc@fridge-nf0.shore.net>
Zonycat (zonycat@flash.net) wrote:
: I am trying to get the size of my browser window or anybody's browser
: window that displays my WEB page. Is there an environmental variable or
: cookie I could look at to see the window size?
Why are you asking us? This has nothing to do with Perl; maybe it's a
Javascript issue. Maybe it's Sanskrit.
See: comp.infosystems.www.authoring.cgi
See: comp.lang.javascript
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: Wed, 18 Jun 1997 14:09:55 +0200
From: Mattias Lvnnqvist <mattias.lonnqvist@uidesign.se>
Subject: Re: Is there an easy way to send email in perl ? Using version 4
Message-Id: <33A7D013.574A@uidesign.se>
John L. Stein wrote:
>
> Is there an easy way to send email in perl ? Using version 4
>
> Thanks
> -js
Try this:
#!/usr/bin/perl
$mailprog="/usr/lib/sendmail";
$shopowner="whoever\@whatever.com";
open (MAIL, "|$mailprog $shopowner");
print MAIL "whatever\n";
close(MAIL);
/Mattias
--
+--------W-O-R-K-------------------------+----------H-O-M-E-------------------+
| Phone: +46 - (0)13 - 371205 | Phone: +46 - (0)13 -
144156 |
| mail-to: Mattias.Lonnqvist@uidesign.se | Main coder, MiT,
tyme.envy.com 6969|
| URL: http://www.uidesign.se/~malo |
http://www-und.ida.liu.se/~c89matlo|
------------------------------
Date: Wed, 18 Jun 1997 19:28:37 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: LOG base 10 operator
Message-Id: <tcyangEBzKrq.Gw@netcom.com>
All of you are right. For some applications, people use 'log' and 'ln'
for base-10 logarithms and natural logarithms. For some others, people
use 'log10' and 'log' instead.
Perl uses 'log' for natural logarithms.
==================================
M.J.T. Guy typed when the mommy tyrannosaurus found him:
: Larry D'Anna <ldanna@ix.netcom.com> wrote:
: >
: >10 ** 1 = 10
: >therefore
: >log(10) = 1
: Not in my perl, it ain't:
: print log(10)
: gives
: 2.30258509299405
--
========= Try the low-crossposting robomoderated 'alt.culture.taiwan' ===
soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
http://www.iglou.com/tcyang/Taiwan_faq.shtml, China_faq.shtml
------------------------------
Date: Wed, 18 Jun 1997 17:17:29 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: map feature request
Message-Id: <EBzEp7.EBE@bcstec.ca.boeing.com>
In article <5o7l4u$hsl$1@news.gte.net>,
Douglas Wilson <dgwilson@gte.net> wrote:
>Charles DeRykus wrote:
>>
>> In article <5ntcvb$l79$1@news13.gte.net>,
>> Douglas Wilson <dgwilson@gte.net> wrote:
>
>> > $qstring="a=one&b=two&c=three";
>
>> Alternatively, you could trade in "split,map" for "push,regex":
>>
>> push(@names,$1),push(@values,$2) while $qstring =~ /(.*?)=(.*?)&/g;
>
>Although I like this, it doesn't quite work unless you append a "&"
>onto the end of "$qstring". And I'm unclear on exactly why the
>regexp matches only the part of the string I'm after (instead of
>nearly all of it), even though
>I know what the individual symbols are for in the regexp.
>
>And I wonder why this doesn't work:
Whoops, this'll correct the problem:
push(@names,$1),push(@values,$2) while $qstring =~ /(.*?)=(.*?)(?:&|$)/g;
^^^^^^^
The addition at the end picks up the alternatives: (& or $) without
creating a backreference. See perlre or the Camel.
>push(@names,$1),push(@values,$2) while $qstring . "&" =~
>/(.*?)=(.*?)&/g;
>
>I think it causes an infinite loop.
>
>
Yes, =~ will bind more tightly than the . so the regex will
sneak in first. "&" =~ /(.*?)=(.*?)&/g is false so evaluating,
reducing, and simplifying, we easily see that the resultant
expression:
push(@values,$1),push(@values,$2) while $qstring;
will loop forever. Both $1 and $2 will be undefined.
You can't do this either:
push(@values,$1),push(@values,$2) while ($qstring . "&") =~ /(.*?)=(.*?)&/g;
because then the expression ($qstring . "&) will will be evaluated
first each time through the loop. The pattern match will be true
each time with a resulting infinite loop. $1 = "a" and $2 = "one"
with each iteration.
HTH,
--
Charles DeRykus
ced@carios2.ca.boeing.com
------------------------------
Date: Wed, 18 Jun 1997 10:25:57 -0700
From: Mehmet Demirkol <demirkol@sgs-server.Stanford.EDU>
Subject: mkdir
Message-Id: <Pine.SOL.3.95.970618101844.8528A-100000@sgs-server.stanford.edu>
I am working on a perl script for a web page, and I need to create a
directory. I used the following line. When I run the script by "perl
filename" on the unix command, it works fine, when it's referenced by the
html file, it doesn't.
mkdir("$dirname", 0777) || die "Cannot mkdir $dirname";
How can I create a directory and edit a file in that directory?
Thanks,
Mehmet
------------------------------
Date: 18 Jun 1997 17:02:48 GMT
From: "Derek Moore" <derek@netlink.co.uk>
Subject: Re: multiple white spaces
Message-Id: <01bc7c09$76d742e0$bd01910a@gobert.fbh.private.cableol.net>
Try:
$str =~ s/[ ]+/ /g;
Regards,
Denis
Denis Geoghegan
Cable Online
md4calle@mdstud.chalmers.se wrote in article
<866558420.7524@dejanews.com>...
> In article <5nmeha$bf0@tsunami.traveller.com>,
> gbacon@adtran.com wrote:
> >
> > [Posted and mailed]
> >
> > In article <EBL6ru.9on@seas.ucla.edu>,
> > trit@olympic.seas.ucla.edu (Tri Duy Tram) writes:
> > : I am wondering how do you change multiple white spaces to just one
single
> > : white space?
> >
> > $str =~ s/\s+/ /g;
> When I do this it removes all newlines as well? Is there a way to do
> it without removing newlines?
>
> /Calle
>
> -------------------==== Posted via Deja News ====-----------------------
> http://www.dejanews.com/ Search, Read, Post to Usenet
>
------------------------------
Date: 18 Jun 1997 16:02:21 GMT
From: "Joop Jansen" <joop@polder.ubc.kun.nl>
Subject: Problems running xsubpp??
Message-Id: <01bc7c01$087506f0$2415ae83@beemster>
Hello,
I am trying to run xsubpp on an .xs file and get an error. Is there an
explanation?
See below for details.
I have the following setup:
---------------------------BEGIN typemap -----------------------------
const char * const T_VP
const int IV
--------------------------- END typemap---------------------------------
---------------------------BEGIN api.xs-----------------------------------
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
/* TASK:: include the header file for your C-functions */
#include "api.h"
/* TASK:: set the name of the module and the name of the package */
MODULE = API PACKAGE = API
void
setFactor(i)
const int i
void
setString(cp)
const char *const cp
void
getString(cp)
char * cp
OUTPUT:
cp
void
computeString()
int
getFactor()
OUTPUT:
RETVAL
---------------------------------END
api.xs------------------------------------------------------
I run:
perl /usr/local/lib/perl5/ExtUtils/xsubpp -C++ -prototypes \
-typemap /usr/local/lib/perl5/ExtUtils/typemap -typemap typemap api.xs >
api.c
I do get a api.c file, but xsubpp generates:
Error: No INPUT definition for type 'const int' found in api.xs, line 12
Error: No INPUT definition for type 'const char * const' found in api.xs,
line 16
Is this a problem?
------------------------------
Date: Wed, 18 Jun 97 10:29:34 PST
From: keith_christian@smtpgate.tais.com ("Keith Christian")
Subject: Scanning for Low & High ASCII in a text file
Message-Id: <9705188666.AA866655461@smtpgate.tais.com>
Hello all:
I have written a Perl script that isn't working quite right. I want
the script to open every file in a directory (ignoring directories
themselves) and print out on one line the filename, and a count of
three ranges of characters found in each file: "low" ascii (<x1F),
"normal" (<0x1F<normal<0x7F), and "high" (>0x7F). Currently my script
says that NO files have any low or high ascii characters.
The purpose of doing this is to locate plain text files which have
been corrupted (this project is for a friend.)
Opinions and/or help appreciated.
Perl Version:
Running Perl under Windows 95.
Perl for Win32 Build 306 - Built 17:50:28 Apr 10 1997
This is perl, version 5.003_07
My script that does not work correctly:
#########################################################
#Scan a directory of files, report count of three ranges
#of characters, to locate text files that have corruption.
#########################################################
foreach $foo (<*.TXT>) {
my(@bar)=$foo;
unless (m/0x00-0x1f/ || m/0x7f-0xff/) {
print "$foo has no control or high ascii characters\n";
}
}
###############
# End of script
###############
Please reply to the list, thanks in advance.
------------------------------
Date: 18 Jun 1997 16:40:36 GMT
From: gerben@cs.vu.nl (Gerben Vos)
Subject: Re: Sending e-mail using Perl for NT - don't wanna... gotta
Message-Id: <5o9324$dmn@star.cs.vu.nl>
Did you read the FAQ? Anyway, the "mail" program doesn't exist on NT.
You want a program called "BLAT", which is a simple utility for sending
SMTP mail from NT. It's available at about every Windows software archive.
. . . . . . . . . . . . . . . . . . . . . . . . . . . G e r b e n V o s <><
mailto:gerben@cs.vu.nl http://www.cs.vu.nl/%7Egerben/
Reality is that which, when you stop believing in it, doesn't go away.
-- Philip K. Dick
------------------------------
Date: Wed, 18 Jun 1997 10:36:04 -0400
From: Frank Gauthier <frank.gauthier@raba.com>
Subject: Re: Serial Communications
Message-Id: <33A7F254.2781@raba.com>
Jeff Walls wrote:
> Here's the specific situation. I'm communicating with a "device".
> I would like to read the device's status (which is prompted by
> a query). So I first write a one-byte request to the device, and
> then immediately read the two-byte reply.
>
> Win95:
>
> open (RS232, "+>COM1") || die "Cannot open Serial Line";
>
> $requestBuffer = 0x80;
> printf (RS232 "%c\n", $requestBuffer);
>
> read (RS232, $replyBuffer, 2);
>
> close (RS232);
You could try this:
$| = 1;
.
.
.
printf (RS232, "%c\n", $requestBuffer);
Perhaps, buffering is killing you...
--
Frank Gauthier (Voice) (410) 715-9399
RABA Technologies (Fax) (410) 715-9397
10500 Little Patuxent Parkway frank.gauthier@raba.com
Columbia, MD 21044 http://www.raba.com
------------------------------
Date: 18 Jun 1997 19:13:19 GMT
From: mjb1@alpha3.csd.uwm.edu (Michael James Braunstein)
Subject: Re: Suppressing Echo to STDOUT?
Message-Id: <5o9c0f$s0@uwm.edu>
on 9 Jun 1997 23:43:29 GMT Ben Neil Gerdemann muttered:
> Hello,
>
> I would like to use Perl to input data from the keyboard without echoing
> it to the screen (like the way passwd works.) How is this possible?
>
> Thanks,
> Ben
well, you could dup(2) >& the stdout file descriptor, and close the original
then use the dup'ed fd as stdout...well it's what i'd do in 'c' anyway,
in perl i'd just do like the thread said, system "stty -echo";
-mjb
------------------------------
Date: Wed, 18 Jun 1997 10:06:18 -0700
From: David Cheitel <david1@earthlink.net>
Subject: Traslate or other method?
Message-Id: <33A8158A.E72E1B6E@earthlink.net>
I am trying to convert a alphanumeric string to ascii equiv.
I would like to use a tr/A-Z/027-053/ but as it stands perl looks at
that as 0 2 7 as individual substitutions.
I would like a string ie. CR000027 converted to the ascii equiv.
Thanks.
------------------------------
Date: Wed, 18 Jun 1997 13:03:08 -0400
From: Scott Barman <sbarman@bdm.com>
To: Patrick Schuster <patrick@mucsun.sps.mot.com>
Subject: Re: unix mail in CGI-Script ?
Message-Id: <33A814CC.72BC@bdm.com>
Patrick Schuster wrote:
>
> Hi Folks !
>
> I want to use the unix mail command in a CGI script, and
> my problem is, that the line below does his work, but I get no
> Subject line, if I start this in Netscape. The rest of the mail is
> really okay.
> Started in the csh Shell directly there are no problems with this line !
>
> system("mail -s TestSubject patrick < /dev/null");
This won't work because the mail program will read from standard input
and will read EOF when trying to read from /dev/null.
> I've tried this with another line
>
> open(FOUT,"|mail -s TestSubject patrick");
> ...
> close(FOUT)
And when you wrote to the open file FOUT, did you specify the name on
the print statement? E.g.:
print FOUT, "Text to send...";
If you do that, I am sure it will work!
scott barman
barman@ix.netcom.com (preferred)
sbarman@bdm.com
(Standard Disclaimers apply)
------------------------------
Date: Wed, 18 Jun 1997 17:41:58 GMT
From: xxbbell@voicenet.com (Bob)
Subject: Re: URL worthy strings in Perl
Message-Id: <5o95q7$apm$1@news3.voicenet.com>
How about:
$value =~ s/([^ \w\-.*])/sprintf("%%%2.2X",ord($1))/ge;
$value =~ s/ /+/g;
Why set the hex value for each character individually?
--
- Bob
http://www.voicenet.com/~bbell
xxbbell@voicenet.com
remove x's to reply
------------------------------
Date: Wed, 18 Jun 1997 12:35:48 -0700
From: Aya fall <ayafall@dartmouth.ccfne.ns.ca>
Subject: What's wrong with my scripts???????
Message-Id: <33A83893.23FD@dartmouth.ccfne.ns.ca>
Hi there:
I have a file where the data is stored in fields.
Name question1 question2 question3 question4....
input1......................................................
input2......................................................
input3......................................................
...
inputn.......................................................
I wrote another script to open that file, and add every rating by field.
open (RESULTS, "myfile.txt");
while (<RESULTS>)
foreach $name {
$question1++;
$question2++;
.............
$questionn++;
Then I divide each total by the number of respondants. But it is not
working, and I would appreciate any help.
Thanks in adv.
Aya
------------------------------
Date: 18 Jun 1997 13:19:00 -0600
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: What's wrong with my scripts???????
Message-Id: <5o9cb4$6u2@flatland.dimensional.com>
Aya fall <ayafall@dartmouth.ccfne.ns.ca> writes:
> I have a file where the data is stored in fields.
> Name question1 question2 question3 question4....
> input1......................................................
> input2......................................................
> input3......................................................
> ...
> inputn.......................................................
Real data would be more helpful, so we can see what your script
is actually being fed.
> I wrote another script to open that file, and add every rating by field.
> open (RESULTS, "myfile.txt");
> while (<RESULTS>)
> foreach $name {
> $question1++;
> $question2++;
> .............
> $questionn++;
> Then I divide each total by the number of respondants. But it is not
> working, and I would appreciate any help.
A real, complete sample of your code would also be more helpful
so we can see exactly what you're doing. And could you elaborate
on "it is not working"? That doesn't really tell us much :-)
--
Michael Fuhr
http://www.dimensional.com/~mfuhr/
------------------------------
Date: Wed, 18 Jun 1997 14:41:15 -0400
From: David Kramer <Dskramer@concentric.net>
Subject: When do I call srand?
Message-Id: <Pine.SUN.3.96.970618143812.11708A-100000@mariner.cris.com>
I am trying to find out the "scope" of srand.
Does it only affect rand() in the one process, or all processes?
If I have one perl program that require()'s another, and both need random
numbers, should I call srand() in the require()'ed program, or only the
outer program?
Also, exactly what does srand expect as a parameter? What range of number
does it expect?
TIA
-------------------------------------------------------------------
DDDD David Kramer dskramer@concentric.net
DK KD http://www.concentric.net/~dskramer
DKK D
DK KD Shh! Be vewy, vewy qwiet! I'm hunting wuntime ewwors...
DDDD
------------------------------
Date: 18 Jun 1997 13:14:31 -0600
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: When do I call srand?
Message-Id: <5o9c2n$6pu@flatland.dimensional.com>
David Kramer <Dskramer@concentric.net> writes:
> I am trying to find out the "scope" of srand.
>
> Does it only affect rand() in the one process, or all processes?
>
> If I have one perl program that require()'s another, and both need random
> numbers, should I call srand() in the require()'ed program, or only the
> outer program?
>
> Also, exactly what does srand expect as a parameter? What range of number
> does it expect?
See the entry for srand in the perlfunc manual page -- it should
answer your questions.
--
Michael Fuhr
http://www.dimensional.com/~mfuhr/
------------------------------
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 631
*************************************