[11178] in Perl-Users-Digest
Perl-Users Digest, Issue: 4778 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 29 10:09:11 1999
Date: Fri, 29 Jan 99 07:00:26 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 29 Jan 1999 Volume: 8 Number: 4778
Today's topics:
Can't send cookie <pouimet@lanasys.qc.ca>
Changing sort order on the fly... (Ed Overton)
Displaying OLE objects scot777@my-dejanews.com
Re: Help!! Lower case!! (Sam Holden)
How to use GDBM (Novice) <csyim@lgnet.lg.co.kr>
Re: htpasswd and perl <tneohcb@pc.jaring.my>
Re: LWP and multiple connections at the same time <onasc@home.com>
Re: LWP and multiple connections at the same time (Sam Holden)
Re: Perl Criticism (I R A Aggie)
Re: perl DBI CGI and mySQL <fty@utk.edu>
Re: Question Serial port programming (Bbirthisel)
reading binary files miulin@erols.com
Regexp matching (Staffan Hdmdld)
Re: Rencontre Perl de Mtl droby@copyright.com
substitution question <jeffhorton@graphatl.com>
Re: substitution question (Mike Stok)
Re: substitution question (Sam Holden)
Re: substitution question (Staffan Hdmdld)
system 'stty', '-echo' on Win32??? <qdtrini@jdicms88.ericsson.se>
Re: system 'stty', '-echo' on Win32??? (Sam Holden)
thousands digit separator <efcspain@sistelnet.es>
Re: thousands digit separator (Sam Holden)
Re: thousands digit separator (Mike Stok)
Re: Visual Perl? (I R A Aggie)
Re: WinNT Perl 5.005-02: Changed behavior of `dir` afte Denis.Haskin@bigfoot.com
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 29 Jan 1999 09:00:28 -0500
From: "Pierre Ouimet" <pouimet@lanasys.qc.ca>
Subject: Can't send cookie
Message-Id: <7cjs2.140$ez1.159@wagner.videotron.net>
Hi !
I have problem to send cookie, everytime the browser ask
to open it or to save it and on netscape it's just show it but
not save the cookie. I try many different demo and nothings want
to work. I'm using perl on novell. But It don't it change something.
This is my code :
#!/usr/contrib/bin/perl5.001
############################################################################
####
$VERSION="cookietest.pl v1.1"; #Aug. 18, 1996 Dale Bewley
<dlbewley@iupui.edu>
# v1.0 29 June 96, v0.9 14 May 96
############################################################################
####
$expDate = "Wednesday, 09-Nov-99 00:00:00 GMT";
$domain = ".deepspace1.com";
$path = "/pierre/cookie2/";
$secure=0;
&setCookie("user_name","ouipe",$expDate,$path,$domain,$secure);
&setCookie("text_color","blue",$expDate,$path,$domain,$secure);
# be sure to print a MIM type AFTER cookie headers and follow with a blank
line
print "Content-type: text/html\n\n";
# this is the first thing the user sees in the browser
print "\nReload for Cookies:<BR>";
%cookies = &getCookies; # store cookies in %cookies
foreach $name (keys %cookies) {
print "\n$name = $cookies{$name}<br>";
}
#- Set
Cookie -----------------------------------------------------------------#
sub setCookie {
# end a set-cookie header with the word secure and the cookie will only
# be sent through secure connections
local($name, $value, $expiration, $path, $domain, $secure) = @_;
print "Set-Cookie: ";
print ($name, "=", $value, "; expires=", $expiration,
"; path=", $path, "; domain=", $domain, "; ", $secure,"\n");
}
#---------------------------------------------------------------------------
---#
#- Retrieve Cookies From
ENV --------------------------------------------------#
sub getCookies {
# cookies are seperated by a semicolon and a space, this will split
# them and return a hash of cookies
local(@rawCookies) = split (/; /,$ENV{'HTTP_COOKIE'});
local(%cookies);
foreach(@rawCookies){
($key, $val) = split (/=/,$_);
$cookies{$key} = $val;
}
return %cookies;
}
#---------------------------------------------------------------------------
---#
Help me please !
Tanks in advance.
Pierre Ouimet
Lanasys
------------------------------
Date: Fri, 29 Jan 1999 14:08:37 GMT
From: saseao@unx.sas.com (Ed Overton)
Subject: Changing sort order on the fly...
Message-Id: <36b1bcb1.1269890445@newshost.unx.sas.com>
Hi there,
I'm working on a program where the user will supply the a sort
order for the output. I store my data in hashes, and keep an array
of references to the hashes. I've come up with one method, but I
feel like there's got to be a better way. A program using my
current solution is at the end of this post.
Obviously, I'm not going to create sort BLOCK statements for each
and every possible sort order. That leads me to using a subroutine
for sorting, and making the subroutine aware of the sort order. The
only way I've been able to make this work is to have the sort order
placed into an array, and then my sort subroutine does this:
sub mysort {
my $res;
foreach (@main::sort_array) {
if ($main::sort_type{$_} eq 'num') {
$res = $a->{$_} <=> $b->{$_};
} else {
$res = $a->{$_} cmp $b->{$_};
}
return $res if $res;
}
return 0;
}
. I predefine the %sort_type, and I'll get @sort_array from the user.
Then, my sort call is simply
sort mysort @array_of_refs;
. Got any better ideas?
Thanks,
Ed
====== SAMPLE PROGRAM ======
#!/usr/local/bin/perl5 -w
require 5.004;
use strict;
sub mysort {
my $res;
foreach (@main::sort_array) {
if ($main::sort_type{$_} eq 'num') {
$res = $a->{$_} <=> $b->{$_};
} else {
$res = $a->{$_} cmp $b->{$_};
}
return $res if $res;
}
return 0;
}
my @array_of_refs = ();
foreach my $i (0 .. 9) {
$array_of_refs[$i] = {
'A' => int(rand(10) + 1),
'B' => int(rand(10) + 1),
'C' => int(rand(10) + 5),
};
}
local %main::sort_type = ( 'A' => 'num',
'B' => 'num',
'C' => 'char' );
local @main::sort_array = qw(A B C);
foreach ((1 .. 3)) {
print "### Sorting by @main::sort_array ###\n";
print join "\n", map { join "\t", values %{$_} }
sort mysort @array_of_refs;
print "\n\n";
push @main::sort_array, shift @main::sort_array;
}
exit 0;
__END__
====== SAMPLE OUTPUT ======
$ sort.pl
### Sorting by A B C ###
1 3 10
3 5 10
3 10 5
4 6 12
4 8 10
5 10 12
6 6 12
7 7 9
7 9 8
9 7 10
### Sorting by B C A ###
1 3 10
3 5 10
4 6 12
6 6 12
9 7 10
7 7 9
4 8 10
7 9 8
5 10 12
3 10 5
### Sorting by C A B ###
1 3 10
3 5 10
4 8 10
9 7 10
4 6 12
5 10 12
6 6 12
3 10 5
7 9 8
7 7 9
$
---------------------
Ed Overton
saseao@unx.sas.com
---------------------
------------------------------
Date: Fri, 29 Jan 1999 13:51:59 GMT
From: scot777@my-dejanews.com
Subject: Displaying OLE objects
Message-Id: <78sedr$eum$1@nnrp1.dejanews.com>
I'm running Active Perl with IIS 4.0 and I'm accessing an Access database
through ODBC. The database has word and excel documents stored in it. I tried
to display these like you would an image but I'm having troubles. Could some
one tell me how to do this?
Thank you
Scot Tucker - Network Data Systems
New Hartford, New York
http://www.mvnhealth.com
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 29 Jan 1999 12:01:29 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Help!! Lower case!!
Message-Id: <slrn7b38op.99s.sholden@pgrad.cs.usyd.edu.au>
Richard Nilsson <qdtrini@jdicms88.ericsson.se> wrote:
>Sam Holden wrote:
>
>> MekaGames Staff <support@mekagames.com> wrote:
>> >Hello,
>> >I have a variable....
>> >
>> >$string = "InterNet";
>> >
>> >I'd like to know how to lowercase the I and the N.
>> >Please reply as fast as possible.
>>
>> RTFM as fast as you can...
<quoted sig snipped>
>
>As Sam says, PERL's man pages describes how. Manipulating text is one
>of the reasons of using PERL, since regexp is built in.
Of course this has nothing to do with a regexp, and using a regexp is
overkill...
>
>Use perldoc perlop, search for tr/, and you'll get the following aswer:
>
>$ARGV[1] =~ tr/A-Z/a-z/; # canonicalize to lower case
Or you could use lc() which has the (dis)advantage of respecting use locale.
But now that we've let the secret out, people won't bother reading the
documentaion and thus getting familiar with it. Instead they will have
impedded into their minds that asking at c.l.p.m is the best way to
search the documentation.
--
Sam
Basically, avoid comments. If your code needs a comment to be
understood, it would be better to rewrite it so it's easier to
understand. --Rob Pike
------------------------------
Date: Fri, 29 Jan 1999 22:09:10 +0900
From: "@SCJ<x" <csyim@lgnet.lg.co.kr>
Subject: How to use GDBM (Novice)
Message-Id: <36B1B2F5.AAAE1E09@lgnet.lg.co.kr>
I want to use GDBM.
I'm novice. So I tried to find some sample script.
But I couldn't find someone.
Please advice to use GDBM with perl.
------------------------------
Date: Fri, 29 Jan 1999 21:01:12 +0800
From: Simon Tneoh Chee-Boon <tneohcb@pc.jaring.my>
To: bann3094@my-dejanews.com
Subject: Re: htpasswd and perl
Message-Id: <36B1B118.1720@pc.jaring.my>
I'm not clear about whether you want a CGI script works like htpasswd or
a perl program which will submit username and password to a website
protected by HTTP Basic Authentication?
Anyway, you are welcome to take a look at
http://www.tneoh.zoneit.com/perl/HTTPPassword/
A perl module which will help you maintain the password file used in
HTTP Basic Authentication.
Hope this helps.
bann3094@my-dejanews.com wrote:
> Does anybody have a script that will send the username and password
> to a website pertected by htpasswd.
> Roger
--
Simon Tneoh Chee-Boon
Application Developer Hitechniaga Sdn. Bhd.
tneohcb@pc.jaring.my 60-3-9660966
http://www.tneoh.zoneit.com/simon/
------------------------------
Date: Fri, 29 Jan 1999 13:24:48 GMT
From: Brett Foster <onasc@home.com>
Subject: Re: LWP and multiple connections at the same time
Message-Id: <36B1C4AC.CDF63229@home.com>
How do use fork()? Thanks
Sam Holden wrote:
>
> On Fri, 29 Jan 1999 11:56:11 +0100, Peter Zozulak <zozulak@point.sk> wrote:
> >Hello,
> >
> >I tried to look for some ideas how to let LWP do multiple network
> >connections at the same time.
> >
> >Imagine you need download 10 files (1.html, 2.html, .... 10.html). By now I
> >use for ($i=1; ...) . It works fine, but do you have an idea about how to
> >make it without cycle ???
>
> From 'perldoc LWP' (I've got version 5.41).
>
> BUGS
> The library can not handle multiple simultaneous requests
> yet. Also, check out what's left in the TODO file.
>
> I guess you could always fork().
>
> --
> Sam
>
> Another result of the tyranny of Pascal is that beginners don't use
> function pointers.
> --Rob Pike
------------------------------
Date: 29 Jan 1999 13:54:49 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: LWP and multiple connections at the same time
Message-Id: <slrn7b3fd8.bv6.sholden@pgrad.cs.usyd.edu.au>
On Fri, 29 Jan 1999 13:24:48 GMT, Brett Foster <onasc@home.com> wrote:
>How do use fork()? Thanks
You would fork() and the child process would use LWP to make the network
connection and send the data back to the parent. Doing this with lots of
connections will be bad for your machine and for whomever is unlucky enough
to be at the other end.
If you don't understand fork() then see 'perldoc -f fork'.
If you don't understand getting the information back to the parent see
'perldoc perlipc'.
I haven't really thought about what you would do. I was thinking along the
lines of using the open(...,"-|) and print get($url) in the child, but I
haven't tried and tus have no idea if it will work...
>
>Sam Holden wrote:
>>
>> On Fri, 29 Jan 1999 11:56:11 +0100, Peter Zozulak <zozulak@point.sk> wrote:
>> >Hello,
>> >
>> >I tried to look for some ideas how to let LWP do multiple network
>> >connections at the same time.
<snip info about LWP not doing multiple connections>
>>
>> I guess you could always fork().
--
Sam
So I did some research. On the Web, of course. Big mistake...
--Larry Wall
------------------------------
Date: Fri, 29 Jan 1999 09:43:39 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Perl Criticism
Message-Id: <fl_aggie-2901990943390001@aggie.coaps.fsu.edu>
STANDARDIZED BONEHEAD REPLY FORM, Version 1.2
(c) copyright 1999 by
someone else.
(check all boxes that apply)
Dear: topmind
[x] Clueless Newbie [x] Lamer [ ] Flamer
[ ] Loser [ ] Spammer [x] Troller
[ ] "Me too" er [ ] Pervert [ ] Geek
[ ] Freak [ ] Nerd [ ] Elvis
[ ] Racist [ ] Fed [ ] WaReZ D00D
[ ] Fundamentalist [ ] Satanist [ ] Homeopath
[x] Stereotypical AOLer [x] "Expert"
[x] Unbearably self-righteous person [x] Hypocrite
[ ] IBM/Mac Bigot [ ] Apologist [x] Revisionist
[ ] Scientologist [x] Evolutionary Dead End
I took exception to your recent:
[ ] Email
[x] "News" article
It was (check all that apply):
[x] Lame [ ] Stupid [x] Abusive
[x] Clueless [ ] Idiotic [x] Brain-damaged
[x] Imbecilic [x] Arrogant [ ] Malevolent
[x] Contemptible [ ] Libelous [ ] Ignorant
[x] Nauseating [ ] Stupid [ ] Fundamentalist
[ ] Boring [x] Dim [ ] Cowardly
[x] Deceitful [ ] Demented [x] Self-righteous
[ ] Crazy [ ] Weird [x] Hypocritical
[x] Loathsome [ ] Satanic [ ] Despicable
[x] Belligerent [x] Mind-numbing [ ] Maladroit
[x] Assinine [x] Pointless [ ] Annoying
[x] Much longer than any worthwhile thought of which you may be
capable.
Your attention is drawn to the fact that:
[ ] You Spammed
[ ] You defended someone who Spammed.
[ ] You doubtlessly violated the Terms of Service of your ISP
[ ] You posted what should have been emailed
[ ] You obviously don't know how to read your newsgroups line
[x] You obviously know nothing about the topic at hand
[ ] You are trying to make money on a non-commercial newsgroup
[ ] You are placing your profits above fundamental ethics
[x] You self-righteously impose your religious beliefs on others
[ ] You self-righteously impose your racial beliefs on others
[x] You made a blanket statement without backing it up
[x] You made unwarranted assumptions
[x] You posted a "news article" without bothering to do basic
research
[ ] You posted a binary in a non-binaries group
[ ] You don't know which group to post in
[x] You made a post and didn't say anything
[x] You posted something totally uninteresting
[ ] You crossposted to *way* too many newsgroups
[x] I don't like your tone of voice
[x] You are the reason some groups are moderated
[ ] You posted in HTML
[ ] You used the phrase "Information Superhighway"
[x] You cannot recognize sarcasm
[x] You made an error and blamed someone else
[ ] You flamed someone for a spelling error.
[ ] And you misspelled something in the process
[x] What you posted has been done before.
[x] Not only that, it was also done better the last time.
[ ] You quoted an *entire* post in your reply
[ ] You quoted nothing, so nobody knows what you refer to
[x] You started a long, stupid thread
[x] You continued spreading a long stupid thread
[x] Your post is absurdly off topic for where you posted it
[ ] You posted a followup to crossposted robot-generated spam
[ ] You posted a URL that had nothing to do with the subject header
[ ] You posted a "test" in a discussion group rather than in alt.test
[ ] You posted a "YOU ALL SUCK" message
[ ] You posted low-IQ flamebait
[ ] You posted a blatantly obvious troll
[ ] You followed up to a blatantly obvious troll
[ ] You said "me too" to something
[ ] You posted a "FAQ" that contains deliberately misleading
information
[x] You make no sense
[ ] Your sig/alias is dreadful
[ ] It contains stupid song lyrics
[ ] It contains a stupid "witty" quote
[ ] It contains worthless ASCII graphics
[ ] Your sig is longer than the body of your message
[ ] You posted a phone-sex ad
[ ] You posted a stupid pyramid money making scheme
[ ] You claimed a pyramid-scheme/chain letter for money was legal
[ ] You argued that spamming was legal, even though nobody claimed it
wasn't
[ ] Your margin settings (or lack of) make your post unreadable.
Each line just goes on and on, not stopping at 75 characters, making
it hard to read.
[ ] You posted in ELitE CaPitALs to look k0OwL
[ ] You failed
[ ] Miserably
[ ] You posted a message in ALL CAPS, and you don't even own a TRS-80
[ ] Your post was FULL of RANDOM CAPS for NO APPARENT REASON
[ ] You referred to the Usenet Cabal (There is no Cabal)
[ ] You attempted a deliberate invocation of Goodwin's Law
[x] You have greatly misunderstood the purpose of this newsgroup.
[x] You have greatly misunderstood the purpose of the Internet.
[x] You have greatly misunderstood the purpose of email
[x] You have greatly misunderstood the purpose of communication
[x] You are a loser.
[x] This has been pointed out to you before.
[x] You believe O.J. Simpson is innocent
[x] You have a direct genetic link to:
[ ] Sanford Wallace
[ ] Phil Lawlor
[x] John Grubor
[ ] Walter Rines
[ ] Zach Everett
[x] Steven Boursy
[ ] ___other___
[ ] You are one of the scuzzwipes from:
[ ] the Woodside Literary Agency
[ ] the Copy Cat Shop
[ ] You didn't do anything specific, but appear to be so generally
worthless that you are being flamed on general principles.
It is recommended that you:
[x] Get a clue
[x] Get a life
[x] Go away
[x] Grow up
[x] Act something close to your age
[x] Never post again
[x] Smoke less of what you are smoking
[ ] Consider how low the tolerance on the Internet is for Spam
[x] Become Sanford Wallace's love slave
[x] Read every newsgroup you posted to for a week
[x] stop reading Usenet news and get a life
[ ] stop sending Email and get a life
[x] Bust up your modem with a hammer and eat it
[x] Have your medication adjusted
[x] Go to the top of a building and attempt to defy gravity
[x] Jump into a bathtub while holding your monitor
[ ] find a volcano and throw yourself in
[ ] get a gun and shoot yourself
[ ] poke your eye out with a stick
[x] Actually post something relevant
[ ] Read the FAQ
[x] stick to FidoNet and come back when you've grown up
[x] Apologize to everybody in this newsgroup
[x] Attempt to win this year's Darwin Award
[x] Do not pass along yout genes
[ ] consume excrement
[x] consume excrement and thus expire
[ ] Perform solitary sexual congress
[ ] Post your tests to alt.test/misc.test
[ ] Put your home phone number in your ads from now on
[ ] Don't bother getting a new account when this one is pulled
[x] Refrain from posting until you have a vague idea what you're
doing
In Closing, I'd Like to Say:
[x] You need to seek psychiatric help
[x] Take your gibberish somewhere else
[x] *plonk*
[x] Learn how to post or get off the usenet
[ ] Learn the purpose of email
[ ] Take a basic economics course and learn the costs of UCE
[x] Go back to school and actually learn something
[x] Your mother wears army boots
[ ] You are possibly the most annoying person currently alive
[ ] Most of the above
[ ] All of the above
[ ] Some of the above, not including All of the above
[ ] You are so clueless that I didn't even bother filling in this
form.
[ ] _____other______
------------------------------
Date: Fri, 29 Jan 1999 08:43:02 -0500
From: Jay Flaherty <fty@utk.edu>
Subject: Re: perl DBI CGI and mySQL
Message-Id: <36B1BAE6.43ADEFE5@utk.edu>
Mike D. wrote:
> I am wonder if I append a row to the table via the web, do I need to
> lock the table (let's assume there are many people using the datbase
> at the same time) - or is the table locked/secure automatically?
This is a database related question. Check the docs at
http://www.mysql.com
> Also, I was wondering if anyone has any example scripts I can take a
> look at that uses mySQL DBI and the CGI module? (like the source of
> register.cgi at www.pm.org/source/registration)
Check the docs at http://www.turbolift.com/mysql (more specifically
http://mysql.turbolift.com/mysql/DBD_3.21.X.html ). These docs will be
incorporated into the docs at http://www.mysql.com/doc.html
Also, check out perldoc DBD::mysql, perldoc DBI and look at the test
files that come with the DBI and DBD::mysql distributions.
Jay
------------------------------
Date: 29 Jan 1999 14:11:43 GMT
From: bbirthisel@aol.com (Bbirthisel)
Subject: Re: Question Serial port programming
Message-Id: <19990129091143.01188.00000510@ng-fs1.aol.com>
Hi Shang:
>While reading and writing from/to the serial port on Solaris, I found that
>input from the serial port is echoed back to the other end of the serial
>connection. Is there a way to disable this feature?
man stty
You need "stty -echo" for your question. But you will probably need
other options before you are done.
-bill
Making computers work in Manufacturing for over 25 years (inquiries welcome)
------------------------------
Date: Fri, 29 Jan 1999 14:43:23 GMT
From: miulin@erols.com
Subject: reading binary files
Message-Id: <78she9$hnm$1@nnrp1.dejanews.com>
I tried using the binmode() function to read in a binary file. Do anyone
know how I can now analyze it? I also couldn't find information on the
bitwise shift operators, such as how to use them and what they can be used
for. Please help.
thanks,
Miu Lin Lee
miulin@erols.com
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 29 Jan 1999 13:02:12 GMT
From: staham@algonet.se (Staffan Hdmdld)
Subject: Regexp matching
Message-Id: <36b1ae8c.689076639@news.rsv.rsv.se>
Hi,
I have a curious regexp question.. I've made a script that
converts a textfile into a database that I'm using for a
CGI script written in C.
What I'm trying to do is to match a name in a string with numbers
and other things. The name can contain a space or a colon sometimes.
The only thing that is certain about the name is that it starts and
ends with a letter, A-Z or a-z. I would like it to match everything
inbetween the first and the last letter.
The problem is when $ln contains a name that's just one character
long.
I've worked around this by checking the string with if to see if
it's only one character. Is it possible to match this with just
one regexp search?
Here is an example.
$ln = "123 3409 2 4293 239 48234 FOOBAR 014 2930 42348 23 90234"
$name = $ln;
# This matches the name as long as it's more than one character long
$name =~ s/^.*?([a-zA-Z].*[a-zA-Z]).*/\1/;
# fix for short names..
if(($name =~ /[a-zA-Z].*[a-zA-Z]/) == 0)
{
$name =~ s/^.*([a-zA-Z]).*/\1/;
}
print "$name\n";
I've been trying to get the first match to work but without success.
Thanks,
/Staffan - staham@algonet.se
------------------------------
Date: Fri, 29 Jan 1999 14:39:22 GMT
From: droby@copyright.com
Subject: Re: Rencontre Perl de Mtl
Message-Id: <78sh6q$hij$1@nnrp1.dejanews.com>
In article <36b05906.7516065@news.highwayone.net>,
richardc@tw2.com (Richard Clamp) wrote:
> On 28 Jan 1999 01:15:30 -0000, Jonathan Stowe
> <gellyfish@btinternet.com> wrote:
>
> >
> >Is 'missionnaires' the same as 'mongers' ?
>
> Pass me beer, I have important missionary work to fulful :)
>
We need a better way to say 'monger' in French. I propose 'mongeur'.
And then perhaps we should expand on 'm(o|u)nger' to incorporate this. Or
perhaps not. Because then we really should include German, Italian, Spanish,
Portuguese, Russian, Chinese, Hindi... The regex would be messy to say the
least. Not to mention unicode.
However, the m(o|u)nger arose from language differences across the puddle.
Should the Quebecois and Parisiens similarly have similar but unique versions?
Une biere, s'il vous plait.
--
Don Roby
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 29 Jan 1999 07:58:43 -0500
From: "Jeff Horton" <jeffhorton@graphatl.com>
Subject: substitution question
Message-Id: <78sb7o$3ar$1@camel0.mindspring.com>
I have a line of text that I want to substitute all of the "*" in it.
Such as: "* some text * some more text * more text"
I want to replace it with a return instead. I have been unsucessful in even
replacing it with a space. What I have is this:
&theText = "* some text * some more text * more text";
&space = "";
s/'*'/&space/;
print &theText;
what am I inputting incorrectly?
--
Thanks - Jeff Horton
----------------------------------------------------------------------------
--
A Dummy Learns From You Who Becomes Clever
------------------------------
Date: Fri, 29 Jan 1999 07:20:44 -0600
From: mike@stok.co.uk (Mike Stok)
Subject: Re: substitution question
Message-Id: <#bDEuo4S#GA.296@news1.texas.rr.com>
In article <78sb7o$3ar$1@camel0.mindspring.com>,
Jeff Horton <jeffhorton@graphatl.com> wrote:
>I have a line of text that I want to substitute all of the "*" in it.
>Such as: "* some text * some more text * more text"
>I want to replace it with a return instead. I have been unsucessful in even
>replacing it with a space. What I have is this:
>&theText = "* some text * some more text * more text";
>&space = "";
>s/'*'/&space/;
>print &theText;
>
>what am I inputting incorrectly?
You probably need to get an introductory book on perl, like O'Reilly's
_Learning Perl_ as there are some fundamental flaws in the code you've
presented. This might be closer to what you want:
$theText = "* some text * some more text * more text";
$newLine = "\n";
$theText =~ s/\*/$newLine/g;
print $theText;
You probably need to be familiar with perl's use of prefix characters,
defaults and context to use it effectively, otherwise you are likely to
end up frustrated. Once you have the basics under your belt then the
manual pages will be much more useful to you.
Many of perl's detractors point to its use of prefixes and context and
defaults as some kind of flaw; many of perl's users find them useful.
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
| 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: 29 Jan 1999 13:30:05 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: substitution question
Message-Id: <slrn7b3dut.bv6.sholden@pgrad.cs.usyd.edu.au>
On Fri, 29 Jan 1999 07:58:43 -0500, Jeff Horton <jeffhorton@graphatl.com> wrote:
>I have a line of text that I want to substitute all of the "*" in it.
>Such as: "* some text * some more text * more text"
>I want to replace it with a return instead. I have been unsucessful in even
>replacing it with a space. What I have is this:
>&theText = "* some text * some more text * more text";
>&space = "";
>s/'*'/&space/;
>print &theText;
>
>what am I inputting incorrectly?
That is not perl code. That obviously isn't what you have or you would have
compile errors. Scalars are prefixed with a $ not a &... "" is not a space...
regexes don't work like that...
* is a special characters to regexes and so needs to be escaped, you don't
use 's though. You use what the documentation tells you to 'perldoc perlre'
(it's specifically mentioned in near the end in the
'Version 8 Regular Expressions' section).
What you probably want is tr// which you can find out all about in
'perldoc perlop'
However, I would recomment learning the language a bit before you actually
try and do something with it. Every line of code you posted is shows a
misunderstanding of perl. the 3rd line shows three all by itself...
I strongly suggest you get a book 'Learning Perl' is good, or read the
documentation that comes with perl.
--
Sam
Another result of the tyranny of Pascal is that beginners don't use
function pointers.
--Rob Pike
------------------------------
Date: Fri, 29 Jan 1999 13:32:34 GMT
From: staham@algonet.se (Staffan Hdmdld)
Subject: Re: substitution question
Message-Id: <36b4b6fb.691235303@news.rsv.rsv.se>
On Fri, 29 Jan 1999 07:58:43 -0500, "Jeff Horton" <jeffhorton@graphatl.com> wrote:
I think you should start reading some perl tutorials. For example:
http://agora.leeds.ac.uk/Perl/
There you can find a rather good Perl tutorial.
To fix the program you'd have to replace most of it..
>&theText = "* some text * some more text * more text";
^
& is used for subroutines, not strings. $ would be a better
choice here.
>&space = "";
Even $space = ""; wouldn't make it a space. That would just be an
empty string anyway. $space = " "; would work, but why make things
harder than they need to be. Just use " " instead.
Try this instead:
$theText = "* some text * some more text * more text";
$theText =~ s/\*/ /g;
print "$theText\n";
/Staffan - staham@algonet.se
------------------------------
Date: Fri, 29 Jan 1999 14:10:36 +0100
From: Richard Nilsson <qdtrini@jdicms88.ericsson.se>
Subject: system 'stty', '-echo' on Win32???
Message-Id: <36B1B34B.B135BD43@jdicms88.ericsson.se>
Hi,
I sent a question before, and got very satisfying answers, so I'll try
again.
I have a program which must be operational on both UNIX and Win NT. In
one part
of the system flow, a password has to be inserted. As with most
applications, the written
password is not allowed to be printed on the screen.
Those examples I found so far is using system 'stty', '-echo', but stty
is a command
on UNIX (it works fine though). However, I'm looking for something that
works on
both platforms.
If I wrote this in C/C++, it's a pice of cake. Win32 supplies the
function getche()/
_getche(), but that's C... (of course, writing a samll C-program is one
way of solving it,
but not a very nice one).
As always, PERL code which solves this is Very Much Appriciated.
Thanks in Advance
/Richard Nilsson
------------------------------
Date: 29 Jan 1999 13:45:27 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: system 'stty', '-echo' on Win32???
Message-Id: <slrn7b3ern.bv6.sholden@pgrad.cs.usyd.edu.au>
On Fri, 29 Jan 1999 14:10:36 +0100, Richard Nilsson
<qdtrini@jdicms88.ericsson.se> wrote:
>Hi,
>
>I sent a question before, and got very satisfying answers, so I'll try
>again.
You could try looking for yourself as well you know...
>
>I have a program which must be operational on both UNIX and Win NT. In
>one part
>of the system flow, a password has to be inserted. As with most
>applications, the written
>password is not allowed to be printed on the screen.
>
>Those examples I found so far is using system 'stty', '-echo', but stty
>is a command
>on UNIX (it works fine though). However, I'm looking for something that
>works on
>both platforms.
>
>If I wrote this in C/C++, it's a pice of cake. Win32 supplies the
>function getche()/
>_getche(), but that's C... (of course, writing a samll C-program is one
>way of solving it,
>but not a very nice one).
>
>As always, PERL code which solves this is Very Much Appriciated.
If you read the documentation that comes with perl you would find :
perlfaq8 : How do I ask the user for a password?
Why don't people read the FAQ? If I can find it then so can you... I don't
have any magical powers I've just read through the FAQ and so have a
vague idea what is there and when something rings a bell I go and have
a closer look...
--
Sam
So I did some research. On the Web, of course. Big mistake...
--Larry Wall
------------------------------
Date: Fri, 29 Jan 1999 14:09:10 +0100
From: "Eduardo Fernandez" <efcspain@sistelnet.es>
Subject: thousands digit separator
Message-Id: <78sbgn$ecp$1@talia.mad.ttd.net>
Hello,
After doing some number crunching with my script I get a variable with an
amount, say 65545444 euros.
How can I print this like 65.545.444 euros, to make it more readable?
Thanks in advance
--
Eduardo Fernandez
------------------------------
Date: 29 Jan 1999 13:36:50 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: thousands digit separator
Message-Id: <slrn7b3ebi.bv6.sholden@pgrad.cs.usyd.edu.au>
On Fri, 29 Jan 1999 14:09:10 +0100, Eduardo Fernandez <efcspain@sistelnet.es>
wrote:
>Hello,
>
>After doing some number crunching with my script I get a variable with an
>amount, say 65545444 euros.
>
>How can I print this like 65.545.444 euros, to make it more readable?
You can read the FAQ and find the answer...
perlfaq5 : How can I output my numbers with commas added?
--
Sam
Even if you aren't in doubt, consider the mental welfare of the person
who has to maintain the code after you, and who will probably put parens
in the wrong place. --Larry Wall
------------------------------
Date: Fri, 29 Jan 1999 07:24:34 -0600
From: mike@stok.co.uk (Mike Stok)
Subject: Re: thousands digit separator
Message-Id: <ODoO3q4S#GA.204@news1.texas.rr.com>
In article <78sbgn$ecp$1@talia.mad.ttd.net>,
Eduardo Fernandez <efcspain@sistelnet.es> wrote:
>After doing some number crunching with my script I get a variable with an
>amount, say 65545444 euros.
>
>How can I print this like 65.545.444 euros, to make it more readable?
Section 5 of the FAQ (frequently asked questions) contains a question:
How can I output my numbers with commas added?
whose answer may be a useful starting point. On many systems you can say
perldoc perlfaq5
to view the section. If that doesn't work for you then the FAQs are
on http://www.perl.com under the docs section.
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
| 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: Fri, 29 Jan 1999 09:30:55 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Visual Perl?
Message-Id: <fl_aggie-2901990930560001@aggie.coaps.fsu.edu>
In article <19990128161222.15686.00003829@ng20.aol.com>,
thegroovy@aol.comNOSPAM (THE Groovy) wrote:
+ Maybe this is old news, but I just read a couple days ago that Activestate was
+ attempting to create a "Visual Perl", to compensate for one of Perl's major
+ weak points - No Visual Interface.
You consider it a "weak point" only because you've never known anything
else. I consider it a feature.
James
------------------------------
Date: Fri, 29 Jan 1999 14:37:42 GMT
From: Denis.Haskin@bigfoot.com
Subject: Re: WinNT Perl 5.005-02: Changed behavior of `dir` after Cygwin B20 installed
Message-Id: <78sh3l$hi4$1@nnrp1.dejanews.com>
In article <78qdge$o8h$1@nnrp1.dejanews.com>,
Denis.Haskin@bigfoot.com wrote:
> [snip]
> I am very perplexed as to why the behavior of the dir command, when executed
> in a subprocess (backticks) from Perl, has changed.
I've figured it out, I think. There's an external dir command in cygwin,
which is the file /cygnus/cygwin~1/H-I586~1/bin/dir.exe.
Before I installed cygwin, the $ret = `dir`; in Perl was running the
internal NT cmd.exe dir command. After cygwin was installed, my guess is
that system() or backticks in perl were actually scanning the path to find a
dir.exe first (and finding it in the cygwin /bin directory) and running that
instead of the internal command. I renamed cygwin's dir.exe to
cygnus-dir.exe (since I don't really need it) and all is now hunky-dory.
Phew.
dwh
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 4778
**************************************