[10146] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3739 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 17 12:07:12 1998

Date: Thu, 17 Sep 98 09:00:23 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 17 Sep 1998     Volume: 8 Number: 3739

Today's topics:
    Re: any way to encrypt my script? <jdw@dev.tivoli.com>
    Re: Can I foreach multiple arrays? (Clinton Pierce)
    Re: Can I foreach multiple arrays? (Abigail)
        Can't get cgi-lib.pl to work!? <benderle@mindspring.com>
    Re: Can't get cgi-lib.pl to work!? <Tony.Curtis+usenet@vcpc.univie.ac.at>
        concatinate variables <tpham@ee.gatech.edu>
    Re: concatinate variables (Andrew M. Langmead)
        GDBM, Hashes, 2D vice 3D, and a mental block :) jrobiso2@my-dejanews.com
        Getopt_:Long and non-options arguments (Frank Zimmermann)
    Re: Getopt_:Long and non-options arguments (Hans-Georg Rist)
    Re: help:web mail <Geert.Roovers@ericsson.com>
    Re: how safe is xor encryption ? (Mark-Jason Dominus)
    Re: how safe is xor encryption ? (Mark-Jason Dominus)
    Re: how safe is xor encryption ? (Abigail)
    Re: how safe is xor encryption ? <eashton@bbnplanet.com>
    Re: how safe is xor encryption ? <eashton@bbnplanet.com>
    Re: ifdef in Perl (Andrew M. Langmead)
    Re: Javascript or Perl or Java? (Nathan V. Patwardhan)
    Re: mod function in PERL? <barnett@houston.Geco-Prakla.slb.com>
    Re: mod function in PERL? dave@mag-sol.com
    Re: mod function in PERL? <ets@egnetz.uebemc.siemens.de>
    Re: mod function in PERL? (Abigail)
        more regex/pattern substitution <eglamkowski@angelfire.com>
    Re: more regex/pattern substitution (Sean McAfee)
    Re: more regex/pattern substitution <J.D.Gilbey@qmw.ac.uk>
        Newbie needs help <weinstem@bms.com>
        newbie question on sockets ()
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 17 Sep 1998 07:27:44 -0500
From: "Jim Woodgate" <jdw@dev.tivoli.com>
Subject: Re: any way to encrypt my script?
Message-Id: <obww72kjpb.fsf@alder.dev.tivoli.com>


abigail@fnx.com (Abigail) writes:
> ++ Can
> ++ I encrypt my script so that it can be executed but not read?
> 
> No.

> Abigail
> -- 
> perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'

how can you say 'no'?  Your sig "can be executed but not read"... :)

-- 
Jim Woodgate 
Tivoli Systems
E-Mail: jdw@dev.tivoli.com


------------------------------

Date: 17 Sep 1998 13:15:40 GMT
From: cpierce1@cp500.fsic.ford.com (Clinton Pierce)
Subject: Re: Can I foreach multiple arrays?
Message-Id: <6tr21s$3q81@eccws1.dearborn.ford.com>

In article <3600525E.55CA04AF@qmw.ac.uk>,
	Julian Gilbey <J.D.Gilbey@qmw.ac.uk> writes:
>Abigail wrote:
>> 
>> Colin Kuskie (ckuskie@cadence.com) wrote on MDCCCXLII September MCMXCIII
>> in <URL: news:Pine.GSO.3.96.980916095515.20066A-100000@pdxue150.cadence.com>:
>> ++ On 15 Sep 1998, Abigail wrote:
>> ++
>> ++ > Tom Christiansen (tchrist@mox.perl.com) wrote on MDCCCXLI September
>> ++ > MCMXCIII in <URL: news:6tmlgd$hbp$2@csnews.cs.colorado.edu>:
>
>Why 1841, 1842 and 1993?
>

Must be a Y2K bug.



*duck*
-- 
+------------------------------------------------------------------------+
|  Clinton A. Pierce    |   "If you rush a Miracle Man,   | http://www.  |
|  cpierce1@ford.com    |     you get rotten miracles"    | dcicorp.com/ |
| fubar@ameritech.net   |--Miracle Max, The Princess Bride| ~clintp      |
+------------------------------------------------------------------------+
GCSd-s+:+a-C++UALIS++++P+++L++E---t++X+b+++DI++++G++e+>++h----r+++y+++>y*



------------------------------

