[10148] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3741 Volume: 8

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

Date: Thu, 17 Sep 98 11:00:21 -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: 3741

Today's topics:
        .htpasswd generation on NT <simon@targeting.co.uk>
        Calling another script from perl <matt@godzilla.tamu.edu>
        CPAN.pm shell from behind a firewall jboes@qtm.net
        DCOM testing <mordkoff@acm.org>
        Formatting a variable to three digits <michael@datahost.com>
    Re: Formatting a variable to three digits <eashton@bbnplanet.com>
    Re: Formatting a variable to three digits (David A. Black)
    Re: Formatting a variable to three digits <Tony.Curtis+usenet@vcpc.univie.ac.at>
    Re: Formatting a variable to three digits <tpham@ee.gatech.edu>
        formatting numerical values <alcazar@netcomp.net>
    Re: formatting numerical values <ajohnson@gpu.srv.ualberta.ca>
    Re: how safe is xor encryption ? <sgordon@kenan.com>
    Re: how safe is xor encryption ? (Stefan Berglund)
        internal error 500 <sjeREMOVE@ican.net>
    Re: internal error 500 (David A. Black)
    Re: internal error 500 <sjeREMOVE@ican.net>
        making a number decimal splonka@my-dejanews.com
        making number a decimal splonka@my-dejanews.com
    Re: mod function in PERL? buckybeaver73@yahoo.com
    Re: mod function in PERL? (Andre L.)
    Re: more regex/pattern substitution (Craig Berry)
    Re: newbie question on sockets (Sean McAfee)
    Re: newbie question on sockets <gbarr@asic.sc.ti.com>
    Re: Perl & Java - differences and uses rizzo@best.com
        perl compiler <CHANGE_THIS@CHANGE_THIS_ALSO.ch>
        perl compiler <CHANGE_THIS@CHANGE_THIS_ALSO.ch>
    Re: perl compiler (David A. Black)
    Re: Perl write data into text file (Craig Berry)
        Popping into a Dir. wayne_allison@hotmail.com
        Removing double entries from array (Marc-A. Woog)
    Re: Removing double entries from array <eashton@bbnplanet.com>
    Re: searching a file in ranges (Vladimir Parkhaev)
        SSI , Perl and IIS <cmorgado@corimagem.pt>
    Re: stock quote service (Michael Allen Gelman)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Thu, 17 Sep 1998 16:45:04 +0100
From: Simon Wistow <simon@targeting.co.uk>
Subject: .htpasswd generation on NT
Message-Id: <645CAC0140CED111AF1500805FEDDB8AD79B@ns.new-mediacom.co.uk>

I've written a script (based on one by David Levy) that will generate
'.htpasswd's for me. It's being run from the command line with
Activestate Perl (build 502, August 11) on NT4SP3. Howvere it doesn't
seem to work
The script I copied it from was
http://world.inch.com/Scripts/htpasswd.pl.html
and my version below doesn't produce the same answer as their CGI
version at.
http://www.inch.com/info/tech/HOWTOS/htaccess/htpasswd.html
Any ideas?

