[10423] in Perl-Users-Digest
Perl-Users Digest, Issue: 4016 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 20 05:02:57 1998
Date: Tue, 20 Oct 98 02:00:17 -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, 20 Oct 1998 Volume: 8 Number: 4016
Today's topics:
Re: Can someone help me with the following for a friend (Ronald J Kimball)
Re: CGI problem...probably a simple answer. <tupshin@tupshin.com>
Converting UNIX dates to times? <sean@vcommunities.com>
Re: Converting UNIX dates to times? (Martien Verbruggen)
Re: CPAN and Netscape 4.5/Linux (Per Steinar Iversen)
Filehandle(?) for read and write <mw@workmail.com>
Re: Heinous - Nothing! (Ronald J Kimball)
Library for modem IO routines? <sink@cbl.umces.edu>
Searching for long lines in a huge text file. <psdspss@execpc.com>
Re: Searching for long lines in a huge text file. (Martien Verbruggen)
Sending Word-Docs directly to the Browser via CGI <tanja.riedel.tr3@bayer-ag.de>
Re: Sending Word-Docs directly to the Browser via CGI <tupshin@tupshin.com>
Shell/Telnet Server for win32 <@bigpond.com>
Re: Subroutines in Substitutions: Possible? <zenin@bawdycaste.org>
Re: Subroutines in Substitutions: Possible? (Larry Rosler)
Re: Subroutines in Substitutions: Possible? (Sam Holden)
trouble with sub <cousin@ensam.inra.fr>
Web Developer? <gretchen@frontiersystems.com>
Re: What isn't Perl good for? (Ilya Zakharevich)
Re: What isn't Perl good for? <fsg@ultranet.com>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 19 Oct 1998 23:59:25 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Can someone help me with the following for a friend I know?
Message-Id: <1dh665v.pd353prfr6qN@bay1-269.quincy.ziplink.net>
<richardhutnik@hotmail.com> wrote:
> I had a friend send me the following request via email, for a PERL class they
> are taking. I was wondering if you could help me out here. Thanks.
There's only one thing worse than coming to clpm to beg for help with
your Perl homework.
And that is coming to clpm to beg for help with someone else's Perl
homework.
:-P
--
_ / ' _ / - 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: 19 Oct 1998 23:20:23 PDT
From: "Tupshin Harper" <tupshin@tupshin.com>
Subject: Re: CGI problem...probably a simple answer.
Message-Id: <70ha37$p6c@chronicle.concentric.net>
Or alternatively, enclose what you're spitting out in a <PRE></PRE> tag
which will force the browser to display it as a monospaced font and treat \n
as line breaks.
-Tupshin Harper
-Programmer/Network Administrator
-Studio Verso
Kevin Falcone wrote in message ...
>Well, this isn't a perl problem, its really an HTML program, instead
>of a newline, you need to be printing a <br> which your browser knows
>to interpret as a newline
>-kevin
>
>On Tue, 20 Oct 1998, piercew@netscape.net <piercew@netscape.net> wrote:
>>I created the following as a way to parse a firewall log file. For some
>>reason I can't get it to place each item on a new line:
>>
>>#begin file
>>#!/usr/bin/perl
>>
>>print "Content-type: text/html\n\n";
>>print "<HTML>";
>>print "<BODY>";
>>
>>open (fwfile, "fw2.log") || die "Couldn't open file: $!";
>>
>>@data = split(/ /, <fwfile>);
>>foreach $line (@data) {
>> print "$item\n";
>> }
>>
>>close (fwfile);
>>print "</BODY>";
>>print "</HTML>";
>>
>>
>> I've tried placing the carrage return on a separate line and it doesn't
work
>>either. I know the data is being broken up, because I can print something
>>between each item.
>>
>> Thanks for any assistance that can be provided,
>>
>--
>Kevin Falcone
>kevinfal@seas.upenn.edu
>
>If a cow laughed, would milk come out her nose?
------------------------------
Date: Tue, 20 Oct 1998 04:40:58 GMT
From: "Sean Taylor" <sean@vcommunities.com>
Subject: Converting UNIX dates to times?
Message-Id: <uvUW1.924$0h.1685544@news.rdc1.wa.home.com>
Is there any easy way to convert the date string returned by the "date"
shell command into the standard "time" - i.e. seconds since 1970. Thanks in
advance.
-Sean Taylor
------------------------------
Date: Tue, 20 Oct 1998 04:54:52 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Converting UNIX dates to times?
Message-Id: <wIUW1.52$6a4.288040@nsw.nnrp.telstra.net>
In article <uvUW1.924$0h.1685544@news.rdc1.wa.home.com>,
"Sean Taylor" <sean@vcommunities.com> writes:
>
> Is there any easy way to convert the date string returned by the "date"
> shell command into the standard "time" - i.e. seconds since 1970. Thanks in
> advance.
Why would you want to do that? Use perl's builtin time() to get that
information.
# perldoc -f time
There is no 'string returned by the date command' as such. One has to
specify the format.
If what you really mean is: "How do i convert some odd textual
representation of a date and time into the number of second since
epoch?', that is another issue:
# perldoc perlfaq4
/How can I take a string and turn it into epoch seconds?
# perl -MCPAN -e shell
cpan> i /date/
[snip]
Module Date::Manip (SBECK/DateManip-5.33.tar.gz)
Module Date::Parse (GBARR/TimeDate-1.08.tar.gz)
[snip]
cpan> look date::Parse
[...]
cpan> install Date::Parse
cpan> quit
# perldoc Date::Parse
NAME
Date::Parse - Parse date strings into time values
SYNOPSIS
use Date::Parse;
$time = str2time($date);
($ss,$mm,$hh,$day,$month,$year,$zone) = strptime($date);
DESCRIPTION
Date::Parse provides two routines for parsing date strings
into time values.
I trust that next time you will be able to do this by yourself
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | You can't have everything, where would
Commercial Dynamics Pty. Ltd. | you put it?
NSW, Australia |
------------------------------
Date: 20 Oct 1998 08:02:29 GMT
From: PerSteinar.Iversen@adm.hioslo.no (Per Steinar Iversen)
Subject: Re: CPAN and Netscape 4.5/Linux
Message-Id: <slrn72ogsp.ath.PerSteinar.Iversen@elbonia.p52.hioslo.no>
On Mon, 19 Oct 1998 18:20:20 GMT,
droby@copyright.com <droby@copyright.com> wrote:
>In article <slrn72jjdo.99t.PerSteinar.Iversen@elbonia.p52.hioslo.no>,
> PerSteinar.Iversen@adm.hioslo.no wrote:
>> Does anybody else have this problem with CPAN and
>> Netscape 4.5/Linux? The HTML pages that CPAN
>> keeps on ftp-servers are displayed as text,
>> not as HMTL, not very useful. This applies to
>> the Linux version of Netscape 4.5, the Windows
>> version does this OK.
>>
>> For example, this page is displayed as text
>> in my Linux netscape:
>>
>> ftp://sunsite.uio.no/pub/languages/perl/CPAN/README.html
>>
>> Any ideas how to fix this?
>>
>> -psi
>>
>
>Perhaps you should contact Netscape technical support. This does not seem to
>be a Perl problem.
>
>As far as I can tell, it's also not a CPAN problem, or a Netscape 4.5
>problem, as the page you cite above works fine for me using RedHat 5.0 Linux
>(2.0.32) and Netscape 4.5.
I use 2.1.125, RH 5.1 with all updates installed. Even after a
complete re-install (removing ~/.netscape and the whole netscape
tree first) this behaviour persists.
It *is* a CPAN issue though: The web is designed for HTTP, not
FTP. FTP does not support the MIME headers that makes the web
so nice. So, in fact a browser can do whatever it want with
.html files found on an FTP server, displaying them as text
is a reasonable default. I wish CPAN could be bothered to
use HTTP, much nicer for caching too.
-psi
------------------------------
Date: Tue, 20 Oct 1998 09:01:52 +0100
From: Michael Reutter <mw@workmail.com>
Subject: Filehandle(?) for read and write
Message-Id: <362C4370.B00133DC@workmail.com>
hi everybody!
is there a way (and i'm optimistic there is one in perl) to write
something to a pipe and get the result?
for example:
i want to pipe to the sort program of the shell and read its result:
(i know, that i can do a sort in perl too - but this is only an
example!!)
with temporary files i can do this:
$x="3\n1\n5\n2\n4\n";
open(OUT,">$$");
print OUT $x;
close(OUT);
$result=`sort<$$`;
but can i do this *without* creating a temporary file???
bye
michael
------------------------------
Date: Mon, 19 Oct 1998 23:59:26 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Heinous - Nothing!
Message-Id: <1dh66dj.10y94at1lj9e0wN@bay1-269.quincy.ziplink.net>
J T-J <jtjohnston@erase.courrier.usherb.ca> wrote:
> open(HTMLFILE,"<$datafile");
> What heinous little thing have I forgotten?
You forgot to check the result of the open(). How do you know it
worked?
open(HTMLFILE,"<$datafile") or die "Can't open $datafile: $!\n";
--
_ / ' _ / - 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: 19 Oct 1998 14:28:22 -0400
From: Robert Sink <sink@cbl.umces.edu>
Subject: Library for modem IO routines?
Message-Id: <otzpas2ypl.fsf@tempermental.cbl.umces.edu>
I have looked on CPAN for a module that had been specifically written
to deal with IO to and from modems.
Essentially what I want to do is do some diagnostic & resetting of
modems on a modem pool with some kind of intelligence to measure
RTS/CTS, CD and so on and so forth.
If anyone has any suggestions on this, I'd be grateful to hear them.
--
Robert Sink - Asst. Dept. Head - Computer/Network Services
Univ. of Maryland Chesapeake Biological Laboratory - Solomons, MD.
[o] 410/326-7306
------------------------------
Date: Mon, 19 Oct 1998 23:52:41 -0500
From: Deva Seetharam <psdspss@execpc.com>
Subject: Searching for long lines in a huge text file.
Message-Id: <70h49n$mgh@newsops.execpc.com>
A process gets a huge(approx 10MB) text file generated by a Mainframe
job.
We need to process only the sentences longer than 15 words.
Sentences are delimited by period(.).
File is a free form text; so, it may contain any valid strings, phone
numbers,
units, and stuff.
What is the efficient way to do this ?
Deva
------------------------------
Date: Tue, 20 Oct 1998 05:05:36 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Searching for long lines in a huge text file.
Message-Id: <ASUW1.54$6a4.288040@nsw.nnrp.telstra.net>
In article <70h49n$mgh@newsops.execpc.com>,
Deva Seetharam <psdspss@execpc.com> writes:
> A process gets a huge(approx 10MB) text file generated by a Mainframe
> job.
> We need to process only the sentences longer than 15 words.
You are not really giving enough information. Terms like 'sentence'
and 'word' are in normal speech much too fuzzy. You will really need
to be more precise to get a precise answer.
> Sentences are delimited by period(.).
But, are there any other full stops (periods) in the text?
> File is a free form text; so, it may contain any valid strings, phone
> numbers, units, and stuff.
Does this include dots? There was a discussion about this a few weeks
ago in this very group. It is not trivial to recognise a 'sentence'.
it would help tremendously if your sentence was always ended by a dot
followed by two spaces, or a dot followed by a newline, but only if
those combinations of characters do not appear anywhere where a
sentence does not end.
Then we have the problem of what a 'word' is. Is a word a thing made
up of only \w characters? Is a phone number a word? If so, can a phone
number contain non-word characters, whitespace, minus? Is a word
simply a string of non-whitespace characters?
If we ignore possible dots inside sentences and we just define a word
as a string of non-whitespace characters:
set $/ to '.'
open the file for reading, say on file handle INFILE
while (<INFILE>)
{
split the line (in $_) on possibly multipl whitespace characters (\s)
assume that each item split out is a word, and count them.
do something if it's more than 15
}
# perldoc perlvar
# perldoc perlre
Of course, if your definition of sentence and word change, some of
these might become much more complicated, or even impossible. It all
depends on how your input looks, and how precise you want to be.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | A Freudian slip is when you say one
Commercial Dynamics Pty. Ltd. | thing but mean your mother.
NSW, Australia |
------------------------------
Date: Tue, 20 Oct 1998 08:20:37 +0200
From: Tanja Riedel <tanja.riedel.tr3@bayer-ag.de>
Subject: Sending Word-Docs directly to the Browser via CGI
Message-Id: <362C2BB5.BFF71CFB@bayer-ag.de>
Hello!
perhaps someone can help me, I got stuck with a CGI-script, for a
problem, which looked so simple at first glance...
I am using Perl 5.003 on VMS V6.2-1H3 and I would like to send a
Word_document directly to the browser (cause it is not in a subdirectory
of the web-root, so that I can4t use a link).
I use the following code (for tests, "wordneu1.doc" is in the same
directory as the perl script now)
open(FROM, "wordneu1.doc");
binmode FROM;
print <<END_of_Multiline_Text;
Content-type: application/msword
END_of_Multiline_Text
use FileHandle;
STDOUT->autoflush(1);
while (read FROM, $buf, 1024)
{
print $buf;
};
[EOB]
"application/msword" names a Plugin, which works when I type the URL of
the source document "wordneu1.doc" directly in the browser. When I use
the scipt I can see that the content of the document is send. It looks
fine, but neither word nor the plugin are able to open the file (invalid
file format).
When I use a destination file instead of STDOUT and type the URL of the
created file in the browser everything works, so it must be the STDOUT
(format?) causing the problem. I used autoflush, but no effect.
Can please someone help me...???
Thanks a lot in advance!
Tanja,
Leverkusen, Germany.
E-Mail: tanja.riedel.tr3@bayer-ag.de
------------------------------
Date: 20 Oct 1998 00:28:25 PDT
From: "Tupshin Harper" <tupshin@tupshin.com>
Subject: Re: Sending Word-Docs directly to the Browser via CGI
Message-Id: <70he2p$e0u@journal.concentric.net>
If you're not doing anything to the file except serving it up, why wouldn't
you just want to redirect them to the file(i.e. have your CGI script spit
out an HTTP redirect or an HTML meta tag refresh to the URL that you want to
send them to? Then you just need to make sure that your web server has the
correct mime type for .doc files.
-Tupshin Harper
-Programmer/Network Administrator
-Studio Verso
Tanja Riedel wrote in message <362C2BB5.BFF71CFB@bayer-ag.de>...
>Hello!
>
>perhaps someone can help me, I got stuck with a CGI-script, for a
>problem, which looked so simple at first glance...
>
>I am using Perl 5.003 on VMS V6.2-1H3 and I would like to send a
>Word_document directly to the browser (cause it is not in a subdirectory
>of the web-root, so that I can4t use a link).
>
>I use the following code (for tests, "wordneu1.doc" is in the same
>directory as the perl script now)
>
> open(FROM, "wordneu1.doc");
> binmode FROM;
> print <<END_of_Multiline_Text;
> Content-type: application/msword
>
> END_of_Multiline_Text
>
> use FileHandle;
> STDOUT->autoflush(1);
>
> while (read FROM, $buf, 1024)
> {
> print $buf;
> };
> [EOB]
>
>"application/msword" names a Plugin, which works when I type the URL of
>the source document "wordneu1.doc" directly in the browser. When I use
>the scipt I can see that the content of the document is send. It looks
>fine, but neither word nor the plugin are able to open the file (invalid
>file format).
>
>When I use a destination file instead of STDOUT and type the URL of the
>created file in the browser everything works, so it must be the STDOUT
>(format?) causing the problem. I used autoflush, but no effect.
>
>Can please someone help me...???
>
>Thanks a lot in advance!
>
>Tanja,
>Leverkusen, Germany.
>
>E-Mail: tanja.riedel.tr3@bayer-ag.de
>
------------------------------
Date: 20 Oct 1998 08:17:37 GMT
From: "Chris Berkhout" <@bigpond.com>
Subject: Shell/Telnet Server for win32
Message-Id: <01bdfc03$4eccfbc0$bd0ac282@default>
I've been working on a script that allows people to get a dos
shell on a remote machine.
It should work over both tcp/ip or modem, but i havent had the
modem side working yet.
The main drawback is that no program that requires user input
can be run. If for example you run edit.com on a remote machine,
it will be waiting forever, for edit to finish and give some output.
The othe major thing is that only one user can connect at a time.
Also users only recieve output that is printed to STDOUT.
Basicall you can look at and test files, run scripts, perhaps
arrange for files to be transfered, etc..etc..
It is quite limited compared to a unix shell, but so is windows.
Have a play with it and tell me what you think
(ashtar@cranny.schnet.edu.au).
Don't forget to get rid of my password.
############################################################################
#
# Allows people to get a shell (command.com) on windows machines
07/10/1998
############################################################################
#
$connection = 1; # for tcp/ip connections ($localport is local port)
#$connection = 2; # for modem connections ($localport is serial port)
#$connection = 3; # for null modem connections ($localport is serial port)
$localport = 23;
$initstring = "AT Z S0=2 \n"; # modem init string (if modem exists)
$passwd = 'ekW2HoD61rSsA'; # encrypted password ('*' for no password)
$message = '->> Welcome to my Computer <<-'."\r\n"; # greeting message
$passask = "\r\npassword: "; # password request
#---------------------------------------------------------------------------
-
# tcp/ip connect routine
#---------------------------------------------------------------------------
-
use Socket;
sub tcpipconnect {
# get socket
if (socket(MAINSOCK, AF_INET, SOCK_STREAM, (getprotobyname('tcp'))[2]))
{
print "Created tcp socket...\n" }
else { die "Error creating tcp socket: $!\n" }
# bind socket
if (bind(MAINSOCK, pack('S n a4 x8', AF_INET, $localport,
"\0\0\0\0"))){
print "Tcp bind succeeded...\n" }
else { die "Error binding tcp socket: $!\n" }
# one client at a time
listen(MAINSOCK, 1) || die "Error while listen()ing: $!\n";
# turn on autoflushing
select(MAINSOCK);
$| = 1;
select(STDOUT);
# get a connection
accept(PORT, MAINSOCK) || die "Error accepting tcp connection: $!\n";
print "Accepted connection...\n";
# turn on autoflushing
select(PORT);
$| = 1;
select(STDOUT);
}
#---------------------------------------------------------------------------
-
# modem connect routines
#---------------------------------------------------------------------------
-
sub modemconnect {
open(PORT, "+> ${localport}") || die "Error opening COM port: $!\n";
print PORT '+++';
sleep 3;
if (<PORT> !~ /^OK/) { die "COM port error: $!\n" }
else { print PORT $initstring }
if (<PORT> !~ /^CONNECT/) { die "COM port error: $!\n" }
}
sub nulmodemconnect {
open(PORT, "+>$ARGV[1]") || die "Error opening COM port: $!\n";
}
#---------------------------------------------------------------------------
-
# get line routine
#---------------------------------------------------------------------------
-
sub getline {
$line = '';
while (substr($line, -1, 1) ne "\n") {
unless (read(PORT, $line, 1, length $line)) { return 0 }
print PORT substr($line, -1, 1);
}
return $line;
}
#===========================================================================
=
# main
#===========================================================================
=
for(;;) {
# make connection
if ($connection == 1) { tcpipconnect() }
elsif ($connection == 2) { modemconnect() }
elsif ($connection == 3) { nulmodemconnect() }
$screensize = 24;
# check password
print PORT $message;
if ($passwd eq "*") { $passok = 1 }
else { $passok = 0 }
until ($passok == 1) {
print PORT $passask;
if ($password = <PORT>) {
chomp $password;
if (crypt($password, substr($passwd,0,2)) eq $passwd)
{ $passok = 1 }
}
else { last }
}
# do stuff
if ($passok) {
chomp($prompt = `cd`);
print PORT "\r\n\r\n".$prompt.">";
while($command = &getline) {
chomp $command;
while ($command =~ s/.\010//) { undef };
if ($command =~ /^cd (.+)/) { chop($dir = $1); chdir $dir }
elsif ($command =~ /^exit/) { last }
elsif ($command =~ /^quit/) { last }
elsif ($command =~ /^logout/) { last }
else {
chomp(@output = `$command`);
foreach (@output) { $_ = $_."\r\n" }
print PORT $output[0];
for($counter = 1;$counter <= $#output;$counter++) {
if (($counter % $screensize) == 0) {
print PORT "---press enter---";
chomp($cmd = &getline);
if ($cmd =~ /^a/) {
print PORT @output[$counter..$#output];
$counter = ++$#output;
}
if ($cmd =~ /^q/) { $counter = ++$#output }
if ($cmd =~ /^s/) { $counter = ++$#output }
if ($cmd =~ /^(\d+)/) { $screensize = $1-1 }
}
print PORT $output[$counter];
}
}
chomp($prompt = `cd`);
print PORT $prompt.">";
}
}
}
############################################################################
#
------------------------------
Date: 20 Oct 98 04:29:21 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Subroutines in Substitutions: Possible?
Message-Id: <908857831.160028@thrush.omix.com>
[posted & mailed]
dmulholl@cs.indiana.edu wrote:
: I just hit a problem that I can solve readily in lex but not nicely
: in perl.
>snip<
: s/(\w) ([0-9]+)/\1 chr(\2)/g;
: Where "chr" is Perl's built in function.
So close, so very close:
s/(\w) ([0-9]+)/"$1 " . chr($2)/eg;
perldoc perlre
--
-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: Mon, 19 Oct 1998 21:57:10 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Subroutines in Substitutions: Possible?
Message-Id: <MPG.1095b8045a345f419898cb@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <70h0o0$6l0$1@nnrp1.dejanews.com> on Tue, 20 Oct 1998
03:40:48 GMT, dmulholl@cs.indiana.edu <dmulholl@cs.indiana.edu> says...
...
> s/(\w) ([0-9]+)/\1 chr(\2)/g;
>
> Where "chr" is Perl's built in function. This isn't working (nor did
> &chr or \&chr my next guesses), is there a way to escape subroutines
> in substitutions to do this. If not, tragic :( , what is the most
> elegant way out of the problem?
s/(\w )(\d+)/$1 . chr($2)/ge;
If your perl is 5.005, you can use look-behind:
s/(?<=\w )(\d+)/chr($1)/ge;
Elegant enough?
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 20 Oct 1998 06:39:31 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Subroutines in Substitutions: Possible?
Message-Id: <slrn72oc13.70q.sholden@pgrad.cs.usyd.edu.au>
On Tue, 20 Oct 1998 03:40:48 GMT, dmulholl@cs.indiana.edu
<dmulholl@cs.indiana.edu> wrote:
>
>
>Greetings All,
>
> I just hit a problem that I can solve readily in lex but not nicely
>in perl. I would like to write a filter that detected numbers after
>words, then converted the number (which I know won't exceed 3 digits)
>to an ascii character. Here is a simplified version of what seemed
>like the nice way to go about it:
>
>
> s/(\w) ([0-9]+)/\1 chr(\2)/g;
>
>
>Where "chr" is Perl's built in function. This isn't working (nor did
>&chr or \&chr my next guesses), is there a way to escape subroutines
>in substitutions to do this. If not, tragic :( , what is the most
>elegant way out of the problem?
The elegant way is to read the documentation that came with perl
especially the part about s// in perlop...
Also $N is much nicer than \N since it makes sense for N>9.
--
Sam
Remember that the P in Perl stands for Practical. The P in Python
doesn't seem to stand for anything.
--Randal Schwartz in <8cemsabtef.fsf@gadget.cscaper.com>
------------------------------
Date: Tue, 20 Oct 1998 08:00:46 +0000
From: Xavier Cousin <cousin@ensam.inra.fr>
Subject: trouble with sub
Message-Id: <362C432E.56FC8466@ensam.inra.fr>
I send this message some days ago but didn't receive any answer, may be
because the "subject" was not attractive enough : i post it again with a
new subject...
Don't you think this puzzling ?
Hello, first of all sorry for the subject, it's sometimes hard to be
precise in some words...
Here is my problem in the following script "writing 2" allow printingof
the result while "writing 1" does not. I can't find any reason.
Somedbody could give me some indications ?
script :
NB1 I use writing 1 OR 2
NB2 In the original script, there is several routines to call
open (IN,essai_automat);
while (<IN>){
if ($_ !~ /^\"/){
$une_table = "non";
$c=0;
}
if ($une_table eq "oui"){
$passe = $_;
&$rout($passe); #writing 1
&distribution_des_champs1($passe); #writing 2
}
if ($_ =~ /acedb\>/){
$une_table = "oui";
$table ++;
$rout="distribution_des_champs".$table;
&$rout($premiere_ligne); #writing 1
&distribution_des_champs1($premiere_ligne); #writing 2
}
}
foreach $key (sort keys %Molec){ # OK with writing 2 but
print STDOUT "Molec $d $key\n"; # not with writing 1 in case
} # 1 %Molec seams to not exist
sub distribution_des_champs1 {
my ($entree) = @_;
($molec,$kin)=split /\t/,$entree;
$Molec{$molec} = $molec;
$kin{$molec} .= "$kin#";
}
Thanks for your answer(s).
Xavier
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Xavier Cousin cousin@ensam.inra.fr
INRA - DCC tel. (33) 04 99 61 28 14
2, place Pierre Viala fax (33) 04 67 54 56 94
34060 Montpellier Cedex 1
ESTHER URL http://www.ensam.inra.fr/cholinesterase/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Xavier Cousin cousin@ensam.inra.fr
INRA - DCC tel. (33) 04 99 61 28 14
2, place Pierre Viala fax (33) 04 67 54 56 94
34060 Montpellier Cedex 1
ESTHER URL http://www.ensam.inra.fr/cholinesterase/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: Mon, 19 Oct 1998 16:56:22 EDT
From: Gretchen Frantz <gretchen@frontiersystems.com>
Subject: Web Developer?
Message-Id: <70g91m$hil$1@earth.superlink.net>
Need Web Developer with Perl CGI experience. Email me if you have any
leads. The project is a 3 month right to to hire located in
Connecticut.
Thanks,
Gretchen
------------------------------
Date: 20 Oct 1998 04:50:20 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: What isn't Perl good for?
Message-Id: <70h4qc$8ck$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Tom Christiansen
<tchrist@mox.perl.com>],
who wrote in article <70gv7s$7h4$1@csnews.cs.colorado.edu>:
> Just as
> the crunchers of yesteryear ripped out core routines and hand-crafted
> these with tedious care in asm, so too do we use XS today to turbo-charge
> time-critical functions. Check out the chimeric composition of the
> compiler's various backend code generators for another approach to this
> kind of thing. I believe that we'll see plenty of that in the future.
> Heck, we see a lot of it now.
And nobody said that those XSUBs will not use asm code to do their
dirty works. Witness Math::Pari - Perl module for doing math as it
supposed to be done.
Though dynamic loading with asm code present looks like black magic to
me... Any expert on PIC assembler? Sparc, hppa, alpha, x86?
Ilya
------------------------------
Date: Mon, 19 Oct 1998 22:55:19 -0700
From: "Felix S. Gallo" <fsg@ultranet.com>
Subject: Re: What isn't Perl good for?
Message-Id: <70h8i7$5ru@enews2.newsguy.com>
Tom writes:
> [ the long story ]
>Now that you've read the somewhat long story, the short story is that
>using Perl is a good first stab at just about everything, and more often
>than you would imagine, a perfectly adequate last stab, too.
Unless it involves graphics, speed, threading, timing,
low level OS APIs, bare metal access, and, some might
credibly suggest, C, C++, OOP, or networking.
That last bit's said with half a smiley. XS makes sense to
about 90 people in the world. XS-plus-C++ makes sense to
about 5. OO-Perl is a good first draft. Networking is starting
to look a little embarrassing and dated. All "can be used",
none, I respectfully suggest, "very well".
Felix
------------------------------
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 4016
**************************************