Date: 17 Sep 1998 15:07:09 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Can I foreach multiple arrays?
Message-Id: <6tr8it$fub$1@client3.news.psi.net>

Clinton Pierce (cpierce1@cp500.fsic.ford.com) wrote on MDCCCXLIII
September MCMXCIII in <URL: news:6tr21s$3q81@eccws1.dearborn.ford.com>:
++ In article <3600525E.55CA04AF@qmw.ac.uk>,
++ 	Julian Gilbey <J.D.Gilbey@qmw.ac.uk> writes:
++ >Abigail wrote:
++ >> 
++ >> Colin Kuskie (ckuskie@cadence.com) wrote on MDCCCXLII September MCMXCIII
++ >> in <URL: news:Pine.GSO.3.96.980916095515.20066A-100000@pdxue150.cadence.com>:
++ >> ++ On 15 Sep 1998, Abigail wrote:
++ >> ++
++ >> ++ > Tom Christiansen (tchrist@mox.perl.com) wrote on MDCCCXLI September
++ >> ++ > MCMXCIII in <URL: news:6tmlgd$hbp$2@csnews.cs.colorado.edu>:
++ >
++ >Why 1841, 1842 and 1993?
++ >
++ 
++ Must be a Y2K bug.


s/bug/fix/;

HTH. HAND.


Abigail
-- 
perl -MNet::Dict -we '(Net::Dict -> new (server => "dict.org")\n-> define ("foldoc", "perl")) [0] -> print'


------------------------------

Date: Thu, 17 Sep 1998 09:43:02 -0400
From: Brian Enderle <benderle@mindspring.com>
Subject: Can't get cgi-lib.pl to work!?
Message-Id: <360111E6.3BF14345@mindspring.com>

I am attempting to build a cgi file using the cgi-lib.pl file but am
unable to get even the simple following script to work:

#!/usr/local/bin/perl

push(@INC, "/cgi-bin/submit");
require ("cgi-lib.pl");

print &PrintHeader;
print "hello!";

When I try to run the script I just receive a '500 Server Error'
cgi-bin/submit is the directory where my cgi scripts are stored and the
server my provider is using is NCSA servers on BSD UNIX machines.

Any help would be greatly appreciated

Brian Enderle

PS: I would prefer replys be sent to my e-mail at
benderle@mindspring.com





------------------------------

Date: 17 Sep 1998 16:50:13 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Can't get cgi-lib.pl to work!?
Message-Id: <8390ji4wuy.fsf@vcpc.univie.ac.at>

Re: Can't get cgi-lib.pl to work!?, Brian
<benderle@mindspring.com> said:

Brian> push(@INC, "/cgi-bin/submit");
                  ^^^^^^^^^^^^^^^^^
Are you sure that's the *directory* with the library in it?

And why not use CGI.pm instead?  Much nicer (IMHO.pm).

-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien,  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


------------------------------

Date: Thu, 17 Sep 1998 10:19:12 -0400
From: Tien Pham <tpham@ee.gatech.edu>
Subject: concatinate variables
Message-Id: <36011A60.23EDE5D0@ee.gatech.edu>

Hi there:

How do we concatinate variables in the LHS of the "=" in Perl 5?
I mean

---------------
#!/usr/local/bin/perl

@x = (1,0,1);

for $num (0..2) {
  $tmp_$num[$num] = $x[$num];
  print STDOUT "$num\t$tmp_$num[$num]\tqqq\n";
}
-------------

so that I can create vars tmp_0, tmp_1, and tmp_2.

thanks,

tien pham
tpham@ee.gatech.edu

--
Plan:

To live
 To enjoy
  To appreciate
   every opportunity and every minute here, in America!
--------------------------------------





------------------------------

Date: Thu, 17 Sep 1998 15:12:43 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: concatinate variables
Message-Id: <EzFox8.450@world.std.com>

Tien Pham <tpham@ee.gatech.edu> writes:

>How do we concatinate variables in the LHS of the "=" in Perl 5?
[stuff deleted]
>so that I can create vars tmp_0, tmp_1, and tmp_2.

You would really probably be better off using an array

$tmp[$num][$num] = $x[$num]

But if you really wanted to, or there is some part of the problem that
I'm not understanding, you could use the "symbolic references" feature
of perl 5;

${"tmp_$num"}[$num] = $x[$num];
-- 
Andrew Langmead


------------------------------

