[6948] in Perl-Users-Digest
Perl-Users Digest, Issue: 573 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 5 03:12:12 1997
Date: Thu, 5 Jun 97 00:00:31 -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, 5 Jun 1997 Volume: 8 Number: 573
Today's topics:
Re: Atomic file create or fail if already existing <bob@sitecraft.com>
Re: Code examples: right justify text? (Fred Elbel)
Re: Compatibility Issues between Perl and Oracle (John D Groenveld)
Re: find out no.of lines in open file (Tad McClellan)
Re: Help with weird cron interaction (Mike D. Kail)
Re: How can I set up this server to run perl faster?... (Abigail)
Re: how do I delete all the $s from a string(probably s (Eric Roode)
Re: How do you handle non-sequential text processing? (Tad McClellan)
Re: Making directories in NT using PERL (Jeremy D. Zawodny)
Need a special characters->"normal characters" converte (Michael Genrich)
Re: Newbie question <ajohnson@gpu.srv.ualberta.ca>
Re: newbie question (Tung-chiang Yang)
Re: pack template that packs like 'a' but unpacks like <uwe@ptc.spbu.ru>
Re: PGPERL problem <cphillip@kerr.phys.utas.edu.au>
Re: printing a hash in order? <allenjs@nic.techops.lmco.com>
Re: replacing spaces with underscores <perlprogrammer@hotmail.com>
Re: replacing spaces with underscores (Dennis Marti)
Suggestion to all frequent posters/answerers (Jahwan Kim)
Voting Script <amerar@unsu.com>
Re: Voting Script (Nathan V. Patwardhan)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 05 Jun 1997 00:14:40 -0400
From: Bob McWhirter <bob@sitecraft.com>
To: Leonard Megliola <lmegliol@inertia.acs.uci.edu>
Subject: Re: Atomic file create or fail if already existing
Message-Id: <33963CF1.604B@sitecraft.com>
Leonard Megliola wrote:
> Given that my filenames are randomly generated, maybe this is
> something that I shouldn't worry about. But it will bug me in the
> back of my mind.
Generally a concatenation of PID and a timestamp are unique for
filenames. Using a psuedo-random generator may indeed cause problems.
If each instance of this program runs with a seperate process id, then
there is your uniqueness (along with timestamp and/or usename, etc).
But pids will at least keep the namespace of multiple processes from
munging each other.
-Bob
------------------------------
Date: Thu, 05 Jun 1997 01:21:54 GMT
From: frelbel@csn.net (Fred Elbel)
Subject: Re: Code examples: right justify text?
Message-Id: <3397132a.18188138@news-2.csn.net>
> In article <33946969.11658356@news-2.csn.net>
> frelbel@N0SPAMcsn.net (Fred Elbel) writes:
>
> > I'm about to design a routine to right justify text paragraphs, but
> > perhaps it's already been done...
On 4 Jun 1997 16:08:14 GMT, Ronald.J.Kimball@dartmouth.edu (Chipmunk)
wrote:
> Do you want all the lines to be exactly 55 characters long (with added
> spaces between words to get the necessary length) or at most 55
> characters long?
At most 55 chars. "Ragged right" margins would be fine.
> Is it okay to join shorter lines together, or do you only want to split
> long lines?
Yes, lines should be joined..
> What should be done if there is a string of consecutive non-white space
> characters longer than 55 characters?
Ideally, it should not happen. If such a string occurs, I'd probably
insert a hyphen and \n.
> < code snipped >
Thanks! I certainly appreciate your response. The code looks like
what I'm after -- I'll give it a shot. Did you sit down and grind
that out in 5 minutes <G>?
On the other hand, if code fragments like that are archived, point me
to the source. I checked CPAN but did not find anything that seemed
relevant.
Thanks again,
Fred
-- Fred Elbel frelbel@csn.net
------------------------------
Date: 5 Jun 1997 01:57:33 -0400
From: groenvel@cse.psu.edu (John D Groenveld)
Subject: Re: Compatibility Issues between Perl and Oracle
Message-Id: <5n5kgd$90a$1@tholian.cse.psu.edu>
In article <5n1q2c$poe$1@news-sj-3.cisco.com>,
Michael Swertfager <mswertfa@cisco.com> wrote:
>Not trying to start rumors...
>Just concerned about compatibility from what I heard...want to clarify
>if this is as fact or rumor.
>
>If anyone has heard or experienced anything about this, please email
>me with what you know. I will soon be making requests from Perl5 to an
>Oracle database and want to make sure I am using the correct versions
>and patches if any.
Best to fetch http://www.perl.com/CPAN/CPAN.html which will help you find
the latest version of Perl5--5.004. Then you can grab the module list
and investigate the appropriate database modules--DBI and DBD-Oracle.
The README contains a pointer to DBI mailing list and Alligator Descartes'
DBI modules page.
As far as your compatability question, these DB modules are being used
on many of Oracle's supported platforms and with nearly all Oracle7
versions.
Does that give you enough to get started?
John
groenvel@cse.psu.edu
------------------------------
Date: Wed, 4 Jun 1997 06:32:24 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: find out no.of lines in open file
Message-Id: <8oj3n5.vi.ln@localhost>
Pui Ming WONG (s11976@net2.hkbu.edu.hk) wrote:
: I have a trivial question as i just get started on perl
: In my program i have opened a file,i.e.
: open(COUNT,"$myfilename")
You should do it this way:
open(COUNT, $myfilename) or die "could not open '$myfilename' $!";
1) don't use double quotes when interpolation is not needed.
2) check the return value from open to see if it succeeded.
3) if no success, show the name of the file you were trying to open.
4) if no success, show some helpful error message text from the
Operating System ($!)
5) I like to delimit both ends of the filename output, in case there
is some whitespace in the filename.
: Now i would like to know the total no. of lines in this file COUNT,
: what statements are available, perl's own
Count them yourself:
open(COUNT, $myfilename) or die "could not open '$myfilename' $!";
while (<COUNT>) {
$lines++;
}
close(COUNT);
: or could i call the
: unix command
: wc -l $COUNT ?
That won't work.
1) $COUNT in an undefined variable (filehandles are not variables)
2) wc takes a filename argument, not a filehandle argument
$lines = `wc -l $myfilename`; # backwards single quotes
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: 5 Jun 1997 04:24:05 GMT
From: mdkail@fv.com (Mike D. Kail)
Subject: Re: Help with weird cron interaction
Message-Id: <slrn5pcfvh.lba.mdkail@dime.fv.com>
On Wed, 04 Jun 1997 17:42:24 -0500, Dave Mencin <dmencin@unavco.ucar.edu> wrote:
>
>
>I have been having a problem running a perl script from a crontab.
>I have verified all the paths (i.e. a simple perl program works fine.)
[...]
>if at the command line I enter
>
>perl tester | /usr/ucb/Mail -s "test" dmencin@unavco
>
[...]
>if I put the following line in my crontab
>
>* * * * * perl tester | /usr/ucb/Mail -s "test" dmencin@unavco
>
>I get a blank email every minute.
>All paths are set up in cron using the PATH statement as documented in crontab.
>Any ideas on how to proceed from here ?
use the FULL path to 'tester' in your crontab entry
e.g.
* * * * * perl /path/to/tester | /usr/ucb/Mail -s "test" dmencin@unavco
--
/*-------------------------------------------------------------*/
/* Mike D. Kail | voice: (619) 350-3524 */
/* Unix System Architect | fax: (619) 793-2950 */
/* FIRST VIRTUAL Holdings Inc. | e-mail: mdkail@fv.com */
/*-------------------------------------------------------------*/
------------------------------
Date: Thu, 5 Jun 1997 04:38:28 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: How can I set up this server to run perl faster?...
Message-Id: <EBACw5.3y9@nonexistent.com>
On Sun, 01 Jun 1997 23:22:22 -0700, perl guy (perlprogrammer@hotmaill.com)
wrote in
comp.infosystems.www.servers.unix,comp.os.linux.setup,comp.os.linux.misc,comp.lang.perl,comp.lang.perl.misc
<URL: news:32C32A590C2FC98A.DEE78EECC673D950.F1A9127287613D60@library-proxy.airnews.net>:
++
++ That's not really the problem though.. I assume that the time out,
++ keepalive, keepalive timeout, etc. time needs to be set differently..
++ I'm not sure what these need to be set to really.. as I did the perl..
++ but my server admin seems to need advice on how to configure the server
++ better, and I am clueless.. This is why it's partly being posted in the
++ unix/linux. As well as for the server configs that may help or IDEAS
++ that may help me with how to run less instances, etc of the perl.exe?. I
++ am so lost.. the script works great, untill I get over 50 or 60 people
++ in the rooms.. then it gets very slow and has problems.. it starts to
++ crash my server, and I have to telnet in and restart the websever 3
++ times a day!.. it's getting out of control, and I don't have weeks or
I keep it short cause it's off topic in most groups.
Your entire setup is flawed. HTTP isn't designed for something like
a chat system. Get something that doesn't have a problem with many
long connections, and very well suited for chatting: MUD, Diku, MOO,
IRC have been doing it for many, many years without a problem.
Don't use screwdrivers to hammer in nails.
But if you insist using a screwdriver, look into the Apache driver
with its perl module.
Abigail
--
Followups set (to groups I don't read, so email me if you want to
reply to me.)
------------------------------
Date: Thu, 5 Jun 1997 00:51:00 GMT
From: sdn@mv.mv.com (Eric Roode)
Subject: Re: how do I delete all the $s from a string(probably simple)
Message-Id: <EBA2D0.4Fv@mv.mv.com>
In article <3395E0F7.7E95@mail.tds.net>, The Halls <bhall@mail.tds.net> wrote:
>Hi,
Hello.
[...]
>my $extra_price_1 = '$123.89';
>I need the result to be 123.89. I thought it would be something like:
>$extra_price_1 =~ s/$/d/;
So close. That will change each $ to the letter d.
What you want is: s/$//; except! that $ is a special character
and must be quoted: s/\$//;
Not that you asked, but according to the book, tr is faster for
deleting characters from a string: tr/$//d;
HTH
--
"I feel my body weakened by the years
As people turn to gods of cruel design
Is it that they fear the pain of death
Or could it be they fear the joy of life?" -- Toad The Wet Sprocket
------------------------------
Date: Wed, 4 Jun 1997 23:49:03 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: How do you handle non-sequential text processing?
Message-Id: <vfg5n5.24d.ln@localhost>
kendall shaw (kshaw@plight.lbin.com) wrote:
: I'm used to using emacs lisp for processing SGML.
I'm used to using Perl for processing SGML.
: Recently I've been
: using the SGMLS module in perl.
Recently I've been Scheme instead.
: Aside from that I've been somewhat
: envious of various perl features.
I often "punt", and resort to post-processing w/Perl for the
pattern matching intensive stuff...
: So, I'm learning perl.
Bravo!
: Now (then),
Which is it, now or then ;-)
: I keep stumbling over how to process text when I need to
: either deal with multiple lines at once,
The usual "mind block" here is that the "while (<>)" idiom normally
reads a line at a time. So _getting_ a multiline string to match
against takes extra work. Though I don't think you need to deal
with multiple lines to solve this problem (especially if you
can run it through 'sgmlnorm' first).
If you did though, you could do something like this to deal with
each <def> element (and its content) as a unit (UNTESTED):
while (<>) {
$def = $_ if /^<def/; # the first part
next unless /^<term/; # don't have the second part yet
$def .= $_; # concatenate onto the first part
# now we have a two line string in $def to work with...
}
: or make multiple passes over
: the file.
I usually just open-read-close once for each pass.
You could also use seek() in between passes to get back to the
start of the file.
: Example 1:
: I have a file of text that consists of terms and definitions, e.g.:
: <def id=t1>
: <term>blech<p>Ho di ho see blail.
: <def id=t2>
: <term>blail<p>Ho di he see bleph.
: <def id=t3>
: <term>bleph<p>Hetch hetchy wetch (blech).
: And I want to tag cross-references to terms in their text, e.g.:
: <def id=t1>
: <term>blech<p>Ho di ho see <xref rid=t2>blail</>.
: <def id=t2>
: <term>blail<p>Ho di he see <xref rid=t3>bleph</>.
: <def id=t3>
: <term>bleph<p>Hetch hetchy wetch (<xref rid=t1>blech</>).
[ snip Lisp code ]
: Is there a simple way I can do this in perl?
Perhaps not as simple as you might like, but this will work:
-------------------------------------
#! /usr/bin/perl -w
### first pass: get the term -> ID mapping
open(SGML, 'dict.sgml') or die "could not open 'dict.sgml' $!";
while (<SGML>) {
$id = $1 if /<def id=([a-zA-Z][a-zA-Z0-9.-]*)/; # find the ID
$term{$1} = $id if /<term>([^<]+)/; # save the mapping
}
close(SGML);
$re = join '|', keys %term; # construct string that will or together
# all of the terms when used in a regex
### second pass: insert the refs
open(SGML, 'dict.sgml') or die "could not open 'dict.sgml' $!";
while (<SGML>) {
print, next unless /^<term>/; # next line if doesn't start with <term>
($term, $p) = split /(?=<p>)/; # zero length lookahead
$p =~ s!($re)!<xref rid=$term{$1}>$1</>!go;
print $term, $p;
}
close(SGML);
-------------------------------------
The split() is to facilitate inserting more than one <xref> on a line.
See also this question in the Perl FAQ (http://www.perl.com/FAQ):
=head2 How do I efficiently match many regular expressions at once?
: Example 2:
: I want to remove yack tags that have an id attribute of foop (err...
: and the white space too):
: asdf <yack id=foop>fdsa</yack> asdf yip
: asdf <yack id=foop>
: fdsa
: </yack> asdf yip
: asdf <yack id=foop>fdsa
: </yack> asdf yip
: In emacs lisp I could:
: (while (re-search-forward
: "<yack id=foop>[ \t\n]*\\([^<]+\\)[ \t\n]*</yack>" nil t)
: (replace-match "\\1"))
: In perl I don't know a simple way to do this.
Your lisp regex works (after deleting the backwacks that Perl doesn't
need):
s!<yack id=foop>[ \t\n]*([^<]+)[ \t\n]*</yack>!$1!g;
--------------------------------------------
#! /usr/bin/perl -w
undef $/; # enable slurp mode
$_ = <DATA>; # slurp the whole file into a string
s!<yack id=foop>\s*([^<]+)\s*</yack>!$1!g;
print;
__DATA__
asdf <yack id=foop>fdsa</yack> asdf yip
asdf <yack id=foop>
fdsa
</yack> asdf yip
asdf <yack id=foop>fdsa
</yack> asdf yip
--------------------------------------------
: Perhaps, if I could set
: $\ to a regular expression then I could handle groups of lines, but
: it only handles literal text.
Yeah, bummer ;-(
: I don't read other people complaining about this, so what am I missing?
It just takes a little extra work to get groups of lines into a
variable to match against.
Hope this helps!
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Thu, 05 Jun 1997 03:42:28 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: Making directories in NT using PERL
Message-Id: <33963540.437701551@news.bgsu.edu>
On Wed, 04 Jun 1997 15:11:01 -0400, Greg Chronowski
<chronow1@jeflin.tju.edu> wrote:
>I have a forum script that runs fine on Linux.
>
>I need to install it on an NT server with PERL installed.
>
>The subroutines that create directories and write files to the server
>don't work, here's two examples (that work on a UNIX server but not an
>NT server):
[deletia]
Okay, I'm willing to help, but I'm hardly about to debug you script
*for you*. Have you run it with some debugging code to see where it
dies? Does it generate *any* error messages? Might you need some
extra error-checking? It could be that one of your function calls is
silently dying, and you never hear about it.
Jeremy
---
Jeremy D. Zawodny
WCNet Technical Geek & Web Stuff
<URL:http://www.wcnet.org/~jzawodn/>
"You are what you think."
------------------------------
Date: 4 Jun 1997 18:25:40 GMT
From: mikeg@mit.edu (Michael Genrich)
Subject: Need a special characters->"normal characters" converter
Message-Id: <5n4bv4$t81@senator-bedfellow.MIT.EDU>
Some folks in my group are looking for a perl script that will
subsitute regular ASCII characters for 'special' characters like
smart quotes, accented letters, grave letters, etc.
Anyone know where one of these might be found? I could roll my
own but would (lazily) prefer to not do so if there is a publicly
available script.
Thanks,
Mike
--
Michael Genrich mikeg@mit.edu
Serving Fine Email Since 1989 mikeg@world.std.com
"The fact that I have no remedy for all the sorrows of the world is
no reason for my accepting yours. It simply supports the strong
probability that yours is a fake." -- H.L. Mencken
------------------------------
Date: Wed, 04 Jun 1997 14:49:20 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Newbie question
Message-Id: <3395C6C0.6407EE31@gpu.srv.ualberta.ca>
Tom Phoenix wrote:
!
! On Tue, 3 Jun 1997, Andrew Johnson wrote:
!
! > $nchars=pos if /$/g;
! > or
! > $nchars=s/(.)/$1/g;
!
! Nice try, but inaccurate on some strings, like C<$foo ="ha\n" x 4;>.
print "oops";
$nchars=$foo=~s/(.)/$1/sg;
> s/(.)/!$`?$nchars=1:$nchars++;$1/eg;
! That fails on the same ones, and also on ones which start with zero.
print "oops " x2;
$nchars=$foo=~s/(.)/$1 ne ""?$nchars=1:$nchars++;$1/seg;
! Don't try to re-write length(). It's too simple for these complex
! attempts! :-)
Aw...gee whiz :-)
regards
andrew
------------------------------
Date: Thu, 5 Jun 1997 06:03:57 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: newbie question
Message-Id: <tcyangEBAGuM.9s7@netcom.com>
I am a newbie ...... but why will every line after the first be indented
by one space? Of course, this is a DOS file and maybe something funny
is going on there......
========================================
Tom Phoenix (rootbeer@teleport.com) wrote:
: (deleted)
: > open (FILE1,"c:/files/file1.txt");
: > while (<FILE1>) {
: > s/something/something else/g;
: > push (@mylist,$_);
: > }
: > print "@mylist";
: No. The main problems with that code are
: 1. it never checks that the file was successfully opened,
: 2. it needlessly loads the entire file into memory (in @mylist), and
: 3. it will indent every line after the first by one space.
: (deleted)
--
Tung-chiang Yang tcyang@netcom.com
soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
http://www.iglou.com/tcyang/Taiwan_faq.shtml, China_faq.shtml
------------------------------
Date: Thu, 5 Jun 1997 10:00:00 +0400
From: "Valeriy E. Ushakov" <uwe@ptc.spbu.ru>
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: pack template that packs like 'a' but unpacks like 'A'
Message-Id: <%OyklzY7II@snark.ptc.spbu.ru>
Hi, Tom.
On Wed, 4 Jun 1997, Tom Phoenix wrote:
> > Since string is printable, I want nulls to be stripped off when I unpack
> > the struct. But when I pack the struct, I want padding with nulls since
> > this is the way C wants it.
>
> Oho! I (finally) get it! :-) The problem is that pack and unpack aren't
> symmetric when you use 'a' in a template: Trailing nulls are put on with
> pack, but they aren't stripped off during unpack.
You get it! But things are a little bit more subtle. The 'a' is
(very) usefully symmetric for it's purpose. I prefer to think about
these formats in the following way:
a - any - This one is for binary data. You can grab some bytes as is
when you unpack. You can put some bytes when you pack and null
padding is just what you expect for binary data (least surprise).
This one is symmetric for bynary.
A - ASCII - This one is controversial. It strips away nulls and
spaces when you unpack and when you need to grab some printable text
this is what you expect. But padding with spaces when you pack is a
bit useless. I wonder if people actully use 'A' for packing. If
one is to work with text, split/sprintf/format will do better most
of the time. I suspect 'A' is commonly used for unpacking only.
This one is symmetric for text.
Z - ASCIZ - The one we miss. (I use upper case this time, unlike my
first exaple, for it is more similar to 'A' than to 'a' (any)).
Packs with trailing nulls. Unpacks stripping nulls. I came to
think that it should strip *ONLY* nulls, not spaces, if we intend it
to work with C null delimited strings. This one is symmetric for
C strings.
To reiterate: the problem I have been talking about is the *lack* of
format that is symmetric for C null delimited strings.
> That's not right, IMHO. In fact, I'd be tempted to call it a bug, except
> that AFAIK it's been this way since time immemorial.
I've been using perl about four years by now and I just never tried to
pack and unpack the same structure in one script before. When I only
packed, I used 'a'. When I only unpacked, I used 'A'. That seemed
natural. In fact I've done quite a bit of wtmp parsing and the like
before I stumbled across this problem. Perhaps in common scenario
people use 'er' from 'perl', i.e. do 'E'xtraction and 'R'eporting. I
think that explains why it stayed unnoticed this long.
SY, Uwe
--
uwe@ptc.spbu.ru | Zu Grunde kommen
http://www.ptc.spbu.ru/~uwe/ | Ist zu Grunde gehen
------------------------------
Date: Thu, 5 Jun 1997 11:54:40 +1000
From: Chris Phillips <cphillip@kerr.phys.utas.edu.au>
To: Sean Gillen <Sean_Gillen@sbphrd.com>
Subject: Re: PGPERL problem
Message-Id: <Pine.GSO.3.94.970605115025.22569G-100000@kerr.phys.utas.edu.au>
On Mon, 2 Jun 1997, Sean Gillen wrote:
> Hi, I'm using PGPERL to call functions from the popular PGPLOT graphics
> library. I've printed line graphs and have the following problem.
>
[snip]
>
> The problem is that i'm using the PGENV function that puts the data
> values on the x-axis and it requires a real number and doesn't therefore
> allow letters like Jan or Feb on the axis.
>
> Is there anyway around this problem? Is there a function I can use with
> PGENV which will allow me to put letters ( Jan - Dec ) along the x-axis
> instead of numbers.
NO. Sorry. This is a limitation(?) of pgplot (and infact nothing to
do with perl as such).
You could use PGMTXT to put the labels on yourself, and tell pgenv
not to put the numbers up it self
See the doco for pgenv and pgmtxt that comes with pgplot
Cheers
Chris Phillips
------------------------------
Date: Tue, 03 Jun 1997 19:27:43 -0700
From: Jay Allen <allenjs@nic.techops.lmco.com>
To: Andrew Starr <atstarr@negia.net>
Subject: Re: printing a hash in order?
Message-Id: <3394D29F.5F26@nic.techops.lmco.com>
Andrew Starr wrote:
>
> Am I correct that it is basically impossible, just using a hash, to
> print it in order?
> I.e. I had a hash consisting of the split pairs, and wished to print
> variable name and value for each pair, in order of their appearance in
> the input, but at a time in the script later than when the pairs were
> being split.
Very easy (lemme guess... Formmail? :):
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$CONFIG{$name} = $value;
push(@Names, $name);
}
then later:
foreach (@Names) {
print "$_ = $CONFIG{$_}\n";
}
Fed back in order, thank you very much...
-j-
---------
Jay Allen
allenjs@nic.techops.lmco.com
ICYRA-Internet Coordinator
Lockheed-Martin - Web Page Lead
The Maxim Group - Sr. Programmer/Analyst
(w) (310) 727-1086
(h) (562) 433-7727
------------------------------
Date: Wed, 04 Jun 1997 17:57:41 -0700
From: perl guy <perlprogrammer@hotmail.com>
Subject: Re: replacing spaces with underscores
Message-Id: <33960F05.46E2@hotmail.com>
Matt Ferrell wrote:
>
> Howdy, sorry about the simplicity of this question but I have a simple
> perl
> script that I need to hack some to simply replace the spaces in one of my
> variables with underscores
>
> I have a variable that gets assigned
>
> $subject = ARGV[0];
>
> and subject can be ( This is a test Subject )
>
> Now I want to set $subject equal to ( This_is_a_test_Subject )
>
> I'm really in a bind here so any help would be greatly appreciated, Thanks
> in advance.
>
> Matt Ferrell
> mferrell@planeteers.com
> 972-713-2611
you can do it this way
$subject =~ tr/ /_/;
or this way.. (depending really here)-->
$subject =~ s/^* */_/ig;
the "^* *" makes it so anything before of after the space doesn't
interfer.. You CAN do that, or not.. otherwise, someone could type
something"space"somethingelse...
------------------------------
Date: 5 Jun 1997 03:42:00 GMT
From: marti@netrail.net (Dennis Marti)
Subject: Re: replacing spaces with underscores
Message-Id: <5n5ci8$9to$1@skipper.netrail.net>
perl guy (perlprogrammer@hotmail.com) wrote:
: Matt Ferrell wrote:
: > and subject can be ( This is a test Subject )
: > Now I want to set $subject equal to ( This_is_a_test_Subject )
: you can do it this way
: $subject =~ tr/ /_/;
: or this way.. (depending really here)-->
: $subject =~ s/^* */_/ig;
_I__l_i_k_e_d__y_o_u_r__f_i_r_s_t__a_n_s_w_e_r__b_e_t_t_e_r_._
Replacing 0 or more "beginning of strings" and 0 or more case
insensitive spaces with an underscore doesn't produce the desired
results. It will also turn an empty string into "_", which could
cause problems other problems.
Be careful about making everything in a regular expression optional.
Dennis Marti
------------------------------
Date: 5 Jun 1997 03:38:23 GMT
From: jahwan@supernova.math.lsa.umich.edu (Jahwan Kim)
Subject: Suggestion to all frequent posters/answerers
Message-Id: <slrn5pcd5f.qnq.jahwan@supernova.math.lsa.umich.edu>
Dear all perl-lover/clpm-regulars,
I've been following this group quite closely for about 2-3 months.
As is expected from such a heavy traffic news group, I've seen/posted flames,
clueless/ad hoc questions being asked and answered. All in all, this helped
me understand/love Perl better.
One thing I noticed is, there're quite a lot of postings which contain
only RTFM/RTF/check CPAN. While these postings will help and guide the
original poster, they do not interest regular READERS like myself so much.
So I suggest/ask you with all my respect to include RTFM/RTF/CCPAN in
the subject line, when your posting does not have anything else at all.
I surmise that this suggestion, if taken by most of clpm answer guys(*),
will reduce the time I spend reading clpm by 10-20%. I hope many of you out
there agree with me.
Jahwan
(*) Isn't it so sad that clpm now *appears* to be a question/answer bulletin
board rather than a discussion group? (But remember you'll always find Perl
in mud.)
------------------------------
Date: Wed, 04 Jun 1997 21:43:08 -0500
From: Arthur Merar <amerar@unsu.com>
Subject: Voting Script
Message-Id: <339627BC.1536@unsu.com>
Hello,
I am looking for a script that will perform some voting functions for
me. Basically the user will select an area on a graphical image. A
number ranging from 1 to 10 will be passed to the script and it will
tally and return a percentage.
Can anyone help out? I'm having trouble locating one.
Arthur
amerar@unsu.com
http://www.unsu.com
------------------------------
Date: 5 Jun 1997 05:14:34 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Voting Script
Message-Id: <5n5hvq$7in@fridge-nf0.shore.net>
Arthur Merar (amerar@unsu.com) wrote:
: I am looking for a script that will perform some voting functions for
: me. Basically the user will select an area on a graphical image. A
: number ranging from 1 to 10 will be passed to the script and it will
: tally and return a percentage.
Sounds like a CGI / Imagemap question, in which case you're looking
for the Imagemap module which is available from a CPAN near you!
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
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 573
*************************************