[9179] in Perl-Users-Digest
Perl-Users Digest, Issue: 2797 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 3 12:17:30 1998
Date: Wed, 3 Jun 98 09:00:47 -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, 3 Jun 1998 Volume: 8 Number: 2797
Today's topics:
Re: "1" Question <jdporter@min.net>
Re: A problem with [\d]+ (Tad McClellan)
Re: CGI/Perl Department Head birgitt@my-dejanews.com
Re: Eerie Explorer error on Randal's site (Abigail)
FORMAT to console <prl2@lehigh.edu>
Hot to interpret the output from mstat pra@mint.se
Re: How do you kill a Windows NT process using Perl? <ndsimpso@ingr.com>
Re: map in void context regarded as evil - suggestion (Abigail)
Re: map in void context regarded as evil - suggestion (Chris Nandor)
Negative values from Win32::GetTickCount? <cbrown_<NoSpam>@erols.com>
odbc and unix perl <dturley@ravine.binary.net>
Re: perl for windows 3.1? (Klaus Kettner)
Re: Perl, ODBC and OLE help <perlguy@inlink.com>
perlshop error <arcst8@vms.cis.pitt.edu>
Re: Regex: parens inside quantifiers: can you capture a <aqumsieh@matrox.com>
Re: Regex: parens inside quantifiers: can you capture a (Larry Rosler)
removing lines (delete regexp) <porkchop@fleaflicker.com>
Re: removing lines (delete regexp) (Chris Nandor)
scalar string to array <studft@nortel.ca>
Re: scalar string to array <tchrist@mox.perl.com>
setting precision??? <genisiob@pilot.msu.edu>
Re: setting precision??? <quednauf@nortel.co.uk>
Re: setting precision??? (Larry Rosler)
Re: smtpmail script for win32 scott@softbase.com
Re: smtpmail script for win32 <mbl@startext.de>
Re: STDIN on IIS <perlguy@inlink.com>
Re: study; (Mike Heins)
Re: Submitting html form to Perl script. <perlguy@inlink.com>
Re: Taking data out of strings <aqumsieh@matrox.com>
Re: very quick s/// question <aqumsieh@matrox.com>
Re: Year 2000 Compliant <Dave.Cross@gb.swissbank.com>
Re: Year 2000 Compliant (Tom Grydeland)
Re: Year 2000 Compliant (Abigail)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 03 Jun 1998 14:27:49 GMT
From: John Porter <jdporter@min.net>
Subject: Re: "1" Question
Message-Id: <35755F0E.634D@min.net>
First, let's clean up your code a bit.
Then, we'll actually fix your algorithm. (It's wrong.)
John Timotheou wrote:
> if (-e $totalTB)
I don't see where $totalTB is defined. ???
> while (read TOTAL, $stuff, 20000 ){
> @lines = split(/\n/,$stuff);
Uggghhh. Just do the normal input, hey?
@lines = <TOTAL>;
> @NUMdataTP = split(" ",$a);
Where's this $a coming from?
You aren't using perl -w, are you. You should be.
> for ($i=0; $i<=$#NUMdataTP; $i++)
> {
> $count++;
> }
Uggghhh.
If you want the number of items in an array, you can get it directly:
$count = @NUMdataTP;
And again:
$countB = @ATTRIBnum;
I'm beginning to suspect you didn't actually post all the code.
Where the hell is $string coming from?
I infer it's from STDIN, but how can we be sure?
> @ATTRIBnum = split(" ",$string);
You might want to be bit more flexible on the spacing; try this:
@ATTRIBnum = split( /\s+/, $string );
Now, the problem (bug) in your code is that you're counting the
number of tokens on *each line* (or maybe only the last line) of
the $totalTB file, when you should be counting the *number of lines*.
At least, if the sample you gave is correct:
Char Name
Int Idnum
Let's do a right way (not *the* right way; TIMTOWTDI).
#!/usr/bin/perl -w
my @table; # to store all the field definitions. array of hashrefs.
#
# read in the table definition and store in @table:
#
open(TOTAL,"< $totalTB") || die "open $totalTB: $!";
for (<TOTAL>) {
chomp; # get rid of the newline
my( $type, $name ) = split; # splits on any amount of whitespace
if ( defined $name ) {
push( @table,
{
type => $type,
name => $name
}
);
}
}
close(TOTAL);
#
# get user input
#
while (<>) {
chomp;
my @input = split;
if ( @input < @table ) {
# too few
}
elsif ( @input > @table ) {
# too many
}
else {
# ahhh, just right
}
}
There you go.
Now, I hate to suggest it to a newbie, but the first part could be
recoded "succintly" as follows. (Something to chew on.)
open(TOTAL,"< $totalTB") || die "open $totalTB: $!";
my @table = map {
chomp;
my %r; @r{ qw( type name ) } = split;
defined $r{name} ? \%r : ();
} <TOTAL>;
close(TOTAL);
hth,
John Porter
------------------------------
Date: Wed, 3 Jun 1998 07:42:44 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: A problem with [\d]+
Message-Id: <4cg3l6.h81.ln@localhost>
Shaun Sides (arch@abts.net) wrote:
: This may be one more newbie thing on my part, but I can't see why you'd
: use [\d]. I can see why you'd use [^\d], but I don't understand the
^^^^^^^^^
\d matches digit characters
\D matches non-digit characters...
I can't see why you would wrap it in a character class for either case.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 03 Jun 1998 15:35:34 GMT
From: birgitt@my-dejanews.com
Subject: Re: CGI/Perl Department Head
Message-Id: <6l3qg6$g94$1@nnrp1.dejanews.com>
In article <6l2agr$ign$1@nnrp1.dejanews.com>,
rishi_bhat@hotmail.com wrote:
[snip]
> Compensation :
>
> To begin with, we will implement a pay per article system. For each article
> you write, you will be paid $35 US dollars. Once we get the site launched,
> and ad revenue begins pouring in :-), we will both sign a contract that
> guarantees you your equal share of all ad and consulting revenues received
> by the site. This will be discussed in further detail in the interviewing
> process.
>
A non technical freelancer who writes for wire services (and who
doesn't know what he is writing about in 90 out of 100 cases) gets
$1.50 per line.
Considering that you are asking experts to write more than
22 lines per article about something they know in and out,
I would like to know what experts in this group think a fair/
acceptable pay should be.
Birgitt Funk
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 3 Jun 1998 15:39:30 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Eerie Explorer error on Randal's site
Message-Id: <6l3qni$rj5$1@client3.news.psi.net>
Tom Phoenix (rootbeer@teleport.com) wrote on MDCCXXXVI September MCMXCIII
in <URL: news:Pine.GSO.3.96.980602164714.15370A-100000@user2.teleport.com>:
++ On 2 Jun 1998, Neil Kandalgaonkar wrote:
++
++ > Subject: Eerie Explorer error on Randal's site
++
++ Eerie Explorer - it's kind of like MSIE, but every so often the
++ disembodied head of Bill Gates appears and moans scary things like
++ "Ohhh.... Federal meddling in free commerce! Whooooo.... Natural
++ monopoly... Windows '98... Buahahahaha!" :-)
My Netscape (Unix version) crashes on http://www.5sigma.com/joseph/.
It isn't just MSIE, or M$ software that's bad.
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
------------------------------
Date: Wed, 3 Jun 1998 09:49:30 -0400
From: "Phil R Lawrence" <prl2@lehigh.edu>
Subject: FORMAT to console
Message-Id: <6l3k9d$146g@fidoii.cc.Lehigh.EDU>
Hello,
I want to write to console from a database. My problem is with FORMATing the
data. Is there a good way to send 24 lines at a time, wait for the user to
strike ENTER, and then display the next screen? The best test I could cobble
together follows, but output looks a little awkward. Any suggestions?
_____________________________
#!/usr/local/bin/perl -w
$= = 20;
format STDOUT_TOP =
PAGE@>>>
$%
PostgreSQL RDBMS
---
Central Registry Roster
---------------------------------------
ID Last Name First Name
---------------------------------------
.
format STDOUT =
@>>>>>>>>>>>>>>>>> @>>>>>>>>>>>>>>>>>> @<<<<<<<<<<<<<<<
$row[0],$row[1],$row[2]
.
open FILE, '>test.prn' or die;
for (1..100) {
print FILE "0654654,ewqfwrefwefregregege,ergregergregregreg\n";
}
close FILE or die;
open FILE, '<test.prn' or die;
system 'tput clear';
my $counter = 0;
while (<FILE>) {
@row = split /,/, $_;
$counter++;
write STDOUT;
if ($counter == 12) {
$counter = 0;
my $thingamabob = <STDIN>;
#system 'tput clear' also works (and looks nicer), but you can't
#scroll up to look at data you've already ENTERed past.
print "\n";
}
}
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Phil R Lawrence phone: 610-758-3051
Programmer / Analyst e-mail: prl2@lehigh.edu
194 Lehigh University Computing Center
E.W. Fairchild - Martindale, Bldg. 8B
Bethlehem, PA 18018
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: 3 Jun 1998 15:01:26 GMT
From: pra@mint.se
Subject: Hot to interpret the output from mstat
Message-Id: <6l3og6$2tj$1@news.mint.se>
--
I have found no information anywhere how to interpret the output when
running perl with mstat on, that is
env PERL_DEBUG_MSTATS=2 perl script.pl
Or when using Devel::Peek 'mstat'.
Does any body know of a god pointer to info, or perhaps is ready to explain the
different fields in output like:
Memory allocation statistics after compilation: (buckets 8..16384)
264048 free: 0 95 54 19 6 5 1 3 2 3 3 13
6297744 used: 0 10273 33290 61453 2730 227 211 497 14 0 2 4
Total sbrk(): 6562512. Odd ends: sbrk(): 720, malloc(): 0 bytes.
(My actual problem is that perl does not seem to free memory during execution,
at least no for mee - and I have found no god way of checking the actual memory
usage. I have a larg object tree, witch should be freed at a certain point. The
objects reports beeing destroyd, and I have found no dangling global variable
hanging around wich keeps the reference count up. Inspite of this, ps reports
the same high memory usage for Perl as before the object tree goes out of scope)
\Peter
--------------------------------------------------------
Peter Antman MARIEBERG INTERACTIVE AB
System Developer Box 27 205, 102 53 Sockholm
Epost: pra@mint.se WWW: http://www.mint.se/
Tel: 08-459 39 33 Fax: 08-661 51 30
--------------------------------------------------------
------------------------------
Date: Wed, 3 Jun 1998 10:25:29 -0500
From: "Nik Simpson" <ndsimpso@ingr.com>
Subject: Re: How do you kill a Windows NT process using Perl?
Message-Id: <Xrn4CMwj9GA.149@pet.hiwaay.net>
ffinstad@globalsight.com wrote in message
<6l1pf0$oei$1@nnrp1.dejanews.com>...
>
>
>To restart Apache on UNIX I'm doing:
>
>echo "killing the web server..."
>echo
>kill `cat /usr/local/apache/conf/httpd.pid`
>echo "restarting the web server..."
>echo
>/usr/sbin/httpd -f /usr/local/apache/conf/httpd.conf
>
>How can I do the same thing on Windows NT?
Net stop servicename
Net start servicename
Where servicename is the name of the Apache service.
--
Nik Simpson
------------------------------
Date: 3 Jun 1998 14:18:12 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: map in void context regarded as evil - suggestion
Message-Id: <6l3lv4$q5t$1@client3.news.psi.net>
Russ Allbery (rra@stanford.edu) wrote on MDCCXXXVII September MCMXCIII in
<URL: news:m3wwaz0xxl.fsf@windlord.Stanford.EDU>:
++ Zenin <zenin@bawdycaste.org> writes:
++ > Russ Allbery <rra@stanford.edu> wrote:
++
++ >> It's less intrusive. Count the number of characters of markup per amount
++ >> of text. If HTML were as light-weight as POD, I doubt anyone would
++ >> complain about it.
++
++ > When <insert a shell newsreader here> can handle POD, sure.
++
++ No, that's my point. POD is *so* lightweight that it doesn't interfere at
++ all with the readability of the text. I'm not saying that B<everyone>
++ should I<immediately> start using POD to mark up their articles; I'm just
++ saying that a little POD scattered into a message really isn't at all
++ comperable to HTML.
++
++ Of course, if people were using =over, =item, =back lists all the time, I
++ may consider that a bit much, because that *is* intrusive.
<p>
But that is the same problem people have with HTML postings! It's
overdone usually. That is because those postings are usually
automatically created, and people add all kinds of formatting
into it (which shouldn't be part of HTML anyway).
<p>
But I doubt anyone has problems reading this article, yet HTML
markup is being used. HTML itself isn't a problem, just like
POD isn't. But you can overuse HTML, and you can overuse POD.
<hr>
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
------------------------------
Date: Wed, 03 Jun 1998 15:40:02 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: map in void context regarded as evil - suggestion
Message-Id: <pudge-0306981134220001@192.168.0.3>
In article <6l3lv4$q5t$1@client3.news.psi.net>, abigail@fnx.com wrote:
# But I doubt anyone has problems reading this article, yet HTML
# markup is being used. HTML itself isn't a problem, just like
# POD isn't. But you can overuse HTML, and you can overuse POD.
Yep. I would bounce excessive POD from clp.mod (depending on the
circumstances), and I would allow HTML like yours to pass.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: Wed, 3 Jun 1998 09:51:00 -0400
From: "Chris Brown" <cbrown_<NoSpam>@erols.com>
Subject: Negative values from Win32::GetTickCount?
Message-Id: <6l3keh$q9k@world2.bellatlantic.net>
When using Win32::GetTickCount on a NT machine that has been up for 32 days
I receive a negative value. This negative value is basically trash when
determining how long a machine has been running.
This module works fine for machines running 15 days (haven't nailed down the
exact point the tick count switches to negative).
Any ideas on a fix, besides not letting a NT machine run that long without a
reboot?
Here's the code I'm using, it came from
http://www.inforoute.capway.com/leberre1/ :
$tick = Win32::GetTickCount();
$days = int($tick/86400000);
$hours = int( ($tick = ($tick - $days*86400000)) /3600000);
$mins = int( ($tick = ($tick - $hours*3600000)) /60000);
$secs = int( ($tick = ($tick - $mins*60000))/1000);
Thanks,
Chris
------------------------------
Date: 3 Jun 1998 14:22:59 GMT
From: David Turley <dturley@ravine.binary.net>
Subject: odbc and unix perl
Message-Id: <6l3m83$n08$1@oksennus.binary.net>
I need to query a MS SQL Server database running on NT, from perl running
under Solaris. I've searched www.perl.com and all the odbc modules appear
to be written for win32 perl. How do I query the NT database from Unix?
thanks in advance for any suggestions
--
_____________________________________________________________________
David Turley
dturley@pobox.com
http://www.pobox.com/~dturley
"You don't want to be the only person sitting on a crocodile's back."
-- heard on a PBS nature show
______________________________________________________________________
------------------------------
Date: Wed, 03 Jun 1998 14:59:16 GMT
From: kk@sbs.de (Klaus Kettner)
Subject: Re: perl for windows 3.1?
Message-Id: <35756478.534722910@192.129.41.5>
On Tue, 02 Jun 1998 21:07:30 GMT, Gellyfish@btinternet.com (Jonathan Stowe)
wrote:
> You can find it at :
>
> http://www.delorie.com/djgpp/dl/ofc/simtel/v2gnu/perl54b.zip
Thank you. If anybody else is interested, the correct link is:
http://www.delorie.com/djgpp/dl/ofc/simtel.cgi/simtel/v2gnu/perl54b.zip
--
-kk-
priv: mailto:kk@sesom.de
work: mailto:kk@sbs.de
web : http://www.n-online.de/~kettner
------------------------------
Date: Wed, 3 Jun 1998 11:57:40 GMT
From: Brent Michalski <perlguy@inlink.com>
Subject: Re: Perl, ODBC and OLE help
Message-Id: <35753A34.1164D657@inlink.com>
Have you thought about storing the JPEG file on the web server, and the
LOCATION/URL of the JPEG in the database? Sounds easier to me, but I
don't know all of the details of your project...
HTH,
Brent
------------------------------
Date: Wed, 03 Jun 1998 11:48:05 -0400
From: Albert Cunningham <arcst8@vms.cis.pitt.edu>
Subject: perlshop error
Message-Id: <35757035.446B@vms.cis.pitt.edu>
can anybody help me
we are setting up perlshop and have encountered the following problem
we have an enter button on our top page--when you click on it, we get
the following message::
Invalid Transmission #3 received from: 136.142.74.83
If your connection was interrupted, you must Enter the shop from the
beginning again.
any help will be greatly
al
------------------------------
Date: Wed, 03 Jun 1998 10:08:38 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Regex: parens inside quantifiers: can you capture all of them?
Message-Id: <357558E5.D7FFECB9@matrox.com>
Peter Scott wrote:
> # animal foods mammal? sounds
>
> $_ = "dog kibble biscuits pal Y bark woof";
> @fs = /(\w+) (?: \s+ (\w+) )* \s+ ([YN]) (?: \s+ (\w+) )*/x;
Are you sure you want to use (?:) here? This allows the matching of what's
inside the brackets without the creation of a backreference! So whatever is
matched there won't appear inside @fs.Also, the /x modifier is not needed
unless your regexp spreads over multiple lines.
> print "$1: @fs[1..$#fs]\n";
> Output: dog: pal Y woof
>
> Now, if I wanted to capture all of the foods and all of the sounds
> using a regex, is there a way? Being able to express the syntax of
> the statement in a single regex is just too appealing to want to
> give it up without a fight...
>
My solution might not be the best one, but it works:
$_ = "dog kibble biscuits pal Y bark woof";
$_ =~ /^(\w+)\s*(.*)\s*([YN])\s*(.*)\s*$/x;
print "$1: $2 $3 $4\n";
$2 and $4 contain a list (if any) of the foods and sounds, respectively.
You can access individual foods and sounds using split.
Hope that helps.
--
Ala Qumsieh | No .. not just another
ASIC Design Engineer | Perl Hacker!!!!!
Matrox Graphics Inc. |
Montreal, Quebec | (Not yet!)
------------------------------
Date: Wed, 3 Jun 1998 08:37:00 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Regex: parens inside quantifiers: can you capture all of them?
Message-Id: <MPG.fdf0d792c7ac782989684@hplntx.hpl.hp.com>
In article <357558E5.D7FFECB9@matrox.com>, aqumsieh@matrox.com says...
> Peter Scott wrote:
>
> > # animal foods mammal? sounds
> >
> > $_ = "dog kibble biscuits pal Y bark woof";
> > @fs = /(\w+) (?: \s+ (\w+) )* \s+ ([YN]) (?: \s+ (\w+) )*/x;
>
> Are you sure you want to use (?:) here? This allows the matching of what's
> inside the brackets without the creation of a backreference! So whatever is
> matched there won't appear inside @fs.Also, the /x modifier is not needed
> unless your regexp spreads over multiple lines.
Yes it is, when the regex includes *any* white-space that is not intended
to be matched. You should try small tests before making such assertions,
and/or read the documentation more carefully.
--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: Wed, 03 Jun 1998 09:35:52 -0600
From: Dave Jackson <porkchop@fleaflicker.com>
Subject: removing lines (delete regexp)
Message-Id: <35756D58.ABF2DCE@fleaflicker.com>
how do i delete stuff from files?
i get errors when i try:
/BOB/d;
trying to delete all BOBs from my file
so, assuming i want to remove all blank lines, i tried i would try
these:
/^$/d;
s/^$//g;
s/\n//g
/\n\n/d;
none of which worked...
------------------------------
Date: Wed, 03 Jun 1998 15:50:53 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: removing lines (delete regexp)
Message-Id: <pudge-0306981145120001@192.168.0.3>
In article <35756D58.ABF2DCE@fleaflicker.com>, Dave Jackson
<porkchop@fleaflicker.com> wrote:
# how do i delete stuff from files?
#
# i get errors when i try:
# /BOB/d;
# trying to delete all BOBs from my file
?? /d is not a modifier for m//, let alone s///. And what you are doing
there is m//, which just matches, it does not modify the string.
# so, assuming i want to remove all blank lines, i tried i would try
# these:
# /^$/d;
Matching, not modifying, and /d is not a modifier of m//.
# s/^$//g;
That deletes an empty string, not an empty line.
# s/\n//g
That deletes all newlines.
# /\n\n/d;
That does nothing (see above).
Perhaps you want:
s/\n(?=\n)//g;
or:
s/\n^$//gm;
Though neither will remove an initially blank line. The first one can be
fixed with:
s/^\n+|\n(?=\n)//g;
But I think it makes most sense to use two regexes:
s/^\n+//;
s/\n(?=\n)//g;
If you don't understand /m and (?=), good. Look it up in perlre.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: Wed, 03 Jun 1998 10:37:52 -0400
From: Don Skinner <studft@nortel.ca>
Subject: scalar string to array
Message-Id: <35755FC0.693F@nortel.ca>
I am looking for a way to quickly convert a string of characters to an
array. I am currently splitting on null (i.e. split //, $someString),
but this takes a while. I would really like to know a way to access the
underlying array that represents the string, but any other suggestions
would be helpful.
Don Skinner
------------------------------
Date: 3 Jun 1998 15:15:29 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: scalar string to array
Message-Id: <6l3pah$pv2$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, Don Skinner <studft@nortel.ca> writes:
:I am looking for a way to quickly convert a string of characters to an
:array. I am currently splitting on null (i.e. split //, $someString),
:but this takes a while. I would really like to know a way to access the
:underlying array that represents the string, but any other suggestions
:would be helpful.
Why are you wanting to do this? Perl is about strings, not characters.
In general, if you find yourself doing character-by-character processing,
it's quite possible there's a better way to go about it. Instead of
using index and substr or split and unpack, it might be easier to use
a pattern. Instead of computing a 32-bit checksum by hand, the unpack
function can do the same thing far more efficiently.
Byte-by-byte processing is usually indicative of C-headed thinking,
and isn't very natural in Perl, which more often than not has better
ways to do this.
--tom
--
You want it in one line? Does it have to fit in 80 columns? :-)
--Larry Wall in <7349@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: Wed, 03 Jun 1998 14:41:51 +0000
From: Brian Genisio <genisiob@pilot.msu.edu>
Subject: setting precision???
Message-Id: <357560AF.35A095F6@pilot.msu.edu>
Being a C++ guy, I usually use setprecision to format my money to two
decimal places. For the life of me, I cannot figure out how to do that
in perl 5. Please help me!!!!!
Thanks,
Brian
------------------------------
Date: Wed, 03 Jun 1998 16:35:03 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: setting precision???
Message-Id: <35756D27.40AACB38@nortel.co.uk>
Brian Genisio wrote:
> Being a C++ guy, I usually use setprecision to format my money to two
> decimal places. For the life of me, I cannot figure out how to do that
> in perl 5. Please help me!!!!!
It's sprintf STRING, LIST. Check man sprintf (I know, I hate mans, too).
Unfortunately I am too f... mindnumb to give you an example right now :(
--
____________________________________________________________
Frank Quednau
http://www.surrey.ac.uk/~me51fq
________________________________________________
------------------------------
Date: Wed, 3 Jun 1998 08:47:31 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: setting precision???
Message-Id: <MPG.fdf0ff2295e13c4989685@hplntx.hpl.hp.com>
In article <357560AF.35A095F6@pilot.msu.edu>, genisiob@pilot.msu.edu
says...
> Being a C++ guy, I usually use setprecision to format my money to two
> decimal places. For the life of me, I cannot figure out how to do that
> in perl 5. Please help me!!!!!
>
> Thanks,
> Brian
perldoc -f sprintf
It works just like in C.
--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: 3 Jun 1998 12:26:59 GMT
From: scott@softbase.com
Subject: Re: smtpmail script for win32
Message-Id: <6l3fej$l4s$3@mainsrv.main.nc.us>
Carlo Espiritu (cespirit@engr.csulb.edu) wrote:
> Does anyone know of a good Perl script for sending form mail?
Yes, and it's about time I posted it! This function WILL WORK WITH
EXCHANGE SERVERS. I hacked it when our UNIX box had a disk crash and we
had to run an exchange server for a few weeks. It also works with
several flavors of UNIX.
I use this function extensively in my system admin work, particularly
for background processes like backups -- I generally log everything it
does to an array, and pass the array to this function to mail it.
Be sure to read this function and customize the hostnames and
mail addresses! This is a Q and D hack in that respect.
Scott
--
Look at Softbase Systems' client/server tools, www.softbase.com
Check out the Essential 97 package for Windows 95 www.skwc.com/essent
All my other cool web pages are available from that site too!
My demo tape, artwork, poetry, The Windows 95 Book FAQ, and more.
----------------------------------------------------------------------
######################################################################
# This function has been specifically developed to work with
# Microsoft Exchange Server 5.0's Internet Mail Service. It is based
# on the typical UNIX-based Perl code for an SMTP transaction.
#
# You pass this subroutine the e-mail address to send the message
# to, the subject of the message, and an array of strings that
# makes up the body of the message. The common idiom to build the
# array of strings is to push a string onto the array every time
# you would print out (or in addition to printing out) information
# to the console.
#
# This subroutine must be configured to work on your intranet before
# you use it!
######################################################################
sub smtpmail {
my ($to, $subj, @msg) = @_;
my ($whoami, # the name of your computer
$remote, # the name of the SMTP server
$port, # the mail port
$iaddr, $paddr, $proto, $line); # these vars used internally
$whoami = "garbage.trashcan.com";
$remote = 'mail.trashcan.com';
$port = 25;
$iaddr = inet_aton($remote) || die "no host: $remote";
$paddr = sockaddr_in($port, $iaddr);
$proto = getprotobyname('tcp');
select(SOCK);
$| = 1;
socket(SOCK, PF_INET, SOCK_STREAM, $proto) || die "socket: $!";
connect(SOCK, $paddr) || die "connect: $!";
# The sleeps in this transaction are necessary in order to let
# the Exchange server work with your
print SOCK "HELO $whoami\n";
sleep(5);
print SOCK "MAIL FROM: backup\n";
sleep(5);
print SOCK "RCPT TO: scott\@softbase.com\r\n";
sleep(5);
print SOCK "DATA\n";
print SOCK "From: scott\@softbase.com\n";
print SOCK "Subject: $subj\n";
print SOCK "To: $to\n";
print SOCK "\n";
print SOCK @msg;
print SOCK "\n.\n";
sleep(5);
print SOCK "QUIT\n";
sleep(5);
close (SOCK) || die "close: $!";
}
------------------------------
Date: Wed, 03 Jun 1998 17:07:14 +0200
From: Marcus Blaha <mbl@startext.de>
To: Carlo Espiritu <cespirit@engr.csulb.edu>
Subject: Re: smtpmail script for win32
Message-Id: <357566A2.7E3E@startext.de>
Carlo Espiritu wrote:
>
> Does anyone know of a good Perl script for sending form mail? I've used
> Unix based scripts before with Unix systems, but I seem to have a lot of
> difficulty setting it up on a Windows NT web server. I need some help on
> finding a working program as well as how to implement it....
>
> I've used mail-lib.pl with formmail.pl and the script seems to work with
> it processing the information and giving me a message that it has been
> sent, but I never seem to receive the tests in any of the email directions
> that I have assigned them to...
>
> Carlo
> cespirit@engr.csulb.edu
Hi Carlo,
I had the same problem under NT. I udes BLAT as an sendmail-comparable
tool
under NT:
Her is a part of my code:
$rcpt='somebody@x.y';
if (!$stxtool::formempty){
if (&stxtool::isNT) {
$m_prog = "D:\\blat\\blat";
open (MESSAGE,"|$m_prog - -f $stxtool::FORM{'F_FROM'} -t $rcpt
-s \"$stxtool::FORM{'F_SUBJ'}\" -q") ;
}
else{
open (MESSAGE,"|sendmail $rcpt ") or die "mail nicht
aufgerufen";
print MESSAGE "From: $stxtool::FORM{'F_FROM'} \n" ;
print MESSAGE "Reply-to: $stxtool::FORM{'F_FROM'} \n";
print MESSAGE "Subject: $stxtool::FORM{'F_SUBJ'} \n";
}
print MESSAGE "Sender\t" . $stxtool::FORM{'F_FROM'} . "\n";
print MESSAGE $stxtool::formtext;
}
stxform::FORM is a hash containing FORM parameters
$stxtool::formtext contains preformatted text
Blat 1.5 may be found under
http://gepasi.dbs.aber.ac.uk/softw/Blat.html
Marcus
--
#################################################################
# Marcus Blaha startext Unternehmensberatung GmbH
# Kennedyallee 2 / 53175 Bonn
# Tel.: +49.228.95996-16 Fax.: +49.228.95996-66
# Compuserve 101317,3140 eMail mbl@startext.de
# WWW http://www.startext.de
#################################################################
------------------------------
Date: Wed, 3 Jun 1998 11:27:17 GMT
From: Brent Michalski <perlguy@inlink.com>
Subject: Re: STDIN on IIS
Message-Id: <35753315.A0C10CAD@inlink.com>
Correct me if I am wrong, but if you are looking to get data from
<STDIN>, you need to be at the web server console to enter the data.
Since your question didn't go into enough detail I can only guess what
you are looking for...
Are you trying to get input from the user????
If so, use HTML forms and read them in using CGI.pm or cgi-lib.pl.
HTH,
Brent
------------------------------
Date: 3 Jun 1998 11:57:48 -0500
From: mikeh@minivend.com (Mike Heins)
Subject: Re: study;
Message-Id: <3575727c.0@news.one.net>
Dean Jenkins <jenkinsrd@cf.ac.uk> wrote:
> I'd like to speed up the following search using study.
> Where is the best place to put it and would it be better to build a
> string for eval (if so how)? There are about 20 - 40 keywords and 1000
> lines to search in the form of a (|) delimited text database.
Study is not what you want -- look at the docs closely. It is only
for when you are matching on the same string.
If this is a one-time search:
@words = map { "\Q$_\E" } @words;
$searchstring = join '|', @words;
foreach $card (@lines) { # for every line
while ($card =~ /($searchstring)/g) {
$keyword = $1;
...some code...
}
}
This should speed things up dramatically.
If it isn't use Tom C.'s match_many routine you can find in the
Perl docs.
--
Mike Heins http://www.minivend.com/ ___
Internet Robotics |_ _|____
There ain't nothin' in this world 131 Willow Lane, Floor 2 | || _ \
that's worth being a snot over. Oxford, OH 45056 | || |_) |
--Larry Wall <mikeh@minivend.com> |___| _ <
513.523.7621 FAX 7501 |_| \_\
------------------------------
Date: Wed, 3 Jun 1998 11:19:55 GMT
From: Brent Michalski <perlguy@inlink.com>
Subject: Re: Submitting html form to Perl script.
Message-Id: <3575315B.1C276DF4@inlink.com>
If you think that CGI.pm may be the problem, why not try using
cgi-lib.pl?
It isn't as powerful as CGI.pm but if you are just reading in the FORM
elements from a web page, it is more than adequate!
You can find it at:
http://cgi-lib.stanford.edu/cgi-lib/
HTH,
Brent
------------------------------
Date: Wed, 03 Jun 1998 10:34:57 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Taking data out of strings
Message-Id: <35755F11.9F407D94@matrox.com>
Ray Rarey wrote:
> LAST NAME, FIRST NAME GRAD. YEAR GPA
> Is there some function like in BASIC and JavaScript that starts from the
> right or left of a string and reads a certain number of characters?
There are better functions ;-)
Assuming that the GPA is of the form X.XX
open FILE, $file_name or die "Can't open $file_name: $!";
chomp(@lines = <FILE>);
foreach $line (@lines) {
($last_name, $first_name, $year, $gpa) = ($line =~
/^(\w+),\s*(\w+)\s*(\d+)\s*(\d+\.\d+)$/);
}
You might be also able to use split. Hope that helps.
--
Ala Qumsieh | No .. not just another
ASIC Design Engineer | Perl Hacker!!!!!
Matrox Graphics Inc. |
Montreal, Quebec | (Not yet!)
------------------------------
Date: Wed, 03 Jun 1998 10:17:18 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: very quick s/// question
Message-Id: <35755AEE.3861EA01@matrox.com>
James Lawrence wrote:
> can you tell me what's wrong with this?
> --------
>
> #!/usr/bin/perl -w
>
> $str = "a b c" ;
> $str =~ s/(\w)\s(\w)/$1\*$2/g ;
The first (\w) is matching the "a" and the second one is matching the
"b". So that puts a "*" in between and looks at *THE REST* of the
variable for more matching!
> print "$str\n" ;
>
> --------
>
> I want to convert "a b c" into "a*b*c" but I get "a*b c"
> instead.
>
> -jl
If this is all what you want, then you should use either:
tr/ /*/;
or
s/\s/\*/g;
Hope this helps.
--
Ala Qumsieh | No .. not just another
ASIC Design Engineer | Perl Hacker!!!!!
Matrox Graphics Inc. |
Montreal, Quebec | (Not yet!)
------------------------------
Date: Wed, 3 Jun 1998 13:31:16 GMT
From: David Cross-cmt <Dave.Cross@gb.swissbank.com>
Subject: Re: Year 2000 Compliant
Message-Id: <eq0hg22a9y3.fsf@gb.swissbank.com>
"Robert Page" <robertpage@capitalgroup.co.uk> writes:
> Can anyone point me in the direction of information covering the various
> versions of Perl that covers year 2000 compliancy.
Look in perlfaq4 for the section "Does Perl have a year 2000 problem?".
To summarise: Perl doesn't, your programs might have.
hth,
Dave...
--
If I wasn't so busy writing status reports,
my status report might just become a progress report.
Dave.Cross@gb.swissbank.com
------------------------------
Date: 3 Jun 1998 14:37:59 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: Year 2000 Compliant
Message-Id: <slrn6nanu7.2qd.Tom.Grydeland@mitra.phys.uit.no>
On 3 Jun 98 11:20:15 GMT,
Robert Page <robertpage@capitalgroup.co.uk> wrote:
> Can anyone point me in the direction of information covering the various
> versions of Perl that covers year 2000 compliancy.
>
Some questions are asked more often than others. These are called
"Frequently Asked Questions", abbreviated FAQ.
In many cases, to avoid answering the same questions over and over,
some helpful soul compiles a list of such questions with authoritative
answers. It is commonly considered a minimum effort to search for such
a list and consult it before posting your problem to the newsgroup
-- especially if you're a beginner, since your problem is then even less
likely to be new. --
With your copy of perl, you should have received extensive
documentation, and the Perl FAQ is part of this documentation.
A search for the word "2000" in the headlines of the FAQ pages gives
only one hit:
perlfaq4.pod: =head2 Does Perl have a year 2000 problem?
That seems oddly appropriate, don't you think?
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
- Do radioactive cats have 18 half-lives? -
------------------------------
Date: 3 Jun 1998 15:40:23 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Year 2000 Compliant
Message-Id: <6l3qp7$rj5$2@client3.news.psi.net>
Robert Page (robertpage@capitalgroup.co.uk) wrote on MDCCXXXVII September
MCMXCIII in <URL: news:01bd8edf$c44131a0$ef0416c3@ccb030.capital>:
++ Can anyone point me in the direction of information covering the various
++ versions of Perl that covers year 2000 compliancy.
Read the FAQ.
Abigail
--
perl -pwle '$_ .= reverse'
------------------------------
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 2797
**************************************