[7029] in Perl-Users-Digest
Perl-Users Digest, Issue: 654 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 24 15:27:26 1997
Date: Tue, 24 Jun 97 12:00:27 -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 Tue, 24 Jun 1997 Volume: 8 Number: 654
Today's topics:
"system" output into array <jim.condit@fmr.com>
Re: ADDLINE TO DATES <sfairey@adc.metrica.co.uk>
Re: Checking a string for "@' and "." <rootbeer@teleport.com>
Re: Checking a string for "@' and "." <mattias.lonnqvist@uidesign.se>
Re: Checking a string for "@' and "." <rootbeer@teleport.com>
Re: distributed objects in perl <rootbeer@teleport.com>
find2perl documentation <clark@s3i.com>
Re: find2perl documentation (Nathan V. Patwardhan)
Re: Generating random numbers fast <rootbeer@teleport.com>
HELP:compile fails with ODBM_File.xs errors (Bruno Boettcher)
Re: Is perl support recursion (Tim Smith)
Re: leading zeroes (Tung-chiang Yang)
Re: long file rename to 8.3 <sfairey@adc.metrica.co.uk>
Re: long file rename to 8.3 (Magnus Bodin)
Re: Newbie : FAQ location ?? ...can u solve my problem? <rootbeer@teleport.com>
Re: Perl (Binary) <sfairey@adc.metrica.co.uk>
Re: perl and perl5 (Joel Coltoff)
Re: perl cgi script can't load an applet (Magnus Bodin)
perl core on Solaris 5.5.1 tjohnson@ameritrade.com
Re: PERL/CGI Database (Jay Flaherty)
Re: Q: an alternative to this use of "goto"? <rootbeer@teleport.com>
Re: Q: an alternative to this use of "goto"? <rootbeer@teleport.com>
Re: regular expressions (Tri Tram)
Re: Remove duplicate values from array <sfairey@adc.metrica.co.uk>
Re: SShell Windoww in Win95 disappes <hartje@etech.hs-bremen.de>
Re: Threads in perl ? (Eric Arnold)
Trouble using Win32::Registry to edit NT environment <chriswareham@dial.pipex.com>
Re: Why do i get text/octet-stream download when i try (Bogdan Sumni)
XSubpp man page? <jheck@merck.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 24 Jun 1997 13:00:50 -0400
From: Jim Condit <jim.condit@fmr.com>
Subject: "system" output into array
Message-Id: <33AFFD42.5F53@fmr.com>
I would like to take the output generated by the system() function and
put it into an array, something like this:
system("command which prints to the screen") > @screencapture ;
This does not work, of course. I'm running 5.003 on NT 3.51.
Thanks in advance!
------------------------------
Date: Tue, 24 Jun 1997 14:50:07 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: Brad Nelson <norseman@erols.com>
Subject: Re: ADDLINE TO DATES
Message-Id: <33AFD08F.52BF@adc.metrica.co.uk>
Brad Nelson wrote:
>
> Good Day,
> I seek help. I'm trying to learn Perl and have run against a wall. I don't
> know how to make Perl do as I want. Thank you for your help. Brad
> PLEASE USE THE SUBJECT LINE: "ADDLINE TO DATES".
> Using the following text file format, I'd like to have Perl insert a text
> line. Location, Date, and number of attendees are single-tab delimited.
> City name and state are double-space delimited.
> Specifically,
> 1. While the location (Field 1) is:(example: New York City NY)2. Check the
> dates in Field/Column 3 against sequence of dates "X" [I'd like Perl to
> take the sequence from the text file (a "sort uniq"-type function) In this
> case, 9602 through 9702]
> 3. If a date missing from the sequence,
> 4. Add in a line with Field 1 the correct date and a "0" for number of
> attendees. Location (tab)9606 (tab) 0
> location (tab) date (tab) attendees
>
Try storing the date in an associative array where the key is the date
and initialise the values to 0 then within a loop over the input file
do:
extract the current city and date
if the city has changed then
go through the date associative array and check for entries of 0
for each one found add the necesary line to the file.
re-initialise the date array entries to 0 ready for next city
endif
set the entry in the date array for the current date to 1
output the current line to the file
save the current city as the last city for comparison with the next one
Thats some rough pseudo code, hopefully you should be able to convert
that to perl fairly easily..
Have fun
Simon
------------------------------
Date: Tue, 24 Jun 1997 10:11:36 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: ? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au>
Subject: Re: Checking a string for "@' and "."
Message-Id: <Pine.GSO.3.96.970624100621.3042J-100000@kelly.teleport.com>
On 24 Jun 1997, ? the platypus {aka David Formosa} wrote:
> Dean Hollister <deanh@nospam.mail> writes:
> >Can anyone point me to the required code to check whether or not a
> >string has BOTH the "@" and "." characters in it?
>
> I would use the regex /(\@.*\.)|(\..*\@)/
That's not very efficient, and it won't give the right answer for some
strings. (Although I admit that the original question probably didn't care
about newlines, since it was probably a poor attempt at checking e-mail
addresses.)
this string has an @-sign
and also a period.
I would have used index, or maybe a pair of pattern matches.
index($_, '@') > -1 and
index($_, '.') > -1
/\@/ and /\./ # Find @ and . both
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 23 Jun 1997 10:19:23 +0200
From: Mattias Lvnnqvist <mattias.lonnqvist@uidesign.se>
Subject: Re: Checking a string for "@' and "."
Message-Id: <33AE318B.2A2E@uidesign.se>
Dean Hollister wrote:
>
> Hello,
>
> Can anyone point me to the required code to check whether or not a
> string has BOTH the "@" and "." characters in it?
>
> Using Perl 5.
>
One easy way is:
$_=$string_to_check;
if ((/@/)&&(/./) {
}
A simple perl tutorial that covers this, and much more, can be found on
http://agora.leeds.ac.uk/Perl/start.html
/Mattias
--
This was a message from Mattias Lonnqvist * mailto:malo@uidesign.se
http://www.uidesign.se/~malo * phone +46 - (0)13- 37 12 05
Unsolicited commercial email is subject to an archival fee of $400.
See <http://www.uidesign.se/~malo/mail.html> for more info.
------------------------------
Date: Tue, 24 Jun 1997 10:27:22 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Chris Wareham <chriswareham@dial.pipex.com>
Subject: Re: Checking a string for "@' and "."
Message-Id: <Pine.GSO.3.96.970624101645.3042M-100000@kelly.teleport.com>
On 24 Jun 1997, Chris Wareham wrote:
> Dean Hollister <deanh@nospam.mail> wrote in article
> <33ADE275.395B@nospam.mail>...
> > Can anyone point me to the required code to check whether or not a
> > string has BOTH the "@" and "." characters in it?
> if ($string_to_search =~ /[\@\.].*[\@\.]/g) {
Oooooh, I don't think so. That produces a false positive for many
strings...
....Do you mean to say that this string qualifies?
...and false negative for some...
Although this string has both an @-sign and a dot,
it fails your test. :-(
...and it's pretty inefficient. (Besides that, what's the /g doing there?
Do you understand what m//g does in a scalar context? I don't think
you're doing what you think you're doing.)
I recommend either two simple matches or using index, as shown elsewhere
in this thread. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 24 Jun 1997 10:13:35 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: German Cancio Melia <German.CancioMelia@cern.ch>
Subject: Re: distributed objects in perl
Message-Id: <Pine.GSO.3.96.970624101217.3042K-100000@kelly.teleport.com>
On Tue, 24 Jun 1997, German Cancio Melia wrote:
> PS. I forgot to say that I cannot use Perl/Tk since the system has to
> be 100% reliable.
Thank you for writing this. You've made my day! Please let me know what
system you find that is 100% reliable. (Gosh, it's not Visual Basic, is
it? :-)
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 24 Jun 1997 09:15:17 -0400
From: Clark Dorman <clark@s3i.com>
Subject: find2perl documentation
Message-Id: <dafkgnnve.fsf@s3i.com>
Greetings,
I have been playing with find2perl but admit that I'm a little
confused about what it does and how it does it. Unfortunately, there is not
the normal documentation for it. I cannot find information about find2perl
in: PODs, FAQ, CPAN (using search), perldoc (which does exist for a2p and
s2p), info, and find2perl source.
So, is there documentation? Or does it specifically (and only)
mirror the syntax of find?
--
Clark
------------------------------
Date: 24 Jun 1997 13:36:48 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: find2perl documentation
Message-Id: <5ooihg$snu@fridge-nf0.shore.net>
Clark Dorman (clark@s3i.com) wrote:
: So, is there documentation? Or does it specifically (and only)
: mirror the syntax of find?
If you understand find, I don't understand why you're having
difficulties with find2perl. I've been able to do just about
everything I can do in find with find2perl. If you don't understand
find, I'd suggest checking out the manpages.
HTH!
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: Tue, 24 Jun 1997 10:16:13 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Steve Lamb <morpheus@calweb.com>
Subject: Re: Generating random numbers fast
Message-Id: <Pine.GSO.3.96.970624101404.3042L-100000@kelly.teleport.com>
On 24 Jun 1997, Steve Lamb wrote:
> MoNoLiTH+@CMU.EDU in <<snfeIJS00iWS0401U0@andrew.cmu.edu>> wrote:
> >I want to find a quick way to generate decent random numbers fast.
>
> Math:TruleyRandom
"Truley" you spell poorly. :-)
> On a 486DX4-100 it can seed the random generator in two seconds.
> Not sure what it'll do on a faster machine.
It'll take about two seconds. It relies upon hardware delays to get its
randomness, and that takes a little time. Maybe a _little_ less with fast
hardware, but processor speed is pretty much irrelevant. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 24 Jun 1997 16:58:00 GMT
From: bboett@yoda.u-strasbg.fr (Bruno Boettcher)
Subject: HELP:compile fails with ODBM_File.xs errors
Message-Id: <5oouao$en5@news.u-strasbg.fr>
hello,
please could somebody help me with that error? i try to compile
perl5.004_01 (same error with other versions of perl5) on my linux 2.1.42
i686 system....
the error is:
cp ODBM_File.pm ../../lib/ODBM_File.pm
../../miniperl -I../../lib -I../../lib ../../lib/ExtUtils/xsubpp
-noprototypes -typemap ../../lib/ExtUtils/typemap -typemap typemap
ODBM_File.xs >ODBM_File.tc && mv ODBM_File.tc ODBM_File.c
cc -c -Dbool=char -DHAS_BOOL -I/usr/local/include -O2
-DVERSION=\"1.00\" -DXS_VERSION=\"1.00\" -fpic -I../.. ODBM_File.c
ODBM_File.xs: In function `XS_ODBM_File_FETCH':
ODBM_File.xs:90: incompatible types in assignment
ODBM_File.xs: In function `XS_ODBM_File_FIRSTKEY':
ODBM_File.xs:113: incompatible types in assignment
ODBM_File.xs: In function `XS_ODBM_File_NEXTKEY':
ODBM_File.xs:118: incompatible types in assignment
make[1]: *** [ODBM_File.o] Error 1
--
ciao
bboett@erm1.u-strasbg.fr
==============================================================
bboett@erm1.u-strasbg.fr
------------------------------
Date: 24 Jun 1997 04:54:45 -0700
From: trs@azstarnet.com (Tim Smith)
Subject: Re: Is perl support recursion
Message-Id: <5ooci5$bd9@web.azstarnet.com>
In article <Pine.SOL.3.95.970624135821.12505A-100000@b1.hkstar.com>,
Aldoliu Chan <chiyung@b1.hkstar.com> wrote:
>Hi,
> As title. Thanks.
Recursive calls to subroutines are easy with Perl. Here is a simple
example:
#!/usr/bin/perl
my $RECURSION_LIMIT = 5;
my $recursion_level = 0;
recurse($recursion_level);
exit 0;
sub recurse {
my ($level) = @_;
print ' ' x $level, "starting level $level\n";
recurse($level + 1) if $level < $RECURSION_LIMIT;
print ' ' x $level, "ending level $level\n";
}
__END__
Enjoy,
Tim
------------------------------
Date: Mon, 23 Jun 1997 00:19:14 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: leading zeroes
Message-Id: <tcyangEC7Cw2.Ko4@netcom.com>
Well, he just forgot the '^' in the pattern....., but that makes the
'leading' irrelevant, though.
=============================
Tom Phoenix typed before Poison Ivy kissed him:
: On Sun, 22 Jun 1997, Justin Banks wrote:
: > $four =~ s/0+(\d+)/$1/o;
: I don't like what that does when $four is 1000. :-)
--
========= Try the low-crossposting robomoderated 'alt.culture.taiwan' ===
soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
http://www.iglou.com/tcyang/Taiwan_faq.shtml, China_faq.shtml
------------------------------
Date: Tue, 24 Jun 1997 14:34:01 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: bigham@ix.netcom.com
Subject: Re: long file rename to 8.3
Message-Id: <33AFCCC9.6201@adc.metrica.co.uk>
bigham wrote:
>
> I need to
> 1) rename a large number of long filenames to be consistent with a DOS 8.3
> format (e.g. unsigned_integer.ada ==> uns_int.ada)
> 2) track the filename changes and modify the references to the long filenames
> to the newer 8.3 equivalent in an index/build file.
>
> Is there anything that currently does the filename rename?
> thanks,
> tim (bigham@ix.netcom.com)
Look at the rename() function in perl then you can just do a loop over a
list of files and use a regexp or somesuch to extract the first 8 chars
and the last 3.
i.e.
#!/bin/perl -n
chomp;
next if !/^(........).*\.(...)$/;
rename( $_, "$1.$2" );
This would be invoked as:
ls -1|scriptname
Have fun.
Simon
------------------------------
Date: Tue, 24 Jun 1997 17:24:06 GMT
From: magnus.bodin@tychonides.se (Magnus Bodin)
Subject: Re: long file rename to 8.3
Message-Id: <33b0026e.1129574@news1.telenordia.se>
Simon Fairey <sfairey@adc.metrica.co.uk> wrote:
>bigham wrote:
>>
>> I need to
>> 1) rename a large number of long filenames to be consistent with a DOS 8.3
>> format (e.g. unsigned_integer.ada ==> uns_int.ada)
>> 2) track the filename changes and modify the references to the long filenames
>> to the newer 8.3 equivalent in an index/build file.
>Look at the rename() function in perl then you can just do a loop over a
>list of files and use a regexp or somesuch to extract the first 8 chars
>and the last 3.
>i.e.
>
>#!/bin/perl -n
>chomp;
>next if !/^(........).*\.(...)$/;
>rename( $_, "$1.$2" );
>
>
>Simon
an improvement to this is also to check if the filename exist and do
a win8.3-mumbo-jumbo-replace of the last 2 characters to ~# where # is
a number 0-9A-Z
------------------------------
Date: Tue, 24 Jun 1997 10:30:50 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Steve Lamb <morpheus@calweb.com>
Subject: Re: Newbie : FAQ location ?? ...can u solve my problem?
Message-Id: <Pine.GSO.3.96.970624102922.3042O-100000@kelly.teleport.com>
On 24 Jun 1997, Steve Lamb wrote:
> Newsgroups: comp.lang.perl.misc, comp.lang.perl.questions, comp.lang.perl
If your news server really carries all those groups, you should ask your
news admin to read the frequent posting in news.announce.newgroups about
bogus newsgroup names.
> Will the real perl faq please rise?
http://www.perl.com/CPAN/doc/FAQs/FAQ/html/perlfaq.html
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 24 Jun 1997 14:18:19 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: Marc Boumedine <mboumedi@anubis.ccm.itesm.mx>
Subject: Re: Perl (Binary)
Message-Id: <33AFC91B.4487@adc.metrica.co.uk>
Marc Boumedine wrote:
>
> Hi:
>
> I would like to know if it exists binary version of Perlk for the SunOs?
>
> That you for you time.
>
> Marc
> mboumedi@campus.ccm.itesm.mx
Do a web search for 'software porting sun' I know there is one for HP-UX
but I have no idea about SunOS also you could try looking for a
alt.something.binaries.sun or somesuch newsgroup and ask there.
Hope you find it... :)
Have fun.
Simon
------------------------------
Date: Tue, 24 Jun 1997 13:53:28 GMT
From: joel@wmi0.wmi.com (Joel Coltoff)
Subject: Re: perl and perl5
Message-Id: <5oojg4$pgn@netaxs.com>
In article <Pine.SOL.3.95.970624033916.8330F-100000@crocus>,
mike mah <esupu@warwick.ac.uk> wrote:
>hi perl gurus,
> I wonder whether there is different between
> #!/usr/local/bin/perl and
> #!/usr/local/bin/perl5
> will the same version of perl call?
Shh! I'll let you in on a little secret. I'm not a guru. There's
another secret. This isn't a perl question. However, I'm in a foul
mood today so I'll help you answer it. It's almost impossible for
most of us to do it for you. I'll also show the world how ancient
my version of perl is.
Try this
%tycho> ls -li /usr/local/bin/perl*
592 -rwxr-xr-x 3 root 598016 Oct 21 1996 /usr/local/bin/perl
592 -rwxr-xr-x 3 root 598016 Oct 21 1996 /usr/local/bin/perl5.003
See those numbers at the beginning of the line? Notice anything about
them? That's right they are less than 1000. They are also the same.
If yours are the same then they are. If they are different they are
not.
--
Joel Coltoff
I'd explain it, but there's a lot of math. -- Calvin
------------------------------
Date: Mon, 23 Jun 1997 08:28:10 GMT
From: Magnus.Bodin@tychonides.se (Magnus Bodin)
Subject: Re: perl cgi script can't load an applet
Message-Id: <33b132de.355023847@news1.telenordia.se>
Slava Zimine <zimine@mail.cern.ch> wrote:
>Hi.
>
>I ve got the following problem:
>my perl cgi script writes at stdout an html code which loads an applet.
>I need perl to read a variable number of files in directories which
>change daily
>and pass the texts in applet parameters.
>and while executing script i got "myApplet.class not found.
>
>if press on "view source" button the script produces a right code
>with
><applet code = myApplet.class base = /fullpath >
>
According to my nutshellbook, the correct tag for directory is
CODEBASE.
<APPLET CODE="myApplett.class" CODEBASE="path"></APPLET>
should work better.
------------------------------
Date: Tue, 24 Jun 1997 13:10:09 -0600
From: tjohnson@ameritrade.com
To: tjohnson@ameritrade.com
Subject: perl core on Solaris 5.5.1
Message-Id: <867174816.30764@dejanews.com>
This code ran fine under an older version of Solaris. On version 5.5.1
it now cores sometimes, sometime not. Help me.
$sort_out = $dir{"amer"} . "/" . "$files{$xfer}";
$cmd = 'TMPDIR="/vrs/tmp";export TMPDIR;';
$cmd .= '/usr/bin/sort +0 -1 +2 -3 -o ';
$cmd .= $sort_out;
open(SORT_AMER, "| $cmd") || die "can't run $cmd: $!";
Terry Johnson
tjohnson@ameritrade.com
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 23 Jun 1997 13:19:49 GMT
From: fty@hickory.engr.utk.edu (Jay Flaherty)
Subject: Re: PERL/CGI Database
Message-Id: <5olt5l$ori$2@gaia.ns.utk.edu>
Jay Flaherty (fty@hickory.engr.utk.edu) wrote:
: Darren Shilson (darren.shilson@wago.de) wrote:
: :
: : Does anyone know where I can get hold of examples of databases written
: : in PERL/CGI.
:
: for your database I would use MySQL at:
: http://www.tcx.se
: For your access from perl I would use the DBI/DBD modules at:
: http://www.hermetica.com/technologia/DBI/
:
: Jay
I forgot to point you to where you can get the CGI module at:
http://www-genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html
Jay
--
**********************************************
Jay Flaherty fty@utk.edu
If software was free, who would pay "THE BILL"
**********************************************
------------------------------
Date: Tue, 24 Jun 1997 09:52:00 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: jared still <jkstill@teleport.com>
Subject: Re: Q: an alternative to this use of "goto"?
Message-Id: <Pine.GSO.3.96.970624094939.3042F-100000@kelly.teleport.com>
On Tue, 24 Jun 1997, jared still wrote:
> On Mon, 23 Jun 1997 11:21:08 -0700, Tom Phoenix
> <rootbeer@teleport.com> wrote:
> >
> >the future of goto is much more in doubt. Hope this helps!
> What happened to 'There's more than one way to do it.' ?
There's more than one way to put a CD into my CD player; it doesn't matter
much which way you use unless you're trying to make music. :-)
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 24 Jun 1997 10:05:26 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Larry D'Anna <ldanna@ix.netcom.com>
Subject: Re: Q: an alternative to this use of "goto"?
Message-Id: <Pine.GSO.3.96.970624100213.3042I-100000@kelly.teleport.com>
On Mon, 23 Jun 1997, Larry D'Anna wrote:
> Randal Schwartz wrote:
> > It's also amazingly slow.
> Did you guys do that on purpose? :-)
There's no need to spend lots of time and energy optimizing goto, since
it's used quite rarely, and it should never be used when efficiency is an
issue.
> Why does perl have a goto operator anyway?
> Some kind of sick joke...
No, actually it's used when translating from other languages to Perl. If
the other language has a goto, it's probably the easiest thing to use a
goto in Perl until a human brain can look at the code and rewrite it in a
better way.
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 24 Jun 1997 17:35:45 GMT
From: tram@olympic.seas.ucla.edu (Tri Tram)
Subject: Re: regular expressions
Message-Id: <ECAJJM.EAr@seas.ucla.edu>
Thanks, but I also wanted the words inside the parenthesis to have
underscores in them.
Tung-chiang Yang (tcyang@netcom.com) wrote:
> s/#/add_text/;
> Hey, ASUCLA usually has book sales. Grab a copy of the Camel book in
> Ackerman Union next time. Last time I got my 2nd edition there, I got a
> rose as a freebie.
> ==============================
> Tri Tram typed before Poison Ivy kissed him:
> : Can somebody please help me with the regular expressions? I have the
> : following:
> : text #(text)
> : text #(more test)
> : test #(text and more text)
> : I want to change it to:
> : text add_text(text)
> : text add_text(more_text)
> : test add_text(text_and_more_text)
> : thanks for your help.
> --
> ========= Try the low-crossposting robomoderated 'alt.culture.taiwan' ===
> soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
> http://www.iglou.com/tcyang/Taiwan_faq.shtml, China_faq.shtml
--
-----------------------------------------------------------------
Tri Tram, Computer Science and Engineering at UCLA
http://www.seas.ucla.edu/~tram
------------------------------
Date: Tue, 24 Jun 1997 12:31:20 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: george.pieri@mci.com
Subject: Re: Remove duplicate values from array
Message-Id: <33AFB008.237C@adc.metrica.co.uk>
George Pieri wrote:
>
> I would like to remove all the duplicate values from a one dimensional
> array... Is there an easy way to do this....?
>
> e.g.
>
> If the array @last_names lists all last names of individuals and the
> name Smith is in the array 50 times how can I insure that the array
> has only DISTINCT or unique values so Smith is only once in the array
> ??
Use an associative array to begin with and you won't suffer from this
problem; or see below..
>
> Thanks in advance!
I am in a good mood so...
>From the FAQ which can be found at http://www.perl.com
--------------
How can I extract just the unique elements of an array?
There are several possible ways, depending on whether the array is
ordered and whether you wish to preserve the ordering.
a) If @in is sorted, and you want @out to be sorted:
$prev = 'nonesuch';
@out = grep($_ ne $prev && ($prev = $_), @in);
This is nice in that it doesn't use much extra memory, simulating uniq's
behavior of removing only adjacent duplicates.
b) If you don't know whether @in is sorted:
undef %saw;
@out = grep(!$saw{$_}++, @in);
c) Like (b), but @in contains only small integers:
@out = grep(!$saw[$_]++, @in);
d) A way to do (b) without any loops or greps:
undef %saw;
@saw{@in} = ();
@out = sort keys %saw; # remove sort if undesired
e) Like (d), but @in contains only small positive integers:
undef @ary;
@ary[@in] = @in;
@out = @ary;
----------------
Download the FAQ and then just grep for any problems you have in the
future before posting to the newsgroup.
Have fun.
Simon
------------------------------
Date: Tue, 24 Jun 1997 19:54:54 +0200
From: "Dr. Michael Hartje" <hartje@etech.hs-bremen.de>
Subject: Re: SShell Windoww in Win95 disappes
Message-Id: <33B009EE.A0E@etech.hs-bremen.de>
Scott McMahan wrote:
>
> Rafal S. Konopka (rafalk@hyde.park.uga.edu) wrote:
> : I browsed through all the FAQ's available, but I couldn't find a satisfactory
> : answer. If I run a perl perogram byy double clicking on the actual script,
> : the shell window appears with the outpout, and then disappears. Yes, I
> : know, somebody in one of the FAQ's DID say that perl is not meant to be
> : run lie that, but ut DOES run, The thing is I cannot see the output.
>
> : Does it mean that I can only run perl in the DOS shell window?
>
> Generally, double-clicking a Perl program in Explorer is a waste
> of time. If the program outputs anything interesting, or takes
> command line arguments*, running it from Explorer is dumb.
> You won't see the output and can't give it arguments.
> Perl is a command line tool, and you should use it from the
> command line. I don't know why anyone would want to run the program
> from Explorer.
Look at the Macintosh implementation! So may be You get an impression,
what a drag 4n drop can do for You instead of typing everything into the
keyboard. -- Well port of Perl since 4.036 is aware of the d4nd. -- I
like it. I missed that when I now came to an other port of perl without
it!!
Michael
--
Hochschule Bremen Labor fuer Hochspannungstechnik
Prof. Dr. Michael Hartje Neustadtswall 30; 28199 Bremen
Telefon: +49 421 5905-444 FAX: +49 421 5905-476
mailto:hartje@etech.hs-bremen.de http://www.hs-bremen.de
------------------------------
Date: 24 Jun 97 18:05:51 GMT
From: eric.arnold@sun.com (Eric Arnold)
Subject: Re: Threads in perl ?
Message-Id: <ERIC.97Jun24180551@m-e-ir1.sun.com>
In article <5obnu1$2qn$2@canopus.cc.umanitoba.ca>
rahard@wine.ee.umanitoba.ca (Budi Rahardjo) writes:
>On 19 Jun 1997 03:00:07 GMT, Zenin <zenin@best.com> wrote:
>> See fork(). No, it isn't threading but it's the best available
>> right now. You can fake shared data using SysV shared memory,
>> and even mask that more using a tied perl class.
>
>If I can't use thread in perl, I am forced to use Java :-(
>
>-- budi
>--
>Budi Rahardjo <rahard@ee.umanitoba.ca> Just Another Perl Hacker
>VLSI,Computer Networks,Operating Systems,Programming Languages,
>Formal Methods,NCs,WebTV,UNIX,System Design,Telecommunications.
There has been work done on threads for Perl. These are the last messages
I've seen:
>From mbeattie@sable.ox.ac.uk (Malcolm Beattie)
Path: jethro.Corp.Sun.COM!news2me.EBay.Sun.COM!venus.sun.com!cs.utexas.edu!howland.erols.net!rill.news.pipex.net!pipex!warwick!lyra.csx.cam.ac.uk!news.ox.ac.uk!sable.ox.ac.uk!mbeattie
Newsgroups: comp.lang.perl.misc
Subject: Re: Patch to add threads to Perl5.003
Date: 7 Feb 1997 16:22:52 GMT
Organization: Oxford University, England
Lines: 32
Message-ID: <5dfkss$41d@news.ox.ac.uk>
References: <5d3ipm$cpn$1@nadine.teleport.com>
NNTP-Posting-Host: sable.ox.ac.uk
Keywords: Perl, Threads
In article <5d3ipm$cpn$1@nadine.teleport.com>,
Eric Arnold Anderson <eanders@u98.CS.Berkeley.EDU> wrote:
>I've created a patch that adds threads to Perl5.003; since this
>requires that the interpreter and any extensions are recompiled, and
>since it hasn't been extensively tested, I haven't submitted it yet to
>CPAN, and am just making it available from a web page. The web page
>is: <http://www.cs.berkeley.edu/~eanders/thrperl/>; since we've been
>having some trouble with file servers, you may also try the reference
><http://now.cs.berkeley.edu/~eanders/thrperl/>. The release notes
>from the patch are included below.
My multi-threading patches have been around for a couple of years
and are queued to be folded into the perl core once 5.004 is out.
Eric's patches are for "fake" threads (i.e. state explicitly saved
and restored by perl and scheduled within perl at op granularity).
They are rather like the Plthread module I put out a couple of
years back. The threading support going in to the perl core for
5.006/5.006 subsumes both fake threads and real threads. Systems
with real threads (POSIX pthreads API or others can be added) get
real, those without can get (via macro support which needs adding
but shouldn't be too hard) the explicit save/restore of contexts
that give you "fake" threads. It may well be that Eric's patches
are useful for some until the official support comes along (it may
be a while before core threading is stable) but be aware that the
API may well be different for the real thing.
--Malcolm
--
Malcolm Beattie <mbeattie@sable.ox.ac.uk>
Oxford University Computing Services
"Widget. It's got a widget. A lovely widget. A widget it has got." --Jack Dee
>From eanders@u98.CS.Berkeley.EDU (Eric Arnold Anderson)
Path: jethro.Corp.Sun.COM!news2me.EBay.Sun.COM!venus.sun.com!cs.utexas.edu!howland.erols.net!news.sprintlink.net!news-peer.sprintlink.net!uunet!in1.uu.net!192.108.254.3!news.teleport.com!not-for-mail
Newsgroups: comp.lang.perl.announce,comp.lang.perl.misc
Subject: Patch to add threads to Perl5.003
Followup-To: comp.lang.perl.misc
Date: 3 Feb 1997 02:33:26 GMT
Organization: University of California, Berkeley
Lines: 30
Sender: news-merlyn@gadget.cscaper.com
Approved: merlyn@stonehenge.com (comp.lang.perl.announce)
Message-ID: <5d3ipm$cpn$1@nadine.teleport.com>
NNTP-Posting-Host: gadget.cscaper.com
Keywords: Perl, Threads
X-Disclaimer: The "Approved" header verifies header information for article transmission and does not imply approval of content.
Xref: jethro.Corp.Sun.COM comp.lang.perl.announce:544 comp.lang.perl.misc:63125
I've created a patch that adds threads to Perl5.003; since this
requires that the interpreter and any extensions are recompiled, and
since it hasn't been extensively tested, I haven't submitted it yet to
CPAN, and am just making it available from a web page. The web page
is: <http://www.cs.berkeley.edu/~eanders/thrperl/>; since we've been
having some trouble with file servers, you may also try the reference
<http://now.cs.berkeley.edu/~eanders/thrperl/>. The release notes
from the patch are included below.
-Eric
Release Notes: This patch file adds threading to perl5.003; it creates
threading V0.2 Two modifications need to be made to config.sh files
from the ones used to build the normal version of perl. 1)
-DWITH_THREADING needs to be added to the ccflags= line in config.sh;
2) Thread needs to be added to the dynamic_ext and extensions liens in
config.sh. ***IMPORTANT*** Threading turns on the multiplicity option
in the interpreter. This means that threaded perl is incompatible
with any extensions you may have already compiled (they have to be
recompiled) Furthermore, threading produces some slight performance
hit when threading is turned off, and a more substantial (but as yet
unquantified) performance hit when you use threads. The reasons are
documented in the Threads manpage. This patch file can be applied by
cd'ing into a perl5.003 directory and typing patch -p1 <patch_file_name
--
**************************************************
1996 is the Year of the Rat; people born in the Year of
the Rat are smart and diligent, previous years were
1984,1972, ...
------------------------------
Date: 23 Jun 1997 09:55:30 GMT
From: "Chris Wareham" <chriswareham@dial.pipex.com>
Subject: Trouble using Win32::Registry to edit NT environment
Message-Id: <01bc7fbb$fcc67e10$038182c1@TI_SGML_SUNDOG>
I have recently written a Perl script to install the horrendously complex
emTeX system on Windows NT. The last hurdle I have to overcome is adding
the Environment variables, and appending to the path.
Ive tried to use the Win32::Registry module to add subkeys to the
Environment key in HKEY_CURRENT_USER, and add to the PATH subkey. The
example in the documentation doesn't seem to work, complaining about an
attempted modification to a read-only value at various lines in the
Registry.pm itself. It even does this if I attempt to just read the values
into an array using the GetKeys function (or is it one of them there
new-fangled OOP methods?).
Has anyone successfully used this module to edit the Environment on an NT
machine? I can't resort to editing them by hand, as the whole point of the
script was to completely automate the installation.
Chris
chriswareham@dial.pipex.com
Product Application, Development and Research
Technical Indexes Ltd
------------------------------
Date: Mon, 23 Jun 1997 08:48:57 GMT
From: Bogdan.Sumni@x42.com (Bogdan Sumni)
Subject: Re: Why do i get text/octet-stream download when i try to create html document with perl?
Message-Id: <33b23737.356136427@news1.telenordia.se>
Jonas Thvrnvall <labah@algonet.se> wrote:
>I'm creating a simple guestbook that work excellent on my pc with http
>server, but when i try to configure it for my hompage server at
>www.algonet.se i dont get any documents, netscape just ask me i wan't to
>save the text/octet-stream. Can someone tell me how to fix this, or what
>the problem is?
>This is the string i use in perl to create the document
>print "<!--Content-type: text/html-->\n\n";
>
>Jonas T
be sure to check out
http://www.algonet.se/support/web/hur_gora_en_gastbok.cgi
Algonet are also using the cgiwrap-program. Do you use this in your
html-file?
print "Content-type: text/html\n\n";
is the right way. Why do you use the comment? Is it because if you
don't, you see the text? Then you're lost. If your print
"Content-type" gets through into the very document to the browser,
then something is wrong with the cgi-setup. Please refer to the
httpd-docs.
/bog
------------------------------
Date: Tue, 24 Jun 1997 09:12:52 -0400
From: "James J. Heck" <jheck@merck.com>
Subject: XSubpp man page?
Message-Id: <33AFC7D4.41C6@merck.com>
Is there an xsubpp man page? I am haveing problems compiling my xsub on
an SGI Irix 6.2 machine. I found the CCFLAGS options to add "-64" to
it, however, something still seems to be compiled as 32 bit code. I
think it has to do with the XSubpp stuff.
Any help is greatly appreiciated. As always, pls respond to
jheck@acm.org for any mailed responses.
TIA,
James
--------------------
James J. Heck
jheck@acm.org
http://www.bucknell.edu/~jheck
The contents of this message express only the sender's opinion.
This message does not necessarily reflect the policy or views of
my employer, Merck & Co., Inc. All responsibility for the statements
made in this Usenet posting resides solely and completely with the
sender.
------------------------------
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 654
*************************************