[8605] in Perl-Users-Digest
Perl-Users Digest, Issue: 2222 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 1 05:07:27 1998
Date: Wed, 1 Apr 98 02:00:31 -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 Wed, 1 Apr 1998 Volume: 8 Number: 2222
Today's topics:
Re: 'Search and Replace' for multiple files <rjk@coos.dartmouth.edu>
ANNOUNCE: "Bit::Vector" 5.2 (Steffen Beyer)
Can I get bulk data? (ddiddung@nuri.net)
Re: CGI-Calling a Perl script within a Perl script <fr39@dial.pipex.com>
Re: cgi: works form cmd line only <ebohlman@netcom.com>
Re: Date manipulations? (Steffen Beyer)
Re: file permissions <fr39@dial.pipex.com>
Re: file trees (Steffen Beyer)
Re: Identifying how a perl program was called <fr39@dial.pipex.com>
Re: Is there a "Newsgroup" for Newbies to Perl? (Craig Berry)
Re: Is there a "Newsgroup" for Newbies to Perl? <merlyn@stonehenge.com>
Re: need regexp help <rjk@coos.dartmouth.edu>
Re: Odd or even function (Craig Berry)
Re: Odd or even function (Steffen Beyer)
Re: Relative address problem (Kirrily 'Skud' Robert)
sending mail using perl <abp@holly.colostate.edu>
Re: Someone put my munged e-mail address on a spam list (Bart Lateur)
Re: Sorting a Delimeted Text File? <ebohlman@netcom.com>
Re: Sysadmin struggeling with PERL/Sed and etc... <rjk@coos.dartmouth.edu>
Re: Why this one doesn't work ? <jr@scms.rgu.ac.uk>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 01 Apr 1998 02:36:22 -0500
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: 'Search and Replace' for multiple files
Message-Id: <3521EE7B.AA7A1B9E@coos.dartmouth.edu>
Jon Drukman wrote:
>
> Stephanie Ray <sray@netnuevo.com> wrote:
> > Cat worked wonderfully! I always did like cats :-)
>
> > A couple of things- I had to be careful to use backquotes, and not
> > single (forward quotes) and to double quote the search & replace string
> > as well as use a semicolon:
>
> > perl -p -i -e "s/search-for/replace-with/;" `cat test.txt`
>
> read the perlrun manpage. you can get rid of the cat if you eliminate
> the -i option (which says to edit the file in-place). if you just
> want to print a file with your edits, do this:
>
> perl -p -e 's/search-for/replace-with/' test.txt
You seem to be missing the point. The cat is necessary, because test.txt
contains a list of filenames to be edited.
Thus, if test.txt contains
foo.html
bar.txt
baz.c
perl -p -i -e "s/search-for/replace-with/;" `cat test.txt`
is equivalent to
perl -p -i -e "s/search-for/replace-with/;" foo.html bar.txt baz.c
Whereas your suggestion would perform the substitution on the listed filenames themselves.
Obviously, the -i was also used intentionally.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J. Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 31 Mar 1998 22:42:46 GMT
From: sb@engelschall.com (Steffen Beyer)
Subject: ANNOUNCE: "Bit::Vector" 5.2
Message-Id: <6frrh6$5fd$2@en1.engelschall.com>
I am glad to announce version 5.2 of the "Bit::Vector" module:
=====================================
Package "Bit::Vector" Version 5.2
=====================================
The package is available for download either from my web site at
http://www.engelschall.com/u/sb/download/
or from any CPAN (= "Comprehensive Perl Archive Network") mirror server:
(allow a few days for propagation if necessary)
http://www.perl.com/CPAN/authors/id/STBEY/
The package consists of a C library (designed for maximum efficiency)
which is the core of a Perl module (designed for maximum ease of use).
The C library is specifically designed so that it can be used stand-alone,
without Perl.
What does it do:
----------------
This module is useful for a large range of different tasks:
- For example for implementing sets and performing set operations
(like union, difference, intersection, complement, check for subset
relationship etc.),
- as a basis for many efficient algorithms, for instance the
"Sieve of Erathostenes" (for calculating prime numbers),
(The complexities of the methods in this module are usually either
O(1) or O(n/b), where "b" is the number of bits in a machine word
on your system.)
- for shift registers of arbitrary length (for example for cyclic
redundancy checksums),
- to calculate "look-ahead", "first" and "follow" character sets
for parsers and compiler-compilers,
- for graph algorithms,
- for efficient storage and retrieval of status information,
- for performing text synthesis ruled by boolean expressions,
- for "big integer" arithmetic with arbitrarily large integers,
- for manipulations of chunks of bits of arbitrary size,
- for bitwise processing of audio CD wave files,
- to convert formats of data files,
and more.
(A number of example applications is available from my web site at
http://www.engelschall.com/u/sb/download/.)
A large number of import/export methods allow you to access individual
bits, contiguous ranges of bits, machine words, arbitrary chunks of
bits, lists (arrays) of chunks of bits or machine words and a whole
bit vector at once (for instance for blockwrite/-read to and from
a file).
You can also import and export the contents of a bit vector in binary,
hexadecimal and decimal representation as well as ".newsrc" style
enumerations.
Note that this module is specifically designed for efficiency, which is
also the reason why its methods are implemented in C.
To further increase execution speed, the module doesn't use bytes as its
basic storage unit, but rather uses machine words, assuming that a machine
word is the most efficiently handled size of all scalar types on all
machines (that's what the ANSI C standard proposes and assumes anyway).
In order to achieve this, it automatically determines the number of bits
in a machine word on your system and then adjusts its internal configuration
constants accordingly.
The greater the size of this basic storage unit, the better the complexity
(= execution speed) of the methods in this module, but also the greater the
average waste of unused bits in the last word.
The range of available methods is exceptionally large for this kind of library;
in detail:
Version() Word_Bits() Long_Bits()
new() new_Hex() new_Bin()
new_Dec() new_Enum() Shadow()
Clone() Concat() Concat_List()
Size() Resize() Copy()
Empty() Fill() Flip()
Primes() Reverse() Interval_Empty()
Interval_Fill() Interval_Flip() Interval_Reverse()
Interval_Scan_inc() Interval_Scan_dec() Interval_Copy()
Interval_Substitute() is_empty() is_full()
equal() Lexicompare() Compare()
to_Hex() from_Hex() to_Bin()
from_Bin() to_Dec() from_Dec()
to_Enum() from_Enum() Bit_Off()
Bit_On() bit_flip() bit_test()
Bit_Copy() LSB() MSB()
lsb() msb() rotate_left()
rotate_right() shift_left() shift_right()
Move_Left() Move_Right() Insert()
Delete() increment() decrement()
add() subtract() Negate()
Absolute() Sign() Multiply()
Divide() GCD() Block_Store()
Block_Read() Word_Size() Word_Store()
Word_Read() Word_List_Store() Word_List_Read()
Word_Insert() Word_Delete() Chunk_Store()
Chunk_Read() Chunk_List_Store() Chunk_List_Read()
Index_List_Remove() Index_List_Store() Index_List_Read()
Union() Intersection() Difference()
ExclusiveOr() Complement() subset()
Norm() Min() Max()
Multiplication() Closure() Transpose()
Important note:
---------------
Note again that the C library at the core of this module ("BitVector.c")
can also be used stand-alone (i.e., without Perl).
To do so, simply link the output file "BitVector.o" (which is produced
when you build this module or when you just compile "BitVector.c") with
your application.
Example applications:
---------------------
See the module "Set::IntRange" for an easy-to-use module for sets
of integers of arbitrary ranges.
See the module "Math::MatrixBool" for an efficient implementation
of boolean matrices and boolean matrix operations.
(Both modules are also available from my web site or any CPAN server.)
An application relying crucially on this "Bit::Vector" module is "Slice",
a tool for generating different document versions out of a single
master file, ruled by boolean expressions ("include english version
of text plus examples but not ...").
(See also http://www.engelschall.com/sw/slice/.)
This tool is itself part of another tool, "Website META Language" ("WML"),
which allows you to generate and maintain large web sites.
Among many other features, it allows you to define your own HTML tags which
will be expanded either at generation or at run time, depending on your
choice.
(See also http://www.engelschall.com/sw/wml/.)
Both tools are written by Ralf S. Engelschall.
Changes in version 5.2:
-----------------------
In version 5.2, the method "Norm()" has been improved and should now be
faster by a factor varying between about 1.13 and 9.09, depending on the
number of set bits (using a method suggested and according to benchmarks
done by Krzysztof Koczyjan <krzysztofk@rocketmail.com>).
Moreover, the implementation of the overloaded operators "<<" and ">>"
has been changed so that they should also be more performant now, on
average (the former implementation was faster under certain circumstances
but not on average).
And finally, four new methods have been added: "new_Hex()", "new_Bin()",
"new_Dec()" and "new_Enum()", which allow you to create a new bit vector
and to initialize it in a single statement.
Changes in version 5.1:
-----------------------
In version 5.1, systematic exception handling was added to "Vector.pm" so that
error conditions arising from method calls in overloaded operators do not show
error messages anymore pointing to the location in "Vector.pm" where the method
was called, but rather to the location in your application program where the
overloaded operator was used.
New features in version 5.0:
----------------------------
In version 5.0, the following new methods have been added:
- Word_Bits()
- Long_Bits()
- Concat()
- Concat_List()
- Primes()
- Reverse()
- Interval_Reverse()
- Interval_Copy()
- Interval_Substitute()
- Lexicompare()
- to_Bin()
- from_bin()
- to_Dec()
- from_dec()
- Insert()
- Delete()
- add()
- subtract()
- Negate()
- Absolute()
- Sign()
- Multiply()
- Divide()
- GCD()
- Block_Store()
- Block_Read()
- Word_Size()
- Word_Store()
- Word_Read()
- Word_List_Store()
- Word_List_Read()
- Word_Insert()
- Word_Delete()
- Chunk_Store()
- Chunk_Read()
- Chunk_List_Store()
- Chunk_List_Read()
- Index_List_Remove()
- Index_List_Store()
- Index_List_Read()
- Transpose()
Please see the "Bit::Vector" man page (after installing this module)
for more details about these new methods.
The following methods have been re-implemented in C (instead of Perl):
- Version()
- Shadow()
- Clone()
- to_Enum() (previously named "to_ASCII")
- from_enum() (previously named "from_ASCII")
The following method has changed its behaviour:
- Compare() (now assumes that bit vectors are SIGNED)
The following methods have been renamed:
- to_String() --> to_Hex()
- from_string() --> from_hex()
- to_ASCII() --> to_Enum()
- from_ASCII() --> from_enum()
(Aliases for the old names are still available but deprecated!)
And finally, the following methods are gone:
- lexorder()
- new_from_String()
A tool is available in the module's distribution to upgrade your existing
applications and to provide substitutes for the two methods that are gone.
Legal issues:
-------------
This package with all its parts is
Copyright (c) 1995, 1996, 1997, 1998 by Steffen Beyer.
All rights reserved.
This package is free software; you can redistribute it and/or
modify it under the same terms as Perl itself, i.e., under the
terms of the "Artistic License" or the "GNU General Public License".
The C library at the core of this Perl module can additionally
be redistributed and/or modified under the terms of the "GNU
Library General Public License".
Please refer to the files "Artistic", "GNU_GPL" and "GNU_LGPL"
in the package's distribution for details!
Prerequisites:
--------------
Perl version 5.000 or higher, and an ANSI C compiler (!)
======
Author's note:
--------------
If you have any questions, suggestions or need any assistance, please
let me know!
Also, if there is anything you would like to do with this module which
the module doesn't allow yet, please let me know! If it fits the module's
overall concept, I'll implement it as soon as possible. Frequently this is
only a matter of a few days.
I hope you will find this module beneficial!
Yours,
--
Steffen Beyer <sb@engelschall.com> http://www.engelschall.com/u/sb/
"There is enough for the need of everyone in this world,
but not for the greed of everyone." - Mahatma Gandhi
------------------------------
Date: Wed, 01 Apr 1998 15:58:45 +0900
From: "Sangjin Joung(ddiddung@nuri.net)" <ddiddung@nuri.net>
Subject: Can I get bulk data?
Message-Id: <3521E5A5.359E179E@nuri.net>
Hi all.
I have used Perl and Oracle in CGI program.
But I haven't known and not Know how to get Oracle bulk data
in Perl.
I have gotten multirows with 'while' statement but it takes much time...
so I think if I could get many rows at a time, I can save time.
How can I get Oracle multi row data in "Perl"...?
Jin.
------------------------------
Date: 1 Apr 1998 09:52:49 GMT
From: "Miss WILKINS" <fr39@dial.pipex.com>
Subject: Re: CGI-Calling a Perl script within a Perl script
Message-Id: <01bd5d53$d8295ca0$73f482c1@lonriu3>
Hi
what I would do, is take the second program, and incorporate it into the
first, isn't that what perl's all about, finding a way around a brick wall,
rather than climbing it. :-)
Maybe combine it as a subroutine or something
Iqbal
James Watson <james_vs_watson@yahoo.com> wrote in article
<35226f91.39770123@news.erols.com>...
> I have posted a similar message on comp.infosystems.www.authoring.cgi,
> but have not gotten a reply yet and I was hoping someone here might be
> able to help me.
> I have a Perl script that is inputted a filename that can be
> downloaded from the Internet. I then call another Perl script to
> download this file and save it on the local hard drive. My other Perl
> script should then continue and change the file.
> But when I call the other Perl script, nothing changes, yet I can use
> this second Perl script by calling it from the shell. Is there an
> aspect about Perl that I am missing.
> Any help would be most appreciated.
> Thanks
> - James Watson
>
------------------------------
Date: Wed, 1 Apr 1998 09:00:40 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: cgi: works form cmd line only
Message-Id: <ebohlmanEqq914.JKB@netcom.com>
Mike Collins <mike@w3z.com> wrote:
: system(`perl /export/httpd/cgi-bin/id.pl`);
Are you sure you're really trying to do what this really does? You're
executing id.pl, gathering up its output, treating the output as the name
and arguments of an executable program, and trying to execute that
program. I suspect what you really want to do is just execute id.pl and
have its output sent out via the Web server; if so, replace the backticks
with single quotes.
------------------------------
Date: 31 Mar 1998 12:28:39 GMT
From: sb@engelschall.com (Steffen Beyer)
Subject: Re: Date manipulations?
Message-Id: <6fqnhn$aaq$1@en1.engelschall.com>
Tom Mornini <tmornini@netcom.com> wrote:
> Burt Lewis (burt@ici.net) wrote:
> : I need to determine 2 dates based on today's date.
> Try Date::Manip on CPAN. Don't know if it'll do it directly,
> but from what I've read, if it can't do it, it can't be done. :-)
Not by you, sure! ;-)
See also Date::DateCalc on CPAN or from
http://www.engelschall.com/u/sb/download/
Then proceed as follows (example):
-------------------- cut here -------------------- cut here --------------------
#!/sw/bin/perl
use Date::DateCalc qw(:all);
use Date::DateCalcLib qw(parse_date);
@today = parse_date(`/bin/date`); # there are actually more portable ways
# using localtime(time) - see man perlfunc
$dow = day_of_week(@today);
if ($dow == 6) # 1 = Monday, ... , 6 = Saturday, 7 = Sunday
{
$prev = -7;
$next = 7;
}
else
{
if ($dow > 6)
{
$prev = 6 - $dow;
}
else
{
$prev = -$dow - 1;
}
$next = $prev + 7;
}
@prev_saturday = calc_new_date(@today, $prev);
@next_saturday = calc_new_date(@today, $next);
print "Today is: ", date_to_short(@today), "\n";
print "Last saturday was: ", date_to_short(@prev_saturday), "\n";
print "Next saturday will be: ", date_to_short(@next_saturday), "\n";
-------------------- cut here -------------------- cut here --------------------
Hope this helps.
Yours,
--
Steffen Beyer <sb@engelschall.com>
Feel free to visit my download area with free software at
http://www.engelschall.com/u/sb/download/
------------------------------
Date: 1 Apr 1998 09:45:45 GMT
From: "Miss WILKINS" <fr39@dial.pipex.com>
Subject: Re: file permissions
Message-Id: <01bd5d52$dbb02ee0$73f482c1@lonriu3>
Hi
The cgi will run as the owner of the web server unless they have set SUID
or have individual V.servers running under different UID/GID.
Basically to make sure that all is set as you wish I would do a chown (no
need for the exec I think) on the directory and file, as long as you have
pemission to do that.
Iqbal
emai iqbal@etc.prestel.co.uk
Michael Wentzel <wentzel@umr.edu> wrote in article
<352165e7.0@news.cc.umr.edu>...
> I have a script that is being run with a POST method from a HTML document
> that will create a directory, on server side, if it does not exist then
> will create a file in this directory(this is to allow files that should
> be grouped together to reside in the same directory). The problem is
> that the newly created directory has a owner id of 32766 and not the
> owner of the directory above, therefore when it tries to create a file in
> the newly create dir the script fails. Any suggestions... The only thing
> I can think of is using 'exec "chown <user> <directory name>";'.
>
>
> Michael Wentzel
> wentzel@umr.edu
>
------------------------------
Date: 31 Mar 1998 11:53:10 GMT
From: sb@engelschall.com (Steffen Beyer)
Subject: Re: file trees
Message-Id: <6fqlf6$7b2$1@en1.engelschall.com>
> On 30 Mar 1998, Robs hols wrote:
>> Can anyone suggest some perl code that would allow me to, given a
>> particular directory, list all files in that directory AND in all
>> directories below it
One of the shortest ways is:
@array = split(/\n/, `find . -type f -print`);
Yours,
--
Steffen Beyer <sb@engelschall.com>
Feel free to visit my download area with free software at
http://www.engelschall.com/u/sb/download/
------------------------------
Date: 1 Apr 1998 09:46:58 GMT
From: "Miss WILKINS" <fr39@dial.pipex.com>
Subject: Re: Identifying how a perl program was called
Message-Id: <01bd5d53$07085fe0$73f482c1@lonriu3>
Hi
wouldn't HTTP_Referer do the trick
Iqbal
PS email is iqbal@etc.prestel.co.uk , couldn't be bothered to change my
mates settings
Glenn Schworak <Glenn.J.Schworak@state.or.us> wrote in article
<352165E9.730A7D63@state.or.us>...
> I am new to perl and have looked for this answer in the man pages and a
> couple perl books but I suspect I am not looking for the right key
> phrases or words. So please don't laugn too much if this is a really
> basic question.
>
>
> I have an HTML document calling my perl program using the inline method
> #exec and I am passing it parameters. This works great. I have also done
> a couple using forms to call the perl code. I am wondering, is there a
> way for my perl program to know what HTML document called it without
> using an argument passed via the #exec line for an inline call?
>
> To clerify, is there some ENV variable (or any other variable) that perl
> can check to see the name of the HTML document that initiated the perl
> script?
>
> Why would I do this? I want to write a few scripts that act in special
> ways depending on what HTML document calls them. But I don't want to
> trust the HTML coder to properly set the arguments passed to perl.
> Especially since they will most likely use a cut/paste method to add the
> code that calls the perl script.
>
> Thanks for your time and patients in dealing with a new guy on the
> block.
>
>
------------------------------
Date: 31 Mar 1998 21:55:22 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Is there a "Newsgroup" for Newbies to Perl?
Message-Id: <6frooa$12a$2@marina.cinenet.net>
Howard Davies (Howard@roslyn.demon.co.uk) wrote:
[snip]
: The FAQ is a great help, but can't solve every problem.
: Has anyone thought of setting up a "comp.lang.perl.help" newsgroup?
: I read the java.help group and reading the threads there have solved
: many of my Java problems, how about the same thing for Perl?
How would its charter (or actual use) differ from c.l.p.misc?
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: 01 Apr 1998 01:38:09 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: smitty77@pacbell.net
Subject: Re: Is there a "Newsgroup" for Newbies to Perl?
Message-Id: <8ciuouc4y6.fsf@gadget.cscaper.com>
>>>>> "smitty77" == smitty77 <smitty77@pacbell.net> writes:
smitty77> My first experience with perl was in a class at Silicon
smitty77> Graphics taught by Randall Schwartz. It was a pretty good
smitty77> class, but even then I could tell that Randall had no
smitty77> patience for people who asked what he felt were 'stupid
smitty77> questions'. To each his own, I guess.
I'm a bit flabberghasted by this. It's not my intention to come
across as someone who "had no patience for people who asked what he
felt where 'stupid questions'". Since you've broadsided me, I'm gonna
ask you why you didn't come up to me in class to tell me your
perception, or at least write it down on the readily available SGI
"eval" forms at the end of the week. If you can relate a specific
conversation in detail, I'll be happy to attempt to recall the
situation and try to understand what happened.
I take special care to ensure that each and every student gets what
they came for in my classes. And my associates (rootbeer, Joseph, and
Chip Salzenberg) do the same, or they don't work with me. I'm
committed to that. I've bet my company's entire reputation on that.
When I fall short of that goal, I want to be called on it. But
please, it's a bit rude to have done that in a public forum such as
this.
I can assure you that if my general classroom perception was one such
as yours, SGI wouldn't have let me teach the next class (they're very
picky about my work there). As it is, I'm booked solid through the
end of the year with SGI (as well as many other regular clients) and
generally score 3-5 on the 1-5 scale in *all* areas (except class
length :-). I'm sorry you had a uniquely different experience, and
would be happy to try to understand why your experience was different.
Sorry for being lengthy, but attacking my reputation in a public forum
demands a public response on my part. (And I'd be happy to give
anyone who asks a list of references to validate my assertion. Just
write perl-training-info@stonehenge.com for details, or visit
www.perltraining.com.)
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 153 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Wed, 01 Apr 1998 01:52:36 -0500
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: need regexp help
Message-Id: <3521E436.E06973B0@coos.dartmouth.edu>
david smith wrote:
>
> Ronald J Kimball wrote:
>
> > {split "."} is equivalent to {split /./}. So is {split "\."}; do you see why?
>
> I see why {split "."} is equivalent to {split /./}, but explain to me why {split
> "\."} is the same. Why isn't {split "\."} equivalent to {split /\./}? Just
> curious....
Cool, I was hoping someone would ask.
The answer is that the string goes through double-quotish processing *before*
it is handed off to split. In double-quotish processing, "\." is changed to
'.'. So by the time the string is used as a regex, the backslash is gone.
Here's another way of looking at it:
$str = "\."; # $str = '.'
split $str; # split /./
$str = "\\."; # $str = '\\.'
split $str; # split /\./
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J. Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 31 Mar 1998 22:00:31 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Odd or even function
Message-Id: <6frp1v$12a$3@marina.cinenet.net>
John Porter (jdporter@min.net) wrote:
: Craig Berry wrote:
: >
: > Dan Serban (judas@interprice.com) wrote:
: > :
: > : if odd(variable)
: >
: > Well, you'd actually have to write that as 'if (odd($variable))', of
: > course.
:
: uh...
:
: sub variable() { yadda(); }
:
: print "odd" if odd(variable) ;
Refer to the original post; he had it written in the conditional-block
form, 'if () {}'. I was responding specifically to that. (I trimmed his
curly braces, which were on lines following what I quoted. Bad idea, in
retrospect.)
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: 31 Mar 1998 12:31:54 GMT
From: sb@engelschall.com (Steffen Beyer)
Subject: Re: Odd or even function
Message-Id: <6fqnnq$aaq$2@en1.engelschall.com>
Dan Serban <judas@interprice.com> wrote:
> Is there an odd or even perl function that could be used as a boolean
> operator? ie
> if odd(variable)
> {
> }
if ($variable & 1) # odd
if (!($variable & 1)) # even
--
Steffen Beyer <sb@engelschall.com>
Feel free to visit my download area with free software at
http://www.engelschall.com/u/sb/download/
------------------------------
Date: 1 Apr 1998 08:56:33 GMT
From: krobert@skud.cc.monash.edu.au (Kirrily 'Skud' Robert)
Subject: Re: Relative address problem
Message-Id: <slrn6i40ad.1gj.krobert@skud.cc.monash.edu.au>
In article <6fafd3$dd1@eng-ser1.erg.cuhk.edu.hk>, Sleep wrote:
>When I grab down another homepage and show in the browser using Perl,
>problem will occur when user click on those relative addresses as the
>broswer wrongly recognize the domain. Which way should I use to solve
>this problem ?
>By changing the relative address to absolute address (how?) ?
>Or ... by jumping to the homepage rather than get and show the html
>content (also how ?) ?
To point them at the other page, rather than reading it in and barfing it
out again, you need to do an HTTP redirect. This is a FAQ, and the details
of how to do it can be found in the appropriate document (perlfaq9).
K.
--
Kirrily "Skud" Robert (skud@monash.edu.au)
http://w3.cc.monash.edu.au/~krobert/
Anything sufficiently bizarre is indistinguishable from truth.
- Zik Saleeba
------------------------------
Date: Wed, 1 Apr 1998 01:57:10 -0700
From: "Aaron Propst" <abp@holly.colostate.edu>
Subject: sending mail using perl
Message-Id: <6fsvoq$334s@yuma.ACNS.ColoState.EDU>
I need to send an e-mail from perl, I have a form that collects data from
the user and creates an e-mail to the person of their choice.
using the following code, I can successfully send an e-mail, but it isn't
turning out the way I want it.
Problems:
1. The Reply-to address and the Subject show up in the message text.
2. The rest of the message body has no returns for separate lines.
open (MAIL, "|$mailprog $advisormail") || die "Can't open $mailprog! \n";
print MAIL "Reply-to: $replyaddy \n";
print MAIL "Subject: Advising information for $firstname $lastname (abroad)
\n";
print MAIL "The following information has been directed to you because you
have been named as the advisor for $firstname $lastname. Please look over
the registration request, and respond to: $replyaddy";
print MAIL "thank you for your co-operation";
print MAIL "CSU, International Education";
close (MAIL);
variable values defined:
$mailprog = "/usr/mail/" $advisormail = recipient's address
$replyaddy = reply address
$firstname, $lastname = first and last name of user
I'm very new to the language, and am open to new ways of achieving the same
goal. does anyone have a better method of sending e-mail?
if this is the best method, are there ways I can define returns, and
formatting?
thanks for any help you can offer
Aaron
------------------------------
Date: Wed, 01 Apr 1998 07:32:25 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Someone put my munged e-mail address on a spam list
Message-Id: <3522e7fd.3383874@news.tornado.be>
John Stanley wrote:
>Address munging avoids the costs incurred by spam, and it causes the
>spammers to waste time sending mail to invalid addresses.
It hardly costs any time to the spammer, since it's a fully automated
process. It wastes a lot of OUR bandwidth though.
Bart.
--
Spam spam spam spam spam spam spam spam,
Lovely Spam!... Loooooovely Spam!!!
Monty Python, "The Spam Song"
------------------------------
Date: Wed, 1 Apr 1998 09:14:03 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Sorting a Delimeted Text File?
Message-Id: <ebohlmanEqq9nF.Jy6@netcom.com>
Anthony F. Sanchez <ncadmin@nova-creations.com> wrote:
: Does anyone know of a simple way to "sort" a field or fields in a
: delimited text file?
I believe the author of the Perl FAQ does. You should have it on your
system; if not, go over to <URL:http://www.perl.com> and grab it.
------------------------------
Date: Wed, 01 Apr 1998 02:29:59 -0500
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: Sysadmin struggeling with PERL/Sed and etc...
Message-Id: <3521ECFB.78295B12@coos.dartmouth.edu>
Roland Huss wrote:
>
> Ronald J Kimball <rjk@coos.dartmouth.edu> writes:
>
> > while (defined($line1 = <IN1>) and defined($line2 = <IN2>)) {
> > $line1 =~ tr/\n//d; # ** remove newline from $line1 **
> > print "$line1$line2";
> > }
>
> While this works fine if both files have the same number of lines (and
> this was the case in the original posting), I suggest to add the
> following to handle files with different number of lines, too:
>
> while (defined(<IN1>) or defined(<IN2>)) {
> print $_;
> }
<> magically assigns to $_ *only* when it is alone in the conditional of a
while or for loop. Your code reads in a line from IN1 or IN2, throws it away,
and prints the value of $_. You need to add an explicit assignment to $_.
Anyway, I'd rather do it like this:
# tested
while (defined($line1 = <IN1>) and defined($line2 = <IN2>)) {
chomp $line1;
print $line1, $line2;
}
if (not eof IN1) { # print extra lines in IN1
print while <IN1>;
} elsif (not eof IN2) { # print extra lines in IN2
print while <IN2>;
}
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J. Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Tue, 31 Mar 1998 13:33:35 +0100
From: John Riddoch <jr@scms.rgu.ac.uk>
Subject: Re: Why this one doesn't work ?
Message-Id: <3520E29F.6A921EFE@scms.rgu.ac.uk>
indhiraa@hotmail.com wrote:
>
> I have a PERL program whose first 3 lines are like this:
>
> #!/bin/sh
> # this line will be comment for PERL \
> exec perl "$0" $@"
>
> print "hello..\n";
>
> My intention is to avoid hard-coding the path to the Perl interpreter.
> but this script continuously execs and never goes beyond that.
>
> Am I missing anything here.
Probably the path to perl; does /bin/sh have a full path? You'll have
to tell the shell where to find perl either via PATH= or perhaps using a
$PERL variable in the calling shell.
--
John Riddoch Programmer/Webmaster
Room C6, School of Computer and Mathematical Science
Robert Gordon University, Aberdeen, AB25 1HG
E-mail jr@scms.rgu.ac.uk Telephone: (01224)262721
It IS as bad as you think, and they ARE out to get you.
------------------------------
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 2222
**************************************