Date: Thu, 17 Sep 1998 14:40:21 GMT
From: jrobiso2@my-dejanews.com
Subject: GDBM, Hashes, 2D vice 3D, and a mental block :)
Message-Id: <6tr70l$148$1@nnrp1.dejanews.com>

OK, stupid question of the day. In my mind, I see (regular, flat) databases
like a spreadsheet. Fields (keys) along the top, index on the left, and data
(values) below the field names.

Here's my quandry: Hashes have keys and values. One value per key (usually).
So, when I imagine reading a db file into a hash with "dbmopen(%hash,
"/root/myfile.db", 0666)", I see it reading the field names, and the FIRST
set of values. All lower (second, etc) get cut off because the hash can only
contain the keys (fields) and values (one per key). Retrieval via $hash{$key}
can obviously only access the FIRST row (set) of data from the db.

So, obviously, I have a mental block on how to access the subsequent sets of
data in the db.

Can anyone provide a mental image to help, and possibly code examples?

I often use MySQL and DBI.pm for my database work, but for some simple jobs,
thats obvious overkill. I'd like to learn how to properly use db files, but
can't get around this mental block. Thanks for any help you can offer.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


------------------------------

Date: Thu, 17 Sep 1998 14:10:47 GMT
From: fz@hlsv.de (Frank Zimmermann)
Subject: Getopt_:Long and non-options arguments
Message-Id: <360115f0.25864881@172.16.254.11>

I want to read a command line with options and non-options arguments. 

(Perl for Win32 Build 310 - Built 19:24:08 Sep  4 1997 
This is perl, version 5.003_07) 

But I can't get through...
Is there a trivial error?

Frank.
--->input: 
perl cdrom.pl 1 -t="test"
--->code: 
#!/usr/bin/perl -w
use Getopt::Long;

$Getopt::Long::debug = 9;
$Getopt::Long::order = $PERMUTE;

sub arguments{
}

$result = GetOptions("<>",\&arguments,
		     "help", \$help,
		     "t=s", \$titel,
		     "u=s", \$userid);

 ...
--->error:
GetOptions $Revision: 2.4 $ [GetOpt::Long 2.04] -- called from package
"main".
  (1 -t=test)
  autoabbrev=1,bundling=0,getopt_compat=1,order=1,
  ignorecase=1,passthrough=0,genprefix="(--|-|\+)".
Error in option spec: "CODE(0xbe74b8)"
=> link "help" to SCALAR(0xbea628)
=> link "t" to SCALAR(0xbe63c4)
=> link "u" to SCALAR(0xbe646c)

-- 
Frank Zimmermann
HLSV / ZV4
Tel  : 0511 8073 - 795
email: fz@hlsv.de


------------------------------

Date: Thu, 17 Sep 1998 15:10:13 GMT
From: hans-georg.rist@zkrd.de (Hans-Georg Rist)
Subject: Re: Getopt_:Long and non-options arguments
Message-Id: <36012401.2077437@news.uni-ulm.de>

fz@hlsv.de (Frank Zimmermann) wrote:

>I want to read a command line with options and non-options arguments. 
>
>(Perl for Win32 Build 310 - Built 19:24:08 Sep  4 1997 
>This is perl, version 5.003_07) 
>
>But I can't get through...
>Is there a trivial error?
>
>Frank.
>--->input: 
>perl cdrom.pl 1 -t="test"
>--->code: 
>#!/usr/bin/perl -w
>use Getopt::Long;
>
>$Getopt::Long::debug = 9;
>$Getopt::Long::order = $PERMUTE;
>
>sub arguments{
>}
>
>$result = GetOptions("<>",\&arguments,
>		     "help", \$help,
>		     "t=s", \$titel,
>		     "u=s", \$userid);
>
>...

put the <> option specifier at the end of the parameter list:

$result = &GetOptions(
             "help", \$help,
             "t=s",  \$titel,
             "u=s",  \$userid,
             "<>",   \&arguments,
);

