[10629] in Perl-Users-Digest
Perl-Users Digest, Issue: 4221 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 14 21:07:13 1998
Date: Sat, 14 Nov 98 18:00:21 -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 Sat, 14 Nov 1998 Volume: 8 Number: 4221
Today's topics:
Re: 64-bit Perl? <berend@istanbul.engr.sgi.com>
[PLEASE HELP]: Eliminate spaces at end of string dannyboyvod@my-dejanews.com
Re: [PLEASE HELP]: Eliminate spaces at end of string (Tad McClellan)
Re: [PLEASE HELP]: Eliminate spaces at end of string (Liam Quinn)
Re: [PLEASE HELP]: Eliminate spaces at end of string <zenin@bawdycaste.org>
Re: BUILDING BLOWFISH IN PERL (Maurice Aubrey)
Re: BUILDING BLOWFISH IN PERL <jimfl@bnl.gov>
Can Perl get a list of user's midi out devices? (VYTiS)
Re: Can Perl get a list of user's midi out devices? (brian d foy)
CPAN.pm V1.40 acting flaky!! <rjberman@mindspring.com>
Re: download never finishes (brian d foy)
Re: download never finishes <splinter@monmouth.com>
Re: download never finishes (Andre L.)
Re: File Locking Problems (brian d foy)
Re: HELP! Concat'ing multiple variables into one (Ronald J Kimball)
Re: HTML editor for perl? <rgl34@hotmail.com>
Re: Installing Perl modules <palincss@tidalwave.net>
Re: MacPerl, Help, and Internet Config (Rich Morin)
Re: need help with file manipulating (brian d foy)
Re: need help with file manipulating <splinter@monmouth.com>
Re: need help with file manipulating (Andre L.)
Re: need help with file manipulating <dgris@moiraine.dimensional.com>
Re: need help with file manipulating (Ronald J Kimball)
Re: need help with file manipulating (Tad McClellan)
Re: Occasional Perl Script Failure tory1@mail.idt.net
Program mysteriously crashes waiting for file zephaar@my-dejanews.com
Re: Q: are symbolic refs really needed (was Re: Modific <zenin@bawdycaste.org>
Screen Flash Black - Perl on NT4.0 (Chris Jones)
Re: Why is this quiting out of the subroutine early? (Ronald J Kimball)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 14 Nov 98 17:03:16 PST
From: "Berend Ozceri" <berend@istanbul.engr.sgi.com>
Subject: Re: 64-bit Perl?
Message-Id: <72l98k$9fvmr@fido.engr.sgi.com>
I appreciate all the input about additional packages for large integer support,
but that really is not what I am interested in. I have an application where
calling XXXX->new("YYYYY") everytime you need a new 64-bit constant is not
acceptable.
I know Perl can be compiled 64-bit native on systems that have a native "long"
type of 64-bits and that there is efforts to clean up the code so "long long"
types can be used on systems that have 32-bit longs in C. What I am asking is
what the status of that effort is? Can I compile Perl with native 64-bit
integers on a system with 32-bit int's and 64-bit long long's?
Thanks.
Berend
------------------------------
Date: Sat, 14 Nov 1998 23:27:19 GMT
From: dannyboyvod@my-dejanews.com
Subject: [PLEASE HELP]: Eliminate spaces at end of string
Message-Id: <72l3ko$3m3$1@nnrp1.dejanews.com>
If anyone knows how to do this, please email me back at
baumbadj@flyernet.udayton.edu
All I need to know is how I can take out any spaces at the end of a string.
I have a cgi form set up that takes a person's email address, name and other
stuff. But, if the user hit the space bar after entering his/her name, I need
to get rid of those spaces. Does anyone know how to do this?
Thanks.
Dan
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Sat, 14 Nov 1998 19:24:27 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: [PLEASE HELP]: Eliminate spaces at end of string
Message-Id: <bgal27.f06.ln@flash.net>
dannyboyvod@my-dejanews.com wrote:
: If anyone knows how to do this, please email me back at
: baumbadj@flyernet.udayton.edu
If you want to know how to do this, please read the
comp.lang.perl.misc newsgroup to see the followups.
: All I need to know is how
... to do a word search on the documents that came with perl
and are already on my hard disk.
: I can take out any spaces at the end of a string.
Perl FAQ, part 4:
"How do I strip blank space from the beginning/end of a string?"
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 15 Nov 1998 01:00:41 GMT
From: liam@htmlhelp.com (Liam Quinn)
Subject: Re: [PLEASE HELP]: Eliminate spaces at end of string
Message-Id: <364e2792.28683673@news.sprint.ca>
On Sat, 14 Nov 1998 23:27:19 GMT, dannyboyvod@my-dejanews.com wrote:
>All I need to know is how I can take out any spaces at the end of a string.
The Perl FAQ is cool. It also answers your question:
http://www.perl.com/CPAN-local/doc/manual/html/pod/perlfaq4.html#How_do_I_strip_blank_space_from_
--
Liam Quinn
Web Design Group Enhanced Designs, Web Site Development
http://www.htmlhelp.com/ http://enhanced-designs.com/
------------------------------
Date: 15 Nov 1998 01:05:05 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: [PLEASE HELP]: Eliminate spaces at end of string
Message-Id: <911091830.995338@thrush.omix.com>
[posted & mailed]
dannyboyvod@my-dejanews.com wrote:
: If anyone knows how to do this, please email me back at
: baumbadj@flyernet.udayton.edu
:
: All I need to know is how I can take out any spaces at the end of a string.
: I have a cgi form set up that takes a person's email address, name and other
: stuff. But, if the user hit the space bar after entering his/her name, I need
: to get rid of those spaces. Does anyone know how to do this?
perldoc perlre
$email =~ s/\s*$//;
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: Sat, 14 Nov 1998 23:30:01 GMT
From: maurice@hevanet.com (Maurice Aubrey)
Subject: Re: BUILDING BLOWFISH IN PERL
Message-Id: <slrn74s4jq.4r4.maurice@we-24-130-48-83.we.mediaone.net>
On Sat, 14 Nov 1998 14:02:56 GMT, fantastic2@my-dejanews.com
<fantastic2@my-dejanews.com> wrote:
>I am having an argument with a friend at work about using Blowfish decryption
>with PERL.
>
>He says that you need to download some stupid module to do it, and I say that
>BLOWFISH could be built using basic PERL command without having to use a
>separate module.
[snip]
>Has anyone actually built the Blowfish decryption into a single script? I
>checked CPAN and all I can find are modules.
Why would you develop something as useful as Blowfish and not create
a module out of it? Are you familiar with how modules actually work?
--
Maurice Aubrey <maurice@hevanet.com>
I have made this letter longer than usual because I lack the time
to make it shorter.
- Blaise Pascal
------------------------------
Date: Sat, 14 Nov 1998 17:38:11 -0800
From: Jim Flanagan <jimfl@bnl.gov>
To: fantastic2@my-dejanews.com
Subject: Re: BUILDING BLOWFISH IN PERL
Message-Id: <364E3083.6783336A@bnl.gov>
fantastic2@my-dejanews.com wrote:
> I am having an argument with a friend at work about using Blowfish decryption
> with PERL.
>
> He says that you need to download some stupid module to do it, and I say that
> BLOWFISH could be built using basic PERL command without having to use a
> separate module.
One could indeed do this. I have done it with the "Alleged RC4" for a
quick-and-dirty hack in some proof of concept code. The operations in
BLOWFISH are adds and XORs on 32-bit quantities, plus a little
bit-twidding; something perl can handle reasonably quickly.
You are almost certain to get better performance by writing it in C,
and
wrapping it up with XS to make a perl module, but I suspect that's
not
the crux of your argument with friend...
> My reasoning is that decryption is much quicker than encryption (if you have
> the key) and that it just boils down to some math functions that PERL can
> handle all on its own.
This reasoning, I think, is somewhat flawed in that, with BLOWFISH,
decryption
is exactly the same as encryption, only backwards.
> I checked CPAN and all I can find are modules.
Modules, modules everywhere, and not a script! to think!
CPAN's modules are rich field of exploration, I've found.
Cheers,
Jim Flanagan
Computing and Communications Division
Brookhaven National Laboratory
------------------------------
Date: Sat, 14 Nov 1998 13:01:52 GMT
From: vip@takas.lt (VYTiS)
Subject: Can Perl get a list of user's midi out devices?
Message-Id: <364d80e8.0@news.takas.lt>
Hi, I don't think it's possible, but maybe it is?
I wonder if I can get what MIDI out devices are available on user's system?
I'm working on a cgi script that will play random MIDI files, but these MIDI's
must be played on XG devices only, so if none of the MIDI out's includes "XG",
means it can not be played back.
Just in case anyone knows ... :)
------------------------------
Date: Sat, 14 Nov 1998 17:21:33 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Can Perl get a list of user's midi out devices?
Message-Id: <comdog-ya02408000R1411981721330001@news.panix.com>
In article <364d80e8.0@news.takas.lt>, vip@takas.lt (VYTiS) posted:
> Hi, I don't think it's possible, but maybe it is?
> I wonder if I can get what MIDI out devices are available on user's system?
> I'm working on a cgi script that will play random MIDI files, but these MIDI's
> must be played on XG devices only, so if none of the MIDI out's includes "XG",
> means it can not be played back.
it might be possible if you ran the script on the client machine,
but this sort of information is not generally available through
HTTP which likes to be device independent.
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Sat, 14 Nov 1998 16:58:58 -0500
From: Bob Berman <rjberman@mindspring.com>
Subject: CPAN.pm V1.40 acting flaky!!
Message-Id: <364DFCAF.21C8D0AD@icehouse.com>
I have the latest CPAN.pm installed (V1.40) and have been playing with it. But I
discovered that sometimes it complains about a release not containing a
Makefile.PL when it fact it does, and sometimes it doesn't really install the
latest release, it just downloads it!
The following illustrates my points. I have DateManip V5.30 currently installed
and CPAN.pm correctly deduces that there is a version 5.33 out there. It then
downloads 5.33, says (incorrectly ) it doesn't have a Makefile.PL, it then does
some sort of installation and completes. If I search the perl tree, the version
of Date::Manip which is installed is still V5.30! This is confirmed by the "r"
command of CPAN.pm itself. So whatever it did during the "installation", it
really didn't do anything!
cpan> install Date::Manip
Running make for SBECK/DateManip-5.33.tar.gz
CPAN: MD5 loaded ok
Checksum for /root/.cpan/sources/authors/id/SBECK/DateManip-5.33.tar.gz ok
Compression not available.
CPAN: Archive::Tar loaded ok
Use of uninitialized value at /usr/local/lib/perl5/site_perl/Archive/Tar.pm line
489.
Use of uninitialized value at /usr/local/lib/perl5/site_perl/Archive/Tar.pm line
489.
Use of uninitialized value at /usr/local/lib/perl5/site_perl/Archive/Tar.pm line
493.
Use of uninitialized value at /usr/local/lib/perl5/site_perl/Archive/Tar.pm line
511.
print on closed filehandle Archive::Tar::FILE at
/usr/local/lib/perl5/site_perl/Archive/Tar.pm line
513.
Use of uninitialized value at /usr/local/lib/perl5/site_perl/Archive/Tar.pm line
546.
Use of uninitialized value at /usr/local/lib/perl5/site_perl/Archive/Tar.pm line
546.
Use of uninitialized value at /usr/local/lib/perl5/site_perl/Archive/Tar.pm line
548.
Use of uninitialized value at /usr/local/lib/perl5/site_perl/Archive/Tar.pm line
548.
Use of uninitialized value at /usr/local/lib/perl5/site_perl/Archive/Tar.pm line
548.
Use of uninitialized value at /usr/local/lib/perl5/site_perl/Archive/Tar.pm line
553.
Use of uninitialized value at /usr/local/lib/perl5/site_perl/Archive/Tar.pm line
553.
Package comes without Makefile.PL.
Writing one on our own (calling it Date::Manip)
CPAN.pm: Going to build SBECK/DateManip-5.33.tar.gz
Writing Makefile for Date::Manip
mkdir blib
mkdir blib/lib
mkdir blib/lib/Date
mkdir blib/arch
mkdir blib/arch/auto
mkdir blib/arch/auto/Date
mkdir blib/arch/auto/Date/Manip
mkdir blib/lib/auto
mkdir blib/lib/auto/Date
mkdir blib/lib/auto/Date/Manip
/usr/local/bin/make -- OK
Running make test
No tests defined for Date::Manip extension.
/usr/local/bin/make test -- OK
Running make install
Writing /usr/local/lib/perl5/site_perl/i586-linux/auto/Date/Manip/.packlist
Appending installation info to
/usr/local/lib/perl5/i586-linux/5.00502/perllocal.pod
/usr/local/bin/make install -- OK
cpan> r
Package namespace installed latest in CPAN file
Date::Manip 5.30 5.33 SBECK/DateManip-5.33.tar.gz
------------------------------
Date: Sat, 14 Nov 1998 16:15:54 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: download never finishes
Message-Id: <comdog-ya02408000R1411981615540001@news.panix.com>
In article <72kp8u$bsi$1@news.monmouth.com>, "Matt" <splinter@monmouth.com> posted:
> print "Content-type: text/html\n\n";
>
> NOT this:
>
> print "Content-type: text/html","\n\n";
why not the second? perhaps you've never used print?
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Sat, 14 Nov 1998 16:27:57 -0500
From: "Matt" <splinter@monmouth.com>
Subject: Re: download never finishes
Message-Id: <72ksu1$e9e$1@news.monmouth.com>
I know....
sometimes stuff like that makes a difference....I was taking a guess.
-Matt
------------------------------
Date: Sat, 14 Nov 1998 18:15:20 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: download never finishes
Message-Id: <alecler-1411981815200001@dialup-555.hip.cam.org>
In article <MPG.10b78b30fed5a31989908@nntp.hpl.hp.com>, lr@hpl.hp.com
(Larry Rosler) wrote:
> In article <72kp8u$bsi$1@news.monmouth.com> on Sat, 14 Nov 1998 15:25:48
> -0500, Matt <splinter@monmouth.com> says...
> > its like this...
> >
> > print "Content-type: text/html\n\n";
> >
> > NOT this:
> >
> > print "Content-type: text/html","\n\n";
>
> What a useful post. :-<
>
> These two statements have *identical* effects. Of course, the one you
> prefer is three characters shorter. That makes all the difference.
...except if the output field separator ($,) is set, of course.
Andre
------------------------------
Date: Sat, 14 Nov 1998 16:20:40 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: File Locking Problems
Message-Id: <comdog-ya02408000R1411981620400001@news.panix.com>
In article <OW#gWlAE#GA.284@upnetnews02.moswest.msn.net>, "Grace Carter" <cheers69@email.msn.com> posted:
> Having scrawled through various other flock examples I was curious to know
> why so few used some sort of unlock call.
between the time that you unlock the file and close the filehandle,
another process may be able to print to the file. if you haven't
flushed your buffers before then, your data gets all jumbled up.
besides, closing a filehandle will release the lock.
btw, this is covered in perlfaq5.
> I'll remove all flock (FILE, 8) calls in my scripts and see how I get on
i guess if you have nothing better to do than bang your head against
a wall...
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Sat, 14 Nov 1998 18:10:59 -0500
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: HELP! Concat'ing multiple variables into one
Message-Id: <1dihb6x.1513ywb3ksaeeN@bay1-14.quincy.ziplink.net>
Uri Guttman <uri@sysarch.com> wrote:
> sorry ronald, but that makes no sense. the 3 array elements match the 3
> assignments above.
You're right; I mixed up which variables were which and of what type.
Woops!
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Sat, 14 Nov 1998 17:40:47 -0800
From: "Robert Long" <rgl34@hotmail.com>
Subject: Re: HTML editor for perl?
Message-Id: <72lbcg$97f$1@pollux.dnai.com>
I have found Allaire's Homesite to be an excellent editor for Perl. It
allows you to have your Perl color coded for ease of reading. Check them
out at www.allaire.com
Clarence Hsu wrote in message <364dafc4.0@news1.ibm.net>...
>I tried to use Frontpage to edit the HTML webpage
>inside a perl file, but it won't work. Is there
>a software that I can use?
>
>Please email me: chsu@edfax.com
>Thanks.
>
>
------------------------------
Date: Sat, 14 Nov 1998 10:54:05 -0500
From: Steve Palincsar <palincss@tidalwave.net>
Subject: Re: Installing Perl modules
Message-Id: <364DA79D.E109407@tidalwave.net>
Doesn't OS/2 support the typical "make" installation
technique (perl Makefile.PL; make; make test; make install)?
ppp:vdkamp@inter.nl.net@inter.nl.net wrote:
>
> Hello Perl community,
>
> Although I have a long time experience with Perl, I have no experience
> with installing modules. But now I have to.
> I want to use ANSIColor and Perlmenu. I copied the ANSIColor.pm file to
> the path mentioned in INC. Then I try to run my Perl script. But it
> stopped with the message "Undefined subroutine &main::color at..".
> I think this message indicates that I have to recompile Perl with the
> new modules? Or are there other ways? I also have the vague feeling
> that .pm files are OS specific. Or not?
> I work with Perl 5.004_55 (binary distribution) for OS/2 Warp 4.0.
> Any help is appreciated.
>
> Peter van der Kamp
------------------------------
Date: Sat, 14 Nov 1998 17:16:04 -0800
From: rdm@cfcl.com (Rich Morin)
Subject: Re: MacPerl, Help, and Internet Config
Message-Id: <rdm-1411981716190001@140.174.42.30>
In <72g5eo$312$1@nnrp1.dejanews.com> johnny99@sydney.dialix.oz.au writes:
> ...
>I can't get MacPerl's help menu to work.
> ...
> >TIA, please crosspost, redirect me, flame me, etc as appropriate ...
In <1dih4nw.1py5xgu1mquns8N@jorn.pr.mcs.net> jorn@mcs.com writes:
> I need some help getting started with MacPerl ...
The definitive MacPerl starting point, IMHO, is PTF's MacPerl Pages:
http://www.ptf.com/macperl
It will tell you about assorted MacPerl resources, including:
* The MacPerl mailing list
* "MacPerl: Power and Ease" (available in HTML and hard-copy!)
* miscellaneous MacPerl-related articles, stories, promotion, etc.
-r
--
Canta Forda Computer Laboratory | Prime Time Freeware - quality
UNIX consulting, training, & writing | freeware at affordable prices
+1 650-873-7841 | +1 408-433-9662 -0727 (Fax)
Rich Morin, rdm@cfcl.com | www.ptf.com, info@ptf.com
------------------------------
Date: Sat, 14 Nov 1998 16:22:00 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: need help with file manipulating
Message-Id: <comdog-ya02408000R1411981622000001@news.panix.com>
In article <364DEC2F.B8D5A305@home.com>, Justin Park <jjpark@home.com> posted:
> how can i search for a specific string in a opened file and if it finds
> it, replace that line with other string?
see, in perlfaq5, the answer to
How do I change one line in a file/delete a line in a
file/insert a line in the middle of a file/append to the
beginning of a file?
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Sat, 14 Nov 1998 16:26:16 -0500
From: "Matt" <splinter@monmouth.com>
Subject: Re: need help with file manipulating
Message-Id: <72ksqs$e1h$1@news.monmouth.com>
So you don't have to look it up in teh FAQ like everyone around here tells
you to just do this:
$scalar =~ s/find-this-string/replace-with-this/g,i,o
OR
$scalar =~ tr/find-this-string/replace-with-this/g,i,o,e
The one with the s in front of it allows you to perform expressions to find
the string using *?^ and stuff like that. tr does not.
-Matt
------------------------------
Date: Sat, 14 Nov 1998 17:53:15 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: need help with file manipulating
Message-Id: <alecler-1411981753150001@dialup-555.hip.cam.org>
In article <72ksqs$e1h$1@news.monmouth.com>, "Matt"
<splinter@monmouth.com> wrote:
> So you don't have to look it up in teh FAQ like everyone around here tells
> you to just do this:
>
>
> $scalar =~ s/find-this-string/replace-with-this/g,i,o
>
> OR
>
> $scalar =~ tr/find-this-string/replace-with-this/g,i,o,e
>
> The one with the s in front of it allows you to perform expressions to find
> the string using *?^ and stuff like that. tr does not.
I'm afraid this doesn't answer the question; besides, it is incorrect. The
FAQ, on the other hand, does answer the question very well.
Andre
------------------------------
Date: 14 Nov 1998 16:20:09 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: need help with file manipulating
Message-Id: <m3zp9tzwt2.fsf@moiraine.dimensional.com>
"Matt" <splinter@monmouth.com> writes:
> So you don't have to look it up in teh FAQ like everyone around here tells
> you to just do this:
Do you actually think that he's better off _not_ looking in the FAQ?
At least if he looks there the answers he finds will work, unlike what
you posted below.
> $scalar =~ s/find-this-string/replace-with-this/g,i,o
^^^^^
I don't think that does what you think it does. Unless you
think that it globally replaces `find-this-string' with
`replace-with-this' in $scalar, then calls a function named `i'
and then calls a function named `o'.
> $scalar =~ tr/find-this-string/replace-with-this/g,i,o,e
This isn't even valid perl.
$ perl -e ' $scalar =~ tr/find-this-string/replace-with-this/g,i,o,e'
Bareword found where operator expected at -e line 1,
near "tr/find-this-string/replace-with-this/g"
syntax error at -e line 1, near "tr/find-this-string/replace-with-this/g"
Execution of -e aborted due to compilation errors.
$
Please, take a minute to make sure that what you are saying
works before posting. Posting completely inaccurate code
doesn't help the person who asked the question.
dgris
--
Daniel Grisinger dgris@moiraine.dimensional.com
Supporter of grumpiness where grumpiness is due on clpm.
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: Sat, 14 Nov 1998 18:34:41 -0500
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: need help with file manipulating
Message-Id: <1dihxim.l5d35qaxpf7sN@bay1-14.quincy.ziplink.net>
[posted and mailed]
Matt <splinter@monmouth.com> wrote:
> So you don't have to look it up in teh FAQ like everyone around here tells
> you to just do this:
Thank you, Matt, for actually demonstrating the usefulness of the FAQ!
(Unintentionally, obviously.)
> $scalar =~ s/find-this-string/replace-with-this/g,i,o
s///gio
There should be no commas between modifiers to s/// or m//.
> OR
>
> $scalar =~ tr/find-this-string/replace-with-this/g,i,o,e
tr///gioe
See above - there should be no commas between tr/// modifiers, either.
Those aren't valid modifiers to tr///. tr///'s modifiers are /d, /c,
and /s.
> The one with the s in front of it allows you to perform expressions to find
> the string using *?^ and stuff like that. tr does not.
You obviously have no clue what tr/// does. tr/// is for TRanslate. It
does a one-to-one character translation. It cannot be used to replace
one string with another.
Of course, neither of these solutions even comes close to doing what the
original poster asked for - to change a line *in a file*. Changing the
value of a variable in memory is the easy part; now you have to get that
changed value back into the file.
Telling someone to read the FAQ is helpful. Giving someone an incorrect
solution (especially when it's as ridiculously incorrect as the solution
you provided) is extremely unhelpful.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Sat, 14 Nov 1998 18:15:57 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: need help with file manipulating
Message-Id: <tf6l27.cn5.ln@flash.net>
Matt (splinter@monmouth.com) wrote:
: So you don't have to look it up in teh FAQ like everyone around here tells
: you to just do this:
If you don't look it up in the FAQ, you may get foolish answers
that don't do what was asked for, don't work, or don't even
parse.
: $scalar =~ s/find-this-string/replace-with-this/g,i,o
: OR
: $scalar =~ tr/find-this-string/replace-with-this/g,i,o,e
^^^^^^
tr/// does NOT work on strings...
: The one with the s in front of it allows you to perform expressions to find
: the string using *?^ and stuff like that. tr does not.
See?
Please stop posting guesses. It makes it worse not better.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 14 Nov 1998 19:06:52 -0500
From: tory1@mail.idt.net
Subject: Re: Occasional Perl Script Failure
Message-Id: <364E1B1C.5E7E@mail.idt.net>
Thanks for the advice so far...
I have been running the script with all signal handlers
resolved to a central function which logs the signal
number abd attepmts to return to the position that the
signal occrred. So far so good. I test it with a Ctrl-Z
and it seems to work fime.
I also check the return codes (from an open/close) where
I spawn a decryption program to decode incoming files.
All other codes are being logged at every possible position
especially in the Net::ftp module. The program is watched
by a monitor process that checks for the existance of the
perl script every 30 seconds.
As far as the DNS timing out, I suspect that is probable,
and will try to test by running the script with a kill
on the DNS server (primary and backup).
My suspicion is still with the sleep call however and
I thought of replacing it with a select defined with
a 30 second timeout value. Does this sound plausible?
Thanks in Advance,
Jim
------------------------------
Date: Sun, 15 Nov 1998 01:11:03 GMT
From: zephaar@my-dejanews.com
Subject: Program mysteriously crashes waiting for file
Message-Id: <72l9n7$8km$1@nnrp1.dejanews.com>
I have a largish perl script that has been running in production for
almost 9 months. The program basically waits for a file to arrive
in a directory and having arrived ftps the file to another machine.
I use a sleep loop of 30 seconds before waking up and doing:-
for(;;) {
if ( -e $Filename ) {
&FTP_files_to_new_machine();
}
sleep(30);
}
The program seems to run for "lomg time" around 3 to 6 weeks before
mysterioulsy crashing when no files are incoming; presumably while
in the sleep loop. I cant seem to get any information on what the
error is.
I dont have any signal handlers, but pehaps the system I am on,
a Sun Solaris 2.6 box - 96 Meg of memory, is generating a spurious
TERM signal???
Any ideas on how to capture the problem? or even what is wrong?
Thanks in Advance,
Jim
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 15 Nov 1998 00:56:46 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Q: are symbolic refs really needed (was Re: Modification of a read-only??)
Message-Id: <911091331.760686@thrush.omix.com>
Bart Lateur <bart.mediamind@ping.be> wrote:
: Uri Guttman wrote:
: > BL> Can't you do that using eval?
: > BL> eval "\$$Packagename\::$VarName = \"Some Value\"";
: >too slow! can't do that for all imports.
:
: Are you guessing, or do you have evidence to back you up?
$ perl foo.pl 30000
Benchmark: timing 30000 iterations of Eval, SoftRef...
Eval: 11 secs (11.95 usr 0.05 sys = 12.00 cpu)
SoftRef: 1 secs ( 0.75 usr 0.00 sys = 0.75 cpu)
$ cat foo.pl
#!/usr/local/bin/perl -w
use Benchmark;
my $pkg = "Foo";
my $var = "Bar";
timethese shift || 1000, {
SoftRef => sub { ${"${pkg}::$var"} = 10 },
Eval => sub { eval "\$${pkg}::$var = 10" },
};
: Since 'use' is based upon 'require' which is based upon 'do (file)'
: which is based upon 'eval', it should compare very favorably to pulling
: in a module of 160k (like CGI.pm), if you combine all your statements in
: one string before evalling. My guess. :-)
s/\bif\b/iff/g; ## but there are many other problems/risks.
: This looks very safe to me:
: eval join(";\n", map { "\$$Packagename\::$_ = \$assign{'$_'}" }
: keys %assign);
But why do that? You're also forgetting the error checking of $@
to see if it even worked.
for (keys %assign) {
${"${Packagename}::$_"} = $assign{$_};
}
: Tom Phoenix wrote:
: >Symbolic references are generally merely troublesome. eval (of a string)
: >is outright dangerous.
:
: In really controlled situations, like this one, I can't see any danger.
: Maybe I'm overlooking something. :-)
$assign{'Foo;print "bye system!\n";`rm -rf /`; exit; $foo'} = 666;
: Besides, eval is less troublesome with regards to 'my' variables, than
: symbolic refs. You can try out the next test script for yourself, if you
: like.
Symbolicly modifying lexical variables is *begging* for trouble.
>snip<
: Now, as I recall, the original question was: "do we really need symbolic
: refs, or are there alternatives?". Not only IS there an alternative, but
: sometimes it even behaves better.
No, it doesn't. You're asking lexical variables to not be lexical
anymore. This is more likely to confuse then anything else.
: No, we don't really need symbolic refs.
Yes, we do. Mainly for safer black magic, but we do need them.
: Unless I'm mistaking, symbolic refs were introduced as an extension for
: the Perl4 idiom:
: $SIG{'INT'} = 'interrupted';
: sub interrupted { die "Got killed!" }
: And for the sake of the holy backward compatibility...
And for safety, speed, etc.
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: Sat, 14 Nov 1998 17:54:14 GMT
From: cj@interlog.com (Chris Jones)
Subject: Screen Flash Black - Perl on NT4.0
Message-Id: <364dc35f.7157131@news.interlog.com>
I have installed Perl and I am running cgi scripts successfully. When
ever a script runs, the screen goes black the reappears. Is there a
setting in NT4.0 or Perl to prevent the console window from showing?
------------------------------
Date: Sat, 14 Nov 1998 18:34:44 -0500
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Why is this quiting out of the subroutine early?
Message-Id: <1dihy29.cs48ofrbhq2fN@bay1-14.quincy.ziplink.net>
[posted and mailed]
Jason C. Hill <jhill22@csc.com> wrote:
> sub read_file {
>
> $period_count = 0;
>
> for ($i = 0; $i < @needed_files; $i++) {
^^^^^^^^^^^^^^^^^^
> [...]
> &compare_pop_users;
^^^^^^^^^^^^^^^^^^
> } #end for
> } #end sub read_file
> [...]
> sub compare_pop_users {
> $count_var = 0;
> for ($i = 0; $i < @pop_user; $i++) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> [...]
> } #end outter for
> } #end sub compare_pop_users
>
> As you can see, read_file calls &compare_pop_users;
I sure can... Can you see why this ends up being a "bad thing"?
> However, I don't understand why after &compare_pop_users; the program
> just quits.
Then I guess you haven't yet learned about the implications of using
global variables. :-)
Hint: my $i;
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 12 Jul 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 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 4221
**************************************