[17407] in Perl-Users-Digest
Perl-Users Digest, Issue: 4827 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 6 21:05:32 2000
Date: Mon, 6 Nov 2000 18:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <973562709-v9-i4827@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 6 Nov 2000 Volume: 9 Number: 4827
Today's topics:
Re: Backtick problems on Windows98 (Michael P. Soulier)
Re: Backtick problems on Windows98 (Martien Verbruggen)
changing user password davidchew@my-deja.com
Re: changing user password (Martien Verbruggen)
Re: changing user password <mischief@velma.motion.net>
Re: Converting ?!& etc. characters into unicode entitie <godoy@conectiva.com>
Re: do you know why this doesn't work? (Garry Williams)
Re: Freelance Programmer Neede - Good Money (Al)
Re: Help - read from CSV <mischief@velma.motion.net>
Re: how to sort corresponding arrays? (Mark-Jason Dominus)
Re: Looking for idiom for getting value from @ARGV, or <uri@sysarch.com>
Re: Looking for idiom for getting value from @ARGV, or (Martien Verbruggen)
Re: Need help getting out of a foreach loop <ren.maddox@tivoli.com>
Newbie Question: Hiding password? na0ise@my-deja.com
Re: Newbie Question: Hiding password? (Martien Verbruggen)
pass by reference to C <vidulats@yahoo.co.uk>
Read from csv file <c.darlington@virgin.net>
Re: Read from csv file <jeff@vpservices.com>
Script needed <icare2@gte.net>
Re: Script needed (Martien Verbruggen)
Re: Search engine woes... <mischief@velma.motion.net>
Re: Sorting hash of hashes by value (Michael P. Soulier)
Re: Sorting hash of hashes by value <nospam@david-steuber.com>
Re: Sorting hash of hashes by value <ren.maddox@tivoli.com>
Re: Sorting hash of hashes by value <crt@kiski.net>
Re: Sorting hash of hashes by value <crt@kiski.net>
Re: Splitting variable length fixed records (Martien Verbruggen)
Re: Timeout option on CGI script????? <brondsem@my-deja.com>
using perl, is there a command to change or set user pa dcc1234@pacific.net.sg
Re: Where does a core dump come from? <nospam@david-steuber.com>
Win32::Internet <nihad@yahoo.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 6 Nov 2000 23:23:59 GMT
From: msoulier@nortelnetworks.com (Michael P. Soulier)
Subject: Re: Backtick problems on Windows98
Message-Id: <8u7eif$h9l$1@bmerhc5e.ca.nortel.com>
In article <8u75do$5a3$1@newstoo.ericsson.se>, Peter Lerup wrote:
>Hi
>
>I have a strange phenomenon that I wonder if someone else have seen and
>hopefully have the solution for.
>
>The problem is that on some Windows 98 machines the redirection of stdout
>doesn't seem to work. Whenever doing anything like
>
>$a = `dir`;
>
>The result of the command goes directly to the console window and not into
>the variable.
>
>The strangest thing is that this only happens on some machines and not
>others, different hardware but all using the same version of Windows 98.
>I've tried several different versions of Win32 Perl but always the same
>result.
Hi Peter. Redirection is quite broken on windoze. However, the win32 perl
book seems to assume that it works.
@files = `dir`; # gets dir output
Have you tried a list instead of a scalar? If the scalar doesn't work I
don't see why the list would, but who knows?
If not, I'd think something is wrong with some of those machines. I'm
wondering if there is a way to properly specify the command shell on win32?
I don't have one to test on (thankfully) so I can't verify this.
Mike
--
Michael P. Soulier, TD12, SKY Tel: 613-765-4699 (ESN: 39-54699)
Optical Networks, Nortel Networks, SDE Pegasus
"...the word HACK is used as a verb to indicate a massive amount
of nerd-like effort." -Harley Hahn, A Student's Guide to UNIX
Nortel Linux User's Group Ottawa: (internal) http://nlug.ca.nortel.com
------------------------------
Date: Tue, 07 Nov 2000 01:29:24 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Backtick problems on Windows98
Message-Id: <slrn90emnn.7ck.mgjv@verbruggen.comdyn.com.au>
On Mon, 6 Nov 2000 21:55:24 +0100,
Peter Lerup <peter.lerup@ecs.ericsson.se> wrote:
> Hi
>
> I have a strange phenomenon that I wonder if someone else have seen and
> hopefully have the solution for.
>
> The problem is that on some Windows 98 machines the redirection of stdout
> doesn't seem to work. Whenever doing anything like
>
> $a = `dir`;
My recommendation would be to not use external commands for this,
since Perl is perfectly capable of doing this internally with a
minimum amount of fuss. You'll end up with code which is faster and
more portable.
opendir DIR, '.' or die $!;
my @files = readdir DIR;
closedir DIR;
my @files = glob '*';
I'm not sure whether you really wanted information on the files, but
parsing the output of dir is probably not the best way to get it. Use
stat() for that.
You might want to read the perlfunc documentation, in particularthe
entries for opendir(), readdir(), closedir(), glob() and stat().
Martien
--
Martien Verbruggen |
Interactive Media Division | Begin at the beginning and go on till
Commercial Dynamics Pty. Ltd. | you come to the end; then stop.
NSW, Australia |
------------------------------
Date: Tue, 07 Nov 2000 00:17:03 GMT
From: davidchew@my-deja.com
Subject: changing user password
Message-Id: <8u7hlp$8dq$1@nnrp1.deja.com>
Is there a command in perl
to change user password in the passwd file
david
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 07 Nov 2000 01:41:55 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: changing user password
Message-Id: <slrn90enf5.7ck.mgjv@verbruggen.comdyn.com.au>
On Tue, 07 Nov 2000 00:17:03 GMT,
davidchew@my-deja.com <davidchew@my-deja.com> wrote:
> Is there a command in perl
> to change user password in the passwd file
In short:
No. Yes. No. Yes. No.
Slightly longer:
No, there is no direct command. Yes, you can do it. No, you do not
want to do it that way. Yes, there are other ways. No, don't go there,
unless you know what you're doing.
Even longer:
No, Perl doesn't have a command to change the user password. The
reason for that is that not all platforms or installations do this the
same way. Some use password files, some shadow password files, some
NIS or LDAP, and yet others totally novel and interesting ways. Of
course, not all systems have passwords.
Yes, if you know how your systems organises its information in the
password file, and possibly shadow password file, you can open those,
parse them, change the stuff you want to change, and write them back
out. You'll need to be root. Read the perlsec documentation.
No, you don't ever want to do this. You'd have to become root, and
that's a dangerous thing to do unless you really know what you're
doing. You'd have to ensure the right locking protocol so you don't
get in the way of other things changing those files. And of course, it
wouldn't work on all those systems where the passwords are kept
somewhere else than in /etc/passwd and/or /etc/shadow. Can of worms
open, wriggly things everywhere.
Yes, there are ways in which you could do this better. You use the
standard system tools that came with your system. You still need to
become the user that needs to change the password, or a privileged
user. Read the perlsec documentation, and the relevant documentation
on your system.
No, if you didn't know this answer already, I recommend that you don't
do it. There are many, many possibilities in which you could leave
open large security holes. Are you prepared to be blamed when
something goes wrong?
Martien
--
Martien Verbruggen |
Interactive Media Division | I'm just very selective about what I
Commercial Dynamics Pty. Ltd. | accept as reality - Calvin
NSW, Australia |
------------------------------
Date: Tue, 07 Nov 2000 01:50:45 -0000
From: <mischief@velma.motion.net>
Subject: Re: changing user password
Message-Id: <t0envlaa3thg4f@corp.supernews.com>
davidchew@my-deja.com wrote:
> Is there a command in perl
> to change user password in the passwd file
Since you assume that we know what password file you
are talking about, I'll assume you mean something
Unix-like.
This might just be a good start:
###----- start untested but trivial example -----###
$passwd = <STDIN>;
$salt = '.!';
$passwd = crypt($passwd, $salt);
###----- end untested but trivial example -----###
Or maybe 'perldoc -f crypt'?
If that's too much trouble, try:
system('passwd');
> david
--
Christopher E. Stith
mischief@motion.net
------------------------------
Date: 06 Nov 2000 21:25:34 -0200
From: Jorge Godoy <godoy@conectiva.com>
Subject: Re: Converting ?!& etc. characters into unicode entities?
Message-Id: <kpzojcptsh.fsf@dagon.conectiva>
On Mon, 6 Nov 2000, paul.groves@oucs.ox.ac.uk wrote:
> Does anyone know if there is an easy way (e.g. a function of some
> sort) to convert characters like "!", "?" "&" etc. into their
> respective (unicode) entity values when these values occur in
> strings containing paragraphs of text (they cause processing errors
> in my code otherwise, don't ask...). i.e. is there something I can
> just use to convert the whole string?
Take a look at Unicode::String, Unicode::Map, Unicode::Map8 and
Unicode::Map8UTF. These modules can go from ISO-8859-1 (aka Latin-1)
to UTF and from UTF to ISO-8859-1 (and some variations).
See you,
--
Godoy. <godoy@conectiva.com>
Departamento de Publicações Conectiva S.A.
Publishing Department Conectiva Inc.
------------------------------
Date: Tue, 07 Nov 2000 00:02:26 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: do you know why this doesn't work?
Message-Id: <mEHN5.699$FG.45448@eagle.america.net>
On Tue, 7 Nov 2000 09:39:07 +1100, jason <elephant@squirrelgroup.com>
wrote:
>Garry Williams wrote ..
>>On Wed, 1 Nov 2000 13:38:16 +1100, jason <elephant@squirrelgroup.com> wrote:
>>>jt_2000_ky@my-deja.com wrote ..
>>>>I'm trying to write a simple script to check to make sure a box is up.
>>>>I thought the easy part would be to get the Ping module to work
>>>>correctly but the script below doesn't work. Any suggestions?
>>>...
>>>thus endeth the first lesson in testing functions that have command line
>>>equivalents
>>
>>What makes you think there's a command line equivalent to the
>>functionality in Net::Ping? Did you read the Net::Ping manual page?
>
>pinging microsoft.com always times out because it doesn't respond to
>pings .. it is the simplest functionality possible that needs to be
>tested because that's all that the originator's code uses from Net::Ping
>
>I'm guessing (because the originator never stated it) that the "doesn't
>work" they were talking about was probably because they expected a
>response from microsoft.com and yet it doesn't respond .. because other
>than that there is nothing unexpected about the code or its output - it
>correctly pings www.virginrecords.com
The real point is that the command line ping program sends icmp echo
requests and the default protocol used by Net::Ping is udp:
$ cat x
#!/usr/local/bin/perl -w
use strict;
use Net::Ping;
my $h = 'www.virginrecords.com';
my $p = Net::Ping->new;
$p->ping($h)
? print "$h responded to udp echo\n"
: print "$h no answer to udp echo\n";
$p = Net::Ping->new('icmp');
$p->ping($h)
? print "$h responded to icmp echo\n"
: print "$h no answer to icmp echo\n";
$ sudo perl x
www.virginrecords.com no answer to udp echo
www.virginrecords.com responded to icmp echo
$
Not all hosts are configured to respond to any echo request, but very
few these days are configured to respond to udp or tcp echo requests.
--
Garry Williams
------------------------------
Date: Mon, 06 Nov 2000 23:52:46 GMT
From: nospamapgraham@ispchannel.com--- (Al)
Subject: Re: Freelance Programmer Neede - Good Money
Message-Id: <3a0a444f.7608621@news.ispchannel.com>
On Sun, 05 Nov 2000 20:27:54 GMT, David Steuber
<nospam@david-steuber.com> wrote:
>... I don't
>really know how to read a DTD.
>
Reading it's easy. Staying awake and figguring out WTF they're saying
is the hard part.
-Al-
------------------------------
Date: Tue, 07 Nov 2000 01:25:42 -0000
From: <mischief@velma.motion.net>
Subject: Re: Help - read from CSV
Message-Id: <t0emgmto7nsmb9@corp.supernews.com>
Simon E. John <simon@suit-u-sir.com> wrote:
> I'm trying to write a poll in Perl, I've got most of it done, but would like
> to read in the results from a flat file e.g. CSV or pipe-delimited.
> The format would only consist of two fields with each record separated by a
> newline, e.g.
> Bush|1
> Gore|2
> Homer Simpson|100
> I'd like to be able to setup a loop so that the file is read into an array
> until EOF and the number of records counted and put into a variable,
> processed and then written back to the file.
Here's a script that does more than what you explicitly asked:
--------------------------------------
#!/usr/bin/perl -w
open(poll, 'poll.txt');
%votes = ();
$numrecords = 0;
while(<poll>) {
chop;
($foo, $bar) = split(/\|/, $_);
$votes{$foo} = $bar;
$numrecords++;
}
close(poll);
open(poll, '>>poll.txt');
print(poll "$numrecords\n");
close(poll);
-------------------------------------
This actually uses a hash for the votes instead of an array, because
I thought it'd be nice to have the ability to do something similar
to this somewhere in the script:
------------------
$democratic_votes = $votes{gore};
------------------
You could later recover all the hash entries using the each() keyword
in a loop. If you really do want everything in an array instead of
a hash, then you have a few choices of how to do that, but you wouldn't
need to count array entries, since in Perl there's a way to find that
already.
Here's one simple but probably suboptimal way to do it with arrays:
-----------------
#!/usr/bin/perl -w
open(poll, 'poll.txt');
@candidate = ();
@votes = ();
while(<poll>) {
chop;
($x, $y) = split(/\|/, $_);
push(@candidate, $x);
push(@votes, $y);
}
close(poll);
open(poll, '>>poll.txt');
print(poll "$#candidate\n");
close(poll);
------------------
None of these examples include error checking, which should be added
to any production script (probably pre-production, too, since it makes
troubleshooting and debugging a lot easier).
> This way I could change the survey simply by changing the CSV file.
True. Is this necessarily an overall advantage?
> Someone said use the DBD::CSV or Text::CSV modules, but I'd prefer not to -
> someone else mentionned grep....
I think grep is one possible solution, but split seems to be more
straightforward here.
Specifically why you'd prefer not to use the module approaches
I'm not sure, and would wonder about.
<module speech>
I personally am not the strongest advocate of using a module
in every case, as some regular readers of the group may know.
For a quick project with limited production use, I may eschew
the available modules. I do use modules often though.
The modules may increase overhead somewhat in some cases, but
almost always they are well designed, well tested, and well
benchmarked. You can often import only those parts of a module
you find most useful. The quality afforded a module by being
the end of a project and not the means of a project often
equate to a more efficient design and more thorough testing,
profiling, and debugging. This means the limited overhead of
loading a module can, although not always will, be offset or
more than offset by the benefit of its use even in terms of
performance.
The module writers aren't considering your specialized case,
so they write something more general and portable. General
software and portable software tend to be less buggy and more
robust. This is true especially of software that is both
general and portable.
The module writer is also designing an entire project just
for the problem realm of the module, so while the module is
more general than your solution for the task at hand, the
time spent on it is more specifically targeted at that problem
domain. That means that, in general, it will have had more
time contributed to it than something written ad hoc for a
specific case. This allows more maintenance time, more testing
time, and in the case of Open Source Software (which any Perl
module is pretty sure to be, especially if someone mentions
it being on CPAN) more peer review than your individual project.
What would you give to have hundreds of other programmers
review an important part of your code?
Last of all, and probably most important, if you are having
problems (due to lack of time, lack of desire, or lack of
knowledge) producing an acceptable solution for some problem
which is already addressed in a readily available form such as
a module, it is a duplication of someone else's efforts
(pronounced: wayst uv tAIm) to produce an equivalent or
slightly better solution from scratch. It is better to improve
on the existing module unless you can make fundamental
improvements with a fresh project. It is never beneficial to
replace a working solution with one that is inferior, learning
experience aside. Remember that no one person can learn every
aspect of programming for every problem, so even a learning
experience is only as good as what it teaches you and what you
do with the knowledge later. I'd rather have code written by
someone with extensive knowledge of the problem than someone
who is learning how to program for the problem, even if the
latter is a good overall programmer.
</module speech>
> --
> Simon E. John, BA(Hons), DipM
> Email: simon@suit-u-sir.com | Running RISC OS 4.02,
--
Christopher E. Stith
mischief@motion.net
------------------------------
Date: Tue, 07 Nov 2000 00:07:37 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: how to sort corresponding arrays?
Message-Id: <3a0747c8.3410$2b3@news.op.net>
Keywords: Johannesburg, Sacramento, Sheppard, virginal
In article <geFN5.205$Bf7.188786688@news.frii.net>,
Chris Fedde <cfedde@fedde.littleton.co.us> wrote:
>Maybe it's just me but...
>
> fetch -1 http://perl.plover.com/yak/hw2/slide003.html
> fetch: slide003.html: Not Found
>
You have the wrong IP address for perl.plover.com. Try
http://209.152.214.112/yak/hw2/slide003.html
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f|ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Mon, 06 Nov 2000 23:59:03 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Looking for idiom for getting value from @ARGV, or a default
Message-Id: <x77l6ghcu0.fsf@home.sysarch.com>
>>>>> "BL" == Bart Lateur <bart.lateur@skynet.be> writes:
BL> Uri Guttman wrote:
>> $s = defined( $ARGV[0] ) ? shift : 'default' ;
BL> @ARGV is a special case, an array for which it's garanteed that no
BL> existing item can be undefined. If an element exists, it is defined. So
BL> you can do:
BL> $s = @ARGV ? shift : 'default';
i note that in another post. normally you can't have an undefined value
in @ARGV from the shell, but someone could be messing around with @ARGV
in a BEGIN block.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Tue, 07 Nov 2000 01:24:03 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Looking for idiom for getting value from @ARGV, or a default
Message-Id: <slrn90emdm.7ck.mgjv@verbruggen.comdyn.com.au>
On Mon, 06 Nov 2000 23:59:03 GMT,
Uri Guttman <uri@sysarch.com> wrote:
>>>>>> "BL" == Bart Lateur <bart.lateur@skynet.be> writes:
>
> BL> Uri Guttman wrote:
> >> $s = defined( $ARGV[0] ) ? shift : 'default' ;
>
> BL> @ARGV is a special case, an array for which it's garanteed that no
> BL> existing item can be undefined. If an element exists, it is defined. So
> BL> you can do:
>
> BL> $s = @ARGV ? shift : 'default';
>
> i note that in another post. normally you can't have an undefined value
> in @ARGV from the shell, but someone could be messing around with @ARGV
> in a BEGIN block.
Yes, I read that after sending this post as well. But then, anyone
doingthat gets what they deserve :). Or at least, anyone doing that
probably knows what they are doing.
In any case, if that happens, you should probably just treat it like
@_ in a sub.
Martien
--
Martien Verbruggen |
Interactive Media Division | You can't have everything, where
Commercial Dynamics Pty. Ltd. | would you put it?
NSW, Australia |
------------------------------
Date: 06 Nov 2000 17:22:09 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Need help getting out of a foreach loop
Message-Id: <m33dh4u1ni.fsf@dhcp11-177.support.tivoli.com>
"Kevin Millecam" <kmillecam@novell.com> writes:
> My problem is, in some cases, I would like to limit the number of iterations
> in the following loop.
There are several ways to do this. The two that come to mind
immediately are:
1. Keep a counter and use last.
2. If possible, restrict your loop to begin with.
> For example, let's say the file I'm parsing has a total of 15 "items" but I
> only want the first 5 parsed and printed to HTML.
> Here's the original code:
>
> foreach my $item (@{$rss->{'items'}}) {
Well, if you really only want the first five items, you could just
change the loop to only include the first five (#2 above):
foreach my $item ($rss->{items}[0..4]) {
> next unless defined($item->{'title'}) && defined($item->{'link'});
Ah... but maybe you only want the first five that get past this
restriction. If so, you should probably just use a counter,
incremented once the condition is met. Something like (need to
declare it before the loop):
last if $count++ == 5;
[rest of loop (snipped) goes here]
HTH,
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Tue, 07 Nov 2000 00:36:32 GMT
From: na0ise@my-deja.com
Subject: Newbie Question: Hiding password?
Message-Id: <8u7iqg$9f1$1@nnrp1.deja.com>
Hi all,
I am writing a perl script that reads data from a webform. I want to zip
the data I read with a password. I do not want to put the password in
plain text inside the Perl script. Is there a more secure way to achieve
my purpose? Any helps will be greatly appreciated.
Thanks
Naoise. C
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 07 Nov 2000 01:50:05 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Newbie Question: Hiding password?
Message-Id: <slrn90enug.7ck.mgjv@verbruggen.comdyn.com.au>
On Tue, 07 Nov 2000 00:36:32 GMT,
na0ise@my-deja.com <na0ise@my-deja.com> wrote:
> Hi all,
>
> I am writing a perl script that reads data from a webform. I want to zip
> the data I read with a password. I do not want to put the password in
> plain text inside the Perl script. Is there a more secure way to achieve
> my purpose? Any helps will be greatly appreciated.
1 - Put a password in a password protected encrypted file. Read the
file, decrypt it with the password that you get from step 2.
1 - Put a password in a password protected encrypted file. Read the
file, decrypt it with the password that you get from step 3.
keep doing this until ....
12 - Install a password server. Authenticate against the server
with the password from step 13.
13 - Put a password in a file that is owned by you, and only readable
by you, in your home directory. Sue the admin of your system if they
ever look at that file.
Of course you can skip the first 12 steps.
At some point you will have to have a password somewhere. Where you
keep it is up to you.
Of course, if the thing you run is a CGI script, the password file
will have to be readable by the use that CGI program runs as. That
means that it will be readable to any CGI program on your server.
Oh well. Maybe the 'encryption' should be done from a crontab job.
Martien
--
Martien Verbruggen |
Interactive Media Division | Hi, John here, what's the root
Commercial Dynamics Pty. Ltd. | password?
NSW, Australia |
------------------------------
Date: Mon, 06 Nov 2000 23:31:14 -0000
From: <vidulats@yahoo.co.uk>
Subject: pass by reference to C
Message-Id: <t0efq22t7smr4e@corp.supernews.com>
My Perl file is like this:
#!/usr/bin/perl -w
use bytes;
@a = (1, 2, 3);
location (\@a);
In the "xs" file I wrote the location function which prints the address
and value of its passed elements:
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
location(char *x)
{
int i;
for (i=0; i<=2; i++,x++)
printf ("%d element = %c, address=%d, address = %
x\n",i,*x,x);
}
MODULE = bytes PACKAGE = bytes
void
location(x)
char *x
When I execute this program that C function prints some junk values.
I want that location function should print the
Element= 1, address= <some address>, address=<hexvalue>
Element= 2, address= <some address>, address=<hexvalue>
Element= 3, address= <some address>, address=<hexvalue>
--
Posted via CNET Help.com
http://www.help.com/
------------------------------
Date: Tue, 7 Nov 2000 00:52:13 -0000
From: "Chris Darlington" <c.darlington@virgin.net>
Subject: Read from csv file
Message-Id: <9mIN5.54045$mv2.187318@news2-win.server.ntlworld.com>
Hi all
I am completely new to Perl and would appreciate a kind souls help.
I have an address book saved in .csv format and would like a cgi script to
allow a user to enter a value such as county, and the script to return all
occurences that match the county field from the file.
How do I do this ?
I have tried reading a few books , but don't seem to be able to find what I
am looking for, or perhaps I just dont understand it at all!!!!!!!!
Can anyone help?
Chris
------------------------------
Date: Mon, 06 Nov 2000 17:06:15 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Read from csv file
Message-Id: <3A075587.2B966730@vpservices.com>
Chris Darlington wrote:
>
> I have an address book saved in .csv format and would like a cgi script to
> allow a user to enter a value such as county, and the script to return all
> occurences that match the county field from the file.
There are several ways: you could use the standard Perl functions to
open and read the file and then either use a regular expression or the
Text::CSV module to parse the results (see the documentation for open,
read, and perlfaq4); or, if you intend to do a number of database like
operations on the file (insert, update, delete, sort or select by
various fields), you could use the DBD::CSV or DBD::RAM modules (see
http://www.symbolstone.org/technology/perl/DBI/).
Which method you choose is up to you and they both have pitfalls for the
new user. With the standard calls methods you'll be responsible for
things like ensuring that multiple users aren't changing the file at the
same time and that if the fields have things like embedded quotation
marks, embedded commas, embedded newlines in them that they are handled
correctly. With the DBD methods you wouldn't need to worry about any of
those issues but you would need to learn some basic DBI and SQL syntax.
--
Jeff
------------------------------
Date: Tue, 07 Nov 2000 01:29:15 GMT
From: "Michele Gregory" <icare2@gte.net>
Subject: Script needed
Message-Id: <LVIN5.4227$PP3.316306@dfiatx1-snr1.gtei.net>
I have a page on my site that lists events for a wide variety of clubs.
Right now, users have to email me and I add them manually. Is there a
script available that will let users fill in a form, and post those answers
to the bottom of an existing page?
Please reply directly to my email address below as I don't have a chance to
get on here often.
Thanks
Tom
tgregory@agilityzone.com
------------------------------
Date: Tue, 07 Nov 2000 01:56:34 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Script needed
Message-Id: <slrn90eoak.7ck.mgjv@verbruggen.comdyn.com.au>
On Tue, 07 Nov 2000 01:29:15 GMT,
Michele Gregory <icare2@gte.net> wrote:
> I have a page on my site that lists events for a wide variety of clubs.
> Right now, users have to email me and I add them manually. Is there a
> script available that will let users fill in a form, and post those answers
> to the bottom of an existing page?
You're asking us whether there is a script or program that can accept
data in a format that only you know, and that can work with your
database/file/whatever? Only you know (or anyone else that has seen
that program that you use now). No one else can know.
And what does 'post to the bottom of an existing page' mean?
Are you talking about a static HTML page that you need to add stuff
to? HTML::Parser might be a good start. http://www.cpan.org/. CGI.pm
is a must.
> Please reply directly to my email address below as I don't have a chance to
> get on here often.
Pity. You won't read this then.
And I won't read anything else from you.
Martien
--
Martien Verbruggen |
Interactive Media Division | The world is complex; sendmail.cf
Commercial Dynamics Pty. Ltd. | reflects this.
NSW, Australia |
------------------------------
Date: Tue, 07 Nov 2000 01:27:21 -0000
From: <mischief@velma.motion.net>
Subject: Re: Search engine woes...
Message-Id: <t0emjp3qcc3ee0@corp.supernews.com>
acroapl@my-deja.com wrote:
> how can you match strings w/o capitaliztion being checked? Is there a
> function like in C?
$string = lc($string);
Does that work for ya?
--
Christopher E. Stith
mischief@motion.net
------------------------------
Date: 6 Nov 2000 23:28:35 GMT
From: msoulier@nortelnetworks.com (Michael P. Soulier)
Subject: Re: Sorting hash of hashes by value
Message-Id: <8u7er3$h9l$2@bmerhc5e.ca.nortel.com>
In article <8u7bjf$2pn$1@nnrp1.deja.com>, dhartsough@my-deja.com wrote:
>Hi,
> The subject line sort of says it all. I know how to sort a hash by
>value and get the ordered list of keys. However, I do not see how to
>sort a hash of hashes (or hash of hash of hashes...) by value returning
>an ordered list of pairs of keys. Any help greatly appreciated...
Hmm. Interesting. I don't see a problem though.
@list = ();
foreach my $key1 (keys %hash) {
foreach my $key2 (keys %{ $hash{$key1} }) {
push @list, "$key1 $key2";
}
}
@list = sort @list;
Now, I'm sure you could get more advanced than that, as that's fairly
trivial. The question is how you want to store the pair of keys. You could put
them in scalars like I've shown, and split them out again, or you could pass
sort() a function reference to something more advanced to sort any data
structure that you can cook up.
Was this even close to what you were after? ;-)
Mike
--
Michael P. Soulier, TD12, SKY Tel: 613-765-4699 (ESN: 39-54699)
Optical Networks, Nortel Networks, SDE Pegasus
"...the word HACK is used as a verb to indicate a massive amount
of nerd-like effort." -Harley Hahn, A Student's Guide to UNIX
Nortel Linux User's Group Ottawa: (internal) http://nlug.ca.nortel.com
------------------------------
Date: Tue, 07 Nov 2000 00:14:22 GMT
From: David Steuber <nospam@david-steuber.com>
Subject: Re: Sorting hash of hashes by value
Message-Id: <m3zojcocyp.fsf@solo.david-steuber.com>
perldoc -f values
--
David Steuber | Perl apprentice. The axe did not stop the
NRA Member | mops and buckets from flooding my home.
ICQ# 91465842
*** http://www.david-steuber.com/ ***
------------------------------
Date: 06 Nov 2000 17:15:47 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Sorting hash of hashes by value
Message-Id: <m37l6gu1y4.fsf@dhcp11-177.support.tivoli.com>
dhartsough@my-deja.com writes:
> The subject line sort of says it all. I know how to sort a hash by
> value and get the ordered list of keys. However, I do not see how to
> sort a hash of hashes (or hash of hash of hashes...) by value returning
> an ordered list of pairs of keys. Any help greatly appreciated...
You're probably going to have to give us a little more to go on, but
in the hopes that you can find your answer in this example, here it
is:
#!/usr/local/bin/perl -w
use strict;
my %hoh = ( balloons => {
color => "red",
quantity => 99,
},
"ways to leave your lover" => {
color => "",
quantity => 50,
},
dreams => {
color => "red, gold and green",
quantity => 0,
},
);
print "By color:\n";
print " $_ ($hoh{$_}{color})\n"
for sort { $hoh{$a}{color} cmp $hoh{$b}{color} } keys %hoh;
print "By quantity:\n";
print " $_ ($hoh{$_}{quantity})\n"
for sort { $hoh{$a}{quantity} <=> $hoh{$b}{quantity} } keys %hoh;
__END__
HTH...
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Mon, 6 Nov 2000 20:11:56 -0500
From: "Casey R. Tweten" <crt@kiski.net>
Subject: Re: Sorting hash of hashes by value
Message-Id: <Pine.OSF.4.21.0011062008550.26244-100000@home.kiski.net>
Today around 10:33pm, dhartsough@my-deja.com hammered out this masterpiece:
: The subject line sort of says it all. I know how to sort a hash by
: value and get the ordered list of keys. However, I do not see how to
: sort a hash of hashes (or hash of hash of hashes...) by value returning
: an ordered list of pairs of keys. Any help greatly appreciated...
If you have a hash of hashes and you really want to sort by direct
*value*, your going to be sorting on memory addresses. What you need
is knowing what fields you want to sort on within your keys hash
value.
In this example, we sort in accending order, by age:
my %hash = (
Joe => { age => 36 },
Jim => { age => 35 },
Ana => { age => 83 },
Bob => { age => 15 },
);
my @keys = map { $_->[0] }
sort { $a->[1] <=> $b->[1] }
map { [ $_, $hash{$_}->{age} ] } keys %hash;
perlfaq4 is a good place to look for answers.
--
print(join(' ', qw(Casey R. Tweten)));my $sig={mail=>'crt@kiski.net',site=>
'http://home.kiski.net/~crt'};print "\n",'.'x(length($sig->{site})+6),"\n";
print map{$_.': '.$sig->{$_}."\n"}sort{$sig->{$a}cmp$sig->{$b}}keys%{$sig};
my $VERSION = '0.01'; #'patched' by Jerrad Pierce <belg4mit at MIT dot EDU>
------------------------------
Date: Mon, 6 Nov 2000 20:14:13 -0500
From: "Casey R. Tweten" <crt@kiski.net>
Subject: Re: Sorting hash of hashes by value
Message-Id: <Pine.OSF.4.21.0011062013450.26244-100000@home.kiski.net>
Today around 8:11pm, Casey R. Tweten hammered out this masterpiece:
: Today around 10:33pm, dhartsough@my-deja.com hammered out this masterpiece:
:
: : The subject line sort of says it all. I know how to sort a hash by
: : value and get the ordered list of keys. However, I do not see how to
: : sort a hash of hashes (or hash of hash of hashes...) by value returning
: : an ordered list of pairs of keys. Any help greatly appreciated...
:
: If you have a hash of hashes and you really want to sort by direct
: *value*, your going to be sorting on memory addresses. What you need
: is knowing what fields you want to sort on within your keys hash
: value.
:
: In this example, we sort in accending order, by age:
:
: my %hash = (
: Joe => { age => 36 },
: Jim => { age => 35 },
: Ana => { age => 83 },
: Bob => { age => 15 },
: );
:
: my @keys = map { $_->[0] }
: sort { $a->[1] <=> $b->[1] }
: map { [ $_, $hash{$_}->{age} ] } keys %hash;
Of course it's entireley possible to go way overboard on a solution
too ;-)
my @keys = sort { $hash{$a}->{age} <=> $hash{$b}->{age} } keys %hash;
: perlfaq4 is a good place to look for answers.
:
:
--
print(join(' ', qw(Casey R. Tweten)));my $sig={mail=>'crt@kiski.net',site=>
'http://home.kiski.net/~crt'};print "\n",'.'x(length($sig->{site})+6),"\n";
print map{$_.': '.$sig->{$_}."\n"}sort{$sig->{$a}cmp$sig->{$b}}keys%{$sig};
my $VERSION = '0.01'; #'patched' by Jerrad Pierce <belg4mit at MIT dot EDU>
------------------------------
Date: Mon, 06 Nov 2000 23:16:16 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Splitting variable length fixed records
Message-Id: <slrn90eeu2.776.mgjv@verbruggen.comdyn.com.au>
On Mon, 6 Nov 2000 16:48:57 +1300,
Peter Sundstrom <peter.sundstrom@eds.com> wrote:
> I have a file of fixed records of variable length (newline terminated), eg:
>
> F1F2..F120
>
> Where
>
> F1 is 120 bytes
> F2 up to F120 is 60 bytes.
No one has yet suggested unpack, so I'll do that:
#!/usr/local/bin/perl -l
use warnings;
use strict;
my $F1L = 6;
my $FnL = 3;
while (<DATA>)
{
chomp;
my $tmpl = "A$F1L";
$tmpl .= "A$FnL" for (1 .. (length($_) - $F1L)/$FnL);
my @f = unpack $tmpl, $_;
print "@f";
}
__DATA__
123567abcdefghi
123567abcdefghijklmnopqr
Martien
--
Martien Verbruggen |
Interactive Media Division | Useful Statistic: 75% of the people
Commercial Dynamics Pty. Ltd. | make up 3/4 of the population.
NSW, Australia |
------------------------------
Date: Tue, 07 Nov 2000 01:33:41 GMT
From: Dave Brondsema <brondsem@my-deja.com>
Subject: Re: Timeout option on CGI script?????
Message-Id: <8u7m5l$c2k$1@nnrp1.deja.com>
In article <8u7aj6$233$1@nnrp1.deja.com>,
aboveandbeyond@my-deja.com wrote:
> I just add:
>
> alarm(60);
>
> near the top of my scripts somewhere. The default action when the
> alarm goes off is for the process to be killed, so that works fine.
>
> Don't know if that works in windows though.
no, it doesn't
>
> In article <uloN5.123564$47.1802041@news.bc.tac.net>,
> "D" <webmaster@kildare-signs.com> wrote:
> > Good day, I am learing to write cgi scripts on my localmachine and
> have
> > installed ActivaState Perl. My question is this, Is there an
option
> or way
> > to have a script 'timeout' and exit? i'm asking becuase when i make
a
> stupid
> > mistake (like an infinate loop) perl.exe cannot be removed from the
> task
> > manager, I must reboot my computer to end the processes.......
I just close the dos window that perl runs in. Can't you do that?
> >
> > I use linux for my webservers.
It's really bad when your webserver is windows and they host is
inexperienced in perl and you tie up the whole server.
> but for writing and testing scripts i
> use
> > windows2000, activestate, and apache 1.3.12.
> >
> > Thanks for your help
> >
> >
put something like this inside every loop:
++$b;if($b>10000){die("infinite loop");};
however, there are other ways to tie up a computer besides obvious
loops. Like accidentally mistyping a regex that does some backtracking
or some weird unexpected thing and in itself is an infinite loop.
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
--
Dave Brondsema
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 07 Nov 2000 00:13:47 GMT
From: dcc1234@pacific.net.sg
Subject: using perl, is there a command to change or set user password ?
Message-Id: <8u7hfl$835$1@nnrp1.deja.com>
best wishes
david
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 06 Nov 2000 23:55:54 GMT
From: David Steuber <nospam@david-steuber.com>
Subject: Re: Where does a core dump come from?
Message-Id: <m34s1kpsdy.fsf@solo.david-steuber.com>
logan@cs.utexas.edu (Logan Shaw) writes:
' In article <t0cjufomhvo253@corp.supernews.com>,
' Dale Emmons <dale@emmons.dontspamme.com> wrote:
' >> In summary, Unix was TQM when TQM
' >> wasn't cool.
' >
' >Just curious... what does TQM mean? Total Quality Managment?
'
' Exactly. Unix has been dumping core since long before TQM became a
' buzzword, and of course mainframes were probably doing it before Unix.
'
' It's not exactly the same thing as TQM, but it's similar...
I thought it was what Microsoft calls "Just in time debugging", even
though it is a little late. Also, core files can be debugged at any
time until a cron job sweeps them away.
--
David Steuber | Perl apprentice. The axe did not stop the
NRA Member | mops and buckets from flooding my home.
ICQ# 91465842
*** http://www.david-steuber.com/ ***
------------------------------
Date: Mon, 06 Nov 2000 23:31:30 -0000
From: <nihad@yahoo.com>
Subject: Win32::Internet
Message-Id: <t0efqi20ap5e83@corp.supernews.com>
Hello all,
Which local port is being used by Win32::Internet when Fetching a URL,
and can that be controlled?
I know we could control the LocalPort with IO::Socket, however, we would
like to continue on using Win32::Internet if the local port can be
assigned.
Thanks in advance,
NH
--
Posted via CNET Help.com
http://www.help.com/
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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.
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 V9 Issue 4827
**************************************