[8200] in Perl-Users-Digest
Perl-Users Digest, Issue: 1818 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 5 17:07:47 1998
Date: Thu, 5 Feb 98 14:00:25 -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 Thu, 5 Feb 1998 Volume: 8 Number: 1818
Today's topics:
Re: A problem - please help <jdporter@min.net>
Re: Array of Records tobez@plab.ku.dk
Re: Array of Records (I R A Aggie)
Re: Array of Records (I R A Aggie)
Re: Array of Records (Andrew M. Langmead)
Re: CGI.pm and server errors (Guy K. McArthur)
Re: Crazy Idea <vladimir@cs.ualberta.ca>
Re: dbm files <vallon@pearl.fi.bear.com>
Debuggin Tips for beginners (w/o shell) <pjmone@symbioticinc.com>
Re: Debuggin Tips for beginners (w/o shell) <jason@primal.ucdavis.edu>
Re: eval FAQ??? Hardest part of perl to figure out <joseph@5sigma.com>
Help passing argument to the command line (Scott DiNitto)
Re: How do I get the hostname? (Bill D. McAdam)
How to get text into thousands ofHTML-files? aschmidt@student.uni-kassel.de
inplace editing question. <shaun@ms.com>
Re: Is file locking necessary? (Martin Vorlaender)
Re: Module to handle BIND zone files? (Jonathan Stowe)
Re: Newbie question re: Sorting (Martin Vorlaender)
Perl 4 and Associative Arrays? (Don)
Re: Perl ISAPI Build 315 for NT & Arguments (Martin Vorlaender)
Re: posix::strftime (core dumped) <volker@microdata.de>
Re: Quickie: regexp for valid e-mail addresses <jdporter@min.net>
Re: Redirect with cookies ??? <joneil@cks.ssd.k12.wa.us>
Re: Redirect with cookies ??? (Thomas R. Hall)
Re: Redirect with cookies ??? <joneil@cks.ssd.k12.wa.us>
Re: Redirect with cookies ??? (Thomas R. Hall)
Simplest regexp perl program? <lamber45@EGR.msu.edu>
Re: Simplest regexp perl program? (Sean McAfee)
Re: size limit to the length of a perl script <vladimir@cs.ualberta.ca>
Re: solution for multiline comments??? (O'Shaughnessy Evans)
Re: Some Questions Regarding Error Messages Generated b <keson@uswest.com>
Re: Survival Of perl lvirden@cas.org
Wierd Directory Problem (Guy K. McArthur)
Win32::AdminMisc function RenameUser <dbrowne@indiana.edu>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 05 Feb 1998 14:58:49 -0500
From: John Porter <jdporter@min.net>
Subject: Re: A problem - please help
Message-Id: <34DA19F9.3C9D@min.net>
Bart Lateur wrote:
>
> unpack('S', pack('s', $num))
Yahbut, you've got 'S' and 's' backwards.
John Porter
------------------------------
Date: Thu, 05 Feb 1998 20:35:41 +0100
From: tobez@plab.ku.dk
Subject: Re: Array of Records
Message-Id: <34DA148D.3FC9@plab.ku.dk>
Duncan Halstead wrote:
>
> I'm trying to create an array of records; however, with little success.
> I'm using the following code:
>
> @Array[$index]->{RECORD_NAME} = $value;
Change @ to $:
$Array[$index]->{RECORD_NAME} = $value;
There is nothing wrong if some things in dereferencing chain did not
exist
during the assignment; they'll spring into existence automagically.
Hope this helps,
Anton.
------------------------------
Date: Thu, 05 Feb 1998 15:19:44 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Array of Records
Message-Id: <fl_aggie-0502981519440001@aggie.coaps.fsu.edu>
In article <34DA0022.1BBB8A6A@symbios.com>, Duncan Halstead
<duncan.halstead@symbios.com> wrote:
+ I'm trying to create an array of records; however, with little success.
+ I'm using the following code:
+ @Array[$index]->{RECORD_NAME} = $value;
Its better to refer to a particular array element as a scalar, helps to
eliminate confusion. Use: $Array[$index] instead.
+ The compiler thinks that RECORD_NAME is an undefined hash reference, which
+ makes sense. Only, I'm not sure how do do what I actually want. Do I need
+ to declare the record prior to using it, and then new each index before
+ putting data in it? Any ideas?
Ummm...this might be what you're looking for.
$rec=0;
while($value=<INPUT>) {
chomp($value);
$Array[$rec]=$value;
$rec++;
}
Untested, of course...
James
--
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>
------------------------------
Date: Thu, 05 Feb 1998 15:21:05 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Array of Records
Message-Id: <fl_aggie-0502981521050001@aggie.coaps.fsu.edu>
In article <fl_aggie-0502981519440001@aggie.coaps.fsu.edu>,
fl_aggie@thepentagon.com (I R A Aggie) wrote:
+ $rec=0;
+ while($value=<INPUT>) {
+ chomp($value);
+ $Array[$rec]=$value;
+ $rec++;
+ }
Well, duh. An alternative method:
@Array=<INPUT>;
chomp(@Array);
$rec=$#Array; # number of records in the array...
James
--
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>
------------------------------
Date: Thu, 5 Feb 1998 21:01:10 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Array of Records
Message-Id: <EnxBpy.JHx@world.std.com>
Duncan Halstead <duncan.halstead@symbios.com> writes:
>I'm trying to create an array of records; however, with little success.
>I'm using the following code:
>@Array[$index]->{RECORD_NAME} = $value;
Change it to:
$Array[$index]->{RECORD_NAME} = $value;
Then $Array[$index] is a scalar (a single value) which can hold a
reference to an anonymous hash which will be autocreated as necessary.
You only use the "@" symbol when you are refering to an array as a
whole (or a slice of an array or hash.) See the section in on scalars
and arrays in the perldata man page for details.
<URL:http://www.perl.com/CPAN/doc/manual/html/pod/perldata.html>
(I find the way it describes "$" as the english "the" and "@" as the
english "these" as a rule that makes sense.)
You might also want to take a look at the perldsc man page
<URL:http://www.perl.com/CPAN/doc/manual/html/pod/perldsc.html>
for a tutorial on complex data structures in perl.
--
Andrew Langmead
------------------------------
Date: 5 Feb 1998 21:01:28 GMT
From: guym@zippy.as.arizona.edu (Guy K. McArthur)
Subject: Re: CGI.pm and server errors
Message-Id: <6bd9b8$edq$2@news.ccit.arizona.edu>
use CGI qw(standard isa);
------------------------------
Date: 05 Feb 1998 12:06:27 -0700
From: Vladimir Alexiev <vladimir@cs.ualberta.ca>
Subject: Re: Crazy Idea
Message-Id: <omsopxan2k.fsf@tees.cs.ualberta.ca>
> > > > $pat = qr{
> > > > \d+
> > > > | (?:
> > > > \(
> > > > (?d $pat)...
or `$pat=qr{\d+|(?:\($pat...}dx'
- is the inner occurrence of $pat lexical or dynamic? Closures don't
seem to allow postponed lexicals, eg
my $fact=sub{my$n=shift; $n==1?1:$n*&$fact($n-1)}
doesn't work while
$fact=sub{my$n=shift; $n==1?1:$n*&$fact($n-1)}
works.
- what will it do with perversions such as $a=qr{$b}d; $b=qr{$a}d;
just loop forever?
------------------------------
Date: 05 Feb 1998 16:13:36 -0500
From: Justin Vallon <vallon@pearl.fi.bear.com>
Subject: Re: dbm files
Message-Id: <x6ehg6dn4am.fsf@pearl.fi.bear.com>
carols@sabre.com (Carol Lynn Smith) writes:
> Hi,
> I have a two-fold question regarding dbmfiles that I am using to
> store employee information:
> 1. Is there a size restriction on either the .dir or .pag files? I
> am storing key/value pairs and I can't create my 29th one.
I think the 'standard' dbm files have a data length restriction. There
should be no restriction on the number of keys. GDBM (I believe)
removes this restriction.
> 2. How do I sort by value? FYI, my key is a record number I assign,
> but I would like to sort by last name, which makes up part of the
> value (in essence, I have a value that might look like this -
> Smith:Carol:46762:1-8765:13L81:etc.).
1. Sort it when you need it:
local %by_last_name;
while (($key, $val) = each %data) { # I don't know each's syntax.
local ($first, $last) = split /:/, $val;
$by_last_name{$last} = $key;
}
for $last (sort keys %by_last_name) {
local $key = $by_last_name{$last};
print "$key\n";
}
2. Keep the last names in another hash. That is, make %by_last_name a
dbm as well. Addition, deletion, and modification would need to
maintain the index.
This would be useful if you need to lookup by last-name, for example.
Otherwise, the cost of maintaining the index may be greater than just
sorting the values (as in 1) when you need them.
local %data;
local %by_last_name;
local $next_key = 1;
sub GenerateKey {
return $next_key++;
}
sub Add {
local ($first, $last, $id, $phone) = @_;
local $value = join ":", @_;
local $key = GenerateKey;
$data{$key} = $value;
$by_last_name{$last} = $key;
return $key;
}
sub Modify {
# If the last name changes, update by_last_name:
local ($old_last, $new_last) = @_;
$by_last_name{$new_last} = $by_last_name{$old_last};
delete $by_last_name{$old_last};
}
sub Delete {
local ($key) = @_;
local $value = $data{$key};
local ($first, $last) = split /:/, $value;
delete $data{$key};
delete $by_last_name{$last};
}
sub LastNameToKey {
local ($last) = @_;
return $by_last_name{$last};
}
Add "Joe", "Smith", 23, "555-1245";
Add "John", "Doe", 56, "555-8998";
print LastNameToKey "Doe";
print "\n";
print join ",", sort keys %by_last_name;
print "\n";
Delete LastNameToKey "Smith";
print join ",", sort keys %by_last_name;
print "\n";
# Output:
2 (John Doe's key)
Doe,Smith (last names)
Doe (last names after delete)
--
-Justin
vallon@bear.com
------------------------------
Date: Thu, 05 Feb 1998 15:17:29 -0500
From: Paul Mone <pjmone@symbioticinc.com>
Subject: Debuggin Tips for beginners (w/o shell)
Message-Id: <6bd6r8$hbh@bgtnsc02.worldnet.att.net>
I just successfully completed my first script, after almost a week of
debugging. I'm sure there are plenty of peole like me that browse
through this newsgroup looking for answers. If anyone here has tried to
debug a Perl script w/o telnet access, they share my pain...
1. I made the mistake of using the "auto" transfer type in my ftp
program, which ended up sending my script in binary mode, which added
linefeeds to the end of every line (^M)... Sending in Ascii mode solved
this problem.
2. I relied much too heavily on CGI.pm. It turns out my server has a
slightly different version then the one I was refrencing, but support
couldn't tell me what version...anyway, I found the redirect method, as
well as a few HTML methods (namely td) didn't work as they were supposed
to. Also, CGI.pm sent some sort of screwy header, at least not what I
was expecting it to send...probably because I was reading documentation
for a different version :). So, insead of using fancy Object Oriented
code to produce a page, I did it the old fashioned way
(print<<"endtag";). But, by all means, CGI.pm is a very useful module,
I'm not saying don't use it, I'm just saying be more cautious then I
was.
I was lucky enough to eventually find a guy who let me use his server
via telnet to test out my script from the command line, but to all who
can't I suggest Perl for Win32. Perl for Win32 won't solve all of your
problems, but it is very useful for debugging syntax before you upload
to your server.
thanks,
Paul
------------------------------
Date: Thu, 5 Feb 1998 13:09:18 -0800
From: Jason Christian <jason@primal.ucdavis.edu>
Subject: Re: Debuggin Tips for beginners (w/o shell)
Message-Id: <Pine.OSF.3.95.980205130352.13807G-100000@primal.ucdavis.edu>
On Thu, 5 Feb 1998, Paul Mone wrote:
> I just successfully completed my first script, after almost a week of
> debugging. I'm sure there are plenty of peole like me that browse
> through this newsgroup looking for answers. If anyone here has tried to
> debug a Perl script w/o telnet access, they share my pain...
>
> 1. I made the mistake of using the "auto" transfer type in my ftp
> program, which ended up sending my script in binary mode, which added
> linefeeds to the end of every line (^M)... Sending in Ascii mode solved
> this problem.
>
> 2. I relied much too heavily on CGI.pm. It turns out my server has a
> slightly different version then the one I was refrencing, but support
> couldn't tell me what version...anyway, I found the redirect method, as
> well as a few HTML methods (namely td) didn't work as they were supposed
> to. Also, CGI.pm sent some sort of screwy header, at least not what I
> was expecting it to send...probably because I was reading documentation
> for a different version :). So, insead of using fancy Object Oriented
> code to produce a page, I did it the old fashioned way
> (print<<"endtag";). But, by all means, CGI.pm is a very useful module,
> I'm not saying don't use it, I'm just saying be more cautious then I
> was.
>
> I was lucky enough to eventually find a guy who let me use his server
> via telnet to test out my script from the command line, but to all who
> can't I suggest Perl for Win32. Perl for Win32 won't solve all of your
> problems, but it is very useful for debugging syntax before you upload
> to your server.
If you are going to be writing a lot of CGI Perl, you may want to
install Linux on your box. It is free via ftp, or $50-$100 on a cd-rom.
Half a gig of disk space gives a full-featured installation. Then you
can get apache running on *your* box, and try out your scripts in the
privacy of your own home, before loading it onto the server. You can
put up a current copy of CGI.pm, and even compare it to that on your
ISP's box...and urge the ISP to upgrade if necessary.
---------------------------------------------------------------------------
Jason Christian University of California, Davis
jason@primal.ucdavis.edu Agricultural and Resource Economics
Office:(530)752-1357 FAX:(530)752-5614 Davis, CA 95616
------------------------------
Date: Thu, 05 Feb 1998 12:43:10 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: eval FAQ??? Hardest part of perl to figure out
Message-Id: <34DA1642.F2483022@5sigma.com>
Ir-relevant. What data structures problem *needs* soft
references? The original poster's problem certainly didn't.
-joseph
Bart Lateur wrote:
>
> "Joseph N. Hall" <joseph@5sigma.com> wrote:
>
> >Huh? There is no need for string eval in any data structures
> >problem in perl 5, period.
>
> >Bart Lateur wrote:
>
> >> >I can't see any reason why you can't do this with references.
> >> I can. Soft references (= lookup by name) don't work with "my"
> >> variables.
>
> OK, here's a test script.
[...]
--
Joseph N. Hall, prop., 5 Sigma Productions mailto:joseph@5sigma.com
Author, Effective Perl Programming . . . . . http://www.effectiveperl.com
Perl Training . . . . . . . . . . . . . . . http://www.perltraining.com
------------------------------
Date: Thu, 05 Feb 1998 21:32:19 GMT
From: sdinitto@kronos.com (Scott DiNitto)
Subject: Help passing argument to the command line
Message-Id: <34da2d96.103905998@news>
Hello,
I am writing a script that will allow a user to shut down and restart
a database automaticly via a perl script. However, in order to do
that, the user has to su to another user. I do not want to add the
users who need to shut down the databases to the dba group because
then they can do other dba admin stuff I don't want them to touch!!
I firstly rhought having the script su automaticly
system ("su $dbuser -c /path/shutdownscript");
but unless you are root, it will prompt me with a password. And like I
said, I don't want to give that password out.
Then I thought perhaps I could automaticly pass the password to su
from within the script (since su will not allow the password to be
entered as an argument), shut down the database and exit without the
common user ever having to know the dba password. But all attempts
have failed at that.
I need to know if what I am trying is possible... basicly to have perl
automaticly interact with a commands STDIN prompts. Any help is
appreciated!
SD
------------------------------
Date: 5 Feb 1998 20:21:08 GMT
From: bdmcadam@ford.wdi.disney.com (Bill D. McAdam)
Subject: Re: How do I get the hostname?
Message-Id: <6bd6vk$fdm@louie.disney.com>
Watch your step (jefpin@bergen.org) wrote:
: ># What's the best way to get the hostname of the system I'm running on with perl?
: >$_= `hostname`;
: I don't think that's very secure, not to mention it keeps a newline in the
: variable... if you REALLY want to do that, at least do:
: chop($hostname = `hostname`);
: | - Ken Mayers
It would be cheaper to:
use Sys::Hostname;
$host = hostname();
HTH
-WMc
------------------------------
Date: Thu, 05 Feb 1998 21:10:49 GMT
From: aschmidt@student.uni-kassel.de
Subject: How to get text into thousands ofHTML-files?
Message-Id: <34da2ab4.27306527@news.hrz.uni-kassel.de>
Hello,
I'm not sure whether this mail is compatible with this list's policy.
If not: excuse me.
This is the problem, I'm struggling with:
I've downloaded hundreds of html-files each of them a
newspaper-article. The structure of the html-code is almost identical,
as this articles stem from just two different daylies. Thus there are
only two kinds of html-structure, two kinds of files (the contents of
their <title>-tags are diffent).
I cannot handle that mass of unstructured data, so I want to import it
into a fulltext-database. Before this, however, I want to manipulate
the HTML-code to add field names and field separators, e.g.:
"<H3>Clinton: I tried it but I didn't...</H3>" =>
"<H3>TITEL[ Clinton: I tried it but I didn't...]</H3>"
Of course, that's no problem with regular expressions, even for me as
an absoulute beginner in perl sripting.
But I don't know,
- how to let perl (succesivly) open every file in a given folder,
- how to let it decide whether the file should be manipulated by
method1 or method2 (according to the HTML-structure of the article)
- how to close them after editing and go to the next, still not
manipulated file.
As you can see, I don't know how to construct the appropriate loops
and if'n'else. I*ve checked out some of those 1100-pages Perl-Manuals
but I couldn't find that what I was looking for. Unfortunately, time
is running short to get that arfticles manipulated and imprted into
the database.
I would appreciate any little perl-tutaorial on this problem.
bye,
andreas
------------------------------
Date: Thu, 05 Feb 1998 15:41:41 -0500
From: Shaun Ledford <shaun@ms.com>
Subject: inplace editing question.
Message-Id: <34DA2405.702B3F80@ms.com>
I found this example on pg. 190 of the camel book to be very useful,
but I'm stuck when I try to write a entirely new file instead of just
changing line by line. The book uses this example:
--------------------------------------------------
@ARGV = ("/etc/passwd"); #prime the diamond operator
$^I = .bak; # write /etc/passwd.bak for safety
while(<>) { # main loop, once for each line of /etc/passwd
s#:[^:]*$#:/bin/sh#; # change shell to /bin/sh
print; # send output to ARGVOUT: the new /etc/passwd
}
What I want to do is something like:
------------------------------------
while(<>) { # main loop, once for each line of /etc/passwd
foreach $key ( sort keys %pwd ) { # print my NEW passwd file
print $pwd{$key};
}
}
----------------------------------------------------------------------
The diamond operator prints my NEW passwd file for each line of passwd.
If I remove the while statement I cant print to the passwd file. If I
try
to use print ARGVOUT $pwd{$key} that doesn't work either.
Any ideas..
Shaun.
------------------------------
Date: Thu, 05 Feb 1998 18:36:34 +0100
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: Is file locking necessary?
Message-Id: <34d9f8a2.524144494f47414741@radiogaga.harz.de>
Iain Chalmers (bigiain@mightymedia.com.au) wrote:
: you really should check out Randal Schwartz's stuff on his website:
: <http://www.stonehenge.com/merlyn>
Minor glitch: that should be /~merlyn
: particularly columns 4 and 5 in his web techniques column - its got a good
: explanation of how and why he used locking in those scripts.
Yup. All of the WebTechniques articles are great, IMHO.
cu,
Martin
--
| Martin Vorlaender | VMS & WNT programmer
Ceterum censeo | work: mv@pdv-systeme.de
Redmondem delendam esse. | http://www.pdv-systeme.de/users/martinv/
| home: martin@radiogaga.harz.de
------------------------------
Date: 5 Feb 1998 19:28:38 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Module to handle BIND zone files?
Message-Id: <6bd3t6$enf$1@mendelevium.btinternet.com>
In article <slrn6dhi2b.ffl.devin@blacktower.premier1.net>,
devin@premier1.net says...
>
>I've searched CPAN and the web trying to find this without any luck, so
>if anybody knows a URL that I missed, please point me the right way. I
>am looking to see if anyone has any modules available that can parse zone
>files for BIND, and can write them back out.
>
There is a script in the latest distribution of BIND that will take a hosts
file and make the corresponding zone files. This might be some help.
/J\
------------------------------
Date: Thu, 05 Feb 1998 19:03:54 +0100
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: Newbie question re: Sorting
Message-Id: <34d9ff0a.524144494f47414741@radiogaga.harz.de>
Chris Raettig (chrisr@cheese.org) wrote:
: I am trying to sort an array in descending numerical order by a substring...
: Each element in my array contains something like these...
: 'Scooby has been slain by Shaka having reached 52100 points'
: 'Wintermute has been slain by Rincewind having reached 00 points'
: The application is an online MUD game.
Ahhh! Now _that's_ an application worth working on ;-)
: The array is in order of time of kill and I'd like to sort it in order of
: people who've died with the most number of points. I have used the sort
: command but I'm still very much learning and can't work out the syntax
: to do the sorting I described.
Another opportunity to show the ingenious Schwartzian transformation
(which, BTW, is mentioned in perlfaq4, in a section headed 'How do I sort
an array by (anything)?'):
@sorted = map { $_->[0] }
sort { $b->[1] <=> $a->[1] }
map {
[$_, (/\w+ has been slain by \w+ having reached (\d+) points/)[0]]
} @data;
Figuring out how it works is good for your Perl learning curve.
cu,
Martin
--
| Martin Vorlaender | VMS & WNT programmer
Ceterum censeo | work: mv@pdv-systeme.de
Redmondem delendam esse. | http://www.pdv-systeme.de/users/martinv/
| home: martin@radiogaga.harz.de
------------------------------
Date: Thu, 05 Feb 1998 19:40:24 GMT
From: defike@ilstu.edu..spam.not (Don)
Subject: Perl 4 and Associative Arrays?
Message-Id: <34da13fe.22290165@news.ice.net>
I have been using associative arrays with Perl 5 with success.
Recently I passed on one of my scripts to a friend who's ISP is using
Perl 4 and the script seems to have died at the creation of the
associative array.
The code looks something like this;
if (exists($urls{$url_from}))
{
$urls{$url_from}++;
}
else
{
$urls{$url_from} = 1;
}
And generates an error at "exists(". I tried this also with a
statement like;
if ($urls{url_from})
{
$urls{$url_from}++;
}
else
{
$urls{$url_from} = 1;
}
And it still dies at "$urls{".
Is this a problem with my code or with Perl 4?
Is there a way around it?
Any help would be appreciated,
Don
defike@ilstu.edu..spam.not
------------------------------
Date: Thu, 05 Feb 1998 19:47:42 +0100
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: Perl ISAPI Build 315 for NT & Arguments
Message-Id: <34da094e.524144494f47414741@radiogaga.harz.de>
Carlos Dmaz (carloshd@coqui.net) wrote:
: Try this:
: #!/usr/bin/perl
: print "Content-type: text/html\n\n";
: print "Argument= $env['QUERY_STRING'] \n";
Apart from the fact that env should be ENV, and ENV is a hash, not an array.
So:
print "Argument= $ENV{'QUERY_STRING'} \n";
cu,
Martin
--
| Martin Vorlaender | VMS & WNT programmer
Ceterum censeo | work: mv@pdv-systeme.de
Redmondem delendam esse. | http://www.pdv-systeme.de/users/martinv/
| home: martin@radiogaga.harz.de
------------------------------
Date: Thu, 05 Feb 1998 21:24:52 +0100
From: Volker Klau <volker@microdata.de>
To: Tom Grydeland <Tom.Grydeland@phys.uit.no>
Subject: Re: posix::strftime (core dumped)
Message-Id: <34DA2014.78B77C40@microdata.de>
Hello,
> > Hi,
> >
> > my Problem:
> >
> > POSIX::strftime( "%H:%M, on %D", localtime());
> > gives a nice Segmentation fault under
> > - RedHat Linux/Intel 5.0 (glibc)
> > - Perl 5.004
> >
> > Anybody seen/solved this problem ?
>
> Use a temporary:
>
> @a = localtime;
> POSIX::strftime("%H:%M, on %D", @a);
this is very confusing:
@a = localtime;
$update = POSIX::strftime("%H:%M, on %D", @a);
doesn't work for me (dumps also core), BUT:
@a = localtime;
print @a;
$update = POSIX::strftime("%H:%M, on %D", @a);
works fine.
Strange thing ...
> --
> //Tom Grydeland <Tom.Grydeland@phys.uit.no>
Thanx,
Volker
------------------------------
Date: Thu, 05 Feb 1998 14:50:07 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Quickie: regexp for valid e-mail addresses
Message-Id: <34DA17EF.5ECA@min.net>
On a slightly unrelated note:
What's with the pseudonym, Abigail?
Is "Haijo Schipper" a name to be ashamed of?
You in some kind of witness protection program?
John Porter
------------------------------
Date: Thu, 05 Feb 1998 11:02:06 -0800
From: Jerome O'Neil <joneil@cks.ssd.k12.wa.us>
To: Kim Bo Hansen <kbo@kmd.dk>
Subject: Re: Redirect with cookies ???
Message-Id: <34DA0CAD.E0715186@cks.ssd.k12.wa.us>
Kim Bo Hansen wrote:
> I am trying to redirect a page and set a cookie at the same time.
>
> print redirect(-url=>$absolute_scripts_path . 'contract_example.pl',
> -nph=>1,
> -cookie=>[$cookie]);
>
> the url exists, and according to the CGI.pm this should be possible.
>
> The browser redirects correctly to the named URL, but the cookie is
> not set.
>
I fought with this problem for a long time. What I discovered is that
the browser will set the cookie, but not transmit it to the redirected
page. I don't know if this is true of IE, but I know it is of NN.
I eventualy ended up using URL encoding to transmit the cookie value to
the redirected CGI.
Jerome
------------------------------
Date: 5 Feb 1998 20:14:10 GMT
From: trhall@ezinfo.ucs.indiana.edu (Thomas R. Hall)
Subject: Re: Redirect with cookies ???
Message-Id: <6bd6ii$7qo$1@flotsam.uits.indiana.edu>
There is a simple way to get around this. Simply do not use the "redirect"
module in CGI.pm. Do something like this:
print "Set-Cookie: MYNAME=Bob.Smith\n";
print "Location: /cgi-bin/newprogram.pl\n\n";
This will set a cookie, only back on the server with no expiration date
named MYNAME with the value Bob.Smith. By sending this first, the cookie
will be set before the redirect, thus allowing the value to be read.
If you are really picky about this, you need to know one other thing:
Under a UNIX browser, this works fine when redirecting to an ABSOLUTE URL.
However, under Windows/Macintosh, you need to redirect to a RELATIVE URL.
This means that the above Perl code _should_ be:
print "Set-Cookie: MYNAME=Bob.Smith\n";
print "Location: newprogram.pl\n\n";
This will _still_ have the cookie set for the cgi-bin directory (assuming
that's where the first script was) and will be read properly under
Windows/Macintosh.
If you have more questions, feel free to drop me E-mail, as I don't get to
the newsgroup very often.
--
Thomas R. Hall <trhall@indiana.edu> BPO Web Services Coordinator
http://php.indiana.edu/~trhall/ Indiana University Bloomington
RSA KeyID: 0x8F6DFD27 DSS/DH KeyID: 0x443AE82D trhall@acm.org
According to Jerome O'Neil <joneil@cks.ssd.k12.wa.us>:
>Kim Bo Hansen wrote:
>
>> I am trying to redirect a page and set a cookie at the same time.
>>
>> print redirect(-url=>$absolute_scripts_path . 'contract_example.pl',
>> -nph=>1,
>> -cookie=>[$cookie]);
>>
>> the url exists, and according to the CGI.pm this should be possible.
>>
>> The browser redirects correctly to the named URL, but the cookie is
>> not set.
>>
>
>I fought with this problem for a long time. What I discovered is that
>the browser will set the cookie, but not transmit it to the redirected
>page. I don't know if this is true of IE, but I know it is of NN.
>
>I eventualy ended up using URL encoding to transmit the cookie value to
>the redirected CGI.
>
>Jerome
>
--
--
Thomas R. Hall <trhall@indiana.edu> BPO Web Services Coordinator
http://php.indiana.edu/~trhall Indiana University Bloomington
RSA KeyID: 0x8F6DFD27 DSS/DH KeyID: 0x443AE82D trhall@acm.org
------------------------------
Date: Thu, 05 Feb 1998 12:31:18 -0800
From: Jerome O'Neil <joneil@cks.ssd.k12.wa.us>
To: "Thomas R. Hall" <trhall@ezinfo.ucs.indiana.edu>
Subject: Re: Redirect with cookies ???
Message-Id: <34DA2196.BE9BECC7@cks.ssd.k12.wa.us>
Thomas R. Hall wrote:
> There is a simple way to get around this. Simply do not use the "redirect"
> module in CGI.pm. Do something like this:
>
I have found the redirect to be somewhat unreliable in CGI.pm, also. Your
solution is fine, but for a different set of problems.
> print "Set-Cookie: MYNAME=Bob.Smith\n";
> print "Location: /cgi-bin/newprogram.pl\n\n";
>
Which will indeed set a cookie on the client side, and redirect the client to
newprogram.pl. The problem is that newprogram.pl does not see your cookie
MYNAME. If you initiate another connection to newprogram.pl, it will then see
MYNAME, but not if it is called on a redirect.
Jerome
------------------------------
Date: 5 Feb 1998 20:39:51 GMT
From: trhall@ezinfo.ucs.indiana.edu (Thomas R. Hall)
Subject: Re: Redirect with cookies ???
Message-Id: <6bd82n$7ug$1@flotsam.uits.indiana.edu>
: > print "Set-Cookie: MYNAME=Bob.Smith\n";
: > print "Location: /cgi-bin/newprogram.pl\n\n";
: >
:
: Which will indeed set a cookie on the client side, and redirect the
: client to newprogram.pl. The problem is that newprogram.pl does not see
: your cookie MYNAME. If you initiate another connection to newprogram.pl,
: it will then see MYNAME, but not if it is called on a redirect.
Check out the rest of my message. If you notice, I mention that if you
perform a redirect to newprogram.pl INSTEAD OF /cgi-bin/newprogram.pl, the
cookie WILL, in fact, be readable by the script.
I am using this successfully on 30+ CGI programs with 6000+ users...
--
# Thomas R. Hall <trhall@indiana.edu> BPO Web Services Coordinator
# http://php.indiana.edu/~trhall/ Indiana University Bloomington
# RSA KeyID: 0x8F6DFD27 DSS/DH KeyID: 0x443AE82D trhall@acm.org
--
--
Thomas R. Hall <trhall@indiana.edu> BPO Web Services Coordinator
http://php.indiana.edu/~trhall Indiana University Bloomington
RSA KeyID: 0x8F6DFD27 DSS/DH KeyID: 0x443AE82D trhall@acm.org
------------------------------
Date: Thu, 5 Feb 1998 14:38:44 -0500
From: David Lee Lambert <lamber45@EGR.msu.edu>
Subject: Simplest regexp perl program?
Message-Id: <Pine.GSO.3.96.980205142541.28005A-100000@area51>
I'm trying to learn perl, so that I can use it within a procmail
anti-spam filter. Specifically, I want a program that scans its input
for valid E-mail addresses that look like return addresses and prints them
as a comma-seperated list on the output. Even a program that takes a
list, one per line, and puts them as commas would help.
I've tried stuff like:
while (<>) {print m/.*/, ", "}
but this seems to be providing a scalar context for the m//, since I get
sessions like
>>>Hi
<<<1,
>>>
<<<1,
I know the regexp I want to use; something like
[A-Za-z0-9._+-]{3,40}@([A-Za-z0-9_-]\.)+([a-z]{2,3}|uucp|arpa)
I just need help with the perl syntax.
David Lee Lambert MHm 16x20 Hack Programmer and Student
Admin of lmert.dyn.ml.org http://lmert.dyn.ml.org
My web pages are at http://web.egr.msu.edu/~lamber45
------------------------------
Date: Thu, 05 Feb 1998 20:02:22 GMT
From: mcafee@seawolf.rs.itd.umich.edu (Sean McAfee)
Subject: Re: Simplest regexp perl program?
Message-Id: <iVoC.10$Uu1.106503@news.itd.umich.edu>
In article <Pine.GSO.3.96.980205142541.28005A-100000@area51>,
David Lee Lambert <lamber45@EGR.msu.edu> wrote:
>I'm trying to learn perl, so that I can use it within a procmail
>anti-spam filter. Specifically, I want a program that scans its input
>for valid E-mail addresses that look like return addresses and prints them
>as a comma-seperated list on the output. Even a program that takes a
>list, one per line, and puts them as commas would help.
>I've tried stuff like:
>while (<>) {print m/.*/, ", "}
>but this seems to be providing a scalar context for the m//, since I get
>sessions like
>>>>Hi
><<<1,
>>>>
><<<1,
This will print a comma-separated list of all words in the input:
while (<>) { push(@list, /\w+/g) }
print join(", ", @list);
This will work, too:
print join(", ", map { /\w+/g } <>);
Just replace the "\w+" with your own expression.
>[A-Za-z0-9._+-]{3,40}@([A-Za-z0-9_-]\.)+([a-z]{2,3}|uucp|arpa)
Incidentally, this could be shortened a bit:
[\w.+-]{3,40}@([\w-]\.)+([a-z]{2,3}|uucp|arpa)
--
Sean McAfee | GS d->-- s+++: a25 C++ US+++$ P+++ L++ E- W+ N++ |
| K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
| tv+ b++ DI++ D+ G e++>++++ h- r y+>++** | umich.edu
------------------------------
Date: 05 Feb 1998 12:31:40 -0700
From: Vladimir Alexiev <vladimir@cs.ualberta.ca>
To: Kevin Lenzo <lenzo@cs.cmu.edu>
Subject: Re: size limit to the length of a perl script
Message-Id: <omra5halwk.fsf@tees.cs.ualberta.ca>
In article <34D9E889.5FFC8CE2@cs.cmu.edu> Kevin Lenzo <lenzo@cs.cmu.edu> writes:
> perl can deal with ginormous well-formed perl programs.
Depends on the program, I guess. This baby:
perl -e 'print"sub{"x100000,"}"x100000' | perl
causes "Out of memory!" after some 30 seconds. SparcStation 10 with 128Mb.
------------------------------
Date: 5 Feb 1998 19:45:52 GMT
From: shaug@callamer.com (O'Shaughnessy Evans)
Subject: Re: solution for multiline comments???
Message-Id: <6bd4tg$e45$1@ha1.rdc1.occa.home.com>
In article <qz$9802051057@qz.little-neck.ny.us>,
Eli the Bearded <*@qz.to> writes:
Okay, just to see if I understand these....
[snip]
>
> And for a real comment stripping hell (stolen from one of my old posts)
> consider these:
>
> s# foo \# bar
> # qux #x;
Replaces "foo#bar" with "qux" in $_.
> s# wee [\#] fun
> # neat #x;
Replaces "wee#fun" with "neat" in $_. [ On second thought, does this
imply that in the first pattern (foo\#bar), the \# is actually a
comment char instead of a pattern to match, and therefore it's not a
valid s/// op? Hmm... I doubt it, because then (?#...) wouldn't be
necessary. ]
> s[ fee(.*fie.*)foe ][
> ($a=$1, # $1 can't be modified
> $a =~ s# \s #"."#xge # tr might be faster
> && $a # replace with null if s/// failed
> ]xe;
For each "fee<0 or more chars>fie<0 or more chars>foe" in $_, replace
each whitespace char with a dot, or with a null if there's no
whitespace. Thanks for the in-line comments, BTW :)
> $a=~s=j.k.l=wingo=s&&s&#(?#foo)&s;&;
Replace "j<anychar>k<anychar>l" with "wingo" in $a, spanning any line
breaks in $a. If that's successful, replace "#" with "s;" in $_.
> And some new ones for people who remember the answers to what those
> ones do.
>
> s# $ \#ARGV # x #x;
Replace the number of @ARGV's last index with an "x" in $_.
> s# $\#ARGV # xx #x;
Do the same, but replace it with "xx".
> s# ( [\#\s\w]+ ) (?\#?) # ($a=$1, $a =~ s\# \s \#.\#xg, $a) #xe;
For any substring of one or more "#<whitespace char><word char>" when
followed by, hmm, an optional "#" (?), replace each whitespace char
with a dot. The parentheses, BTW, make this so much more clear upon
first glance.
> There are no context free comments in perl. Playing around with toke.c
> from the perl source, I have not been able to implement some of my ideas
> for such a thing. Perl parsing is quite complex.
>
> Elijah
> ------
> sees a "which of these is legal" stump-the-guru question in this stuff
--
O'Shaughnessy Evans
http://www.callamerica.net/shaug/
------------------------------
Date: Thu, 05 Feb 1998 14:22:31 -0700
From: Kevin Eson <keson@uswest.com>
To: "V. Chandrasekhar" <vchandra@mail.delcoelect.com>
Subject: Re: Some Questions Regarding Error Messages Generated by the -w switch
Message-Id: <34DA2D96.9692FF7D@uswest.com>
V. Chandrasekhar wrote:
> [>... snippage ...<]
>
> man perlfaq9 > file9
>
> There are unprintable characters in the file. A couple of years
> ago, I remember jumping through some hoops to print man pages
> without these characters.) I am very interested in acquiring
> more books and resources. I was very surprised to see about
> six Perl books in our local Waldenbooks.
>
> [>... more snippage ...<]
>
> Regards.
>
> V. Chandrasekhar
This is how I create a file from a man page:
man perlfac9 | col -b > file9
--
Kevin Eson
...............................
keson@uswest.com - professional
tarkus@dim.com - personal
+==============================================================================+
| The views presented here are mine and mine alone. They do not reflect the |
| views of my employer nor do I speak for them. My employer's involvement to |
| my post is only as a provider of equipment and connection. |
+==============================================================================+
------------------------------
Date: 5 Feb 1998 20:40:50 GMT
From: lvirden@cas.org
Subject: Re: Survival Of perl
Message-Id: <6bd84i$347$1@srv38s4u.cas.org>
According to John Porter <jdporter@min.net>:
:language level, you can do everything in Perl that you would
:otherwise do in C. And it's free.
Well, you can't build a number of the Perl extension modules without
C...
--
Larry W. Virden <URL:mailto:lvirden@cas.org> ICQ: 5744965
<URL:http://www.teraform.com/%7Elvirden/> <*> O- "We are all Kosh."
Unless explicitly stated to the contrary, nothing in this posting should
be construed as representing my employer's opinions.
------------------------------
Date: 5 Feb 1998 20:59:33 GMT
From: guym@zippy.as.arizona.edu (Guy K. McArthur)
Subject: Wierd Directory Problem
Message-Id: <6bd97l$edq$1@news.ccit.arizona.edu>
For some reason, any Perl package I install insists in going into
/var/tmp/site_perl/usr/lib/perl5 instead of /usr/lib/perl5.
It's not a big problem, I made one a symlink to the other to get around it, but it is kind of strange and I'd like to fix it.
I have perl 5.004-01 which is the latest package available for my platform, RedHat SparcLinux 4.2 (with the 2.0.26 kernel).
Guy
------------------------------
Date: Thu, 5 Feb 1998 15:16:47 -0500
From: "Doug Browne" <dbrowne@indiana.edu>
Subject: Win32::AdminMisc function RenameUser
Message-Id: <6bd6vf$6qk$1@jetsam.uits.indiana.edu>
Howdy.
I can't seem to get this brief script (attached) to make changes on
Windows NT Workstations or stand-alone Servers, even though it does it fine
on Domain Controllers. In all cases I'm using Perl for Win32 Build 315, with
the AdminMisc functions from Roth Consulting. I am a Domain Admin, logged in
as same on the NT Workstation from which I'm working, and that group is in
the Administrators group on all machines involved.
Does anyone see what I'm missing here?
Doug Browne
NT Specialist
Indiana University Student Technology Centers
dbrowne@Indiana.edu
-----------
use Win32;
use Win32::AdminMisc;
$newuid = "Guest2";
$uid = "Guest";
$srv = "\\\\server-a";
Win32::AdminMisc::RenameUser($srv, $uid, $newuid);
------------------------------
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 1818
**************************************