[11601] in Perl-Users-Digest
Perl-Users Digest, Issue: 5201 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 22 18:07:26 1999
Date: Mon, 22 Mar 99 15:00:23 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 22 Mar 1999 Volume: 8 Number: 5201
Today's topics:
07111 -> 7111? <dhenders@cpsgroup.com>
Re: 07111 -> 7111? <jglascoe@giss.nasa.gov>
Re: 07111 -> 7111? (Larry Rosler)
Re: [Q] Big-endian IEEE floats I/O with perl <rgammans@computer-surgery.co.uk>
Re: Accessing database on a PC via ODBC <greg2@surfaid.org>
Database suggestion (Neil Prater)
Re: Difficult hex code replacement problem ran@netgate.net
Re: Difficult hex code replacement problem (Abigail)
Environment variables on Win32 <chad13@bellsouth.net>
FUNCTION accessing args in a sub <zenno22@hotmail.com>
Re: FUNCTION accessing args in a sub <jglascoe@giss.nasa.gov>
Hash Out Of Memory <thollowe@opentext.com>
Re: Hash Out Of Memory (Sam Holden)
Re: Help Needed Please!!! <gellyfish@btinternet.com>
listing Changed deleted and new files (Joonas Timo Taavetti Kekoni)
Re: looking for script... <jglascoe@giss.nasa.gov>
Re: Odd/Even (Larry Rosler)
Re: Passing @ references into and outof sub procedures. <stampes@xilinx.com>
Re: Passing @ references into and outof sub procedures. <kimntodd@dontspamus.execpc.com>
Re: Perl passing arguements to a Web Page <Tony.Curtis@vcpc.univie.ac.at>
Perl processes (Neil Prater)
perl, sendmail and memory problem nick_cotter@my-dejanews.com
PHP newsgroup (Joonas Timo Taavetti Kekoni)
Q: guestbook in middle of document. <gilion@freemail.nl>
Re: Q: opening multiple filehandles concurrently? <gellyfish@btinternet.com>
Re: Sending Mail Though SMTP (Charles DeRykus)
Re: Sending/recieving scsi commands - DLT on Solaris (Casper H.S. Dik - Network Security Engineer)
String chopping <greg2@surfaid.org>
Re: String chopping <jglascoe@giss.nasa.gov>
Re: String chopping (Sam Holden)
Re: String chopping (Jeff Dickens)
Re: Substitution question (Tad McClellan)
Re: Weird $_ behavior <sternji@mail.northgrum.com>
Re: Where to start with Perl (DadKind)
WIN 95 - How to run (velocity)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 22 Mar 1999 15:10:25 -0600
From: Dale Henderson <dhenders@cpsgroup.com>
Subject: 07111 -> 7111?
Message-Id: <87soaxkz7i.fsf@camel.cpsgroup.com>
I've written a script that reads in data some of it is zipcodes,
and some of those have leading zeros (i.e. 07111) perl converts
these to numeric values and when they are printed I get the
value without leading zeros. How do I keep perl from doing this?
How can I print in string context? (I've tried printf "%s").
Thanks
--
Dale Henderson <mailto:dhenders@cpsgroup.com>
"Imaginary universes are so much more beautiful than this stupidly-
constructed 'real' one..." -- G. H. Hardy
------------------------------
Date: Mon, 22 Mar 1999 16:57:16 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Dale Henderson <dhenders@cpsgroup.com>
Subject: Re: 07111 -> 7111?
Message-Id: <36F6BCBC.846887B2@giss.nasa.gov>
[courtesy copy of post sent to cited author]
Dale Henderson wrote:
>
> I've written a script that reads in data some of it is zipcodes,
> and some of those have leading zeros (i.e. 07111) perl converts
> these to numeric values <SNIP>
Perl does no such thing unless you treat the string as
a number, e.g.
$foo = "07111";
print "string: $foo\n";
$bar = "07111";
$bar *= 1; # multiply "$bar" by one.
print "number: $bar\n";
Jay Glascoe
--
> "Imaginary universes are so much more beautiful than this stupidly-
> constructed 'real' one..." -- G. H. Hardy
------------------------------
Date: Mon, 22 Mar 1999 14:02:08 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: 07111 -> 7111?
Message-Id: <MPG.11605dc0f48e641c9897a7@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <87soaxkz7i.fsf@camel.cpsgroup.com> on 22 Mar 1999 15:10:25 -
0600, Dale Henderson <dhenders@cpsgroup.com> says...
>
> I've written a script that reads in data some of it is zipcodes,
> and some of those have leading zeros (i.e. 07111) perl converts
> these to numeric values and when they are printed I get the
> value without leading zeros. How do I keep perl from doing this?
> How can I print in string context? (I've tried printf "%s").
There are many ways to print a number padded to a specific length with
leading zeros. The following is one of the simplest:
printf '%.5d', $zipcode;
--
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 22 Mar 1999 20:48:19 +0000
From: Roger Gammans <rgammans@computer-surgery.co.uk>
Subject: Re: [Q] Big-endian IEEE floats I/O with perl
Message-Id: <cJ1rEGATyq92Ewqs@computer-surgery.co.uk>
In article <MPG.1159795de7015a4f989776@nntp.hpl.hp.com>, Larry Rosler
<lr@hpl.hp.com> writes
>[Posted and a courtesy copy sent.]
>
>In article <36EFCBEB.5AD74BD@ltt.ntua.gr> on Wed, 17 Mar 1999 17:36:11
>+0200, Costis Angelis <loulou@ltt.ntua.gr >says...
>> I handle very often large files containing float numbers, single
>> precision in binary format. Since I work both on Linux and IRIX, I would
>> like to know if there is any easy way to deal with portability problems.
>
>But there is a similar standard convention, and it predates Perl!
>
>There is an IEEE standard representation for both single- and double-
>precision floating-point numbers, which is by now universal among
>hardware systems.
>Hmmm. I just took another look at the Subject of your post, and see
>that you are aware of endian and IEEE issues.
I've being giving the matter of x-architecture data portability some
thought for the last week, I threw together the bare bones of a module
which may be able to help if you want to be really sure about endian
issues. But it is complete overkill for the big<->little endian case
with ints. [1]
I'm not 100% sure of the IEEE issues with byte stream storage, however
with some tweaks what I've written may be useful - bear in mind it's
pre-alpha atm,
But I also notice Costis said that he uses single precision, iirc the
IEEE std correctly they are just 32bits, so quick reverse op on each
float before unpacking might solve your problem with single precision
floats.
> Maybe you are just overly
>concerned about the man pages that you quote without citation. Which
>are they?
Well, perlfunc under pack() [perl 5.005_02] reads in part -
Real numbers (floats and doubles) are in
the native machine format only; due to the
multiplicity of floating formats around, and the
lack of a standard "network" representation, no
facility for interchange has been made. This
means that packed floating point data written on
one machine may not be readable on another - even
if both use IEEE floating point arithmetic (as the
endian-ness of the memory representation is not
part of the IEEE spec).
Is what is said here not correct in some way?
TTFN
[1] To diverge the thread a little I'm planning on writing some tools
for manipulating binary files via a Tie to a Array/Hash
representation. This is part of a toolkit I would like to use for
analysing binary file formats. The above module is `prerequisite'
to get this to work well.
I still consider myself fairly new to Perl, so would like to
discuss this in an appropriate forum...., to ensure I do it
in `the best possible taste'.
--
Roger Gammans
------------------------------
Date: Mon, 22 Mar 1999 22:13:23 +0000
From: Greg Griffiths <greg2@surfaid.org>
To: e_ron.no.spam@netvision.net.il
Subject: Re: Accessing database on a PC via ODBC
Message-Id: <36F6C083.767F1C30@surfaid.org>
ODBC.pm by Dave Roth from http://www.roth.net is a very easy to use
tool, also there is DBI or DBD from PERL as the main entrants. I've used
DBI and ODBC.pm and found both to be nice and easy to use. Although
there are many other methods of doing it, mail me for a more detailed
discussion.
Ron wrote:
>
> Can someone explain how can I do it using Perl
------------------------------
Date: Mon, 22 Mar 1999 14:16:30 -0800
From: neil.prater@ype.gmpt.gmeds.com (Neil Prater)
Subject: Database suggestion
Message-Id: <WizJ2.18432$EF1.73696383@WReNphoon1>
What would be the best possible database tool to run with perl on a unix
platform. I currently dump my output to a text file and just go from there,
but I want to be more efficient. I've read about oraperl, but I'm not sure
what my options are. I'm the only perl programmer
in the area, so I'm kinda limited when I ask for suggestions. Anything you
got would be greatly appreciated.
Thank you
**** Posted from RemarQ - http://www.remarq.com - Discussions Start Here (tm) ****
------------------------------
Date: Mon, 22 Mar 1999 20:12:24 GMT
From: ran@netgate.net
Subject: Re: Difficult hex code replacement problem
Message-Id: <922133544.473.93@news.remarQ.com>
In <7d5u0t$svk$1@nnrp1.dejanews.com>, thst@my-dejanews.com writes:
>But this doesn't work. Why ?
I think the answer is in your headers:
>X-Http-User-Agent: Mozilla/4.5 [de] (WinNT; I)
It's an old feature, going all the way back to DOS 1.0: for
compatibility with data files and programs ported from CP/M, DOS
recognized the 0x1a as an "end-of-file" marker when reading files in
"text" mode, and stripped it (CP/M stored the file size in sectors,
not bytes, so it needed the marker in the last block).
If you put a " print $#oldlines; " in the program, I believe you'll see
a "0" (or 1 less than you expect, if there's more data ahead of your
sample).
To do the substitution, you'll need to read the file in "binary" mode.
Ran
------------------------------
Date: 22 Mar 1999 20:21:28 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Difficult hex code replacement problem
Message-Id: <7d68o8$42o$3@client2.news.psi.net>
thst@my-dejanews.com (thst@my-dejanews.com) wrote on MMXXIX September
MCMXCIII in <URL:news:7d5u0t$svk$1@nnrp1.dejanews.com>:
~~ I was really surprised about the following problem:
~~ Assuming that there is a file with the following contents (in hex code):
~~ ...
~~ 20 64 73 64 73 20 67 68
~~ 66 68 6B 0D 0A 1A 20 20
~~ 67 66 64 67 20 68 66 64
~~ ....
~~ Now I want to replacing this mysterious 1A bytes with a blank (20)
~~
~~ For that I am applying the following statements to the file
~~ @oldlines = <OLDFILE>;
~~ ...
~~ for ($i = $#oldlines; $i >= 0; $i--) {
~~ $oldlines[$i] =~ s/\x1A/\x20/g; }
~~ ...
~~ But this doesn't work. Why ?
In which sense didn't it work? What did you expect it to do, and what
did it? And why are you using C-ish style loops?
foreach (@oldlines) {s/\x1A/\x20/g}
Abigail
--
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'
------------------------------
Date: Mon, 22 Mar 1999 15:49:48 -0500
From: Chad Holliday <chad13@bellsouth.net>
Subject: Environment variables on Win32
Message-Id: <36F6ACEC.87E3AD63@bellsouth.net>
Hello,
I am a Perl newbie struggling with a script on NT. My script sets the
PATH environment variable using
$ENV{'PATH'} = <my new path> . $ENV{'PATH'}
but subsequent calls to system() cannot find the executable in the new
path. Strangely, calls to 'which' do find the executable, so something
was set correctly.
Does Perl retain your initial environment settings for all system
calls? Does this only happen on Win32? This behavior does not seem to
happen on Unix systems.
Thanks,
Chad
------------------------------
Date: Mon, 22 Mar 1999 21:39:16 +0100
From: Zenno <zenno22@hotmail.com>
Subject: FUNCTION accessing args in a sub
Message-Id: <36F6AA68.5499F85B@hotmail.com>
Hi all -
I want to access arguments I gave a function:
#@Klant_EMaildata = a list of lists;
@fields = (2,3,10);
@Klant_EMaildata = &get_Filtered_List(@Klant_EMaildata,@fields);
sub get_Filtered_List {
my(@org_List) = $_[0];
my(@filterElts) = $_[1];
my(@result_List) = ();
but
print $org_List[0][10] . "<BR>";
print $filterElts[1];
prints nothing...
How can I access the arguments in my sub?
Thanks,
Marc
zmbakker@xs4all.nl
------------------------------
Date: Mon, 22 Mar 1999 15:56:26 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Zenno <zenno22@hotmail.com>
Subject: Re: FUNCTION accessing args in a sub
Message-Id: <36F6AE7A.3D0447DB@giss.nasa.gov>
[courtesy copy of post sent to cited author]
Zenno wrote:
>
> Hi all -
hello,
you should use "references": perldoc perlref
my $c_array_ref = my_sub(\@a_array, \@b_array);
my @c_array = @$c_array_ref;
sub my_sub {
# return the concatenation of two lists
my ($a_array_ref, $b_array_ref) = @_;
my @c_array = (@$a_array_ref, @$b_array_ref);
return \@c_array;
}
Jay Glascoe
--
"'We promise, yes I promise!' said Gollum. 'I will serve
the master of the Precious. Good master, good Smeagol,
*gollum*, *gollum*!' Suddenly he began to weep and bite
at his ankle again."
--J.R.R.T.
------------------------------
Date: Mon, 22 Mar 1999 16:20:56 -0500
From: "Skip Hollowell" <thollowe@opentext.com>
Subject: Hash Out Of Memory
Message-Id: <7d6c6o$d86@enews4.newsguy.com>
Got a problem and have looked at it from many sides now. This was a great
concept when playing with 10, 1000 or 100000 terms, but now I am informed I
may have as many as 10,000,000 terms to count in this application. I have
been storing these terms in a hash, and every time the term repeats itself,
I increment the hash value for that term by 1. Makes sense, right? Well
now, when the number of terms gets this large, things get nutty as the
system runs out of memory at about term number 4.5 million. (768 MB of
memory on my solaris.)
So how do you play with large sets of data that need to be manipulated. I
can't even do UNIX sort on it without running out of disk space. The code
that follows is taking each term in hash 1, mixing it with each term in hash
2 and creating the terms in the $words hash. Hash 1 and Hash 2 are then
undef'd and things continue on. This is called 50,000+ times to create the
final list of all $words, with their correspnding counts.
Any ways I can approach this that you can think of off hand in Perl?
while ( ($key1, $value1) = each %first) {
while ( ($key2, $value2) = each %tmp) {
$key = $key1 . ' --- ' . $key2;
$words{$key} = $words{$key} + 1;
}
}
Skip Hollowell
------------------------------
Date: 22 Mar 1999 22:42:20 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Hash Out Of Memory
Message-Id: <slrn7fdhqc.pvk.sholden@pgrad.cs.usyd.edu.au>
Skip Hollowell <thollowe@opentext.com> wrote:
>Got a problem and have looked at it from many sides now. This was a great
>concept when playing with 10, 1000 or 100000 terms, but now I am informed I
>may have as many as 10,000,000 terms to count in this application. I have
>been storing these terms in a hash, and every time the term repeats itself,
>I increment the hash value for that term by 1. Makes sense, right? Well
>now, when the number of terms gets this large, things get nutty as the
>system runs out of memory at about term number 4.5 million. (768 MB of
>memory on my solaris.)
>
>So how do you play with large sets of data that need to be manipulated. I
>can't even do UNIX sort on it without running out of disk space. The code
>that follows is taking each term in hash 1, mixing it with each term in hash
>2 and creating the terms in the $words hash. Hash 1 and Hash 2 are then
>undef'd and things continue on. This is called 50,000+ times to create the
>final list of all $words, with their correspnding counts.
>
>Any ways I can approach this that you can think of off hand in Perl?
>
>
> while ( ($key1, $value1) = each %first) {
> while ( ($key2, $value2) = each %tmp) {
> $key = $key1 . ' --- ' . $key2;
> $words{$key} = $words{$key} + 1;
> }
> }
Well you need to store the count somewhere, so either put it in memory
or put it on disk. Using a hash tied to a dbm might enable you to store
the data on disk by simply adding a few lines to the start of the code, to
tie the hash to a file.
However, I don't know the internals of how dbms work, and for all I know
they might cache all the values you have entered in RAM. I would of
course assume, they use a much more intelligent scheme, and add the lines
of code and see if it improves the situation.
See perldoc -f tie.
Of course you may not have enough disk space either.
--
Sam
Even if you aren't in doubt, consider the mental welfare of the person
who has to maintain the code after you, and who will probably put parens
in the wrong place. --Larry Wall
------------------------------
Date: 22 Mar 1999 21:12:34 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Help Needed Please!!!
Message-Id: <7d6bo3$l7$1@gellyfish.btinternet.com>
On Mon, 22 Mar 1999 00:26:29 +0000 On Line Auctions UK wrote:
<snip HTML>
>
> CGI Script,
> #!/bin/perl
>
> $count = 0;
> $type = "Sail";
>
> &readdata;
>
> sub readdata {
>
> #read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
>
> $buffer = $ENV{QUERY_STRING};
>
> @pairs = split(/&/, $buffer);
>
D'oh !! you used a method of POST in your form but you are getting your
parameters from $ENV{QUERY_STRING} - that just wont work ... you've gotta
read it from STDIN in this case.
Anyhow I really would recommend using CGI.pm to do this stuff it really
does make sense.
>
> print "Content-type: text/html\n\n";
> print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">
> <HTML>
<snip the rest>
You *really do* want to be using a here document to be doing this - you
dont have to worry about all that backwahcking and you wont get confused
by the end of the string -
print <<EIEIO;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
...
EIEIO
Of course if you use CGI.pm you could get rid of a lot of that using the
HTML production methods - check it out you'll never turn back...
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 22 Mar 1999 21:58:58 GMT
From: jkekoni@cc.hut.fi (Joonas Timo Taavetti Kekoni)
Subject: listing Changed deleted and new files
Message-Id: <7d6ef2$1lou$1@midnight.cs.hut.fi>
Has anyone created a solution that can get list
of changed,deleted and new files on certain tree.
DATA::Dumper, MD5 and FILE::Find should do it, but i am sure that
i am not the first one that has had need for thing like this, so
the is no idea for reinventing an obsolate code..
And non perlish(unix) solutions are ok too.
My idea is to have a computer to replicate all changed files to another
computer over a slow network.
--
_- Joonas Kekoni OH2MTF I -_
_-internet: jkekoni@cc.hut.fi I DO NOT EAT. -_
_-slowmail: j{mer{ntaival 7a176 I -_
_- 02150Espoo I It is a monitor -_
_- Finland/Europe I -_
------------------------------
Date: Mon, 22 Mar 1999 15:08:37 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
Subject: Re: looking for script...
Message-Id: <36F6A345.E6BF9A1F@giss.nasa.gov>
having second thoughts on my example:
Jay Glascoe wrote:
>
> perl -0777 -i.bak -ne '
> BEGIN { $id = shift }
> m/(:?^|\n)$id: (.*?)(:?\n\d+:|$)/s and print $2;
> ' 32784 input_file
this copies the data from file "input_file" to "input_file.bak"
then writes everything from the given id to the next id
to the file "input_file". So, running this command twice
could destroy your "input_file".
This is safer:
perl -0777 -ne '
BEGIN { $id = shift }
m/(:?^|\n)$id: (.*?)(:?\n\d+:|$)/s and print $2;
' 32784 input_file > output_file
it leaves "input_file" untouched and writes the results
to standard out (here redirected to "output_file").
Also, Ala's answer is better in situations where the input
file is very large. My command, because of the "-0777",
slurps in the entire file prior to processing.
> Jay Glascoe
--
> cheese! :o)
------------------------------
Date: Mon, 22 Mar 1999 11:55:22 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Odd/Even
Message-Id: <MPG.11604002287daa909897a6@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7d6465$r7m@news.service.uci.edu> on Mon, 22 Mar 1999
11:06:30 -0800, Gabriel Richards <grichard@uci.edu> says...
...
> I'm looking in my Camel book and can't find a way to test if a number is
> even/odd or if a number is an integer as opposed to floating point (then I
> could just divide by 2 and test for an integer).
if ($n % 2 == 0) { print "$n is even\n" }
if (int($n) == $n) { print "$n is an integer\n" }
--
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com == 0
------------------------------
Date: 22 Mar 1999 19:01:32 GMT
From: Jeff Stampes <stampes@xilinx.com>
Subject: Re: Passing @ references into and outof sub procedures.
Message-Id: <7d642c$7q1@courier.xilinx.com>
End User <kimntodd@dontspamus.execpc.com> wrote:
: sub netdom_bdc{
: open(NETDOM, "netdom /domain:$_[0] BDC|");
: while (defined($line=<NETDOM>)){
: if ($line =~ /^BDC/){
: $dc = substr($line,12,15);
: $dc =~ s/\s//;
: push (@BDC, $dc);
: }
: return (\@bdc);
: }
: It should return a list of machines that are BDC's in my domain. Instead,
: this is what it gives me:
Nope, it should return what you told it to return, which is a
reference to an array
: BDC of DOMAIN = ARRAY(0x9b623c)
And that's what it did!
So when it's returned, work with it as a refence, not an array...
meaning:
$foo = Routine_that_returns_ref();
foreach (@{$foo})
{
do_something();
}
read the perlref manpage to better understand references in perl.
--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com
------------------------------
Date: Mon, 22 Mar 1999 15:14:26 -0600
From: "End User" <kimntodd@dontspamus.execpc.com>
Subject: Re: Passing @ references into and outof sub procedures.
Message-Id: <7d6bsh$n4k$1@ffx2nh3.news.uu.net>
Actually, this works just fine. I realized a couple of typo's in my original
post, but here is the fix:
@todd = netdom_bdc(domain);
foreach $todd(@todd){
print "BDC for domain= $todd\n";}
sub netdom_bdc{
open(NETDOM, "netdom /domain:$_[0] BDC|");
while (defined($line=<NETDOM>)){
if ($line =~ /^BDC/){
$dc = substr($line,12,15);
$dc =~ s/\s//;
push (@bdc, $dc);
}
}
return @bdc;
}
>@DBC;
>@todd = netdom_bdc(DOMAIN);
>foreach $todd(@todd){
> print "BDC for DOMAIN= $todd\n";}
>
>sub netdom_bdc{
> open(NETDOM, "netdom /domain:$_[0] BDC|");
> while (defined($line=<NETDOM>)){
> if ($line =~ /^BDC/){
> $dc = substr($line,12,15);
> $dc =~ s/\s//;
> push (@BDC, $dc);
> }
> return (\@bdc);
> }
>
>}
>
>It should return a list of machines that are BDC's in my domain. Instead,
>this is what it gives me:
>
>BDC of DOMAIN = ARRAY(0x9b623c)
>
>Why cant I get it to return the list of servers?
>
>Thanks in advance,
>--
>Todd Hayward
>Global Analyst, Systems Engineer
>MCSE, Compaq ACT
>noc at bakernet dot com
>
>
------------------------------
Date: 22 Mar 1999 21:16:00 +0100
From: Tony Curtis <Tony.Curtis@vcpc.univie.ac.at>
Subject: Re: Perl passing arguements to a Web Page
Message-Id: <83ogll701r.fsf@vcpc.univie.ac.at>
Re: Perl passing arguements to a Web Page,
timespinner <timespinner@my-dejanews.com> said:
timespinner> I know a web page passes environment
timespinner> variables to a Perl script, but is it
Fraid not, it's the browser that passes things.
timespinner> possible to do the reverse? Can you
Not sure what that might mean, but...
timespinner> Page_A is a form and when submitted
s/is/contains/
timespinner> executes script Perl_A Perl_A
timespinner> manipulates data then sets environment
timespinner> variables $var_a and $var_b then
timespinner> redirects to Page_B which is a form
timespinner> which contains variables $var_a and
timespinner> $var_b?
Nope, the environment is not the way to do it. What
you'll want here are the LWP modules.
timespinner> Basically, is it possible to return an
timespinner> HTML page that is:
Yes, servers can return just about anything they
want.
timespinner> 1) Not included in the perl script
Yes (obviously). Otherwise the server wouldn't be
able to return static HTML documents.
perldoc LWP
perldoc HTTP::Request
may bring some enlightenment.
hth
tony
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien. | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds! | private email:
Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>
------------------------------
Date: Mon, 22 Mar 1999 14:07:02 -0800
From: neil.prater@ype.gmpt.gmeds.com (Neil Prater)
Subject: Perl processes
Message-Id: <1azJ2.18358$EF1.73649455@WReNphoon1>
I have a perl program running from the netscape command action line inside
my index.html file. Inside my perl program I
run a few unix commands. When the submit button is clicked, the perl program
executes but will not go forth until the unix
command is dead. Is there any way to fork the process within perl? If so
how? Any help would be greatly appreciated.
**** Posted from RemarQ - http://www.remarq.com - Discussions Start Here (tm) ****
------------------------------
Date: Mon, 22 Mar 1999 20:45:15 GMT
From: nick_cotter@my-dejanews.com
Subject: perl, sendmail and memory problem
Message-Id: <7d6a4o$841$1@nnrp1.dejanews.com>
Hi there,
I have a perl script that's run from a line in /etc/aliases. It works fine on
the Linux box I developed it on but it runs out of memory on a FreeBSD system.
In fact it runs out of memory in the middle of a "require" statement.
Does anyone have any tips on how I could track down this memory problem? I
can't seem to locate it. Could there be a problem with the amount of memory
sendmail can allocate - and is there a way of changing this?
Any help would be greatly appreciated,
Cheers
Nick Cotter
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 22 Mar 1999 21:59:31 GMT
From: jkekoni@cc.hut.fi (Joonas Timo Taavetti Kekoni)
Subject: PHP newsgroup
Message-Id: <7d6eg3$1lou$2@midnight.cs.hut.fi>
Is there a newsgroup for PHP?
(sorry for non perl question)
--
_- Joonas Kekoni OH2MTF I -_
_-internet: jkekoni@cc.hut.fi I DO NOT EAT. -_
_-slowmail: j{mer{ntaival 7a176 I -_
_- 02150Espoo I It is a monitor -_
_- Finland/Europe I -_
------------------------------
Date: Mon, 22 Mar 1999 22:51:04 +0100
From: "Gilion Hautvast" <gilion@freemail.nl>
Subject: Q: guestbook in middle of document.
Message-Id: <922135751.623913@server1.wish.net>
Hi,
I'm a newbie and I just did a tutorial on a guestbook. After doing so I only
had one question:
How can I past the output of my script in the middle of a document?
I learned how to add the output on the end using APPEND.
Thanks in advance,
Gilion Hautvast
gilion@freemail.nl
http://come.to/gilion
ICQ within days.
------------------------------
Date: 22 Mar 1999 22:00:01 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Q: opening multiple filehandles concurrently?
Message-Id: <7d6eh1$mv$1@gellyfish.btinternet.com>
On Sun, 21 Mar 1999 08:18:56 -0800 Larry Rosler wrote:
>
> A new one on me. Fourth definition in my dictionary: 'Informal. A
> few, several: "a couple of days"'. Funny. I always thought that that
> phrase meant "the day after tomorrow". (Every other sense of 'couple'
> in that dictionary is explicitly "two".)
>
As a programmer I'm surprised that you havent run into this usage before -
its well known what *I* mean when I estimate 'a couple of days' for some job
;-}
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Mon, 22 Mar 1999 22:11:40 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Sending Mail Though SMTP
Message-Id: <F90oBG.AKH@news.boeing.com>
In article <36F47619.6197A045@spots.ab.ca>,
Martin Foster <mfoster@spots.ab.ca> wrote:
>Though I have a copy of sendmail on my system, I would much rather
>employ a SMTP connection to send out mail if needed. While this may
>seem pointless to some, it is necessary for me, to have portable code,
>and that means being able to local machines with Sendmail or systems
>that have access to a SMTP server but no direct access to sendmail.
>
>I have constructed a rather rudimentary script that works fairly well on
>a Sendmail server. I have yet to try it on another MTA as yet, so I
>cannot be sure that it will work at all times... But I will admit that
>it will most probably fail. The problem, with the current script is
>the error messages it produces while I am sending out a message.
>Hopefully someone can help, though given time and another few books
>(Code based off Learning Perl, Perl Cookbook did not help), I might be
>able to pull it off.
>
Alternatively, wouldn't using Net::SMTP (see libnet on CPAN)
eliminate some debugging...
hth,
--
Charles DeRykus
------------------------------
Date: 22 Mar 1999 20:54:55 GMT
From: Casper.Dik@Holland.Sun.Com (Casper H.S. Dik - Network Security Engineer)
Subject: Re: Sending/recieving scsi commands - DLT on Solaris
Message-Id: <casper.922136042@nl-usenet.sun.com>
[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]
karrer@iis.ee.ethz.ch (Andreas Karrer) writes:
>I doubt that this (accessing non-standard SCSI commands of non-standard
>SCSI devices) would be possible on Solaris in a simple way with Perl
>or some other Unix user space utility.
It is possible; the Solaris SCSI devices can be opened and a user
program can then perform "USCSI" ioctls which are basically just SCSI
commands.
Casper
--
Expressed in this posting are my opinions. They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.
------------------------------
Date: Mon, 22 Mar 1999 21:07:34 +0000
From: Greg Griffiths <greg2@surfaid.org>
Subject: String chopping
Message-Id: <36F6B116.F6F2DB75@surfaid.org>
Dear All,
I have what is probably a trivial one for you all. I have an ID number
followed by a delimeter and then a string, for example :
123. Joe Bloggs
5} Hello World12
To abstract, they are all in the format :
<numeric ID> <delimeter> <alphanumeric string>
What I need to do is to get at the numeric part only as it is my
identifier. I've played about with this for a while nad not really got
anywhere, so any help or code snippets would be appreciated.
------------------------------
Date: Mon, 22 Mar 1999 16:44:58 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Greg Griffiths <greg2@surfaid.org>
Subject: Re: String chopping
Message-Id: <36F6B9DA.2303F27B@giss.nasa.gov>
[courtesy copy of post sent to cited author]
hi Greg,
Greg Griffiths wrote:
>
> Dear All,
> I have what is probably a trivial one for you all. I have an ID number
> followed by a delimeter and then a string, for example :
>
> 123. Joe Bloggs
> 5} Hello World12
while (chomp(my $line = <FILE>)) {
my ($id, $delim, $rest) = ($line =~ m/^(\d+)(.)\s*(.*)$/);
# do something with "id", $delim", "$rest".
}
> To abstract, they are all in the format :
>
> <numeric ID> <delimeter> <alphanumeric string>
I assume every line begins with a numeric id (no leading spaces).
I'm also assuming the "string" part extends to the end of the line
and has no embedded newlines.
Jay Glascoe
--
boing.
------------------------------
Date: 22 Mar 1999 22:18:41 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: String chopping
Message-Id: <slrn7fdge1.pvk.sholden@pgrad.cs.usyd.edu.au>
On Mon, 22 Mar 1999 21:07:34 +0000, Greg Griffiths <greg2@surfaid.org> wrote:
>Dear All,
> I have what is probably a trivial one for you all. I have an ID number
>followed by a delimeter and then a string, for example :
>
>123. Joe Bloggs
>5} Hello World12
>
>To abstract, they are all in the format :
>
><numeric ID> <delimeter> <alphanumeric string>
>
>What I need to do is to get at the numeric part only as it is my
>identifier. I've played about with this for a while nad not really got
>anywhere, so any help or code snippets would be appreciated.
If you posted what you tried then maybe people could tell you where you
went wrong...
A simple solution which generates warnings with warnings enabled is :
$id = $string+0;
Reading the documentation that comes with perl will show you numerous other
ways of achieving you task.
--
Sam
I took the initiative in creating the Internet.
--Al Gore
------------------------------
Date: Mon, 22 Mar 1999 22:30:22 GMT
From: jdickens@ersi.com (Jeff Dickens)
Subject: Re: String chopping
Message-Id: <36f6bfa7.615112154@news.alt.net>
A regular expression would do the trick:
#!/usr/bin/perl
$_ = '123. joe blow';
/(\d+)\.(.*)/;
$id = $1; $rest = $2;
print "orig is $_ \n id is $id and rest is $rest\n";
You can get pretty fancy with the REs... parse most any tabular data
file.
On Mon, 22 Mar 1999 21:07:34 +0000, Greg Griffiths <greg2@surfaid.org>
wrote:
>Dear All,
> I have what is probably a trivial one for you all. I have an ID number
>followed by a delimeter and then a string, for example :
>
>123. Joe Bloggs
>5} Hello World12
>
>To abstract, they are all in the format :
>
><numeric ID> <delimeter> <alphanumeric string>
>
>What I need to do is to get at the numeric part only as it is my
>identifier. I've played about with this for a while nad not really got
>anywhere, so any help or code snippets would be appreciated.
------------------------------
Date: Mon, 22 Mar 1999 10:14:13 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Substitution question
Message-Id: <5om5d7.8l.ln@magna.metronet.com>
Scratchie (upsetter@ziplink.net) wrote:
: Tad McClellan <tadmc@metronet.com> wrote:
: : Scratchie (upsetter@ziplink.net) wrote:
: : : Also, the backslash is unneccesary before the @ in a regex.
: : The backslash is necessary before the @ in double quotish strings.
: : Regex patterns are double quotish.
: : The backslash is necessary.
: My mistake. It works if you're just looking for an '@' sign (/@/) but
: requires a backslash otherwise.
^^^^^^^^^^
^^^^^^^^^^
That isn't really "it" either...
When its use is ambiguous (is that an array to interpolate or an
at sign?) *then* you need to disambiguate it for perl.
It is ambiguous when what follows the @ "looks like" (Perl's idea of)
a "name".
It is not ambiguous when what follows cannot be an array name.
"name"s are discussed in the first several paragraphs of 'perldata.pod'.
------------------
#!/usr/bin/perl -w
use strict;
$_ = 'foo@bar';
print "matched '$1' in '$_'\n" if /(\@b)/; # need to escape
$_ = 'foo@bar';
print "matched '$1' in '$_'\n" if /(@[b])/; # no escape needed
$_ = 'foo@;bar';
print "matched '$1' in '$_'\n" if /(@;)/; # no escape needed
------------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 22 Mar 1999 19:42:37 GMT
From: "James M. Stern" <sternji@mail.northgrum.com>
Subject: Re: Weird $_ behavior
Message-Id: <36F69D2D.EBA16030@mail.northgrum.com>
Scratchie wrote:
> [...]
>
> foreach (`ls $DATA_DIR`) {
> [Code that uses $_]
>
> # hard code values for testing purposes
> # $cont{$_} = { &File2Hash2($file) };
> $cont{$_} = { 'key1' => 'value1', 'key2' => 'value2' };
>
> print "This is \$_: ", $_, "\n";
> }
> }
> [ It works unless he uncomments the File2Hash2 call. File2Hash2 is:]
> sub File2Hash2 {
> my ($input) = shift @_;
> open (FILE,$input) or die ("Could not open $input: $!");
>
> my %hash;
> my ($key, $value);
> while (<FILE>) {
> chomp;
> # assumes two-field layout
> ($key,$value) = split(/\t/);
> $hash{$key} = $value;
> }
> close FILE;
> return %hash;
> }
> [...]
Localize $_ in File2Hash2. Otherwise the first pass through the 'while'
loop clobbers the caller's $_.
--
James M. Stern Northrop Grumman Corp. Hawthorne, CA
Opinions expressed above are not necessarily my employer's.
------------------------------
Date: Mon, 22 Mar 1999 21:28:16 GMT
From: NOSPAMdadkind@thesocket.com (DadKind)
Subject: Re: Where to start with Perl
Message-Id: <36f683c2.6973314@news.lightspeed.net>
On Sun, 21 Mar 1999 15:25:48 -0800, Ed Wolfe <ewolfe@involved.com>
wrote:
>> If you have the time, _Teach Yourself Perl 5
>
>Would you recommend that book to someone with no programming experience
>or knowledge at all? (Not counting what I did at home with a TI back in
>'82.)
>
>It goes great until I get to accessing arrays and then I start losing
>it. The next section is on for loops and all hope is lost.
>
>Example:
>
>@names=("Muriel","Gavin","Susanne","Sarah","Anna","Paul","Trish","Simon");
>
>for ($x=0; $x <= $#names; $x++) {
> print "$names[$x]\n";
>}
The "Perl5 in 21 Days" book seems to be pretty good. I have a
background in C/C++ but as I recall, the chapter that covers loops,
explains the semantics of the "for(....)" statement pretty good. The
one thing it lack is any mention of CGI or interfacing with HTML. But
overall, not bad.
-tomas vera
Tomas Vera
dadkind@thesocket.com
------------------------------
Date: Mon, 22 Mar 1999 21:37:42 GMT
From: kissqfjg@sp.zrz.tu-berlin.de (velocity)
Subject: WIN 95 - How to run
Message-Id: <36f6b808.5820508@news.zrz.tu-berlin.de>
Hey Folks,
I tried to begin programming in Perl because I want to develop some
scripts to make my web - page more interesting.
I 'm working with Win 95 b and because of that I downloaded
1. perl5.00402-bindist04-bc
2. Active Perl Win 32
3. Dcom 95
But I do not understand how to test my scrips with the extensions like
.cgi or .pl . Do I have to write a html or something like that ? Can
somebody rescue me ? Or can somebody send a good side with FAQ
where somebody answered my questions ?
Thank you very much
Henner
kissqfjg@sp.zrz.tu-berlin.de
------------------------------
Date: 12 Dec 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 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 5201
**************************************