[7519] in Perl-Users-Digest
Perl-Users Digest, Issue: 1146 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 8 16:07:18 1997
Date: Wed, 8 Oct 97 13:00:23 -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 Wed, 8 Oct 1997 Volume: 8 Number: 1146
Today's topics:
Re: "19971008" and (....)(..) <Matthew.Rice@ftlsol.com>
#!/usr/bin/perl for NT ??? <matthew.kravitz@systecinc.com>
64,000 Question unlisted@internet.com
Re: 64,000 Question (Mike Stok)
Re: [Q - newbie] Sockets and bi-directional communicati <kermit@ticnet.com>
Re: Best way to extract array elements, modify, store r (Mike Stok)
CGI and ACCESS <danh@software.org>
Re: DATABASING IN PERL (HELP!) <kermit@ticnet.com>
Re: Forcing numeric interpretation? samdie@ibm.net
Re: Forcing numeric interpretation? (Mike Stok)
Help: Form Input wo/submit or image src <cstewart@flash.net>
Re: libwww for win32 S.O.S <camerond@mail.uca.edu>
Re: MetaCrawler scripting (Faust Gertz)
Re: Module for dealing with INN spools. <usenet-tag@qz.little-neck.ny.us>
Passing Command Lines From Perl in NT <matthew.kravitz@systecinc.com>
Re: Pattern matching with variables <ptimmins@netserv.unmc.edu>
Re: Pattern matching with variables <usenet-tag@qz.little-neck.ny.us>
Re: Perl for Win95 (Michael Ng)
Re: printf character. <Matthew.Rice@ftlsol.com>
Problem with script in LLama book (Andrew Martin Adrian Cater [Andy])
Re: Problem with script in LLama book (Mike Stok)
Process Control for NT/ Perl <matthew.kravitz@systecinc.com>
Re: system() won't run shell script correctly (dave)
Re: Text formatting question <yash@teczar.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 08 Oct 1997 13:56:32 -0400
From: Matthew Rice <Matthew.Rice@ftlsol.com>
Subject: Re: "19971008" and (....)(..)
Message-Id: <m390w4jfzj.fsf@hudson.ftlsol.com>
ckc@dmi.min.dk (Casper K. Clausen) writes:
> First of all, you forgot something important, namely slashes:
>
> "19971008" =~ /(....)(..)/
>
> However, your matches are assigned to $1 and
> $2, not returned as values.
Strange,
($year,$month) = ("19971008" =~ /(....)(..)/);
works for me and the perlop man page (look under m/PATTERN/gimosx) states:
If used in a context that requires a list value, a
pattern match returns a list consisting of the
subexpressions matched by the parentheses in the
pattern, i.e., ($1, $2, $3...)
--
Matthew Rice e-mail: matthew.rice@ftlsol.com
------------------------------
Date: 8 Oct 1997 19:39:49 GMT
From: "Authorized User" <matthew.kravitz@systecinc.com>
Subject: #!/usr/bin/perl for NT ???
Message-Id: <01bcd421$b71ef580$7cfce59b@matthewk.systecinc.com>
i know how to declare a perl script in unix, but how is this accomplished
in NT?
i wanted to avoid typing 'perl <script_name> .
thanks,
matthew e. kravitz
------------------------------
Date: Wed, 08 Oct 1997 19:30:29 GMT
From: unlisted@internet.com
Subject: 64,000 Question
Message-Id: <343bdec4.58695784@news.chickasaw.com>
Is there a way (easy way) using printf to have numbers printed out
with a ',' where it is supposed to be? I am doing some math
calculations and some of the results are like 64000.00456. I am using
the &.2f to change that at 64000.00 but would like to have the comma's
in there like 64,000.00 is there a way this can be done using printf?
Thanks in advance.
------------------------------
Date: 8 Oct 1997 19:54:01 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: 64,000 Question
Message-Id: <61gocp$ssc@news-central.tiac.net>
In article <343bdec4.58695784@news.chickasaw.com>,
<unlisted@internet.com> wrote:
>Is there a way (easy way) using printf to have numbers printed out
>with a ',' where it is supposed to be? I am doing some math
>calculations and some of the results are like 64000.00456. I am using
>the &.2f to change that at 64000.00 but would like to have the comma's
>in there like 64,000.00 is there a way this can be done using printf?
Not using printf directly, but the FAQ (frequently asked questions) which
is at http://www.perl.com/ and can be found on any comprehensive perl
archive network (CPAN) site (the master is at ftp.funet.fi under
/pub/languages/perl/CPAN and the FAQs section is in the doc directory)
suggests:
How can I output my numbers with commas added?
This one will do it for you:
sub commify {
local $_ = shift;
1 while s/^(-?\d+)(\d{3})/$1,$2/;
return $_;
}
$n = 23659019423.2331;
print "GOT: ", commify($n), "\n";
GOT: 23,659,019,423.2331
You can't just:
s/^(-?\d+)(\d{3})/$1,$2/g;
because you have to put the comma in and then recalculate your position.
Note that recent distributions of perl have included the FAQ as part of
the dirstibution, if you have it then
perldoc perlfaq
should get you the FAQ index. It is well worth looking through the faq
every now and again as lots of experience and time has gone into it.
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: Wed, 08 Oct 1997 13:17:26 -0500
From: Kermit Tensmeyer <kermit@ticnet.com>
To: "J. Gregory Wright" <greg_wright@cmsinc.com>
Subject: Re: [Q - newbie] Sockets and bi-directional communication
Message-Id: <343BCE36.B66CF52D@ticnet.com>
J. Gregory Wright wrote:
>
> J. Gregory Wright <greg_wright@smsinc.com> wrote in article
> <01bcd27a$d1ac3be0$990d10ac@gregw-pc.cmsinc.com>...
> > J. Gregory Wright <greg_wright@smsinc.com> wrote in article
> > <01bcd272$7d3596e0$990d10ac@gregw-pc.cmsinc.com>...
> >
> > [ snip ]
> >
> > > My experience with socket programs in 'C' indicates that this should
> > > work, but both the client and the server hang (and I never see the output
> > > from the 'logmsg "Received..." line in the server).
> First of all, my apologies to anyone who responded to my post via E-mail -
> typos in newsreader profiles can cause problems with reply-to-addresses.
> The sole exception to this apology is Graham Barr <gbarr@ti.com>,
> whose response was forwarded to me by the folks at "smsinc.com":
<softly> the author of the package that deals with sockets
of the form Net::XX
where XX is IO, FTP, Telnet and a whole host of other is
Graham Barr.
In this area, he is as highly regarded as Larry Wall.
<all praise....>
>
> >Surly your experience with C code should tell you that using
> >stdio and sockets do not mix. You shold be calling sysread,
> >syswrite and using select to determine if there is any data
> >on the socket.
>
> [flame on]
> This is the kind of snotty help that gets folks on these newsgroups
> labelled as "jerks", "creeps" and "dweebs". I attempted to follow
> general rules of ettiquette by supplying as much information as
> possible, and pointed out that I was taking my examples from
> Wall's book, which *does* show using 'print SOCK' and '$var = <SOCK>'
> for I/O.
I think _you_ used the example of your knownleged of C and sockets
to initiate the request for help.
to use that form requires that an open be done on a file handle.
That particular format requires some other things be done
which were not shown in your request. None of which is
done by command line parameters but only by user written
code.
> A simple "The examples in the book are only good for
> connect-read data-disconnect" and "The standard way to do this
> is to use sysread / syswrite..." would have sufficed. Did you see
> "newbie" in the header? I did not claim to be an expert in Perl -
> I was taking an example in a well-respected book, and modify it
> to do something a little different. My posting to the newsgroup
> after sifting through web sites, FAQs and the books was an attempt
> to get an intelligent answer to my dilema, not a invitation for you
> to pump your flagging ego. Jerk.
> [flame off]
Graham Barr does not do that. In my experience, he has been most
gentle and kind, even with my rank stupid mistakes.
Is it possible that you have a first edition Perl book? (which
documents Perl 4) The IO and Net:: modules are examples of
Perl 5.
The documents (pod pages) get delievered with the source code
and are available with the standard installation. see the
sys admin (bofh)
of course if you are using the Activeware version of Perl
Nothing will work as described. ;-(
>
> At any rate, you *can* use 'print' and '<SOCK>' to do bi-directional
> I/O over a single socket connection, if you use the following code:
>
> my $oldfh = select(SOCK);
> $| = 1;
> select($oldfh);
>
> which turns on auto-flush for output operations on the pipe. It makes
> data available to the other side as soon as the output record separator
> character is encountered in the output stream. This was derived from
> the responses to the article titled "fflush".
>
> Is this the most optimal way to go about doing this? Probably not...
> but I would need some input on the second part of my question, which
> had to do with the use of the IO::Socket library:
>
> >Now one thing I have noticed from digging around in the newsgroup is
> >that most folks seem to be using the IO::Socket library, instead of the
> >"use Sockets". Did I miss something?
>
> Is this a better way to do things? And when did it show up (as in, which
> version of Perl).
>
> Thank you in advance (and my apologies to those who were not the target
> of the "flame" segment of the message for the outburst).
>
> --
> Gregory Wright
> Credit Management Solutions, Inc.
> greg_wright@cmsinc.com
--
-------
Kermit Tensmeyer (E & T - Networking)
Kermit@ticnet.com Dallas
------------------------------
Date: 8 Oct 1997 17:58:58 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Best way to extract array elements, modify, store resulting list?
Message-Id: <61ghl2$cd7@news-central.tiac.net>
In article <343BAF9E.D77A7CE9@dt.wdc.com>, Bruce Reid <reid@dt.wdc.com> wrote:
>Dear Perl folks,
>
>I'm looking for an elegant way to extract from an array all elements
>that satisfy a certain criterion, modify each one in a prescribed way
>(without modifying the original array), and assign the resulting list to
>another array. I'd like to do it as simply as possible without an
>explicit for loop.
>
>The original list consists of file names which are preceeded by either
>'p.' or 's.'. I want to extract all 's.' files, strip off the 's.'
>prefix, and store the resulting filenames in a new list.
>
>The following code is a working method, but it seems a bit cumbersome,
>and I'm wondering if there's a better way.
>
>#!/usr/bin/perl5 -w
>
>@array = ( qw/s.file1.c s.file2.c p.file1.c s.file3.c p.file2.c/ );
>@sfiles = map { ($tmp = $_) =~ s/^s\.//; $tmp } grep /^s\./, @array;
@sfiles = map {s/^s\.//; $_} grep /^s\./, @{[@array]}
or
@sfiles = map {s/s\.// ? $_ : ()} @{[@array]}
if the thing you're testing for and the thing you're removing are the
same.
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: Wed, 08 Oct 1997 14:00:30 -0400
From: Anthony Danh <danh@software.org>
Subject: CGI and ACCESS
Message-Id: <343BCA3E.1657@software.org>
Hi..
Does anyone know any CGI script that can open a table in ACCESS 97 and
write data to it?
Thanks
Anthony
------------------------------
Date: Wed, 08 Oct 1997 13:03:27 -0500
From: Kermit Tensmeyer <kermit@ticnet.com>
To: fain@actcom.co.il
Subject: Re: DATABASING IN PERL (HELP!)
Message-Id: <343BCAEF.23AEE2CE@ticnet.com>
|| Fains || wrote:
>
> OK, if you are willing, I have another question.
> in your example (and something I see everywhere):
> my ($company_name, $date, $number, $description) = split /\s+/, $_, 4;
>
> you use = split /\s+/, $_, 4;
> what does that do exactly (what does /\s+ do as opposed to some other
\s is a whitespace character \s+ is one or more such characters
[ discussed in pattern matching ]
> combination), how does it affect:
> my ($company_name, $date, $number, $description)
> ?
> this is what I do not understand and what I need to understand.
>
> The database that I am trying to use looks like this (a sample line from the
> actual file):
> -2 open pc386 AIM386 CT906M00022 132.65.181.8 utp pcftp2 42 - 640 + * * * 12-1-2-6
@list = split / /;
will take each piece and put it in a seperate element of 'list'
or for example comma delimited files (CSV)[ used by spreadsheets]
($t1, $t2, $t3, $t4, $t5) = split /,/;
@sv = split /,/;
where $sv_count = @sv will tell you the number of elements parsed
by the split.
you can use arrays, lists or hashs to manage the individual elements.
> each space you see (" ") makes a different cell. What I need to do is make my
> perl program split the line by each space (not commas or anything else) and
> make a variable like what was in your example.
> how would I have to change this: = split /\s+/, $_, 4;
> in order to make it work?
>
> I will definitely look for the books you suggested (although I don't know how
> available they will be here in Israel)
ignoring the issues of CGI,
one could read a file of these entries such as this
open(FILE, "filename.log") || carp "can t open filename $!:\n";
while (<FILE>){
@list = split (/\s+/);
$func = $list[2];
$ipaddr = $list[6]; // 132.65.181.8
etc.
// do something with entries
}
close (FILE);
for each row of FILE the contents are placed in standard
variable, and then the other function use that variable.
----
most of these descriptions are in the standard
books on Perl (Llama, Camel, and Panther)
basic description files are also apart of the standard
delivery of the perl code. If you don't have access to
it, then talk to your sysadmin
-------
Kermit Tensmeyer (E & T - Networking)
Kermit@ticnet.com Dallas
------------------------------
Date: Wed, 08 Oct 97 14:37:27 -0400
From: samdie@ibm.net
Subject: Re: Forcing numeric interpretation?
Message-Id: <343bd3b3$2$fnzqvr$mr2ice@news-s01.ny.us.ibm.net>
In <comdog-ya02408000R0810971329560001@news.panix.com>, on 10/08/97
at 01, comdog@computerdog.com (brian d foy) said:
> In article <343bb067$1$fnzqvr$mr2ice@news-s01.ny.us.ibm.net>, samdie@ibm.net
> wrote:
> >Is there a way to force perl to store fields obtained by reading a file as
> >numbers? For example, if I were to read a table of state abbreviations and
> >tax-rates and hash them as start-up housekeeping with the intention of then
> >computing the tax for several hundred thousand sales records. I assume that,
> >left to its own devices, perl would store the rates in the hash as strings.
> why assume anything when you can read the man pages? in this case the
> perldata man page answers your question.
> good luck :)
Maybe I just don't have good luck.
Didn't find the answer beforehand; don't find it afterwards. Any chance you
could provide some unambiguous string on which I could search in order to
locate what you believe to be an answer?
--
-----------------------------------------------------------
samdie@ibm.net 199710080237 -0400
------------------------------
Date: 8 Oct 1997 19:46:45 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Forcing numeric interpretation?
Message-Id: <61gnv5$o1h@news-central.tiac.net>
In article <343bd3b3$2$fnzqvr$mr2ice@news-s01.ny.us.ibm.net>,
<samdie@ibm.net> wrote:
>> >Is there a way to force perl to store fields obtained by reading a file as
>> >numbers? For example, if I were to read a table of state abbreviations and
>> >tax-rates and hash them as start-up housekeeping with the intention of then
>> >computing the tax for several hundred thousand sales records. I assume that,
>> >left to its own devices, perl would store the rates in the hash as strings.
>
>> why assume anything when you can read the man pages? in this case the
>> perldata man page answers your question.
>
>> good luck :)
>
>Maybe I just don't have good luck.
>
>Didn't find the answer beforehand; don't find it afterwards. Any chance you
>could provide some unambiguous string on which I could search in order to
>locate what you believe to be an answer?
It doesn't matter that much, using the Devel::Peek module in the debugger:
DB<1> use Devel::Peek
DB<2> $foo{'bar'} = '1.23'
DB<3> Dump $foo{'bar'}
SV = PV(0x804b584)
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x8114278 "1.23"
CUR = 4
LEN = 5
The PV is the string I just stashed in there
DB<4> $x = $foo{'bar'} + 2
DB<5> Dump $foo{'bar'}
SV = PVNV(0x8144fa0)
REFCNT = 1
FLAGS = (NOK,POK,pNOK,pPOK)
IV = 0
NV = 1.23
PV = 0x8114278 "1.23"
CUR = 4
LEN = 5
Now I've used it as a number perl has stashed the numeric representation
in there *as well as* the string reporesentation, both are marked as OK,
so if I use the scalar as either a string or a number perl doesn't have to
do any conversion
DB<6> $foo{bar} += 2.34
DB<7> Dump $foo{'bar'}
SV = PVNV(0x8144fa0)
REFCNT = 1
FLAGS = (NOK,pNOK)
IV = 0
NV = 3.57
PV = 0x8114278 "1.23"
CUR = 4
LEN = 5
Having modified the numeric value the old string is still there, but not
OK any more, but when I use it in a string context again
DB<8> print "$foo{bar}"
3.57
DB<9> Dump $foo{'bar'}
SV = PVNV(0x8144fa0)
REFCNT = 1
FLAGS = (NOK,POK,pNOK,pPOK)
IV = 0
NV = 3.57
PV = 0x8112d60 "3.57"
CUR = 4
LEN = 28
the string value is regenerated from the number value and marked as valid
again.
So, as long as you don't change the scalar's value perl only does one
conversion. If you do change the scalar's value then you pay the price of
conversion again when it's needed in the "other" context e.g.
#!/usr/local/bin/perl -w
use Benchmark;
$v = $w = "1.1";
$x = 1;
timethese (10000, {
'change' => '$x += $v; $x -= $v; $v .= "3"; chomp $v;',
'no change' => '$x += $v; $x -= $v; $w .= "3"; chomp $w;',
});
__END__
produces
Name "main::v" used only once: possible typo at ./try.pl line 5.
Name "main::w" used only once: possible typo at ./try.pl line 5.
Name "main::x" used only once: possible typo at ./try.pl line 6.
Benchmark: timing 10000 iterations of change, no change...
change: 8 secs ( 7.59 usr 0.00 sys = 7.59 cpu)
no change: 0 secs ( 0.13 usr 0.00 sys = 0.13 cpu)
(warning: too few iterations for a reliable count)
so in the change code using $v in a numeric context and then altering it
in a string context meant that perl had to regenerate the number value
before using it in numeric context again. In the no change loop the
string manupulations were done on $w so the number value of $v stayed
valid.
I'm sure if I'm lying or mistaken someone will correct me, that's just my
understanding as I try to avoid perl internals as a rule :-)
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: Wed, 8 Oct 1997 14:54:27 -0500
From: "Chuck" <cstewart@flash.net>
Subject: Help: Form Input wo/submit or image src
Message-Id: <61gnpf$qfg$1@excalibur.flash.net>
Is there a way to initiate submit at form posting without using submit or
image src?
<INPUT TYPE="submit" value="Do It">
<INPUT TYPE=image src="doit.gif" name="email">
I would like to be able to call a script via a table cell that contains
text. Would this be done with </a> of some sort?
------------------------------
Date: Wed, 08 Oct 1997 12:45:04 -0500
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: libwww for win32 S.O.S
Message-Id: <343BC69F.EBF729BA@mail.uca.edu>
Steve Kilbane wrote:
> In article <34378f16.0@news1.ibm.net>, "Gal Samuel" <nakadina@ibm.net> writes:
> > I can't seem to install the libwww group of modules.
>
> (a) Are you using Perl 5.004_01 or later? If not, check the docs
> that come with libwww - they reference the home site for the module,
> and *that* site has links to scripts that modify earlier an earlier Perl
> distribution and libwww for win32 use. But you'd be advised to go
> for the new, base release.
>
> > - can anyone describe full installation proccess for it on win95 or NT ?
>
> Just like it says in the docs:
> Perl Makefile.PL
> make
> make test
> make install
> using whatever moral equivalent of "make" your system supports - you'll
> need to have the same compilers etc. that you used to build the base
> distribution with.
>
> > - does anyone knows URL's of the libwww for win 32 to download from ?
>
> See the README for libwww.
> --
> <Steve_Kilbane@cegelecproj.co.uk> - All opinions are mine alone.
> Kilbane's law of integration: standardise on protocols and file
> formats, and the applications take care of themselves.
LWP came with both the ActiveState port (5.003) and Gurusamy's port (5.004) as
part of the package, so if you are using either of those, I don't understand why
you should need to reinstall it. And if you are using an earlier port, the
overwhelming advice on this newsgroup has been that you should upgrade to one of
these.
Cameron Dorey
camerond@mail.uca.edu
------------------------------
Date: Wed, 08 Oct 1997 19:09:49 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: MetaCrawler scripting
Message-Id: <343cd75d.2781347@news.wwa.com>
On Wed, 8 Oct 1997 11:54:01 -0500, hmsmch@cyberservices.com
(Superhighway) wrote:
>I am working on a web page right now that I would like to incorporate I
>have a list of 10 search engines and I would like a user to be able to
>enter a search key word or key phrase and then search all 10 search
>engines with the click of a button.
Wow! What a great and original idea. :-)
>Unfortunately, I haven't a clue as to how to do this.
Damn! That is often the problem with great ideas. :-)
>Could anybody help me find this, learn to do this,
>or be willing to do this for me?
Hmmm. . . If I were you, I might go to the CPAN nearest you
(http://www.perl.com/CPAN) and look for something called
'WWW::Search'. I have never used it and I don't think it does exactly
what you described, but it might do enough or at least provide you
with some code to examine. Here is some info from the README.
WHAT IS WWW::Search?
--------------------
WWW::Search is a collection of Perl modules which provide an API to
WWW search engines. Currently WWW::Search includes back-ends for
variations of AltaVista, Dejanews, Excite, HotBot, Infoseek, and
Lycos. We include two applications built from this library:
AutoSearch (an program to automate tracking of search results over
time), and WebSearch, a small demonstration program to drive the
library.
Back-ends for other search engines and more sophisticated clients are
currently under development.
WHAT IS AutoSearch?
-------------------
WWW::Search's primary client is AutoSearch. AutoSearch performs a
web-based search and puts the results set in a web page. It
periodically updates this web page, indicating how the search changes
over time. Sample output from WWW::Search can be found at
<http://www.isi.edu/lsam/autosearch/>. Output format is configurable.
See the man page for AutoSearch details, or Demonstration section
below for the quick-start instructions.
REQUIREMENTS
------------
WWW::Search requires Perl5 and libwww-perl.
For information on Perl5, see <http://www.perl.com>.
For libwww-perl, see <http://www.sn.no/libwww-perl/>.
Both are also available from the Comprehensive Perl Archive
Network (CPAN). Visit <http://www.perl.com/CPAN/> to find a CPAN
site near you.
At this time WWW::Search has been tested with Perl versions 5.002 and
5.003.
AVAILABILITY
------------
The latest version of WWW::Search should always be available from
<http://www.isi.edu/lsam/tools/WWW_SEARCH/>.
WWW::Search is also available as part of CPAN. Visit
<http://www.perl.com/CPAN> to find a CPAN site near you.
Feedback about WWW::Search is encouraged. If you're using it for a
neat application, please let us know. If you'd like to (or have)
implemented a new back-end for WWW::Search, let us know so we don't
duplicate work.
______________END OF SNIPET____________________
Streben nach Wahrheit
Faust Gertz
Philosopher at Large
------------------------------
Date: 8 Oct 1997 18:14:18 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: Module for dealing with INN spools.
Message-Id: <eli$9710081351@qz.little-neck.ny.us>
? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au> wrote:
> Has any one created a perl module for accessing newspools? I have
> looked up CPAN but there seems nothing that provides the required
> funtionality.
>
> Is there any other possable sorce? If not any advice on how to go
> around rolling my own?
What do you want to do with the newsspool? Typical old-style spool,
probably still widely used, is just a use (an abuse) of the filesystem.
comp.lang.perl.misc posts are found in /var/spool/news/comp/lang/perl/misc/
(or change the location of the spool top level). Each post is represented
by a numbered file, the number representing the arrival time on the
server and unique to thr group on that server. The active file gives
the last used number and the oldest number for which the post is still
around (I think).
:r! grep ^comp.lang.perl.misc ~news/active
comp.lang.perl.misc 66566 66268 y
66566 is the last aritcle number used, 66268 is the oldest article
availible. The last character is a flag. "y" is a normal group,
"m" is moderated, "n" is no posting allowed. I seem to recall there
being some other possibilities, but I don't remember exactly what.
Regular file handling stuff can deal with this type of spool fine.
News in a database would require some perl interface to the db.
News on a special filesystem will probably work fine, so long as
you only attempt operations valid for that fs. (Improving name to
inode lookup and junking some or all of the timestamps, atime
in particular, are common fs hacks for newsspools.)
Elijah
------
"But the second or third time I read news on PANIX Jim mentioned
to me that rn had been installed since I'd last looked. He
noticed I was 'more'ing the news spool."
-- Mara Chibnik (mc@panix.com)
------------------------------
Date: 8 Oct 1997 19:49:54 GMT
From: "Authorized User" <matthew.kravitz@systecinc.com>
Subject: Passing Command Lines From Perl in NT
Message-Id: <01bcd423$1fd492a0$7cfce59b@matthewk.systecinc.com>
i need to pass a simple command line from a perl script to a c++ executable
in a NT environment. the command line is built within the perl script.
for example :
\usr\local\matt\script1 -f <filename> -st <source tables> -id <name> -pw
<password>
thanks for the help,
matthew e. kravitz
------------------------------
Date: Wed, 08 Oct 1997 12:54:41 -0500
From: Patrick Timmins <ptimmins@netserv.unmc.edu>
Subject: Re: Pattern matching with variables
Message-Id: <343BC8E1.7D8D@netserv.unmc.edu>
Wayne Magor wrote:
>
> I've run into a snag with this line:
>
> {$TheLine =~ s/$Pattern1/$Pattern2/ig}; # Do it globally and ignore case
>
> It works fine for most simple substitutions, however, whenever the $Pattern2
> variable has a backreference (like a $1 or $2) it ignores it as a backreference
> and actually puts the dollar sign and number into $TheLine.
>
> If I don't use variables, I don't have this problem. For instance, I tried
> this to swap the first two words and it worked fine:
>
> {$TheLine =~ s/^([^ ]+) +([^ ]+)/$2 $1/ig}; # Do it globally and ignore ca
>
> Is there some reason why it doesn't work when the pattern is in a variable?
> I'm just learning Perl and the book I have says they should be equivalent.
You mention that "It works fine for most simple substitutions, however,
whenever the $Pattern2 variable has a backreference (like a $1 or $2) it
ignores it as a backreference and actually puts the dollar sign and
number into $TheLine". If I'm understanding you, you should not be
putting a '$' sign in your backreference, just \1 or \2 ... and the \1
and or \2 needs to refer back to a "parethesized" match in your regex,
not just the regex itself.
eg:
$first = "house";
$second = "dog";
while (<>) {
print if s/($first)/$1 $second/gi;
}
will print "house dog" whenever the input has "house", as you say,
however:
$first = "house";
$second = "dog";
while (<>) {
print if s/($first)/\$1 $second/gi;
}
will print "$1 dog" whenever the input has "house". What you want, if
I'm understanding you is:
$first = "house";
$second = "dog";
while (<>) {
print if s/($first)/\1 $second/gi;
}
This will print "house dog" whenever the input has "house", as (I think)
want.
Hope this helps
Patrick Timmins
U. Nebraska Medical Center
------------------------------
Date: 8 Oct 1997 18:33:39 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: Pattern matching with variables
Message-Id: <eli$9710081416@qz.little-neck.ny.us>
In article <61gbe4$44r1@castor.cca.rockwell.com>, <No@Junk.Mail> wrote:
> {$TheLine =~ s/$Pattern1/$Pattern2/ig}; # Do it globally and ignore case
> It works fine for most simple substitutions, however, whenever the $Pattern2
> variable has a backreference (like a $1 or $2) it ignores it as a
> backreference and actually puts the dollar sign and number into $TheLine.
You want $Pattern2 to be *e*valuated not substituted literally.
Try: s/$Pattern1/qq,"$Pattern2",/igee
:r! perl -e '$_ = "fooBARqux", $pat1 = "(b|q)(a|u)", $pat2 = q,$2 $1,;
s/$pat1/qq,"$pat2",/igee && print'
fooA BRu qx
Elijah
------
or you can include the quotes in $pat2 and drop the qq,, bit
------------------------------
Date: 8 Oct 1997 18:09:58 GMT
From: syng@salami.engr.ucdavis.edu (Michael Ng)
Subject: Re: Perl for Win95
Message-Id: <61gi9m$2e5$1@mark.ucdavis.edu>
I saw there is a perl2exe shareware program. I tried with some Perl 4
simple program, and it worked. And, there is also a perl compiler in
alpha (or beta now). The links can be found in www.perl.com
Jim F. (jimfr@best.com) wrote:
::> Does anyone know if there is a PERL for Win95 that will produce
::> standalone .exe files? (There is a version for Macintosh that
::> produces standalone applications).
::> TIA,
::> jim
--
Michael (syng@engr.ucdavis.edu)
+--------------------------------------------------------------+
| http://www.engr.ucdavis.edu/~syng/ |
| <PGP public key: http://www.engr.ucdavis.edu/~syng/mike.pgp> |
+--------------------------------------------------------------+
------------------------------
Date: 08 Oct 1997 14:05:58 -0400
From: Matthew Rice <Matthew.Rice@ftlsol.com>
Subject: Re: printf character.
Message-Id: <m37mbojfjt.fsf@hudson.ftlsol.com>
Benarson Behajaina <Benarson.Behajaina@swh.sk> writes:
> Look at this simple scrupt:
>
> #!/usr/local/bin/perl
> $char = 'a';
> printf "%c\n", $char;
>
> This script doesn't work , why ?
First, add the -w option to your #! line.
Then, read the perlfunc manpage on sprintf (it describes FORMAT).
> So how ca I write this script to output a character
> using printf "%c" ?
Try the following script and take your pick:
#!/usr/bin/perl -w
$char = 'a';
printf "%.1s\n", $char;
printf "%c\n", ord $char;
$char = 97; # Just to make it really clear.
printf "%c\n", $char;
--
Matthew Rice e-mail: matthew.rice@ftlsol.com
------------------------------
Date: Wed, 08 Oct 1997 18:51:22 GMT
From: amacater@galactic.demon.co.uk (Andrew Martin Adrian Cater [Andy])
Subject: Problem with script in LLama book
Message-Id: <876336682.13367.0.nnrp-07.9e983fd9@news.demon.co.uk>
No obvious reason why: I can't get the script on page 10 to
work.
It dies on the line with
$secretword = $words(name);
Perl -w throws up a warning about that line which tells me nothing.
Script is typed verbatim from the book.
Help!
Andy
------------------------------
Date: 8 Oct 1997 19:48:17 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Problem with script in LLama book
Message-Id: <61go21$p1u@news-central.tiac.net>
In article <876336682.13367.0.nnrp-07.9e983fd9@news.demon.co.uk>,
Andrew Martin Adrian Cater [Andy] <amacater@galactic.demon.co.uk> wrote:
>
>
>No obvious reason why: I can't get the script on page 10 to
>work.
>It dies on the line with
>
>$secretword = $words(name);
Should that be
$secretword = $words{$name};
Hope this helps,
Mike
(no llama to hand...)
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: 8 Oct 1997 19:45:36 GMT
From: "Authorized User" <matthew.kravitz@systecinc.com>
Subject: Process Control for NT/ Perl
Message-Id: <01bcd422$856fbb40$7cfce59b@matthewk.systecinc.com>
i am currently developing an NT based interface to a c++ executable in
perl. this script basically feeds command lines to the c++ executable and
monitors the state of the running processes. for example, i would like to
capture the process id of a child process and monitor its state ( alive or
dead ) . this is easy to do in unix by using 'ps', but seems to be a
little more tricky with NT. i don't think that a simple fork() is the
resolution because if there are 10 children running, how do i know when
number 4 is done?
can you think of any alternatives using NT's native tools or library
functions?
thanks, i appreciate the help.
matthew e. kravitz
------------------------------
Date: Wed, 08 Oct 1997 17:00:33 GMT
From: over@the.net (dave)
Subject: Re: system() won't run shell script correctly
Message-Id: <343bb934.543098@news.one.net>
ilya@math.ohio-state.edu (Ilya Zakharevich) wrote:
>In article <343b92db.230794@news.one.net>, dave <over@the.net> wrote:
>> ilya@math.ohio-state.edu (Ilya Zakharevich) wrote:
>> >> The system command spawns a shell to run the command,
>> >
>> >Wrong. Sometimes it does, but not in the above case.
>> >
>>
>> I think the key issue is a spawned _process_, which is not necessarily a shell.
>> But what you are saying is that Perl makes a distinction between:
>>
>> system( "xterm -e rlogin foo" );
>>
>> and
>>
>> system( "PATH=$PATH:/usr/bin/X11; xterm -e rlogin foo" );
>>
>> Are you sure it makes this distinction?
>
>Are you sure you've read the documentation?
>
>Ilya
My error. Indeed the original poster must have some other problem besides the
parent of the xterm dying. Guess I should be able to stop doing "sh -c"
encapsulation on exec of passed strings.
Dave
|
| Please visit me at http://w3.one.net/~dlripber
|
| For reply by email, use:
| dlripber@one.net
|________
------------------------------
Date: Wed, 08 Oct 1997 14:28:04 -0400
From: Yash Khemani <yash@teczar.com>
To: Jarkko Juntunen <jarkko@avalon.merikoski>
Subject: Re: Text formatting question
Message-Id: <343BD0B4.4C69D0D4@teczar.com>
Jarkko Juntunen wrote:
>
> So, is it possible to format text with Perl something like this. So this is
> what it soppesed to look pinted in paper
>
> Name1 Name2 Name3 Name4 Name5
> Address1 Address2 Address3 Address4 Address5
> zip1 City1 zip2 City2 zip3 City3 zip4 City4 zip5 City5
>
> Names and addressese in fife columns.
>
> Source files are lists from databases, and I have already made that part of
> the script wich put them to form:
> Name1:Address1:zip1:city1
> Name2:Address2:zip2:city2
> Name3:Address3:zip3:city3
> Name4:Address4:zip4:city4
> Name5:Address5:zip5:city5
> and so on.
> But I can only write format which put them this way:
> Name1
> Address1
> zip1 city1
>
> Name2
> Address2
> zip2 city2
>
> -------------------------------------------------------------------------
> Jarkko Juntunen jarkko@avalon.merikoski.fi Tel. +358 8 5306 977
> -------------------------------------------------------------------------
you're best off doing this using nroff. i don't know off hand, but
check
CPAN to see if there is a module to help you with nroff.
cheers!
yash
------------------------------
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 1146
**************************************