then it works (but don't ask me why). See the example on page 451 of
the Camel 2.
But there's no word about the order of the GetOptions parameters.
On p. 449 calling GetOptions with <> is documented as:
   &GetOptions(..."<>", \&mysub...);
Perhaps it's a bug.

Regards,
HG



------------------------------

Date: Thu, 17 Sep 1998 15:48:29 +0200
From: Geert Roovers <Geert.Roovers@ericsson.com>
Subject: Re: help:web mail
Message-Id: <3601132D.1E6F6E9@ericsson.com>

At http://www.hotmail.com :o)

~Geert

lincr@usa.net wrote:
> 
> I want to retrieve and send mail from www,where can i find the software?
> 
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


------------------------------

Date: 17 Sep 1998 10:06:02 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: how safe is xor encryption ?
Message-Id: <6tr50a$b87$1@monet.op.net>

In article <36010614.4A77@DejahsPrivateIce.com>,
Mary E Tyler  <dejah@DejahsPrivateIce.com> wrote:
>it might have been an answer... but it was not one i understood. except
>that it might be some sort of strange joke.

Sorry.  It wasn't a strange joke, although I admit that I've never
felt more peculiar about adding `hope this helps' at the end of an
article.

Maybe a better answer to this question is:

1. There are ways to measure the randomness of an information source.

2. The more random it is the more rapidly it generates information.
   (Extreme example: A source that generates the same thing every time
   is not random and is not generating any information either.)

3. Information content and randomness are both measured in `bits'.

4. To be suitably random, the source of keys (the users) must generate
   information at a rate of at least 53.15 bits per key.

5. To find out what this really means, see (for example) `Symbols,
   Signals, and Noise', by J.R. Pierce.  (Harper, 1961.) It is a
   really fun  introduction to information theory.




------------------------------

Date: 17 Sep 1998 09:46:18 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: how safe is xor encryption ?
Message-Id: <6tr3ra$b5s$1@monet.op.net>

In article <6tqr7o$en6$1@eol.dd.chalmers.se>,
Stefan Berglund <f94stbe+news@dd.chalmers.se> wrote:
>An XOR might keep your kid sister from reading your files, but it
>won't stop a cryptanalyst for more than a few minutes.

Bruce is talking about XOR ciphers where the key is periodic.  That is
not germane to this discussion.

>
>An XOR is very simple to crack it is really just a polyalphabetic 
>Vigenere variant, this is how you do:
>
>1. Discover the keylength.
>   Shift the ciphertext against itself various amounts of bytes and
>   count those bytes that are equal. When you have shifted a whole
>   keylength you will see a dramatic change in the number of equal
>   bytes, from less than .4% to something around 6%
>   The smallest shiftlength with this large index is the keylength.

In this case, you won't, because the ciphertext is only seven bytes
long, and the keylength is also seven bytes.  In fact, you can skip
this step and just assume that the key is seven bytes; I will give you
that for free.

>2. Get rid of the key and get the plaintext
>   Shift the ciphertext that amount of bytes and XOR it against
>   itself.

Shifting the ciphertext seven bytes and XORing it with itself will
always yield "\0\0\0\0\0\0\0".

:)

>   This removes the key and leaves you with the plaintext
>   XOR:ed with itself shifted keylength bytes. As you know that it is
>   a creditcard number and therefor has a specific format (with for
>   example a checksum) it is an easy task to discover the number.

I think you're going to have a difficult task extracting a credit card
number, or anything else, from a string of nulls.  :)

In all seriousness, I did post my credit card number encrypted in this
fashion.  You are invited to decrypt it if you so desire.

>I recommend that you get Bruce Schneiers book if you are generally
>interested in cryptography and/or use cryptography in your work.

I agree.  Schneier's book is really good.

I would join Felix Gallo in advising people to stay away from
cryptography.  Here we have an example of a person with good
intentions, who read the right book, but who misunderstood the context
of what he read and ended up with a conclusion that was completely
wrong for the problem domain.





------------------------------

Date: 17 Sep 1998 15:08:33 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: how safe is xor encryption ?
Message-Id: <6tr8lh$fub$2@client3.news.psi.net>

Elaine -HappyFunBall- Ashton (eashton@bbnplanet.com) wrote on MDCCCXLIII
September MCMXCIII in <URL: news:36008482.4C5FF3DA@bbnplanet.com>:
++ Abigail wrote:
++ 
++ > Uhm, uhm, what keeps you from creating a piece of plastic, about 4 inches
++ > by 2.5 inches, with a nice logo and 16 digits on it - to be used as key?
++ 
++ Well, what do you mean by 'key' in this sense. Practicality and expense
++ would be my first guess an this. Granted, credit cards do this but I do
++ generally regard credit cards as being rather behind the times and
++ barbaric. Besides, if were getting into that we could easily jump to
++ retinal scanning and other such 'id' sort of things.


Uhm. So, it's ok for people to have to remember their 16 digit CC#,
but a 16 digit key is too much?

I fail to understand.



Abigail
-- 
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET", "http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content)) =~ /(.*\))[-\s]+Addition/s) [0]'


------------------------------

Date: Thu, 17 Sep 1998 15:39:04 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: how safe is xor encryption ?
Message-Id: <36012AB3.22B202A7@bbnplanet.com>

Tom Mornini wrote:

> I don't understand why people are so paranoid about this! Do you use that
> card ONLY for on-line transactions? If not, perhaps it was stolen out of
> the trash can at the local 5 and dime...

What? You missed the point. I use e-commerce and I have been burned by
it too. I also have managed machines with 0 level security on home-grown
awful Perl CC transaction scripts. If we aren't asking the tough
questions about security, who will? My computer illiterate mother? I'm
not paranoid, but I do lock my door at night.

> For that matter, perhaps an employee at (your e-commerce vendor here) stole
> it while placing the transaction, or auditing the transactions, etc.

Perhaps, but as either the application developer or the SA, that is out
of my control. 

> I'm not saying that CC security is not an issue. And I would like to think
> that EVERYONE who I give my card to EVERYWHERE I use it cares as much about
> this as all the folks participating in this thread.

Probably not. I usually thank the rare clerk that checks my signature
against the card. The amount of information collected around your CC is
staggering. I like to protect that.

> However, while everyone is sweating the online security issue, I've always
> felt that a much more profitable attack would be a simple analog splice-in
> on the phone system of (your non e-commerce vendor here). They could just
> listen in, write the numbers and important information down (or just record
> it) and then not have to be a propeller head at all!

There is no challenge in that. 


e.

"All of us, all of us, all of us trying to save our immortal souls, some
ways seemingly more round-about and mysterious than others. We're having
a good time here. But hope all will be revealed soon."  R. Carver


------------------------------

Date: Thu, 17 Sep 1998 15:45:46 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: how safe is xor encryption ?
Message-Id: <36012C46.E4AF181F@bbnplanet.com>

Abigail wrote:

> Uhm. So, it's ok for people to have to remember their 16 digit CC#,
> but a 16 digit key is too much?

No, what I'm saying that if you are going to go the way of the card for
a key then maybe consider other alternatives to that. The card is a
comfortable object that people already know. Why not a digital
signature, a finger-print scanning mouse (My boss wanted to start using
these for our workstations) as the key could be generated from the
pattern....I'm digressing but I was letting my imagination go astray.

> perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET", "http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content)) =~ /(.*\))[-\s]+Addition/s) [0]'

This is cute.

e.

"All of us, all of us, all of us trying to save our immortal souls, some
ways seemingly more round-about and mysterious than others. We're having
a good time here. But hope all will be revealed soon."  R. Carver


------------------------------

Date: Thu, 17 Sep 1998 15:21:49 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: ifdef in Perl
Message-Id: <EzFpCD.M95@world.std.com>

dave@mag-sol.com writes:

>What are you getting from your function that you can't get from just checking
>the value of the $^O variable?

Since "use" happens at compile time, it would be executed no the
result ofthe test of $^O. Sticking it in an "eval" delays its
execution until runtime (of the BEGIN block). Sticking the whole mess
in a BEGIN block ensures that the code maintains its semantics despite
its delay in execution. (That prototyped functions are honored, and
that whatever the module does at startup is indeed done.)

-- 
Andrew Langmead


------------------------------

Date: Thu, 17 Sep 1998 13:51:16 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Javascript or Perl or Java?
Message-Id: <ot8M1.83$_c5.886658@news.shore.net>

laksh5614@my-dejanews.com wrote:
: Please can somebody clarify the difference between  using Javascript, Java,
: Perl? As a Beginner what should a person know to start off with Internet
: Programming?

For starters, they are all different, but I'd suggest looking into
Perl if you'd like to get a response from people in this newsgroup.

Magnificent troll!  9.8!

--
Nate Patwardhan|root@localhost
"Fortunately, I prefer to believe that we're all really just trapped in a
P.K. Dick book laced with Lovecraft, and this awful Terror Out of Cambridge
shall by the light of day evaporate, leaving nothing but good intentions in
its stead." Tom Christiansen in <6k02ha$hq6$3@csnews.cs.colorado.edu>


------------------------------

Date: Thu, 17 Sep 1998 08:36:45 -0500
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
To: buckybeaver73@yahoo.com
Subject: Re: mod function in PERL?
Message-Id: <3601106D.CF2C1B6@houston.Geco-Prakla.slb.com>

[courtesy cc to cited author]

buckybeaver73@yahoo.com wrote:
> 
>   Hi all... Is there a mod function in perl? I would like to get the
> remainder of a division. If there isn't I guess I could always parse the
> number out and do the calculation myself... Any help is appreciated.
What's wrong with the "%" operator as detailed in perldoc perlop? 
(Search for /Binary "%"/ to see what I'm referring to)

#!/usr/local/bin/perl -w
#
$number = 4;
$otherNumber = 13;
$modulus = $number % $otherNumber;
if ($modulus) {
    print "Number is not evenly divisible!  D'oh!\n";
} else {
    print "Number is evenly divisible!\n";
}
__END__

> 
> Thanks,
> Justin
> buckybeaver73@yahoo.com
> 
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum
HTH.

Cheers,
Dave

-- 
Dave Barnett	Software Support Engineer	(281) 596-1434


One nice thing about egotists:  They don't talk about other people.


------------------------------

Date: Thu, 17 Sep 1998 13:48:07 GMT
From: dave@mag-sol.com
Subject: Re: mod function in PERL?
Message-Id: <6tr3un$tvu$1@nnrp1.dejanews.com>

In article <6tqvca$p27$1@nnrp1.dejanews.com>,
  buckybeaver73@yahoo.com wrote:
>   Hi all... Is there a mod function in perl? I would like to get the
> remainder of a division. If there isn't I guess I could always parse the
> number out and do the calculation myself... Any help is appreciated.

Justin,

There is, indeed, a mod operator in Perl - as a cursory examination of
'perldoc perlop' would have shown you.

hth,

Dave...


--
dave@mag-sol.com
London Perl M[ou]ngers: <http://www.mag-sol.com/London.pm/>

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


------------------------------

Date: Thu, 17 Sep 1998 15:26:35 +0200
From: "Hr. Jochen Stenzel" <ets@egnetz.uebemc.siemens.de>
Subject: Re: mod function in PERL?
Message-Id: <36010E0B.82CEBD31@egnetz.uebemc.siemens.de>

Hello,

>   Hi all... Is there a mod function in perl?

Try the '%' operator, e.g.: "$modulo=7%2;"

                                            Jochen



------------------------------

Date: 17 Sep 1998 15:47:58 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: mod function in PERL?
Message-Id: <6trave$gt8$1@client3.news.psi.net>

buckybeaver73@yahoo.com (buckybeaver73@yahoo.com) wrote on MDCCCXLIII
September MCMXCIII in <URL: news:6tqvca$p27$1@nnrp1.dejanews.com>:
++   Hi all... Is there a mod function in perl?

No. But you might be able to write one using a certain operator
that is mentioned in the manual.

HTH. HAND.


Abigail
-- 
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))


------------------------------

Date: Thu, 17 Sep 1998 15:09:04 GMT
From: Edward Glamkowski <eglamkowski@angelfire.com>
Subject: more regex/pattern substitution
Message-Id: <360125E1.7E17@angelfire.com>

So, I have a string which may contain one or more "words" that I need
to upper/lower case in an odd way.  For example, PHD or Phd or phd I 
want to all become PhD.

While I could just do:
s/phd/PhD/ig;

I have several words that I want to do this to, and it would be handy
if I could do it all in one statement, something like:
s/(phd|edd)/\u\l\u$1/ig;

That way I can just add more words to the LHS instead of having to write
a new, separate statement for each one.

But, the above doesn't work (on phd, it returns Phd).
Anybody have any suggestions? :)

-- 
               "Have you no sense of decency, sir?
        At long last, have you left no sense of decency?"

http://www.angelfire.com/nj/eglamkowski/null.html <-- Null webring
http://www.angelfire.com/nj/eglamkowski/eia.html  <-- Eia webring


------------------------------

Date: Thu, 17 Sep 1998 15:51:39 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: more regex/pattern substitution
Message-Id: <feaM1.3373$F7.13021476@news.itd.umich.edu>

In article <360125E1.7E17@angelfire.com>,
Edward Glamkowski  <eglamkowski@angelfire.com> wrote:
>So, I have a string which may contain one or more "words" that I need
>to upper/lower case in an odd way.  For example, PHD or Phd or phd I 
>want to all become PhD.

>While I could just do:
>s/phd/PhD/ig;

>I have several words that I want to do this to, and it would be handy
>if I could do it all in one statement, something like:
>s/(phd|edd)/\u\l\u$1/ig;

>That way I can just add more words to the LHS instead of having to write
>a new, separate statement for each one.

>But, the above doesn't work (on phd, it returns Phd).
>Anybody have any suggestions? :)

How about:

s/(ph|ed)d/\u\L$1\ED/gi;

The general case, where the abbreviations don't necessarily have letters
in common, is more complicated.  Suppose the two strings you want to
convert are PhD and, oh, AbC.  This substitution will do both:

s/(ph(?=d)|ab(?=c))(.)/\u\L$1\E\u$2/gi;

-- 
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
            | K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
            | tv+ b++ DI++ D+ G e++>++++ h- r y+>++**          | umich.edu


------------------------------

Date: Thu, 17 Sep 1998 16:53:53 +0100
From: Julian Gilbey <J.D.Gilbey@qmw.ac.uk>
Subject: Re: more regex/pattern substitution
Message-Id: <36013091.76032E4C@qmw.ac.uk>

Edward Glamkowski wrote:
> 
> So, I have a string which may contain one or more "words" that I need
> to upper/lower case in an odd way.  For example, PHD or Phd or phd I
> want to all become PhD.
> 
> While I could just do:
> s/phd/PhD/ig;
> 
> I have several words that I want to do this to, and it would be handy
> if I could do it all in one statement, something like:
> s/(phd|edd)/\u\l\u$1/ig;
> 
> That way I can just add more words to the LHS instead of having to write
> a new, separate statement for each one.
> 
> But, the above doesn't work (on phd, it returns Phd).
> Anybody have any suggestions? :)

It doesn't work, because \u and \l only work on the first character of
the string.  Why not something like:

@abbrevs = ("PhD", "BBC", "EdD", BSc");
foreach $abbrev @abbrevs { s/$abbrev/$abbrev/ig; }

Unfortunately, this requires the regexp to be interpreted each time.

   Julian

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

            Julian Gilbey             Email: J.D.Gilbey@qmw.ac.uk
       Dept of Mathematical Sciences, Queen Mary & Westfield College,
                  Mile End Road, London E1 4NS, ENGLAND
      -*- Finger jdg@goedel.maths.qmw.ac.uk for my PGP public key. -*-


------------------------------

Date: Thu, 17 Sep 1998 11:29:39 -0400
From: Maxim Weinstein <weinstem@bms.com>
Subject: Newbie needs help
Message-Id: <36012AE3.F4C064ED@bms.com>

I'm a perl newbie, though I have a _little_ C programming experience.
I'm trying to create a script that does significant file manipulation,
but I'm unsure how to do it, even after looking over a few perl
resources.

OK, this is what I want the script to do:

Take two arguments:
(1)  The filename of a plain-text file
(2)  A string of text, possibly several paragraphs in length

The script would back up the file specified in (1), then probably read
in that file and the string specified in (2), and ultimately write (to
the original filename of (1)):

1) The first line of file (1)
2) Today's date (centered relative to an 80-char. line)
3) The string (2)
4) "\n---------------\n"
5) The rest of file (1) except its second line (which was the old date)

Example:

* argument (1) is testfile.txt:

                     This is a test file
                          09/10/98

This is a test file.
La la la la la.

* argument (2) is the string:

This is a sample string.

This is still the sample string.

* resulting output should be testfile.txt:

                     This is a test file
                          09/17/98

This is a sample string.

This is still the sample string.

---------------

This is a test file.
La la la la la.

*** Any help is appreciated ***
weinstem@bms.com



------------------------------

Date: 17 Sep 1998 15:43:08 GMT
From: impactid@pantheon.yale.edu ()
Subject: newbie question on sockets
Message-Id: <6tramd$5ae@jupiter.planet.net>

hi all:

can someone show me a very simple skeleton code on opening a socket
connection and write to/read from that socket using perl?

thanks!

impactid @ artnewyork . com


------------------------------

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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 3739
**************************************

home help back first fref pref prev next nref lref last post