[15650] in Perl-Users-Digest
Perl-Users Digest, Issue: 3063 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 16 14:10:49 2000
Date: Tue, 16 May 2000 11:10:23 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <958500623-v9-i3063@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 16 May 2000 Volume: 9 Number: 3063
Today's topics:
Re: deleting from a hash by reference... <aqumsieh@hyperchip.com>
Re: deleting from a hash by reference... jeff_stephens@my-deja.com
Re: deleting from a hash by reference... (Sean McAfee)
Re: deleting from a hash by reference... nobull@mail.com
Re: Directory - Security <rootbeer@redcat.com>
Form <duxbury@kentmere23.freeserve.co.uk>
Re: Form <gellyfish@gellyfish.com>
Re: Form nobull@mail.com
Re: Getting words between two strings <mcollins@oxford.net>
Re: Help with Perl/CGI scripts <rootbeer@redcat.com>
Re: How do I get a user's home directory with NIS+? <rootbeer@redcat.com>
Re: How to COPY a website nobull@mail.com
Re: How to replace "\" , HELP! <jeff@vpservices.com>
insert a link in a specific place in aweb page <wesleys@globeset.com>
Re: insert a link in a specific place in aweb page (Jerome O'Neil)
integer ops: mod, etc: WHERE? (David Combs)
Re: integer ops: mod, etc: WHERE? <peckert@epicrealm.com>
Re: integer ops: mod, etc: WHERE? <sweeheng@usa.net>
Re: integer ops: mod, etc: WHERE? <andkaha@my-deja.com>
Re: Is my Perl 5.005_03 Compiler broken? <rootbeer@redcat.com>
Re: MySQL Iteration <andy@u2me3.com>
Re: MySQL Iteration <billy@arnis-bsl.com>
neo: require doesn't work ninuzzo@my-deja.com
Re: neo: require doesn't work <tina@streetmail.com>
Re: neo: require doesn't work <andkaha@my-deja.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 16 May 2000 15:33:29 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: deleting from a hash by reference...
Message-Id: <7aaehqecir.fsf@Merlin.i-did-not-set--mail-host-address--so-shoot-me>
jeff_stephens@my-deja.com writes:
> I would like to do the following, but of course it doesn't work:
>
> $ref = \$main{$node}{$key}{$text};
> delete ( $ref );
>
> Essentially, I have a multi-level hash that I need to reference
> elsewhere in the program. I can get the value of the hash easily
> with the ref, but no matter what de-ref I try, I can't get it to
> delete the key from the hash. What can I do?
You can't do it that way (as you have noticed). The reason is that
delete() needs to know the hash to delete from, and the key to
delete. In your code, $ref is a reference to the scalar that happens to
be the value of $main{$node}{$key}{$text}. Using $ref, you can't get
back to find out the associated keys in %main.
One trick, which requires a bit of memory, is to keep a record of the
keys you used to get to your value:
$ref = [\$main{$node}{$key}{$text}, $node, $key, $text];
Then, you can delete them later:
delete $main{$ref->[1]}{$ref->[2]}{$ref->[3]};
I can't see any better way to do it.
--Ala
------------------------------
Date: Tue, 16 May 2000 15:40:53 GMT
From: jeff_stephens@my-deja.com
Subject: Re: deleting from a hash by reference...
Message-Id: <8frq61$c2l$1@nnrp1.deja.com>
I am quite aware on the use of delete. That is not my question.
I would like to have a simple scaler reference to the key, buried
somewhere in a multi-level hash, that I can use to delete the hash
entry.
As an example: I create a 4 level hash, with each key being 80 bytes.
I want to then save off, in an array, a ref to each 'leaf' node of this
hash. Later, I want to parse this array, deleting entries from the
hash via the ref. The ref is a simple scaler ref, whereas the 4 levels
of keys would be quite a bit larger to save off in an array.
What I've learned is when you take the ref to a hash, you actually get
the ref to the value, not the key. I need to know a way to get the
ref to point to the key, so delete thinks its a legit hash key to
delete.
Thanks
In article <8fro1o$i30$1@coco.singnet.com.sg>,
"Swee Heng" <sweeheng@usa.net> wrote:
> <jeff_stephens@my-deja.com> wrote in message
> news:8frlii$6c3$1@nnrp1.deja.com...
> > I can't seem to find an answer to this:
> >
> > I would like to do the following, but of course it doesn't work:
> >
> > $ref = \$main{$node}{$key}{$text};
> > delete ( $ref );
> >
> > Essentially, I have a multi-level hash that I need to reference
> > elsewhere in the program. I can get the value of the hash easily
> > with the ref, but no matter what de-ref I try, I can't get it to
> > delete the key from the hash. What can I do?
>
> The following script should illustrate how one uses delete():
>
> ==== BEGIN ====
> #!/usr/bin/perl -w
>
> # TADA! introducing the Data::Dumper module!
> use Data::Dumper;
> #$Data::Dumper::Indent = 1;
> #$Data::Dumper::Terse = 1;
>
> # set some values
> $node = 'a node';
> $key = 'a key';
> $text = 'some text';
> $text2 = 'more text';
> %main = ();
>
> # insert some values into the hash of hash of hash :-)
> $main{$node}{$key}{$text } = 'a value';
> $main{$node}{$key}{$text2} = 'another value';
>
> # displays result, deletes value, displays again
> print Dumper \%main;
> delete $main{$node}{$key}{$text};
> print Dumper \%main;
> ==== END ====
>
> Swee Heng
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 16 May 2000 16:02:23 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: deleting from a hash by reference...
Message-Id: <jieU4.1836$R12.36120@news.itd.umich.edu>
In article <7aaehqecir.fsf@Merlin.i-did-not-set--mail-host-address--so-shoot-me>,
Ala Qumsieh <aqumsieh@hyperchip.com> wrote:
>jeff_stephens@my-deja.com writes:
>> I would like to do the following, but of course it doesn't work:
>> $ref = \$main{$node}{$key}{$text};
>> delete ( $ref );
>> Essentially, I have a multi-level hash that I need to reference
>> elsewhere in the program. I can get the value of the hash easily
>> with the ref, but no matter what de-ref I try, I can't get it to
>> delete the key from the hash. What can I do?
>You can't do it that way (as you have noticed). The reason is that
>delete() needs to know the hash to delete from, and the key to
>delete. In your code, $ref is a reference to the scalar that happens to
>be the value of $main{$node}{$key}{$text}. Using $ref, you can't get
>back to find out the associated keys in %main.
>One trick, which requires a bit of memory, is to keep a record of the
>keys you used to get to your value:
> $ref = [\$main{$node}{$key}{$text}, $node, $key, $text];
>Then, you can delete them later:
> delete $main{$ref->[1]}{$ref->[2]}{$ref->[3]};
>I can't see any better way to do it.
I can think of a couple:
$ref = [ $main{$node}{$key}, $text ];
# ... later ...
delete $ref->[0]{$ref->[1]};
Or better yet, use a closure:
sub delete_later {
my ($hashref, $key) = @_;
sub { delete $hashref->{$key}; };
}
$ref = delete_later($main{$node}{$key}, $text);
# ... later ...
$ref->();
--
Sean McAfee mcafee@umich.edu
print eval eval eval eval eval eval eval eval eval eval eval eval eval eval
q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker ?:~|+=-*&^%$#@!
------------------------------
Date: 16 May 2000 17:55:05 +0100
From: nobull@mail.com
Subject: Re: deleting from a hash by reference...
Message-Id: <u9g0rifn9y.fsf@wcl-l.bham.ac.uk>
Ala Qumsieh <aqumsieh@hyperchip.com> writes:
> > I would like to do the following, but of course it doesn't work:
> >
> > $ref = \$main{$node}{$key}{$text};
> > delete ( $ref );
> You can't do it that way (as you have noticed). The reason is that
> delete() needs to know the hash to delete from, and the key to
> delete.
But you can do:
undef $$ref;
This is not the same but it is quite likely that it is sufficient for
your needs.
> One trick, which requires a bit of memory, is to keep a record of the
> keys you used to get to your value:
>
> $ref = [\$main{$node}{$key}{$text}, $node, $key, $text];
>
> Then, you can delete them later:
>
> delete $main{$ref->[1]}{$ref->[2]}{$ref->[3]};
Of course if $ref->[3] was the last subscript at that level it will
leave you with a dangling empty hash which is probably not what is
wanted if you are not happy to simply use undef() rather than delete()
in the first place.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 16 May 2000 08:59:39 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Directory - Security
Message-Id: <Pine.GSO.4.10.10005160819550.25459-100000@user2.teleport.com>
On Tue, 16 May 2000 sarbx@my-deja.com wrote:
> We have a feature in our web site which would allow our customers to
> create directories and files in specific area of the web server.
> Once a file has been uploaded a script can be called with the 'dirname'
> and 'filename' as parameters.
> The script opens the file like,
>
> open INPUT, $CUST_DIR/<dirname>/<filename>
Is this pseudo-code? It's not Perl. :-)
> and sends the output. The $CUST_DIR is set using a cookie from the
> browser which is set after a successful logon.
Oh, I hope you're checking that - it would be easy to forge a cookie
containing a directory name of the user's choosing.
> The problem now is how do I prevent anybody from passing something like
> <dirname> = ../../../../etc/
> <filename> = passwd
Ah, there's the problem. :-) I'd probably assemble the full directory and
file name, then split that into components. If any component is '..', I'd
complain. I'd also check that it's not a relative path, and that it starts
in the directory (or directories) of my choosing.
> Is there any other clean method to prevent this kind of access.
I use eval on a block, and then just die within the block if something
goes wrong. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 16 May 2000 16:31:42 +0100
From: "Ian" <duxbury@kentmere23.freeserve.co.uk>
Subject: Form
Message-Id: <8frppk$lgg$1@news6.svr.pol.co.uk>
This is another CGI script that I'm having trouble with, when it starts it
asks me for parameters and when I press ctrl^z the first thing diplayed is
Bad command or filename then the program is printed out.
I don't know what the sendmail variable is for (is it calling a Perl module
if so I can't find it in any library).
I have enclosed the HTML and Perl script.Ta.
Perl prog:-
#!c:\perl\bin\perl -w
# mail_form.cgi
# bundle up form output and mail it to the specified address
# This program is copyright 1999 by John Callender.
# This program is free and open software. You may use, copy, modify,
# distribute and sell this program (and any modified variants) in any way
# you wish, provided you do not restrict others from doing the same.
# configuration:
$sendmail = 'c:\perl\'; # where is sendmail?
$recipient = 'duxbuz@hotmail.com'; # who gets the form data?
$sender = 'Anonymous User <forms@lies.com>'; # default sender?
$site_name = 'my site'; # name of site to return to afterwards
$site_url = '//localhost/'; # URL of site to return to afterwards
# script proper begins...
use CGI;
$query = new CGI;
# bundle up form submissions into a mail_body
foreach $field (sort ($query->param)) {
foreach $value ($query->param($field)) {
$mail_body .= "$field: $value\n";
}
}
# set an appropriate From: address
if (($email = $query->param('07_email')) and
($query->param('07_email') =~ /@/)) {
# the user supplied something that looks like
# an email address
if ($name = $query->param('01_name')) {
# the user supplied a name
$name =~ s/"//g; # lose any double-quotes in name
$sender = "\"$name\" <$email>";
} else {
# user did not supply a name
$sender = "$email";
}
}
# send the email message
open(MAIL, "|$sendmail -oi -t") or die "Can't open pipe to $sendmail: $!\n";
print MAIL "To: $recipient\n";
print MAIL "From: $sender\n";
print MAIL "Subject: Sample Web Form Submission\n\n";
print MAIL "$mail_body";
close(MAIL) or die "Can't close pipe to $sendmail: $!\n";
# now show the thank-you screen
print "Content-type: text/html\n\n";
print <<"EOF";
<HTML>
<HEAD>
<TITLE>Thank you</TITLE>
</HEAD>
<BODY>
<H1>Thank you</H1>
<P>Thank you for your form submission. You will be hearing
from me shortly.</P>
<P>Return to
<A HREF="$site_url">$site_name</A>.</P>
</BODY>
</HTML>
EOF
===========================
HTML code:-
<HTML>
<HEAD>
<TITLE>Sample Form</TITLE>
</HEAD>
<BODY>
<H1>Sample Form</H1>
<P>Please fill out this form and submit it. Thank you.</P>
<FORM ACTION="c:\progra~1\apache~1\apache\cgi-bin\mail_f~1.pl"
METHOD="POST">
<TABLE>
<TR>
<TD ALIGN="right"><STRONG>My name:</STRONG></TD>
<TD><INPUT NAME="01_name" SIZE=30></TD>
</TR>
<TR>
<TD ALIGN="right"><STRONG>Address:</STRONG></TD>
<TD><INPUT NAME="02_address" SIZE=30></TD>
</TR>
<TR>
<TD ALIGN="right"><STRONG>City:</STRONG></TD>
<TD><INPUT NAME="03_city" SIZE=30></TD>
</TR>
<TR>
<TD ALIGN="right"><STRONG>State:</STRONG></TD>
<TD><INPUT NAME="04_state" SIZE=2></TD>
</TR>
<TR>
<TD ALIGN="right"><STRONG>Zip:</STRONG></TD>
<TD><INPUT NAME="05_zip" SIZE=10></TD>
</TR>
<TR>
<TD ALIGN="right"><STRONG>Country:</STRONG></TD>
<TD><INPUT NAME="06_country" SIZE=10 VALUE="USA"></TD>
</TR>
<TR>
<TD ALIGN="right"><STRONG>My email:</STRONG></TD>
<TD><INPUT NAME="07_email" SIZE=30></TD>
</TR>
<TR>
<TD ALIGN="right"><STRONG>My favorite color:
</STRONG></TD>
<TD>
<TABLE BGCOLOR="#CCCCFF" BORDER><TR><TD>
<TABLE>
<TR>
<TD><INPUT NAME="08_color" TYPE="radio" VALUE="red">
</TD>
<TD>Red</TD>
</TR>
<TR>
<TD><INPUT NAME="08_color" TYPE="radio" VALUE="green">
</TD>
<TD>Green</TD>
</TR>
<TR>
<TD><INPUT NAME="08_color" TYPE="radio" VALUE="blue">
</TD>
<TD>Blue</TD>
</TR>
</TABLE>
</TD></TR></TABLE>
</TD>
</TR>
<TR>
<TD ALIGN="right"><STRONG>Movies I liked:</STRONG>
</TD>
<TD>
<TABLE BGCOLOR="#CCCCFF" BORDER><TR><TD>
<TABLE>
<TR>
<TD><INPUT NAME="09_movies" TYPE="checkbox"
VALUE="Blade Runner"></TD>
<TD><EM>Blade Runner</EM></TD>
</TR>
<TR>
<TD><INPUT NAME="09_movies" TYPE="checkbox"
VALUE="Pulp Fiction"></TD>
<TD><EM>Pulp Fiction</EM></TD>
</TR>
<TR>
<TD><INPUT NAME="09_movies" TYPE="checkbox"
VALUE="Full Metal Jacket"></TD>
<TD><EM>Full Metal Jacket</EM></TD>
</TR>
</TABLE>
</TD></TR></TABLE>
</TD>
</TR>
<TR>
<TD ALIGN="right"><STRONG>When I grow up I want
to be a(n):</STRONG></TD>
<TD>
<SELECT NAME="10_grow_up">
<OPTION>Astronaut
<OPTION>Fireman
<OPTION>CGI programmer
</SELECT>
</TD>
</TR>
<TR>
<TD ALIGN="right"><STRONG>My opinion on cucumber
sandwiches is:</STRONG></TD>
<TD>
<TEXTAREA NAME="11_sandwiches" ROWS=5 COLS=20 WRAP="virtual">
</TEXTAREA>
</TD>
</TR>
<TR><TD COLSPAN=2> </TD></TR>
<TR>
<TD> </TD>
<TD><INPUT TYPE="submit"> <INPUT TYPE="reset">
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
------------------------------
Date: Tue, 16 May 2000 16:18:21 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Form
Message-Id: <hxeU4.1522$Kc1.206703@news.dircon.co.uk>
On Tue, 16 May 2000 16:31:42 +0100, Ian Wrote:
>
> This is another CGI script that I'm having trouble with, when it starts it
> asks me for parameters and when I press ctrl^z the first thing diplayed is
> Bad command or filename then the program is printed out.
> I don't know what the sendmail variable is for
>
<snip>
> $sendmail = 'c:\perl\'; # where is sendmail?
>
<snip>
> open(MAIL, "|$sendmail -oi -t") or die "Can't open pipe to $sendmail: $!\n";
The $sendmail variable should contain the full path to a 'sendmail' type
mail program. You are unlikely to have one of those on windows. You
will need to read the appropriate part of perlfaq9 entitled :
How do I send mail?
and then amend your program accordingly.
/j\
------------------------------
Date: 16 May 2000 17:53:12 +0100
From: nobull@mail.com
Subject: Re: Form
Message-Id: <u9k8gufnd3.fsf@wcl-l.bham.ac.uk>
"Ian" <duxbury@kentmere23.freeserve.co.uk> writes:
> Subject: Form
Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.
http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post
> Bad command or filename then the program is printed out.
> I don't know what the sendmail variable is for
So look at the ****ing code!
> $sendmail = 'c:\perl\'; # where is sendmail?
> open(MAIL, "|$sendmail -oi -t") or die "Can't open pipe to $sendmail: $!\n";
So $sendmail is expected to be the full name of the sendmail
executable that is installed on your computer.
If you do not have sendmail then don't try to use it - use Net::SMTP
either directly or via some wrapper such as Mail::Mailer.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 16 May 2000 11:59:04 -0400
From: Matt Collins <mcollins@oxford.net>
Subject: Re: Getting words between two strings
Message-Id: <39217047.A122C2FE@oxford.net>
Thanks for the help everyone
------------------------------
Date: Tue, 16 May 2000 09:16:07 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Help with Perl/CGI scripts
Message-Id: <Pine.GSO.4.10.10005160915171.25459-100000@user2.teleport.com>
On Tue, 16 May 2000 jake_spoon54@my-deja.com wrote:
> I am new to PERL/CGI, wondering where I can find a good resource for
> guestbook and registration form.
If you're wishing merely to _find_ (as opposed to write) programs, this
newsgroup may not be the best resource for you. There are many freeware
and shareware archives which you can find by searching Yahoo or a similar
service.
> this page uses a form processor not real CGI. Any advice?
Check with a newsgroup about CGI programming, such as
comp.infosystems.www.authoring.cgi. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 16 May 2000 09:13:54 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: How do I get a user's home directory with NIS+?
Message-Id: <Pine.GSO.4.10.10005160910170.25459-100000@user2.teleport.com>
On Tue, 16 May 2000, Scott Houck wrote:
> >Of course you can use getpwent().
> Not with NIS+.
No? I think it should work, if Perl (and the system libraries) are
properly installed. But maybe I'm mistaken about NIS+. (Still, I'd use
getpwuid, I think.)
> But $ENV{HOME} is just fine!
Maybe, if it's set properly. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 16 May 2000 18:13:28 +0100
From: nobull@mail.com
Subject: Re: How to COPY a website
Message-Id: <u966sefmfb.fsf@wcl-l.bham.ac.uk>
WTF does this have to do with comp.infosystems.www.authoring.html
"J. C." <root@127.0.0.1> writes:
> In article <GiBzydAHTVI5Ewu9@prestwich-smile-gemach.freeserve.co.uk>,
> Alan Silver
> <alan-silver@prestwich-smile-gemach.freeserve.furryferret.co.uk> wrote:
>
> : Have you thought about the legal implications of this ? Unless the site
> : author gives explicit permission for you to copy the site (or any part
> : of it), then it's illegal to copy it.
>
> I think the guy just wants to download it for perusal "offline."
Then a web-cache with a preload facility is probably a better solution.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 16 May 2000 10:06:33 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: How to replace "\" , HELP!
Message-Id: <39218019.B54F43DF@vpservices.com>
"LinkWorm Software, Inc." wrote:
> > > Further, the file name won't contain a back
> > > slashes anyway, Windows won't allow it.
> >
> > Say what???????
>
> Okay, let me make this clear, you can't name a file
> "afile\name.whatevwer". Windows won't allow you to have a "\" in the
> file _name_.
Sorry, I don't mean to belabor the point but only your first sentence
there is true. It *is* true that you can not include a single backslash
inside double quotes and expect it to be treated as a file-path
spearator. However if you change the double quotes to single quotes, or
change the single backslash to a double backslash those both work just
fine. The problem isn't that windows won't allow a backslash, it's
that, in Perl one can only produce a backslash by having a single
backslash inside single quotes or a double backslash inside double
quotes. (Ok, Larry R. yes, if one really wanted to put double
backslashes inside single quotes, that would work too :-)). It's also
true that for *most* cases it is possible to use a forward slash to
replace a backslash. The OP's example of a form that feeds the file
path along with the file is one of the few places where that isn't true.
--
Jeff
------------------------------
Date: Mon, 15 May 2000 16:02:14 -0500
From: "Wes" <wesleys@globeset.com>
Subject: insert a link in a specific place in aweb page
Message-Id: <8fpp56$5bb$2@onion.globeset.com>
Any idea how to do this? What i need to do is insert a link after or before
another link.
Thanks
------------------------------
Date: Tue, 16 May 2000 17:41:50 GMT
From: jerome@activeindexing.com (Jerome O'Neil)
Subject: Re: insert a link in a specific place in aweb page
Message-Id: <yLfU4.240$Wh6.16302@news.uswest.net>
In article <8fpp56$5bb$2@onion.globeset.com>,
"Wes" <wesleys@globeset.com> writes:
> Any idea how to do this? What i need to do is insert a link after or before
> another link.
Whats a link?
------------------------------
Date: 16 May 2000 15:14:10 GMT
From: dkcombs@netcom.com (David Combs)
Subject: integer ops: mod, etc: WHERE?
Message-Id: <8frok2$9r$1@slb1.atl.mindspring.net>
I've grepped the pods (GTFM), including the faqs,
looked in the index of PP and CB -- no "mod" at all,
and the only refs to integer that aren't totally
irrevelant are for "use integer".
Yeah, I did find LOTs of mods in ONE file: op.c!
These things are pretty important when trying to
group things for histograms or hash-buckets; every
OTHER programming language has them, perl must too.
WHERE?
(of course, I've probably grepped for the wrong
string, but "mod" is a fairly standard term!)
(Oh, I searched in "word mode" -- without that
there'd be 10,000 hits for module, etc)
Thanks!
David
------------------------------
Date: Tue, 16 May 2000 15:29:17 GMT
From: Paul Eckert <peckert@epicrealm.com>
Subject: Re: integer ops: mod, etc: WHERE?
Message-Id: <39216832.1409C13F@epicrealm.com>
> These things are pretty important when trying to
> group things for histograms or hash-buckets; every
> OTHER programming language has them, perl must too.
Dear David:
% is the modulus operator $a % $b is the remainder after $a is divided by $b.
perldoc perlop
gives more info on arithmetic operators.
Paul
David Combs wrote:
>
> I've grepped the pods (GTFM), including the faqs,
> looked in the index of PP and CB -- no "mod" at all,
> and the only refs to integer that aren't totally
> irrevelant are for "use integer".
>
> Yeah, I did find LOTs of mods in ONE file: op.c!
>
>
> WHERE?
>
> (of course, I've probably grepped for the wrong
> string, but "mod" is a fairly standard term!)
>
> (Oh, I searched in "word mode" -- without that
> there'd be 10,000 hits for module, etc)
>
> Thanks!
>
> David
--
Paul Eckert
Sr. Software Engineer
Epicrealm Inc.
1651 N. Glenville Dr., Suite 212
Richardson, TX 75081
(972) 479-0135 x300
peckert@epicrealm.com
------------------------------
Date: Tue, 16 May 2000 23:49:19 +0800
From: "Swee Heng" <sweeheng@usa.net>
Subject: Re: integer ops: mod, etc: WHERE?
Message-Id: <8frq0k$h84$1@coco.singnet.com.sg>
David Combs <dkcombs@netcom.com> wrote in message
news:8frok2$9r$1@slb1.atl.mindspring.net...
> I've grepped the pods (GTFM), including the faqs,
> looked in the index of PP and CB -- no "mod" at all,
> and the only refs to integer that aren't totally
> irrevelant are for "use integer".
>
> Yeah, I did find LOTs of mods in ONE file: op.c!
>
> These things are pretty important when trying to
> group things for histograms or hash-buckets; every
> OTHER programming language has them, perl must too.
>
> WHERE?
hush hush... not so loud please. :) do you mean the (integer) modulus
operator that is prevalent in other programming language like C, for
instance? if so, try "print 5432 % 5". it should give you '2'.
incidentally, i believe % is used in C as the modulus operator too. was
'mod' use in Pascal? i cannot remember...
swee heng
------------------------------
Date: Tue, 16 May 2000 15:54:13 GMT
From: Andreas Kahari <andkaha@my-deja.com>
Subject: Re: integer ops: mod, etc: WHERE?
Message-Id: <8frqus$cr1$1@nnrp1.deja.com>
In article <8frok2$9r$1@slb1.atl.mindspring.net>,
dkcombs@netcom.com (David Combs) wrote:
> I've grepped the pods (GTFM), including the faqs,
> looked in the index of PP and CB -- no "mod" at all,
> and the only refs to integer that aren't totally
> irrevelant are for "use integer".
>
> Yeah, I did find LOTs of mods in ONE file: op.c!
>
> These things are pretty important when trying to
> group things for histograms or hash-buckets; every
> OTHER programming language has them, perl must too.
>
> WHERE?
>
> (of course, I've probably grepped for the wrong
> string, but "mod" is a fairly standard term!)
>
> (Oh, I searched in "word mode" -- without that
> there'd be 10,000 hits for module, etc)
>
> Thanks!
>
> David
>
>
You mean "modulo", as in
if ($i % 2) { print "$i is even\n" }
Use '%' as in C and C++, see the perlop manual.
/A
--
# Andreas Kähäri, <URL:http://hello.to/andkaha/>.
# All junk email is reported to the appropriate authorities.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 16 May 2000 09:06:39 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Is my Perl 5.005_03 Compiler broken?
Message-Id: <Pine.GSO.4.10.10005160902410.25459-100000@user2.teleport.com>
On Tue, 16 May 2000, it was written:
> I had a bug in my code:
>
> if defined ($s{$_})
> {print "<tr><td><input type=checkbox name=$_ checked>$sta{id}</td>".
> "<td>$sta{name}</td></tr>"}
>
> where I'd left the ()'s from around the
>
> if (expression).
>
>
> *********************************************************
> perl -cw mysource
>
> said no problem- syntax OK (huh???)
Just because the syntax is okay, that doesn't mean that it's the syntax is
doing what you want. Just like in any language, computer or otherwise. The
syntax may be correct, but the result may not be correctly glorked.
I'd guess that the if looked like it was modifying something previous -
which had a missing semicolon, perhaps?
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 16 May 2000 16:42:14 +0100
From: "Andy Chantrill" <andy@u2me3.com>
Subject: Re: MySQL Iteration
Message-Id: <8frq93$agj$1@gxsn.com>
Yeah, I just wondered if fetch() was the most efficient way of doing it or
not ...
------------------------------
Date: Tue, 16 May 2000 16:43:08 GMT
From: Ilja <billy@arnis-bsl.com>
Subject: Re: MySQL Iteration
Message-Id: <8frtqo$gd3$1@nnrp1.deja.com>
In article <8frq93$agj$1@gxsn.com>,
"Andy Chantrill" <andy@u2me3.com> wrote:
> Yeah, I just wondered if fetch() was the most efficient way of doing
it or
> not ...
>
From DBI perldoc/man page:
#
#fetchrow_arrayref
#
# $ary_ref = $sth->fetchrow_arrayref;
# $ary_ref = $sth->fetch; # alias
#
# Fetches the next row of data and returns a reference
# to an array holding the field values. Null field
# values are returned as undef. This is the fastest way
# to fetch data, particularly if used with
# $sth->bind_columns.
#
Good luck.
Ilja.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 16 May 2000 15:39:46 GMT
From: ninuzzo@my-deja.com
Subject: neo: require doesn't work
Message-Id: <8frq3u$c0p$1@nnrp1.deja.com>
I have a subroutine read_input to parse out CGI query strings.
This returns an associative array which contains the pairs (name,value).
It is fine, but every time i have to paste its code into the script.
To avoid this i decided to put read_input in a separate file
(read_input.pl), and i added this line in a script:
require 'read_input.pl';
but it doesn't work, i get this error:
read-input.pl did not return a true value at ./test.pl line 3.
thanx, Ninuzzo
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 16 May 2000 12:00:15 -0400
From: Tina Mueller <tina@streetmail.com>
Subject: Re: neo: require doesn't work
Message-Id: <3921708F.21888337@streetmail.com>
hi,
ninuzzo@my-deja.com wrote:
> To avoid this i decided to put read_input in a separate file
> (read_input.pl), and i added this line in a script:
>
> require 'read_input.pl';
>
> but it doesn't work, i get this error:
>
> read-input.pl did not return a true value at ./test.pl line 3.
yeah, I'd guess the module doesnt't return a true vale; that's what
perl is trying to say :-)
just put something like
1;
at the end of the module (and you are using read_input.pl as a module).
but you should think about using CGI.pm, then you wouldn't have
this problem...
tina
-- tinamue@gmx.net --| _ enter the
http://user.berlin.de/~tina.mueller | __| |___ ___ _ _ ___
---- tina's moviedatabase ----| / _` / _ \/ _ \ '_(_-< of
--search & add comments or reviews--| \__,_\___/\___/_| /__/ perception
------------------------------
Date: Tue, 16 May 2000 15:51:40 GMT
From: Andreas Kahari <andkaha@my-deja.com>
Subject: Re: neo: require doesn't work
Message-Id: <8frqq4$cp5$1@nnrp1.deja.com>
In article <8frq3u$c0p$1@nnrp1.deja.com>,
ninuzzo@my-deja.com wrote:
> I have a subroutine read_input to parse out CGI query strings.
> This returns an associative array which contains the pairs
(name,value).
> It is fine, but every time i have to paste its code into the script.
>
> To avoid this i decided to put read_input in a separate file
> (read_input.pl), and i added this line in a script:
>
> require 'read_input.pl';
>
> but it doesn't work, i get this error:
>
> read-input.pl did not return a true value at ./test.pl line 3.
>
> thanx, Ninuzzo
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Add
1;
in the end of the file, otherwise the 'require' will fail.
/A
--
# Andreas Kähäri, <URL:http://hello.to/andkaha/>.
# All junk email is reported to the appropriate authorities.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
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 3063
**************************************