<code>
 #!/usr/bin/perl
 ($user,$passwd)  = split (/:/,$ARGV[0],2);
 srand($$|time);
 @saltchars=(a..z,A..Z,0..9,'.','/');
 $salt=$saltchars[int(rand($#saltchars+1))];
 $salt.=$saltchars[int(rand($#saltchars+1))];
 $passwdcrypt = crypt($passwd,$salt);
  print "\n\n$user\:$passwdcrypt";
  exit 1;

</code>



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

Date: Thu, 17 Sep 1998 10:50:20 -0500
From: Matt Turner <matt@godzilla.tamu.edu>
Subject: Calling another script from perl
Message-Id: <36012FBC.FB5B4A8B@godzilla.tamu.edu>

Say that I wanted to call another shell script or perl script from
perl.  How can I do this?  I think it has something to do with the
"system command".  For example, say I wanted to call a script called
runme with a -d parameter from perl.  Would this be how to do it:

system ("runme -d")

Also, does the perl script continue running once the srcipt "runme" is
done running.  In other words,  does the script continue running, wait
for the called script to finish, or terminate once the called script is
called?

Thanks,
Matt



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

Date: Thu, 17 Sep 1998 17:29:53 GMT
From: jboes@qtm.net
Subject: CPAN.pm shell from behind a firewall
Message-Id: <6trgug$brg$1@nnrp1.dejanews.com>

Does anyone have experience to share about how to configure CPAN.pm so that
the shell can be used from behind a firewall? I've tried several variants on
feeding it the name of my proxy server, but whenever I try to actually use
it, it times out trying to use /usr/bin/ftp.

--
Jeff Boes  jboes@qtm.net
http://www.qtm.net/~jboes/

-----== 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 13:21:33 -0400
From: Jeremy Mordkoff <mordkoff@acm.org>
Subject: DCOM testing
Message-Id: <3601451C.CD1BFA39@acm.org>

The product I am working on now is implemented as a collection of DCOM
objects. Most of them will not do much standalone, but the collection of
them implements some pretty powerful stuff. The UI group will use these
interfaces. I would like to create a test driver that parses a script
and makes DCOM calls just like the UI will do. Some of the issues I
forsee are tracking the results (some calls return cookies and/or fill
in complicated data structures) and deciding when to release interfaces
(BTW there are 30 interfaces and about 215 methods). I am thinking that
Perl would handle the script parsing nicely, but that I may have to use
C++ to actually call DCOM.

Has anyone tackled such a job before? What was your approach? How long
did it take? Would you be willing to share some code?

Thanks,
JLM

--
Jeremy L. Mordkoff
http://www.net1plus.com/users/jom/pictel.htm




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

Date: Thu, 17 Sep 1998 09:21:55 -0700
From: Michael Stearns <michael@datahost.com>
Subject: Formatting a variable to three digits
Message-Id: <36013723.49D4@datahost.com>

Hello:

I know I can do something like:

#!/usr/local/bin/perl
$num=12;
printf ("%.3f\n",$num);

And this will output 12.000

But what if I want to just convert the $num variable so the value
assigned to it has three digits beyond the decimal ( in this case, 12 to
12.000). Currently the calculation that create $num is removing the
trailing zeros. 

Is there a good way to assign the formatting to the variable?

(In my particular script, this would need to work no matter what the
value of $text - 12, 12.4, 12.34, etc.)

I have one print statement in my script which has a whole mass of text
and variables in it, including about 6 variable which I want to apply
this formatting to. It seems like it would be difficult (at least for
me) to construct a printf statement that would work.

Thanks,
Michael Stearns


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

Date: Thu, 17 Sep 1998 16:26:36 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Formatting a variable to three digits
Message-Id: <360135D7.80A2F966@bbnplanet.com>

Michael Stearns wrote:

> #!/usr/local/bin/perl
> $num=12;
> printf ("%.3f\n",$num);
> 
> And this will output 12.000

try 'perldoc -f sprintf'
If I understand what you are trying to do you can achieve this with
better 'precision' in the print statement.

> But what if I want to just convert the $num variable so the value
> assigned to it has three digits beyond the decimal ( in this case, 12 to
> 12.000). Currently the calculation that create $num is removing the
> trailing zeros.

Again, precision should help you here. The vaule stays the same, but you
can print it out any way you like.

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 12:22:11 EDT
From: dblack@saturn.superlink.net (David A. Black)
Subject: Re: Formatting a variable to three digits
Message-Id: <6trcvj$o8m$1@earth.superlink.net>

Hello -

Michael Stearns <michael@datahost.com> writes:

>Hello:

>I know I can do something like:

>#!/usr/local/bin/perl
>$num=12;
>printf ("%.3f\n",$num);

>And this will output 12.000

>But what if I want to just convert the $num variable so the value
>assigned to it has three digits beyond the decimal ( in this case, 12 to
>12.000). Currently the calculation that create $num is removing the
>trailing zeros. 

>Is there a good way to assign the formatting to the variable?

I think you want sprintf() -

my $num = sprintf("%.3f", 12);

print $num;  # 12.000



David Black
dblack@saturn.superlink.net





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

Date: 17 Sep 1998 18:48:53 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Formatting a variable to three digits
Message-Id: <837lz24rd6.fsf@vcpc.univie.ac.at>

Re: Formatting a variable to three digits, Michael
<michael@datahost.com> said:

Michael> Hello: I know I can do something like:

Michael> #!/usr/local/bin/perl $num=12; printf
Michael> ("%.3f\n",$num);

Michael> And this will output 12.000

Michael> But what if I want to just convert the $num
Michael> variable so the value assigned to it has three
Michael> digits beyond the decimal ( in this case, 12 to
Michael> 12.000). Currently the calculation that create $num
Michael> is removing the trailing zeros.

I think you are confusing numerals and numbers.

printf() and sprintf() format values for output.

hth
tony
-- 
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 12:50:06 -0400
From: Tien Pham <tpham@ee.gatech.edu>
Subject: Re: Formatting a variable to three digits
Message-Id: <36013DBE.5B206BD4@ee.gatech.edu>

Hi Michael,

I think the function sprintf would do.
For example:

$new_num = sprintf("%.3f",$num);

Notice that sprintf will truncate the values of $num
to whatever you specified, and perl will use these values
then on.

I hope this would help,

tien pham
tpham@ee.gatech.edu

Michael Stearns wrote:

> Hello:
>
> I know I can do something like:
>
> #!/usr/local/bin/perl
> $num=12;
> printf ("%.3f\n",$num);
>
> And this will output 12.000
>
> But what if I want to just convert the $num variable so the value
> assigned to it has three digits beyond the decimal ( in this case, 12 to
> 12.000). Currently the calculation that create $num is removing the
> trailing zeros.
>
> Is there a good way to assign the formatting to the variable?
>
> (In my particular script, this would need to work no matter what the
> value of $text - 12, 12.4, 12.34, etc.)
>
> I have one print statement in my script which has a whole mass of text
> and variables in it, including about 6 variable which I want to apply
> this formatting to. It seems like it would be difficult (at least for
> me) to construct a printf statement that would work.
>
> Thanks,
> Michael Stearns

--
Plan:

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





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

Date: Thu, 17 Sep 1998 12:03:28 -0500
From: "illfigah" <alcazar@netcomp.net>
Subject: formatting numerical values
Message-Id: <#NP0#zl49GA.385@upnetnews03>


    Hello all,

    I've constructed a .pl program which crunches pricing information.  It
works fine however, I would like for the program to format any prices from
the following format:

    4445 or 11234589

to something that is more readible in its context such as:

   $ 4,445.00 or $11,234,589.00

These numbers represent "dollars" and I haven't found a method for adding
commas where they belong.  As for the double zero at the end and the dollar
sign... I suppose I could just tack that on using HTML.  If someone could
please help in finding a way to reliably place the commas as separators... I
would greatly appreciate it.

    Ric.






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

Date: Thu, 17 Sep 1998 12:26:19 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: formatting numerical values
Message-Id: <3601463B.C57BC51@gpu.srv.ualberta.ca>

illfigah wrote:
!
! 
!     Hello all,
! 
!     I've constructed a .pl program which crunches pricing
! information.  It works fine however, I would like for the program to
! format any prices from the following format:
! 
!     4445 or 11234589
! 
! to something that is more readible in its context such as:
! 
!    $ 4,445.00 or $11,234,589.00
! 
! These numbers represent "dollars" and I haven't found a method for
! adding commas where they belong.  As for the double zero at the end
! and the dollar sign... I suppose I could just tack that on using
! HTML.  If someone could please help in finding a way to reliably
! place the commas as separators... I would greatly appreciate it.



the FAQ is your friend:

perlfaq5.pod:=head2 How can I output my numbers with commas added?
### begin quote

This one will do it for you:

    sub commify {
	local $_  = shift;
	1 while s/^(-?\d+)(\d{3})/$1,$2/;
	return $_;
    }

    $n = 23659019423.2331;
    print "GOT: ", commify($n), "\n";

    GOT: 23,659,019,423.2331

You can't just:

    s/^(-?\d+)(\d{3})/$1,$2/g;

because you have to put the comma in and then recalculate your
position.

Alternatively, this commifies all numbers in a line regardless of
whether they have decimal portions, are preceded by + or -, or
whatever:

    # from Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
    sub commify {
       my $input = shift;
        $input = reverse $input;
        $input =~ s<(\d\d\d)(?=\d)(?!\d*\.)><$1,>g;
        return reverse $input;
    }

### End quote

hope it helps
regards
andrew


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

Date: Thu, 17 Sep 1998 11:21:48 -0400
From: Seth Gordon <sgordon@kenan.com>
To: beyret@my-dejanews.com
Subject: Re: how safe is xor encryption ?
Message-Id: <3601290C.28F14002@kenan.com>

(Disclaimer: I am not well-versed in cryptography.)

*If* each user's credit card security code is (a) completely random, (b) not
intercepted between the user and your program, and (c) has at least as many bits
as (your representation of) the credit card number itself, then you have what's
called a "one-time pad", which is unbreakable.  In theory.

In practice, it's hard to meet conditions (a) and (b).  For example, people who
choose their own passwords will often choose English words, or common misspellings
of English words, or common words in other languages, etc.  By taking advantage of
this regularity, a cryptanalyst can narrow the range of keys to be guessed.

Ten or twenty years ago, Unix systems would encrypt passwords using a system
similar to yours.  Now, with a moderately fast computer and a dictionary on
CD-ROM, it's not hard to break a file of passwords encrypted this way.

In a later message, you discuss compiling the script so that it is no longer
human-readable.  I'm not sure how much of an advantage this will get you.
Machine-language programming is not popular these days (you dang kids have it so
easy :-), but it's not too hard to disassemble binary code and then try to figure
out what it does.

The sci.crypt FAQs and  have a lot of very useful information about cryptography,
and they include pointers to other resources.  If you're working on this for
academic purposes or just out of your own curiosity, I encourage you to look at
these sources.

If you're actually building this system for commercial purposes, I strongly
encourage you to hire a professional.  Look at it this way: you don't have
experience *making* crypto systems, but some day, people who *do* have lots of
experience *breaking* crypto systems might come across your site ... and if they
can steal a few thousand bucks by breaking into yours, they might do so.

--
I have a simply marvelous algorithm that will factor any number N
in O(log N) time, but it won't fit in this .signature block.
== seth gordon == sgordon@kenan.com == standard disclaimer ==
== documentation group, kenan systems corp., cambridge, ma ==




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

Date: 17 Sep 1998 15:54:00 GMT
From: f94stbe+news@dd.chalmers.se (Stefan Berglund)
Subject: Re: how safe is xor encryption ?
Message-Id: <6trbao$6jm$1@eol.dd.chalmers.se>

mjd@op.net (Mark-Jason Dominus) wrote:
> 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.

I have to disagree as the original post <6tn6f5$h5s$1@nnrp1.dejanews.com> 
said:

" (if length of CCSC is smaller than CC number's length, i will extend
" it to fit in such a way that i have not thougth about yet)

Where CC is the credit card and CCSC is the key.

If (and only if) he demands a keylength of the same length as the
length of the credit card number it should be equivalent to a
one-time-pad and therefor secure. (I thought of that a little bit to
late, I admit guilty of posting to fast, so sue me :)
This will also mean that the key must have at least fair random
properties, I would not trust anybody to come up with such a key.
OTOH a credit card number has a very specific format so you know quite
a bit about your cleartext, this might prove important!

>>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.

The number of numbers on a credit card varies with the "vendor", a
cleartext of seven bytes would correspond to 14 numbers on the CC.
AFAIK there can be up to 20 numbers. For example there is 16 on my cards.
This will mean a key of up to 10 characters, in my opinion to long for
people to remember => they will be set so that they will be
voulnerable to a dictionary attack.

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

No! As the shift is cyclic ABCDEF shifted three steps will become
DEFABC, not \0\0\0ABC!
Which of cource mean that my attack sketch is not effective if the key
is the same length as the cleartext.

In another message the original poster says that he uses SSL etc for
transfers, why not have at least comparable strength for the database?

> 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.

No I still doesn't think that my conclusion is wrong: Don't use XOR
with a key that is shorter than the data and isn't random.

But if those condictions holds than you will be safe, but they don't
hold in the original post and I very much doubt that they will hold in
real life.

-- 
			/Stefan
			f94stbe@dd.chalmers.se

Life - the ultimate practical joke

finger f94stbe.pgp@dd.chalmers.se for public pgp-key


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

Date: Thu, 17 Sep 1998 11:57:48 -0400
From: "Simon Ewins" <sjeREMOVE@ican.net>
Subject: internal error 500
Message-Id: <6trbfu$o9d$1@news2.tor.accglobal.net>

I'm not sure if this is the right place to ask this but it is perl related
so...

I have a shell script which I am trying to use to get a copy of my current
log sent to me by e-mail from within my browser by accessing the script.

The sending of the log by mail is working fine but what I want to do is
display a web page that says so. Instead I am getting an internal error 500,
I think the problem is in the perl code that I have in the shell script.
This is the script:

mail -s "current access_log" my_account <
/var/httpd/logs/my.domain/access_log
/usr/bin/perl -e '
   print "Content-type: text/html\n\n";
   print "<html><head><title>GetLog</title></head>\n";
   print "<body text=\"#FFFFFF\" bgcolor=\"000000\">\n";
   print "<center><h1>Current log sent to
my_account@my.domain</h1></center>\n";
   print "</body></html>\n";
'

Any thoughts (and apologies if this is not the right place to have asked).

Simon





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

Date: Thu, 17 Sep 1998 12:32:34 EDT
From: dblack@saturn.superlink.net (David A. Black)
Subject: Re: internal error 500
Message-Id: <6trdj2$pip$1@earth.superlink.net>

Hello -

"Simon Ewins" <sjeREMOVE@ican.net> writes:

>I'm not sure if this is the right place to ask this but it is perl related
>so...

>I have a shell script which I am trying to use to get a copy of my current
>log sent to me by e-mail from within my browser by accessing the script.

>The sending of the log by mail is working fine but what I want to do is
>display a web page that says so. Instead I am getting an internal error 500,
>I think the problem is in the perl code that I have in the shell script.

I think so too.

>my_account@my.domain</h1></center>\n";

You have to escape the @.

Why didn't you run the code through perl?  It would have given you
a perfectly cogent error message.  Perl does work from the command
line, you know....


David Black
dblack@saturn.superlink.net
 


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

Date: Thu, 17 Sep 1998 12:55:27 -0400
From: "Simon Ewins" <sjeREMOVE@ican.net>
Subject: Re: internal error 500
Message-Id: <6tres2$rdq$1@news2.tor.accglobal.net>

:>my_account@my.domain</h1></center>\n";
:
:You have to escape the @.
:
:Why didn't you run the code through perl?  It would have given you
:a perfectly cogent error message.  Perl does work from the command
:line, you know....

I didn't realize that would be possible with the html code in it. Now I
know. Thanks. That was it, it now works perfectly.

Thanks, again.





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

Date: Thu, 17 Sep 1998 17:17:31 GMT
From: splonka@my-dejanews.com
Subject: making a number decimal
Message-Id: <6trg7b$b5o$1@nnrp1.dejanews.com>

I'm stuck trying to get my number to print out in decimal format, like dollar
amounts.

see the output of http://www.plonka.com/phentex/products.html

I'm using

$sub =~ s/(\d+)\.*(\d*)/$1\.$2/;

but its not quite right. Can anybody help??

Thanks,
Susan

-----== 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 17:15:28 GMT
From: splonka@my-dejanews.com
Subject: making number a decimal
Message-Id: <6trg3f$b49$1@nnrp1.dejanews.com>

I'm stuck trying to get my number to print out in decimal format, like dollar
amounts.

see the output of http://www.plonka.com/phentex/products.html

I'm using

$sub =~ s/(\d+)\.*(\d*)/$1\.$2/;

but its not quite right. Can anybody help??

Thanks,
Susan

-----== 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 17:00:42 GMT
From: buckybeaver73@yahoo.com
Subject: Re: mod function in PERL?
Message-Id: <6trf7q$9u7$1@nnrp1.dejanews.com>

    I also found out that the % will give the remainder for a division...

Justin


In article <6tr3un$tvu$1@nnrp1.dejanews.com>,
  dave@mag-sol.com wrote:
> 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
>

-----== 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 13:20:52 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: mod function in PERL?
Message-Id: <alecler-1709981320520001@dialup-523.hip.cam.org>

In article <6trave$gt8$1@client3.news.psi.net>, abigail@fnx.com wrote:

> 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.

Curious: what does "HAND" stand for? I'm guessing, "Hope all newbies die." 
HIW.

Andre


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

Date: 17 Sep 1998 16:33:56 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: more regex/pattern substitution
Message-Id: <6trdlk$e32$2@marina.cinenet.net>

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? :)

Here's how I'd do it (untested), assuming that all the patterns you
want to deal with match /\w+/:

  my %casemap = ( phd => 'PhD',
                  edd => 'EdD',
                  foo => 'fOo' };

  # ... get line to be transformed into $_ ...

  s/(\w+)/exists $casemap{lc $1} ? $casemap{lc $1} : $1/eg;

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "Ripple in still water, when there is no pebble tossed,
       nor wind to blow..."


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

Date: Thu, 17 Sep 1998 16:08:14 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: newbie question on sockets
Message-Id: <OtaM1.3377$F7.13027872@news.itd.umich.edu>

In article <6tramd$5ae@jupiter.planet.net>,
 <impactid@pantheon.yale.edu> wrote:
>can someone show me a very simple skeleton code on opening a socket
>connection and write to/read from that socket using perl?

Perl makes it disgustingly simple:

use IO::Socket;

$sock = new IO::Socket::INET(PeerAddr => "www.foo.com", PeerPort => 80);
print $sock "GET / HTTP/1.0\n\n";
while (<$sock>) {
	print;
}

-- 
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: 17 Sep 1998 16:21:46 GMT
From: Graham Barr <gbarr@asic.sc.ti.com>
Subject: Re: newbie question on sockets
Message-Id: <6trcuq$j4l$1@tilde.csc.ti.com>

perldoc IO::Socket

and there are plenty of examples in the huge number of perl books that are
avaliable. Personally I would reccomend 'The Perl Cookbook' by Tom C & Nat

impactid@pantheon.yale.edu wrote:
> 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

-- 
Graham Barr <gbarr@ti.com>
For every action, there is an equal and opposite criticism. 


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

Date: 17 Sep 1998 10:18:20 -0700
From: rizzo@best.com
Subject: Re: Perl & Java - differences and uses
Message-Id: <6trg8s$qfm$1@shell3.ba.best.com>

In article <3600DC33.F878C208@bioreason.com>,
Andrew Dalke  <dalke@bioreason.com> wrote:

>You'll also need to split this across several files since (as I
>recall, prices subject to change without notice) perl only allows
>one class definition per file.

That has never been true, even with the single argument form of bless.




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

Date: Thu, 17 Sep 1998 18:10:55 +0200
From: John Smith <CHANGE_THIS@CHANGE_THIS_ALSO.ch>
Subject: perl compiler
Message-Id: <3601348E.2310D873@CHANGE_THIS_ALSO.ch>

is it possible to compile a perl script ???

i would like to compile a perl script and to execute it under both UNIX
and Windows95/NT ??

some body have an idea ??

many thanks



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

Date: Thu, 17 Sep 1998 18:47:30 +0200
From: John Smith <CHANGE_THIS@CHANGE_THIS_ALSO.ch>
Subject: perl compiler
Message-Id: <36013D22.B9101F82@CHANGE_THIS_ALSO.ch>

I'am searching for a perl compiler (WINDOWS95/NT  and UNIX) .
I would like to do that not to make it faster but to have an executable
programme for Windows and UNIX plateforme and this for people that does
not have the perl interpreter...

i looked at the www.perl.com and it seems that there is an experimental
compiler for Unix, it looks quit complexe ...

any body could help me ???

many thanks .




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

Date: Thu, 17 Sep 1998 12:45:46 EDT
From: dblack@saturn.superlink.net (David A. Black)
Subject: Re: perl compiler
Message-Id: <6trebq$r4p$1@earth.superlink.net>

John Smith <CHANGE_THIS@CHANGE_THIS_ALSO.ch> writes:

>is it possible to compile a perl script ???

>i would like to compile a perl script and to execute it under both UNIX
>and Windows95/NT ??

>some body have an idea ??


You can *already* execute (most) perl scripts under both Unix and
Windows.  If they were compiled to binary, you would not be able to.

So you're ahead of the game.


David Black
dblack@saturn.superlink.net


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

Date: 17 Sep 1998 16:28:12 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Perl write data into text file
Message-Id: <6trdas$e32$1@marina.cinenet.net>

Kotaro Yama (kotaro@geocities.com) wrote:
:     How can i write perl5.005 command to write data in text file ?

perldoc -f print

: It is need exclusive lock file before write data in this file.
: How to use exclusive lock file ?

perldoc -f flock

: I use perl on Unix (Sun2.6) Environment.

Both are platform-independent, within the set of platforms supporting
flock, of which yours is one member.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "Ripple in still water, when there is no pebble tossed,
       nor wind to blow..."


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

Date: Thu, 17 Sep 1998 17:01:57 GMT
From: wayne_allison@hotmail.com
Subject: Popping into a Dir.
Message-Id: <6trfa4$9vv$1@nnrp1.dejanews.com>

All, I had the idea to implement a popping dir type object where it would move
you to directory on creation and move you back when the object died.

if ( $godir ) {
 my $d = PopDir->new ( "/tmp" );
 ... do things in /tmp
 ... etc
}
Now being here I'd be back where I started from.. The idea works but
when I'm in the DESTROY method/cleanup and die if I can't chdir back to
my original dir it doesn't say anything so I warn
and then exit 1; This works be gives a "Callback called exit" message.
So have I made a bad decision.. I wanted it to work like the Filehandle type
objects where they close on destruction..
Any thoughts etc on this approach or ways to fail nicely.
Wayne.

-----== 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 16:59:17 GMT
From: mwoog@pobox.ch (Marc-A. Woog)
Subject: Removing double entries from array
Message-Id: <36023e32.24208563@news.datacomm.ch>

Hi

I am quite new to Perl and I have a "How-to-do-better"-Question:

I have tons of entries in @url_list, sometimes two or more times the
same. I want to remove all redundant entries and this is the code I
came up 'til now:

foreach $url (@url_list) {
  $flag = 1;
  foreach (@temp_url_list) {
    if ( $_ eq $url) {
      $flag = 0;
      next;
    }
  }
if ( $flag == 1 ) { push (@temp_url_list, $url); }
}
@url_list = @temp_url_list;

Is there a more elegant and efficient (meaning faster) way to do the
same (this looks more like basic than perl to me)?

THX in advance,

Marc

-- 
Marc-A. Woog
mwoog@pobox.ch
http://www.dtc.ch/mwoog/


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

Date: Thu, 17 Sep 1998 17:29:29 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Removing double entries from array
Message-Id: <36014495.EB72C82F@bbnplanet.com>

Marc-A. Woog wrote:

> Is there a more elegant and efficient (meaning faster) way to do the
> same (this looks more like basic than perl to me)?

Yes, though yours will do the job there is a less painful way to do it.
Create a hash of your tmp_url_list then you can extract all of the
unique keys from it. i.e. You don't need the second array, make it a
hash.

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: 17 Sep 1998 17:04:52 GMT
From: v_parkh@alcor.concordia.ca (Vladimir Parkhaev)
Subject: Re: searching a file in ranges
Message-Id: <6trffk$sf2$1@newsflash.concordia.ca>

In article <slrn701cde.aoj.adelton@aisa.fi.muni.cz>,
Honza Pazdziora <adelton@fi.muni.cz> wrote:
>On Wed, 16 Sep 1998 20:39:44 -0400, Ash Heikh <ash@rem.hotmail.com> wrote:
>> Can someone tell me a simple way to do that in perl or awk or sed. (not
>
>Try:
>
>	perl -ne '$date = $_ if /^date/;
>		print $date, $_ if (split /\s+/)[7] > 10;'

Or slightly shorter:
perl -lane '$d=$1 if /^\s*date(\d+)/; 
            print $d, " ", $_ if $F[7] >10'

>
>You'll probably probably want to check man pages
>
>	perlrun		for	-ne switch
>	perlvar			what the $_ means
>	perlsyn			the strange position of if
>	perlop			the // thing
>	perlfunc		print and split
>
>Hope this helps,
>






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

Date: Thu, 17 Sep 1998 18:03:09 +0100
From: Cristovao Morgado <cmorgado@corimagem.pt>
Subject: SSI , Perl and IIS
Message-Id: <360140CD.7FCD0B7D@corimagem.pt>

I am trying to make some perl scripts to use on IIS.
Is I call the script : x.pl that is:

print "Content-type: text/html\n \n";
print "teste";

with a form it works

if i use <!-- #exec cgi="x.pl" -->
on a xx.shtm file I get the fowling message :
HTTP/1.1 200 OK Date: Thu, 17 Sep 1998 16:53:08 GMT Server:
Microsoft-IIS/4.0 Content-type: text/html
'd:\Inetpub\wwwroot\teste\2.shtm' script produced no output

Does any1 knows what i'm doing wrong ?
It should return : teste
Why on SSI it says that ?

Thx in advanced
Cristovao Morgado



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

Date: Thu, 17 Sep 1998 13:42:31 -0400
From: nospam@cheta.net (Michael Allen Gelman)
Subject: Re: stock quote service
Message-Id: <MPG.106b14104d5dadc99896c5@news.cheta.net>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

Tom Tingdale wrote:
> I am looking for a stock quote service that can give me this
> information as raw data, and a Perl solution to get this data and
> format it into a web site.

Me, too!  Tom, or anyone else, if you find this service, please email me!

My real address is my last name in front of @cheta.net

Thanks!

Sincerely,
Michael Allen Gelman
Amour Eternal Wedding Photography
        ___________________________________________________________
        Planning to get married in western North or South Carolina?
                          http://AmourEternal.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 3741
**************************************

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