[7342] in Perl-Users-Digest
Perl-Users Digest, Issue: 967 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 3 11:07:11 1997
Date: Wed, 3 Sep 97 08:00:52 -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 Sep 1997 Volume: 8 Number: 967
Today's topics:
Re: ($p=$pc) =~ s/\.[0-9]*/substr($1,3,length($1))=""/g (Lack Mr G M)
/bin/mail <phunter@cableinet.co.uk>
Re: [Q] Stupid question about "use strict" <mf@fishbone.ruhr.de>
Re: Assinging values of HASH in to Array <qdtcall@esb.ericsson.se>
Complex map problem <cphillip@kerr.phys.utas.edu.au>
Re: complex pattern?!? it shouldn't be, i think :) (Matti Kinnunen)
Re: complex pattern?!? it shouldn't be, i think :) <rootbeer@teleport.com>
Re: FTP site mirroring software? (Paul D. Smith)
Re: FTP site mirroring software? <mf@fishbone.ruhr.de>
Re: Handling complex table files (Andrew M. Langmead)
Is this you? rgr@freedomnet.com
Re: need script to modify .htpasswd <sgermain@nortel.ca>
Re: NET::NNTP Woes (M.J.T. Guy)
Re: Newbie File Locking <mf@fishbone.ruhr.de>
Re: Perl (kind of) math question. <seay@absyss.fr>
Re: perl and XEmacs (Chris Nandor)
receive binary data from an URL via Perl script? How2? (Uwe Herting)
Re: receive binary data from an URL via Perl script? Ho (Alberto BARSELLA)
Re: receive binary data from an URL via Perl script? Ho <rootbeer@teleport.com>
Script on input to perl arrays wanted - Newbie learning <nathan@cyberservices.com>
Re: Script Time <SPAMFREEcolmang@ms.com>
Re: Simple Perl for Win 32 Question (not in FAQ) <codie@concentric.net>
simple perl problem <C.Forde@Queens-Belfast.AC.UK>
Time warp - Perl 4 question <menyhert@acm.org>
UTC to locale time? (Michael Kunze)
Re: UTC to locale time? <rootbeer@teleport.com>
Re: UTC to locale time? <seay@absyss.fr>
Web Form: Fields with Multiple values <webwest@webwestdesign.com>
wee quickie on special variables <C.Forde@Queens-Belfast.AC.UK>
Wrote new module, need help with system dependencies. <beverly@kodak.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 03 Sep 1997 12:33:00 BST
From: gml4410@ggr.co.uk (Lack Mr G M)
Subject: Re: ($p=$pc) =~ s/\.[0-9]*/substr($1,3,length($1))=""/g;
Message-Id: <1997Sep3.123300@ukwit01>
In article <34049AB3.132F@btc4.up.net>, "Raymond K. Bush" <rbush@btc4.up.net> writes:
|>
|> each line has a form like:
|>
|> sdfsd 32423.3245 erye5rye eryter 234.234311111666 12314.3543254322222
|> 4456.111111111 4545.345345 dftgdfgdf.345rfwdcf34 234.dgfg 234 345 1.00
|>...
|> what i really wish i could do is something like:
|>
|> ($p=$pc) =~ s/\.[0-9][0-9]* /substr($1,3,length($1))=""/g;
|>...
|> hence my lines would become:
|>
|> sdfsd 32423.32 erye5rye eryter 234.234 12314.35
|> 4456.11 4545.34 dftgdfgdf.34 234.dgfg 234 345 1.00
Since you really do seem to want to remove alpha characters that
succeed 2 digits as well try using:
($p=$pc) =~ s/(\.\d{2}.+?\b)/substr($1,0,3)/ge;
My original thought was that you just wanted all numbers to two
significant figures, which can be done by:
($p=$pc) =~ s/(\d*\.\d+)/sprintf("%0.2f", $1)/ge;
but you obviously don't mean that....
--
----------- Gordon Lack ----------------- gml4410@ggr.co.uk ------------
The contents of this message *may* reflect my personal opinion. They are
*not* intended to reflect those of my employer, or anyone else.
------------------------------
Date: Wed, 03 Sep 1997 13:00:22 +0100
From: Peter Hunter <phunter@cableinet.co.uk>
Subject: /bin/mail
Message-Id: <340D5156.41C6@cableinet.co.uk>
Chaps,
Unable to bind to socket, any ideas why it comes up with this error.
The script is /bin/mail.
Peter Hunter
------------------------------
Date: 3 Sep 1997 14:06:40 +0200
From: Martin Fischer <mf@fishbone.ruhr.de>
Subject: Re: [Q] Stupid question about "use strict"
Message-Id: <5ujjsg$oo7$1@fishbone.ruhr.de>
Nicholas J. Leon <nicholas@neko.binary9.net> wrote:
>Ok, this is a terribly basic and simple question, yet I can't seem to
>divine it myself.
>I just (finally) started using "use strict" in my apps. Ok, not a
>problem. But what I can't seem to do is illustrated with the following
>snippets:
And have you looked after what 'use strict' mean? From perldoc strict:
strict vars
This generates a compile-time error if you access a
variable that wasn't localized via my() or wasn't
fully qualified. Because this is to avoid variable
suicide problems and subtle dynamic scoping issues,
a merely local() variable isn't good enough. See
the my entry in the perlfunc manpage and the local
entry in the perlfunc manpage.
use strict 'vars';
$X::foo = 1; # ok, fully qualified
my $foo = 10; # ok, my() var
local $foo = 9; # blows up
The local() generated a compile-time error because
you just touched a global name without fully
qualifying it.
>I've tried more variation of "$FOO=1" than I can recount. I tried
> eval "$FOO=1";
> my $FOO=1;
> local $FOO=1;
> $main::FOO=1;
> ::FOO=1;
Ahh, you nearly got it and I think you didn't knew why. Try the last one
as $::FOO, but in both files!
ciao
Martin
--
Martin Fischer <mf@fishbone.ruhr.de> -------------------
<Martin.Fischer@fh-bochum.de> | Comp Sci Student
PGP key available at: http://localhost.ruhr.de/~martin | FH-Bochum, Germany
Unsolicited commercial e-mail will be proof-read for $199/hr.
------------------------------
Date: 03 Sep 1997 14:20:37 +0200
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: Assinging values of HASH in to Array
Message-Id: <isg1rmpp0q.fsf@godzilla.kiere.ericsson.se>
Simon Fairey <sfairey@adc.metrica.co.uk> writes:
> Ajitesh Das wrote:
> > Is there any way to assign values ( NOT KEYS ) in to an array.
>
> No builtin function but how about:
>
>From the perlfunc manpage:
values HASH
Returns a normal array consisting of all the values
of the named hash. (In a scalar context, returns
the number of values.) The values are returned in
an apparently random order, but it is the same order
as either the keys() or each() function would
produce on the same hash. As a side effect, it
resets HASH's iterator. See also keys(), each(),
and sort().
--
Calle Dybedahl, UNIX Sysadmin
qdtcall@esb.ericsson.se http://www.lysator.liu.se/~calle/
------------------------------
Date: Wed, 3 Sep 1997 23:11:24 +1000
From: Chris Phillips <cphillip@kerr.phys.utas.edu.au>
Subject: Complex map problem
Message-Id: <Pine.GSO.3.94.970903224819.23669A-100000@kerr.phys.utas.edu.au>
Hi all,
I have just discovered the joys of the map function, but have run
into a problem :-(
Basically, I want the map function to skip a couple of the
elements of the array in question. I cannot get it to work.
A trivial example (that doesn't work):
#!/usr/bin/perl -w
sub testsub {
print "@_\n";
return;
}
$a[0] = 'a';
$a[1] = 'b';
$a[2] = 'c';
# The following line is what I would like to use. It does not compile
#testsub('*', map(@{$_} if ($_ ne 'b'), @a[0..2]), '*');
# This line does compile, but all elements are printed
testsub('*',map(eval {@{$_} if ($_ ne 'b')}, @a[0..2]),'*');
# Another problem with this version is that it returns ' ', rather
#than nothing if I replace the ($_ ne 'b') with 0.
__END__
In my real program, I have an array of arrays (ie an array of array
references), but some elements may have the value 'blank' rather than
an array reference (The program does a nxn grid of plots, and I need
to be able to skip some elements on the plot).
The line I used was:
($maxchan, $nchan) = maxmin(map(scalar(@{$_}) if ($_ ne 'blank'), @vel));
#maxmin return the maximum and minimum value of a list
Which fails.
I also use the line (This basically uses the map function to take
a slice of the separate arrays and return a single list, which maxmin
finds the maximum and minimum value):
($xmax, $xmin) = maxmin(map(@ {$_}[$bchan..$echan], @vel[0..$nspec-1]));
Which works but does not check for blanks. (It obviously croaks badly
if there ARE blanks).
Is there any way I can get this to work.
Cheers
-------------------------------------------------------------------
Department of Physics, Radio Astronomy Group, University of Tasmania
email: Chris.Phillips@utas.edu.au
Phone: (03) 62262405 (Work), (03) 62485285 (Telescope)
(03) 62278324 (Home), (03) 62262410 (Fax)
------------------------------
Date: 03 Sep 1997 16:04:16 +0300
From: matti@universe.pc.helsinki.fi (Matti Kinnunen)
Subject: Re: complex pattern?!? it shouldn't be, i think :)
Message-Id: <lzn2luv99r.fsf@universe.pc.helsinki.fi>
jonathan.hulatt@unilever.com writes:
> I have an scalar srting with lines of an html file in. I would really
> like to chop the tags out. I've had success using split etc. but isn't
> there a pattern that would do it? I tried several ideas, but just end
> up pulling out everything from first < to the last >.
what about:
perl -pe 's/<[^>]+?>//g' < file.hmtl
or
lynx -dump http://url.you.want.to.clean
--
* matti.kinnunen@helsinki.fi *
* http://universe.pc.helsinki.fi/~matti/contact.html *
* !!! +358-(0)40-593 50 91 but try first +358-(0)9-191 23978 *
------------------------------
Date: Wed, 3 Sep 1997 06:21:44 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "MJ.VAN OOSTERHOUT" <v3100411@student.anu.edu.au>
Subject: Re: complex pattern?!? it shouldn't be, i think :)
Message-Id: <Pine.GSO.3.96.970903061021.5823F-100000@julie.teleport.com>
On Wed, 3 Sep 1997, MJ.VAN OOSTERHOUT wrote:
> This script will remove all HTML tags from a file:
>
> undef $/;
> $_ = <>;
> s/<.*?>//g;
> print $_;
I see you have a non-greedy match there. If it were a greedy match, I'd
agree that you'd be able to remove all of the HTML tags. (Of course, you'd
also remove plenty of other stuff! :-)
Actually, HTML tags have a more complex format than that regular
expression will deal with. This is an example of a valid (and potentially
useful) tag.
<img src= "rt-arrow.gif" alt= "==>" >
(Admittedly, this could be written with entity encoding, but that's not
required. You can also include un-encoded angle brackets within HTML
comments.) Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 03 Sep 1997 09:03:26 -0400
From: psmith@baynetworks.com (Paul D. Smith)
Subject: Re: FTP site mirroring software?
Message-Id: <p5bu2a4kip.fsf@baynetworks.com>
Thanks, looks like just the ticket.
Now the question is why my CPAN searches for "mirror", "ftp",
etc. didn't turn this up.
--
-------------------------------------------------------------------------------
Paul D. Smith <psmith@baynetworks.com> Network Management Development
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist
-------------------------------------------------------------------------------
These are my opinions--Bay Networks takes no responsibility for them.
------------------------------
Date: 3 Sep 1997 11:03:43 +0200
From: Martin Fischer <mf@fishbone.ruhr.de>
Subject: Re: FTP site mirroring software?
Message-Id: <5uj95f$nv3$1@fishbone.ruhr.de>
Paul D. Smith <psmith@baynetworks.com> wrote:
>I'm looking for a simple bit of software to maintain a local mirror of
>the directory structure on my ISP FTP site... I just want something to
>download newer files on the FTP site to my local copy, and upload files
>I've modified locally to the FTP site.
>A little perl script utilizing, say, Net::FTP would be cool! :)
>But, I'm open to other suggestions as well.
>I couldn't find anything relevant-looking by searching CPAN for keywords
>like "copy", "mirror", and "ftp".
>Seems like a perfectly useful little script; surely someone must have
>such a thing already?
Yes, you're right. It's available on CPAN at
scripts/ftpstuff/mirror-2.8.tar.gz
ciao
Martin
--
Martin Fischer <mf@fishbone.ruhr.de> -------------------
<Martin.Fischer@fh-bochum.de> | Comp Sci Student
PGP key available at: http://localhost.ruhr.de/~martin | FH-Bochum, Germany
Unsolicited commercial e-mail will be proof-read for $199/hr.
------------------------------
Date: Wed, 3 Sep 1997 14:01:50 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Handling complex table files
Message-Id: <EFxqz2.Aq@world.std.com>
stefano bonacina <stefano.bonacina@st.com> writes:
>name label type default unit
>words {Number of words} {range int 64 32768} 64 {}
>bits {Number of bits} {range int 2 64} 2 {}
>mux {Mux size} {enum int {4 8 16 32}} 4 {}
>Separators are blank space, not tab (too easy :-).
If you mean that each field is a fixed length, then you might want to
look at either using substr or unpack.
while(<>) {
($name, $label, $type, $default, $unit) = unpack 'A7A18A31A8A2', $_;
}
This is discussed in <URL:http://perl.com./CPAN/doc/manual/html/pod/
perlfaq4/How_do_I_extract_selected_column.html>
--
Andrew Langmead
------------------------------
Date: Wed, 3 Sep 1997 08:12:37
From: rgr@freedomnet.com
Subject: Is this you?
Message-Id: <5ujk9n$jc9$1622@news.freedomnet.com>
Are you sick of all the Home Business hype? Most of them are either too expensive or so complicated that you can't explain them to other people. Are you ready for a simple Home Business that makes sense?
A business that doesn't monopolize all of your time. That requires No: Stocking, Selling or Delivery. No:
billing or collections. No: complicated paperwork. No: employees to pay. No: contracts to sign, you can quit any time. There is a one time $29 enrollment. There is never any new money spent after that. If you decide that this business is not for you simply return the business kit within 60 days for a full refund. Tens of thousands of people have been able to make this their full time business in a reasonably short amount of time. This is not "get rich quick." This is a highly reputable company that opened in 1985. I will send you details on this company when you e-mail me for information.
God forbid, but if something should happen where you couldn't work or a loved one became ill and you had to stay home to care for them, would you be able to? Would your company keep paying you?
Nobody likes to think about these things, but they do happen. And unless you have great insurance you may want to consider this business. You've nothing to lose by asking for information. I'll be happy to send it to you. The fact is, if you are trading time for money your income is temporary, ( even if you own the company.) The average person works from paycheck to paycheck with little or nothing left over to save or invest. This business can help you break the paycheck to paycheck cycle.
For information email me at rramsey36@aol.com or rgr@freedomnet.com
------------------------------
Date: Wed, 03 Sep 1997 09:07:25 -0400
From: "Sylvain St.Germain" <sgermain@nortel.ca>
Subject: Re: need script to modify .htpasswd
Message-Id: <340D610D.793B@nortel.ca>
Jeff Garner wrote:
>
> I need a spript that adds a user and their password to the .htpasswd file.
>
> i would like to show the user a web form and have them input a username ad
> their password and have the script add them to my .htpasswd file Please
> help !!!
This is not close to be perl stuff but anyway...
You want to use:
.../httpd/support/htpasswd [-c] .htpasswd SomeOneId
Regards,
Sylvain.
------------------------------
Date: 3 Sep 1997 14:46:40 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: NET::NNTP Woes
Message-Id: <5ujt8g$4jb$1@lyra.csx.cam.ac.uk>
Bruce Hodo <bruceh@interaccess.com> wrote:
>I've been trying to use NET::NNTP.pm in perl, but I get the following
>error:
>
>Can't call method "Net::NNTP::post" without a package or object
>reference at /export/home/getaway/site/cgi-bin/postnews.cgi line 97,
><BODY> chunk 15.
>
>Line 97 is:
> $nntp->Net::NNTP::post($posting);
>
>I've tried it with just "post($posting);", but it still doesn't work. In
>the beginning of my script, I have the following:
>
>use Net::NNTP; # This is how the server I'm using set it up.
>$ENV{'NNTPSERVER'}="news.ilk.com";
>$nntp = Net::NNTP->new(Debug);
I'd guess that your problem is in this line, since you don't do any
check that the new method has succeeded. If it fails, $nntp will be
undefined, leading to the above message.
And if you'd had -w set, you would probably have got a warning that
$nntp was undefined.
Mike Guy
------------------------------
Date: 3 Sep 1997 11:19:46 +0200
From: Martin Fischer <mf@fishbone.ruhr.de>
Subject: Re: Newbie File Locking
Message-Id: <5uja3i$o2s$1@fishbone.ruhr.de>
Stephen Hill <buck@huron.net> wrote:
>I need to lock a file....I have tried the FAQ and can't get the info I
>need (broken link on page).
Have you tried man perlfunc?
>Any help on file locking would be appreciated, Please don't tell me to
>use a module, I want the source code :-) Any info on flock too...
example code:
my $myfile = '/path/to/my/file';
open FILE "+<$myfile" or die "Can't open $myfile: $!";
flock FILE, 2; # blocking waiting for lock, see manpage
# do something with your file ...
flock FILE, 8; # not really needed, perl does it on closing the file
close FILE;
ciao
Martin
--
Martin Fischer <mf@fishbone.ruhr.de> -------------------
<Martin.Fischer@fh-bochum.de> | Comp Sci Student
PGP key available at: http://localhost.ruhr.de/~martin | FH-Bochum, Germany
Unsolicited commercial e-mail will be proof-read for $199/hr.
------------------------------
Date: Wed, 03 Sep 1997 15:18:07 +0200
From: Doug Seay <seay@absyss.fr>
Subject: Re: Perl (kind of) math question.
Message-Id: <340D638F.3FFB200D@absyss.fr>
Patrick Hayes wrote:
>
> Tom Phoenix <rootbeer@teleport.com> writes:
> > Actually, French uses nearly a base-twenty system. The French word for
> > eighty-seven is really saying "fourscore and seven".
>
> It's actually even worse than that. Many numbers in french aren't even
> distinct words like nineteen or eighty, but lists like "ten-nine" and
> "four-twenty". English does the same thing (twenty-one) but limits numbers
> under 100 to two words. French-french takes it to ridiculous lenghts: Seventy
> is "sixty-ten", ninety-nine is "four-twenty-ten-nine". Belgian and Swiss
> french do have distinct words for seventy, eighty and ninety.
English does the same thing. Fourteen is really "four ten" joined into
a single word. Ditto with German's "vierzehn". But you do have a valid
point about all numbers in 70..99 being rather odd. But this gets back
to Tom Phoenix's bit about the old french counting on thier toes and
using a base-20 system.
ObPerl: Is there a radix command to change the base of numbers from the
default decimal? The example in the perlsub man page implies not (why
bother using that example if it was already possible).
- doug
------------------------------
Date: Wed, 03 Sep 1997 07:37:34 -0400
From: pudge@pobox.com (Chris Nandor)
Subject: Re: perl and XEmacs
Message-Id: <pudge-ya02408000R0309970737340001@news.idt.net>
In article <nqok9gyvnyk.fsf@mitra.phys.uit.no>, Tom Grydeland
<tom@mitra.phys.uit.no> wrote:
# pudge@pobox.com (Chris Nandor) writes:
#
# > I think English is the greatest spoken language ever constructed. Is it
#
# English was never constructed. It evolved.
Sorry, I don't see a necessary difference. Intelligent design is often
called evolution.
But somehow I don't think that is the scope of these newsgroups.
--
Chris Nandor pudge@pobox.com http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10 1FF7 7F13 8180 B6B6'])
------------------------------
Date: 3 Sep 1997 11:30:32 GMT
From: uherting@news.htwm.de (Uwe Herting)
Subject: receive binary data from an URL via Perl script? How2?
Message-Id: <5ujhoo$hb0$1@minic5.htwm.de>
Hello!
Sorry for the question, but I have found no other to my problem than to
write here.
My idea was to get an URL (the data of the URL to be exact) with
PERL version 5.002 to a local file (ASCII/binary data).
My main problem is that I cannot use packages as LWP or IPC as they are not
installed on the AIX which I use. The solution should be something like this:
#!/usr/local/bin/perl -w
$url = "www.htwm.de";
$home = $ENV{HOME};
open(MYTEL,"|telnet $url 80 >$home/mytmp") ||
die "cannot open telnet to $url";
print MYTEL "GET / HTTP/1.0\n\n";
close(MYTEL);
open(MYPIPE,"$home/mytmp") ||
die "cannot open file $home/mytmp";
while (<MYPIPE>){
print $_; # hier bekommt man die URL zeilenweise...
}
close(MYPIPE);
unlink("$home/mytmp");
OK, this is not the best code, and not working either, but I have no access to
the necessary packages. How to solve the problem?
Anyone who had the same/a similar problem? I would appreciate any ideas.
Uwe Herting
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|\ _,,,--,,_ | Uwe Herting, uherting AT htwm . de
/,`.-'`' ._ \-;;,_ |
|,4- ) )_ .;.( `'-' |-------------------------------------------
'---''(_/._)-'(_\_) |In a world without fences, who needs Gates?
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: 03 Sep 1997 15:35:16 +0200
From: ishark@lsh01.univ-lille1.fr (Alberto BARSELLA)
Subject: Re: receive binary data from an URL via Perl script? How2?
Message-Id: <m2u3g2h65n.fsf@mokulen.univ-lille1.fr>
In article <5ujhoo$hb0$1@minic5.htwm.de> uherting@news.htwm.de (Uwe Herting) writes:
> Anyone who had the same/a similar problem? I would appreciate any ideas.
I had. I downloaded the w3mir package, which works just fine, and is
able to perform recursive download.
I don't remember where I got it (CPAN I suppose), but it shouldn't be
too hard to find.
Hope this helps,
Alberto
--
Alberto BARSELLA
PGP fingerprint = 13 3F 22 D2 0B 0A D3 25 F1 89 FE B5 82 AD 75 2A
------------------------------
Date: Wed, 3 Sep 1997 07:09:33 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Uwe Herting <uherting@news.htwm.de>
Subject: Re: receive binary data from an URL via Perl script? How2?
Message-Id: <Pine.GSO.3.96.970903070336.5823O-100000@julie.teleport.com>
On 3 Sep 1997, Uwe Herting wrote:
> My idea was to get an URL (the data of the URL to be exact) with PERL
> version 5.002 to a local file (ASCII/binary data).
>
> My main problem is that I cannot use packages as LWP or IPC as they are
> not installed on the AIX which I use.
Maybe you should install them. :-) You have to install _something_, even
if it's your own software. And installing 5.004 and LWP will provide other
useful things and bugfixes as well. (You don't need to have root
privileges to install Perl and LWP, although it's better if the sysadmin
can install those for everyone's use.)
Good luck!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 03 Sep 1997 08:05:01 -0500
From: Nathan Stanford <nathan@cyberservices.com>
Subject: Script on input to perl arrays wanted - Newbie learning
Message-Id: <340D607D.A4DD7BC8@cyberservices.com>
Do anyone have a simple script that will show me how to pull a address
list
and insert it into an array so I can do things with is....
address file
23:123 anywhere st., anycity,state:324:888-555-1212
32:321 john rd.,acity,state:243:888-686-6868
number:address:speeddial:phonenumber
I want an array where -
$number[0] = the first number in the list
$address[0] = the first address in the list
$speeddial[0] = the first speeddial in the list
$phonenumber[0] = the first phonenumber in the list
I am a newbie but learning fast I want to use : to seperate but would
use
other if I can some how make them work in excel ex: if I use comma's
then
the comma's in the addresses would cause a problem what do you suggest
about
that as well?
I want a simple example of how to use a module and how to tell if it is
the
program or some setting on my server as to why it is not working?
Do anyone use perl on NT?
--
____________________________________________________________________
I. N.A.G. - International Network Answers Group
Join today and when you need an answer it will be easier to find
email Nathan Stanford at nathan@cyberservices.com
____________________________________________________________________
Nathan Stanford E-Mail: nathan@cyberservices.com
NetWare 3.X/4.X Windows NT/95/3.X Lan/Wan Engineer
My Web Page http://users.why.net/nathans/
____________________________________________________________________
------------------------------
Date: Wed, 03 Sep 1997 12:17:01 +0100
From: Gary Colman <SPAMFREEcolmang@ms.com>
To: mweber@vt.edu
Subject: Re: Script Time
Message-Id: <340D472D.1B46@ms.com>
Hi Matt
> I would like to put a line of text on my output page that says how
> long it took to run the script...any suggestions? See altavista's
> addurl for an example.
print "Time taken in seconds: ",time()-$^T;
Cheers
Gary
--
remove SPAMFREE from my email address before replying.
------------------------------
Date: Wed, 03 Sep 1997 10:08:59 -0400
From: John Hardegree <codie@concentric.net>
Subject: Re: Simple Perl for Win 32 Question (not in FAQ)
Message-Id: <340D6F7B.16CC@concentric.net>
T. Wheeler wrote:
>
> I am learning perl and want to know how you could strip just the path
> from a command line argument.
[snip]
> Any ideas? I haven't seen this in books or on the net.
Check out page 214 in the llama book.
[snip]
--John Hardegree
------------------------------
Date: Wed, 03 Sep 1997 15:16:08 +0100
From: Colin Forde <C.Forde@Queens-Belfast.AC.UK>
Subject: simple perl problem
Message-Id: <340D7128.3A7C@Queens-Belfast.AC.UK>
hello all
im a beginner to perl.
ive got a script that reads stdin.
when it sees a from line it translates it into a path line.
This results in me having 2 path lines on output.
i only want one. Thanks for your help.
Here it is
open (INEWS, ">/var/tmp/tmp$$") ||
die "$program: can't run $inews\n";
# header munging loop
while (<STDIN>) {
last if /^$/;
# transform real from: line back to icky style
s/^From:\s+(.*) <(.*)>/From: $2 ($1)/;
s/Message-Id/Message-ID/;
# transform from_ line to path header; also works locally
s/^From\s+(\S+)@(\S+).*/Path: $2!$1/
|| s/^From\s+(\S+)[^@]*$/Path: $1\n/;
print INEWS
# if
/^(Date|From|Subject|Path|Newsgroups|Organization|Message-ID):/i;
if
/^(Date|From|Subject|Path|Newsgroups|Message-ID|NNTP-Posting-Host):/i;
$saw_path |= ( $+ eq 'Path' );
$saw_from |= ( $+ eq 'From' );
$saw_subject |= ( $+ eq 'Subject' );
$saw_msgid |= ( $+ eq 'Message-ID' );
$saw_poster |= ( $+ eq 'NNTP-Posting-Host' );
$saw_newsgroup |= ( $+ eq 'Newsgroups' );
}
warn "$program: didn't expect newsgroup in both headers and ARGV\n"
if $newsgroup && $saw_newsgroup;
die "$program: didn't get newsgroup from either headers or ARGV\n"
unless $newsgroup || $saw_newsgroup;
$approved = $newsgroup;
$approved =~ s/\./'-'/eg;
($sec,$min,$hour,$mday,$mon,$year)=localtime(time);
$madeupid = "\<$year$mon$mday.$hour$min$sec.$$\@cmc.qub.ac.uk\>";
printf INEWS "Path: %s\n" unless $saw_path;
printf INEWS "From: %s\n" unless $saw_from;
printf INEWS "Newsgroups: %s\n", $newsgroup unless $saw_newsgroup;
printf INEWS "Approved: test1\@cmc.qub.ac.uk\n", $approved;
print INEWS "Subject: Untitled\n" unless $saw_subject;
printf INEWS "Message-ID: %s\n", $madeupid unless $saw_msgid;
printf INEWS "NNTP-Posting-Host: %s\n" unless $saw_poster;
print INEWS "Organisation: (Queens University of Belfast)\n";
print INEWS "\n";
print INEWS while <STDIN>; # gobble rest of message
close INEWS;
system("/usr/news/bin/rnews </var/tmp/tmp$$");
and the result is:
Path: owner-test1
Path: not-for-mail
From: C.Forde@Queens-Belfast.AC.UK (Colin Forde)
Newsgroups: qub.test
Subject: test6
Date: Wed, 03 Sep 1997 14:55:38 +0100
Message-ID: <340D6C5A.6E06@Queens-Belfast.AC.UK>
NNTP-Posting-Host: cfor.cc.qub.ac.uk
Approved: test1@cmc.qub.ac.uk
Organisation: (Queens University of Belfast)
test6
________________________________________________________________
C.Forde@queens-belfast.ac.uk phone : +44 (0)1232 245133 x3950
fax : +44 (0)1232 230592
------------------------------
Date: Wed, 03 Sep 1997 10:06:49 -0400
From: George Menyhert <menyhert@acm.org>
Subject: Time warp - Perl 4 question
Message-Id: <340D6EF9.537FB81D@acm.org>
This is a multi-part message in MIME format.
--------------20F422470B4B7E69EE831009
Content-Type: text/plain; charset=us-ascii
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Transfer-Encoding: 7bit
I wrote a script using Perl 5.003. It works great. However, it is very
complex and long (4500 lines). The problem is that I have to move it
back
to Perl 4 to guarantee the widest range of acceptance.
I've gotten the script cleaned up and stupified for Perl 4 (no "my" or
"sub" arguments, etc). The problem is that whenever my script exceeds
2000 lines, every line after line 2000 reports a bogus syntax error. Is
this a known limitation of Perl 4, a bug, or am I doing something wrong?
I tried breaking the script up. Having done that, I am able to get all
of
the script parts to compile without warning. However, how do I sew the
parts up again? I tried "require" statements, but that just caused the
interpreter to hang indefinitely. I tried running the same script under
perl 5 (with the require statements) but the result indicated that
global
variables were not shared between the scripts. Is this true? Does perl
4
support some sort of "include" statement that will do what I need?
I would prefer to get this to work as a single script if at all
possible.
My Perl release is:
This is perl, version 4.0
$RCSfile: perl.c,v $$Revision: 4.0.1.8 $$Date: 1993/02/05 19:39:30 $
Patch level: 36
Copyright (c) 1989, 1990, 1991, Larry Wall
MS-DOS port Copyright (c) 1989, 1990, Diomidis Spinellis
P.S. Does anyone know where I can get a perl 4 book?
--
George Menyhert
----------
mailto:menyhert@acm.org
http://w3.one.net/~menyhert
"I love deadlines. I love the whooshing sound they make as they rush
by."
dna@cix.compulink.co.uk
"If there is one thing I can't tolerate it is intolerance."
me
why all the talk of tolerance? what
happened to respect?
--------------20F422470B4B7E69EE831009
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for George Menyhert
Content-Disposition: attachment; filename="vcard.vcf"
begin: vcard
fn: George Menyhert
n: Menyhert;George
adr: ;;;Cincinnati;OH;;USA
email;internet: menyhert@acm.org
title: Software Engineer
x-mozilla-cpt: ;0
x-mozilla-html: TRUE
end: vcard
--------------20F422470B4B7E69EE831009--
------------------------------
Date: Wed, 03 Sep 1997 11:31:54 GMT
From: mkunze.NOSPAM@nowhere.com (Michael Kunze)
Subject: UTC to locale time?
Message-Id: <34124968.127558799@news.netcologne.de>
Hi all,
i want to convert a given UTC time string ("853317838") to local time
( 3/9/97 13:34:56). Is there a module that does this?
------------------------------
Date: Wed, 3 Sep 1997 06:30:20 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: michael.NOSPAM@nowhere.edu
Subject: Re: UTC to locale time?
Message-Id: <Pine.GSO.3.96.970903062958.5823H-100000@julie.teleport.com>
On Wed, 3 Sep 1997, Michael Kunze wrote:
> i want to convert a given UTC time string ("853317838") to local time
> ( 3/9/97 13:34:56). Is there a module that does this?
If there's a module which does what you want, it should be listed in
the module list on CPAN. If you don't find one to your liking, you're
welcome and encouraged to submit one! :-) Hope this helps!
http://www.perl.org/CPAN/
http://www.perl.com/CPAN/
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 03 Sep 1997 15:29:55 +0200
From: Doug Seay <seay@absyss.fr>
Subject: Re: UTC to locale time?
Message-Id: <340D6653.54C608F5@absyss.fr>
Michael Kunze wrote:
>
> Hi all,
>
> i want to convert a given UTC time string ("853317838") to local time
> ( 3/9/97 13:34:56). Is there a module that does this?
~> perl -e 'print scalar gmtime 853317838, "\n"'
Wed Jan 15 08:43:58 1997
~> perl -e 'print scalar localtime 853317838, "\n"'
Wed Jan 15 09:43:58 1997
Of course if you are in a different timezone (I'm in France) that second
value will be different. Change your TZ variable to play with this.
And 853317838 isn't really "UTC". It is seconds since the start of the
unix epoch (jan 1, 1970 GMT).
- doug
------------------------------
Date: Wed, 03 Sep 1997 08:19:17 -0700
From: Webwest design <webwest@webwestdesign.com>
Subject: Web Form: Fields with Multiple values
Message-Id: <340D7FF5.4E7E@webwestdesign.com>
I have a perl script that gets input from fields on an HTML form -
If I have a field with multiple values (ie a SELECT field)
it only picks up the last inputed value from the SELECT field
and overwrites all previous versions.
How do I get the other values???
thanx - np
------------------------------
Date: Wed, 03 Sep 1997 13:09:30 +0100
From: Colin Forde <C.Forde@Queens-Belfast.AC.UK>
Subject: wee quickie on special variables
Message-Id: <340D537A.7DD2@Queens-Belfast.AC.UK>
Hi all
Im reading from std input and wants to remove duplicate stuff:
Ive got this sort of thing:
print INEWS
if/^(Date|From|Path|Subject|Newsgroups|Message-ID|NNTP-Posting-Host):/i;
$saw_path |= ( $+ eq 'Path' );
$saw_subject |= ( $+ eq 'Subject' );
$saw_msgid |= ( $+ eq 'Message-ID' );
$saw_poster |= ( $+ eq 'NNTP-Posting-Host' );
$saw_newsgroup |= ( $+ eq 'Newsgroups' );
Further down ive got
printf INEWS "Path: %s\n" unless $saw_path;
printf INEWS "Newsgroups: %s\n", $newsgroup unless $saw_newsgroup;
printf INEWS "Approved: test1\@cmc.qub.ac.uk\n", $approved;
print INEWS "Subject: Untitled\n" unless $saw_subject;
printf INEWS "Message-ID: %s\n", $madeupid unless $saw_msgid;
printf INEWS "NNTP-Posting-Host: %s\n" unless $saw_poster;
print INEWS "Organisation: (Queens University of Belfast)\n";
print INEWS "\n";
Im getting rid of all duplicates but the path one which
is the first one appearing in the input stream.
Any ideas
Please email me
thanks
Colin
--
________________________________________________________________
C.Forde@queens-belfast.ac.uk phone : +44 (0)1232 245133 x3950
fax : +44 (0)1232 230592
------------------------------
Date: Wed, 03 Sep 1997 10:17:14 -0400
From: Todd Beverly <beverly@kodak.com>
Subject: Wrote new module, need help with system dependencies.
Message-Id: <340D716A.1AC05DA5@kodak.com>
Hi,
I just wrote a Perl (pure Perl) module (and class) using Tom
Christiansen's "FMTEYNTKA" series (perltoot) and created the
distribution files (e.g. Makefile.PL) using 'h2xs' with the -X option.
This class reads a binary file created from a scientific instrument
called a spectrophotometer. The file consists of double floats,
strings, characters and integers and I'm using 'read' and 'unpack'
routines to decipher the results. The files will always be written on a
MS Windows machine, which means, on a UNIX machine, a 'reverse' of the
string before unpacking a float.
I would like to install this package on NT and Unix machines, which
means that I need to differentiate operating systems in order to
properly determine floats. My first thought was to add an entry to
Makefile.PL to determine the OS type during the make and modify the
reading routine code with a conditional, sort of like C's #ifdef.
So my questions are: Is this the best way to implement system dependent
code in modules? If so, could anyone point me to an example
Makefile.PL/*.pm set? If not, what's a more elegant way to do it?
I looked through the FAQs and did a dejanews search before posting, but
if this is an obvious question, please excuse my ignorance.
Thanks,
--
***********************************************
Todd Beverly, System Administrator
Eastman Kodak Research Labs
Email: beverly@kodak.com
**************************************************
------------------------------
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 967
*************************************