[8122] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1740 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 27 14:27:36 1998

Date: Tue, 27 Jan 98 11:00:36 -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           Tue, 27 Jan 1998     Volume: 8 Number: 1740

Today's topics:
    Re: ? random text string (Steve Linberg)
    Re: a perl question (Chip Salzenberg)
    Re: Awk command does not work. Why? (Richard Bellavance)
    Re: Awk command does not work. Why? (Honza Pazdziora)
    Re: Awk command does not work. Why? (Sylvain Juneau)
        drag and drop <markh@manhatten.prestel.co.uk>
    Re: exec, fork and CGI confusion <dcaugh@poodle.nortel.ca>
    Re: Fed up with CGI.pm (Matt Fischer)
    Re: Freidl's book mystery <joseph@5sigma.com>
    Re: Freidl's book mystery (Greg Bacon)
    Re: help: open an existing page and replace parts of it (Chip Salzenberg)
        INSERT INTO Informix with Perl DBI mwendel@marketguide.com
    Re: Multiple copies of the same option on command line (Richard Bellavance)
        Newbie Question (Perl on NT 4.0 and IIS 3.0). <freen@dds.nl>
    Re: newbie: need help with first script -- here it is <rootbeer@teleport.com>
    Re: Perl (4) and images in the code.... (Honza Pazdziora)
        Perl Oracle Long DBI DBD <GERT.FRANCOIS@SD.BE>
        print<< into variable? (Kirk Is)
    Re: Processing Enter in a form field <rootbeer@teleport.com>
        puzzling result from hex() <franzen@pmel.noaa.gov>
        READ THIS FIRST (ENROLD)
    Re: Remove elements of array1 from array2. <dgwilson@gte.net>
    Re: Remove elements of array1 from array2. (Honza Pazdziora)
    Re: Remove elements of array1 from array2. <joseph@5sigma.com>
    Re: Sending binary files on a Socket. There has to be a (Chip Salzenberg)
    Re: ssh <media@organizedmedia.com>
    Re: Survival Of perl <rjc@liddell.cstr.ed.ac.uk>
    Re: Survival Of perl dg50@chrysler.com
    Re: Survival Of perl (Chip Salzenberg)
    Re: Text::ParseWords vs. Split (Rick Freeman)
        Urgent: Perl & Solaris & facls & failure... (Marek Rouchal)
    Re: using packages with perl on Windows (NT)? <noel@integrityonline.com>
    Re: vcard.vcf (I R A Aggie)
    Re: White Hats and Black (Chip Salzenberg)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 27 Jan 1998 13:22:47 -0500
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: ? random text string
Message-Id: <linberg-2701981322470001@projdirc.literacy.upenn.edu>

In article <34C80B98.328558A7@mthcsc.wfu.edu>, scottj@mthcsc.wfu.edu wrote:

> Lars Kr. Lundin wrote:
> > 
> > Can anybody tell me how to produce a random text string that matches
> > /^\w{8}$/ ?
> > 
> > I would be surprised if it is difficult...
> > 
> [snip]
> 
> You can do it with rand() and a lookup table.  For example:
> 
>         @table = ('0'..'9','a'..'z','A'..'Z');
>         srand(time,$$);
>         foreach $i (1..8) {
>                 $randstr .= $table[rand($#table+1)];
>         }
> 
> If the rand formulation looks suspicious to you, just recall that 
> rand returns fractional expressions.
> 
> Hope this helps.
> Kevin.

This works, but a better random seed might be:

srand(time() ^ ($$ + ($$ << 15)) );

(from the Camel)

-- 

*********************************************************************
Steve Linberg                                     
Systems Programmer and Technology Specialist   (general) 215-898-2100
National Center on Adult Literacy             (tech lab) 215 898-0668
Graduate School of Education                       (fax) 215-898-9804
University of Pennsylvania                        
3910 Chestnut Street                       linberg@literacy.upenn.edu
Philadelpia, PA  19104
*********************************************************************


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

Date: Tue, 27 Jan 1998 04:52:57 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: a perl question
Message-Id: <6ajpar$dtr$1@cyprus.atlantic.net>

According to tadmc@flash.net (Tad McClellan):
>You should *always* use the -w switch.
>ALWAYS.
>Really.

During development, sure.  But I recommend omitting it in production
(especially unattendend production), so that new versions of Perl with
new warnings don't break critical operations.
-- 
Chip Salzenberg               - a.k.a. -                <chip@pobox.com>
           ->  Ask me about Perl training and consulting  <-
                  "We can shower it with neutrons."
              "Or we can do the Neutron Dance!"  // MST3K


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

Date: 27 Jan 1998 12:04:40 -0500
From: charlot@CAM.ORG (Richard Bellavance)
Subject: Re: Awk command does not work. Why?
Message-Id: <6al438$4i3@stratus.CAM.ORG>

In article <34cdf7e0.9198936@news.cmc.ec.gc.ca>,
Sylvain Juneau <sjuneau@microtec.net> wrote:
>The following script has an awk command, when I comment that line the
>script work but when I include it it does not work. Why?
>

I don't understand why you'd want to call awk from Perl to perform a simple
field extraction, but TMTOWTDI, I guess.  But your way is extremely
inefficient...

Oh yeah, it would help if you told us what you expect from the script, and what
you mean by "does not work" !

>
>#! /software/pub/bin/perl

You should *always* use the "-w" switch

>#
># This script get info from cise/send2client.conf file and
># list all product found in /users/operator/cislist
>
>$cise="/usr/local/cis/etc";
>open(SWITCH,"/usr/local/cis/etc/switch.conf")|| die "Can't open:\n";
>while (<SWITCH>)
> {
> `awk -F"send2" '{print $2}'`;

And just what text is awk supposed to process ?
I'd replace your call to awk with the following line:

    print((split /send2/)[1], "\n");

># print $conf_name;
> }
>#
># main
>#
>$choice=" ";
>while ($choice ne "q" )
> {
> print "client_product_info>";
> $choice=<STDIN>;
> chop ($choice);
> if ($choice eq "?" ) {&help}
> elsif( $choice eq "i" ) {&info}
> else {}
> }
>

May I suggest you buy a good book on Perl ?

Hope this helps,
Richard.
-- 
Richard Bellavance -- charlot@cam.org -- http://www.cam.org/~charlot/
    "All along this path I tread  /  My heart betrays my weary head
     With nothing but my love to save / From the cradle to the grave"
                                 (Eric Clapton, "From the cradle")


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

Date: Tue, 27 Jan 1998 17:36:13 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Awk command does not work. Why?
Message-Id: <adelton.885922573@aisa.fi.muni.cz>

sjuneau@microtec.net (Sylvain Juneau) writes:

> The following script has an awk command, when I comment that line the
> script work but when I include it it does not work. Why?

[...]

> while (<SWITCH>)
>  {
>  `awk -F"send2" '{print $2}'`;
> # print $conf_name;

What doesn it mean "it does not work"? Does it print some error
message/warning. Does the output differ from what you expect?
If the second is the case, try checking the perlop man page for
backticks and what it really does.

Also, why don't you simply use what Perl provides you out of box?
I believe (but I did not use awk for a long time, som pardon me if
I am wrong) that you could get the same with

	($substr) = (split /s/)[1];

Note that

	awk -F"send2" '{print $2}'

and

	perl -lpe '($_) = (split /s/)[1]'

seem to do exactly the same.

Hope this helps,

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: Tue, 27 Jan 1998 18:05:16 GMT
From: sjuneau@microtec.net (Sylvain Juneau)
Subject: Re: Awk command does not work. Why?
Message-Id: <34d1216f.19853288@news.cmc.ec.gc.ca>

On Tue, 27 Jan 1998 15:10:44 GMT, sjuneau@microtec.net (Sylvain
Juneau) wrote:

>The following script has an awk command, when I comment that line the
>script work but when I include it it does not work. Why?
it will not return a thing !!!!
>
>Thank you in advance
>
What I would like exactly is to open a file called switch.conf and do
the following: 

get rid of lines containing #
get the name of a client only  e.g.

client n  567	/etc/send2italie.conf    

all I would like to have is italie and save it in an array

>
>#! /software/pub/bin/perl
>#
># This script get info from cise/send2client.conf file and
># list all product found in /users/operator/cislist
>
>$cise="/usr/local/cis/etc";
>open(SWITCH,"/usr/local/cis/etc/switch.conf")|| die "Can't open:\n";
>while (<SWITCH>)
> {
> `awk -F"send2" '{print $2}'`;
># print $conf_name;
> }
>#
># main
>#
>$choice=" ";
>while ($choice ne "q" )
> {
> print "client_product_info>";
> $choice=<STDIN>;
> chop ($choice);
> if ($choice eq "?" ) {&help}
> elsif( $choice eq "i" ) {&info}
> else {}
> }
>
>Sylvain
>
>e-mail sjuneau@microtec.net

Sylvain

e-mail sjuneau@microtec.net


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

Date: 27 Jan 1998 17:31:14 GMT
From: "mark hutchinson" <markh@manhatten.prestel.co.uk>
Subject: drag and drop
Message-Id: <01bd26ba$9048bae0$b827acc7@manhatten>

I have a tied 3-listbox and a tied 8-listbox (Tk::TiedListbox). I wish to
be able to select an entry from the first listbox set and drag it over the
2nd set, highlighting 2 rows when the cursor is inbetween the 2 rows.

At worst I could take dragging over one row and highlighting it and
inserting the selected item in the row immediately following.

Those who are awake ( ! ) will have noticed that I wish to select an entry
from a 3-listbox set and insert it in to an 8-listbox set ... I don't
actually want to insert the 3 strings into the 8-listbox set ... I want to
call a routine that adds the other 5 strings.

Here's hoping ...

PS SpecTcl is great!


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

Date: Tue, 27 Jan 1998 11:56:37 -0500
From: Dan Caugherty <dcaugh@poodle.nortel.ca>
Subject: Re: exec, fork and CGI confusion
Message-Id: <34CE11C5.222B@poodle.nortel.ca>

Robert Goheen wrote:
> 
(snip)
>                                         I came up with the following
> statement at the end of my script, which executes after a page has been
> sent to the user:
> 
>   unless ($pid = fork) {
>      unless (fork) {
>        close (STDOUT);     # end of output to browser.
>        exec "cleanup.pl";
>        exit 0;
>        }
>      exit 0;
>   }
>   waitpid($pid,0);
> 
> And it works fine.  The script cleanup.pl runs fine.  HOWEVER, the page
> gets sent to the user 3 times.  

What about trying this modification:

#       ..print the page...ok,now we're done.. 
   close(STDOUT);  # children can't flush unempty buffers now

   unless ($pid = fork) {
      unless (fork) {
        exec "cleanup.pl";  
        # don't bother flushing STDOUT in cleanup.pl now
        exit 0;
        }
      exit 0;
   }
   waitpid($pid,0);

Child processes inherit file descriptor status, so "nailing the
door shut" on STDOUT may help.

HTH,
--  Dan not a perl god, just a fan C.

+---------------------dcaugh@poodle.nortel.ca------------------------+
| Dan Caugherty                  | All opinions herein are MINE only.|
| Member of Sci. Staff, Irritant,| Remove dog from address to reply. |
| and Collector of Spare Change  |                                   |
+---------------------dcaugh@poodle.nortel.ca------------------------+


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

Date: Tue, 27 Jan 1998 12:36:02 -0600
From: mfischer@bad.spam.bad.umr.edu (Matt Fischer)
Subject: Re: Fed up with CGI.pm
Message-Id: <MPG.f37e509e2d055a6989681@usenet.umr.edu>

Done.  Thanks for setting me straight.


In article <6ai72e$bqj$1@cyprus.atlantic.net>, chip@mail.atlantic.net 
says...
> According to mfischer@bad.spam.bad.umr.edu (Matt Fischer):
> >	I am trying to use CGI.pm (v.2.37010), and attempting to use 
> >autoEscape to save some data from a form, but it doesn't seem to work.  I 
> >want to save data like ( ), { }, and spaces, however, CGI.pm saves them 
> >as % and then their Hex ASCII representation.  
> 
> You want the newsgroups next door:
>   comp.infosystems.www.authoring.cgi
>   comp.lang.perl.modules
> 
> -- 
> Chip Salzenberg               - a.k.a. -                <chip@pobox.com>
>            ->  Ask me about Perl training and consulting  <-
>                   "We can shower it with neutrons."
>               "Or we can do the Neutron Dance!"  // MST3K
> 


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

Date: Tue, 27 Jan 1998 11:27:18 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: Freidl's book mystery
Message-Id: <34CE26E2.5C504C74@5sigma.com>

There's always =~.

The last time I benchmarked string nibbling it was slow on larger
strings.  Perhaps it was moving a large pointer.

	-joseph

Tom Christiansen wrote:
> 
>  [courtesy cc of this posting sent to cited author via email]
> 
> In comp.lang.perl.misc, joseph@5sigma.com writes:
> :scalar m//gc is better
> 
> It's fragile.  Call something that does a local $_ and
> prepare to be pissed off.
> 
> And string nibbling just moves a pointer.  No rewrites.

-- 
Joseph N. Hall, prop., 5 Sigma Productions       mailto:joseph@5sigma.com
Author, Effective Perl Programming . . . . . http://www.effectiveperl.com
Perl Training  . . . . . . . . . . . . . . .  http://www.perltraining.com


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

Date: 27 Jan 1998 18:33:36 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: Freidl's book mystery
Message-Id: <6al9a0$kgh$1@info.uah.edu>

[Posted and mailed]

In article <6al21l$52n$1@csnews.cs.colorado.edu>,
	Tom Christiansen <tchrist@mox.perl.com> writes:
: Yes, it would be.  But the m//g state is fragile.  What if you call a
: function that has a local $_ in it?  How could you know?

IMHO, that's a bug in local.

Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: Tue, 27 Jan 1998 04:49:59 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: help: open an existing page and replace parts of it
Message-Id: <6ajp5a$dta$1@cyprus.atlantic.net>

According to "Ilia Lobsanov" <ilia@NOSPAM.detoronics.net>:
>Thanx, but is there any pre-built functions that can do this?
>PowerBuilder has it...

I *repeat* that you *need*:
  1. To learn about the s/// operator;
  2. To go immediately to comp.infosystems.www.authoring.cgi.

I am helping you by saying this.  If you don't believe me, exercise a
little trust and try doing what I suggest.

And if you want PowerBuilder, you know where to find it.
-- 
Chip Salzenberg               - a.k.a. -                <chip@pobox.com>
           ->  Ask me about Perl training and consulting  <-
                  "We can shower it with neutrons."
              "Or we can do the Neutron Dance!"  // MST3K


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

Date: Tue, 27 Jan 1998 12:37:38 -0600
From: mwendel@marketguide.com
To: mwendel@marketguide.com
Subject: INSERT INTO Informix with Perl DBI
Message-Id: <885925585.259915778@dejanews.com>

When doing an INSERT INTO using Perl DBI is there a limit of the number of
rows that can be inserted at one time?  Or a max of rows x columns you can
do INSERT INTO with a single cursor or subroutine?

I keep getting the following messages when I attempt to do updates to the
tables I orignially populated using INSERT INTO:

SQL: -240: Could not delete a row.
ISAM: -134: ISAM error: no more locks

I know I can correct this problem by dropping and recreating the table,
but that isn't very effective nor good Database management.

Thank you in advance.

Regards,

Michael Wendel

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 27 Jan 1998 12:27:24 -0500
From: charlot@CAM.ORG (Richard Bellavance)
Subject: Re: Multiple copies of the same option on command line
Message-Id: <6al5ds$4qg@stratus.CAM.ORG>

In article <34cdfd41.532121059@news-direct>, Ed Avis <epa@datcon.co.uk> wrote:
>Perhaps the solution is to move to Getopt::long, but I don't really
>understand how to use that module.  (I'm running Perl for Win32, and
>it seems the only way to get documentation on a module is to read the
>source code.)  Any help (especially examples) would be appreciated.
>

I'm sorry I can't help you with your Getop problem, but I can help you read
the module documentation on Win32.  Simply use a command like:

    perldoc Getopt::long

Granted, you'll see the same info you found in the source, but it will be
formatted a little better.

Good luck,
Richard.
-- 
Richard Bellavance -- charlot@cam.org -- http://www.cam.org/~charlot/
    "All along this path I tread  /  My heart betrays my weary head
     With nothing but my love to save / From the cradle to the grave"
                                 (Eric Clapton, "From the cradle")


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

Date: Tue, 27 Jan 1998 19:10:04 +0100
From: Fred <freen@dds.nl>
Subject: Newbie Question (Perl on NT 4.0 and IIS 3.0).
Message-Id: <34CE22FC.7EFB@dds.nl>

Hi,

I'm new to Perl on NT. Sorry to bring up a very basic question.
Would anybody be so kind and tell me how I can get the 
'<!--#exec' command to operate properly on IIS 3.0?

I have been porting Perl scripts to NT and got them to function
fine using the <FORM> and <IMG SRC> html tags.
But I dont't want FORMS and empty images. I just want to 
execute a Perl script. 

Is there a way?

Thanks,
Fred



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

Date: Tue, 27 Jan 1998 10:49:11 -0800
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: newbie: need help with first script -- here it is
Message-Id: <Pine.GSO.3.96.980127104238.22373O-100000@user2.teleport.com>

On Mon, 26 Jan 1998, it was written:

> I had a LOT of trouble trying to find anything that explained basic
> things properly. ie. couldn't get a straight explanation of how to
> write a file ... 

The books in the perlbook manpage are good. I'd recommend the Llama for
this.

> took ages before I sussed out you had to 'select' a
> file handle (which was opened for output). Why didn't any of the
> documentation just say that. 

Because you don't _have_ to select a filehandle. It's primarily a
convenience. 

> Anyway, I got this far without help but I'm stuck.

In what way are you stuck? Perhaps your program isn't doing something you
intended, or perhaps it's doing something you didn't intend. Did your
attempt to run it give you any helpful error messages?

> # kerchop is a program for splitting up large ascii files into bight
> size 
> # segments (in this case, for the web). 

That sounds a bit like the unix split(1) program. 

> 	$outputfile = join ('','>',$prefix,$ticker,$suffix) ;

Generally, this would be written like this, although there's nothing
really wrong with your method. 

    $outputfile = ">$prefix$ticker$suffix";

> 	open ( PIECE , $outputfile ) ;

Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 27 Jan 1998 17:33:27 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Perl (4) and images in the code....
Message-Id: <adelton.885922407@aisa.fi.muni.cz>

-=Falcon=- <Falcon@darkwave.org.uk> writes:

> Lo all...
> 
> Question, using Perl 4 (yes I know it's not 5 but that just makes it
> more interesting), is it possible to import a .JPG file as a line
> (or lines) of text (probably ascii escaped) and then at a later point
> in the code, shove it back onto the browser?

Sure, use for example MIME::Base64 to encode the file, then put it
either into

$JPG = <'EOJPG';

 ... your ascii data here ...

EOJPG

and in the right moment do decode and print to STDOUT.

> (i.e I want to hard-code/place a "Powered By" logo onto the output of a
> page...)

You cannot do that (AFAIK). Please check some good HTML tutor on how
one displays pcitures on page.

Hope this helps,

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: Tue, 27 Jan 1998 18:15:35 +0100
From: FRANCOIS GERT <GERT.FRANCOIS@SD.BE>
Subject: Perl Oracle Long DBI DBD
Message-Id: <34CE1637.F2F@SD.BE>

Hi,

I've got a quite general question:

I developped an application in Perl with an ODBC connection to Oracle -
no problem. I 've got good reasons to "port" my application to the
DBI-DBD solution. DBI and DBD are successfully installed. My
configuration:
- Oracle 7.3
- DBI O.9
- DBD-Oracle: 0.47
- Perl 5.004.02
I want the application run on UNIX (RS6000 - Siemens) and preferrably
also on NT 4.0

I'm learning the DBI - DBD modules, but I could use some help for the
following questions:
- I try to access a table which contains a long field, my query doesn't
return anything (not the long field truncated, nor other (not-long)
fields from that table. -> what happens, how to solve this problem? Can
someone give a code-example?
- In FAQ's and mailinglists, people talk about Oraperl, what's the
difference with DBI-DBD? Does Oraperl exist for NT and UNIX?

Thanks in advance

Gert Frangois
Consultant Zeno
Brouwersvliet 5
2000 Antwerp (Belgium)
email: GERT.FRANCOIS@SD.BE


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

Date: 27 Jan 1998 18:08:04 GMT
From: kisrael@allegro.cs.tufts.edu (Kirk Is)
Subject: print<< into variable?
Message-Id: <6al7q4$gae$1@news3.tufts.edu>

Is there any way to use the print<<__EndOfQuote__
syntax to print into a variable directly, rather 
than to a file handle? (eg STDOUT)

And what is the print<< syntax referred to in the html documentation
that comes with perl? I found the binary shift, but not this kind 
of redirection.


--
Kirk Israel - kisrael@cs.tufts.edu - http://www.alienbill.com
"Notice I didn't say 'TV'. 'TV' is a nickname. Nicknames are for friends.  
 Television is not your friend." --Mr.Show


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

Date: Tue, 27 Jan 1998 10:41:46 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: cpowell1@mindspring.com
Subject: Re: Processing Enter in a form field
Message-Id: <Pine.GSO.3.96.980127103707.22373N-100000@user2.teleport.com>

On Mon, 26 Jan 1998 cpowell1@mindspring.com wrote:

> Normally, when I look at the data file in notepad, the data contains, in
> any place the user has hit Enter, a square (some unprintable end-
> of-line character?) and a <br> (never a <p>). These squares are also at
> the end of every record. 

If your string has some odd character, you can find out which one it is
(in hex) by using something like this:

    print "My string: $_\n";
    print "In hex: ", unpack("H*", $_), "\n";

> After one of my testers had problems, I tested this morning in IE4. 
> When I saved the record, then viewed the generated page, everything was
> screwed up.  

If you're having a problem only with some browsers, the question becomes: 
Are you using the right protocol? If you are, then it's the browser's
fault. If not, it's your code's fault. If you're not sure, you should
check the protocol's spec again. If you're still not sure, you should ask
in a newsgroup about the protocol.

Good luck!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 27 Jan 1998 10:04:48 -0800
From: Nathan Franzen <franzen@pmel.noaa.gov>
Subject: puzzling result from hex()
Message-Id: <Pine.SOL.3.96.980127095401.3500A-100000@corona.pmel.noaa.gov>


I've been trying to use hex and sprintf to convert back and forth
from hex- and decimal-formatted numbers.  So, fine.  But I also want to
use negative numbers (as bad data flags in my files).  I've been trying to
figure out how to swap these back and forth.  I didn't get very far before
running into a puzzling result.

I wonder if anyone else can duplicate my result from another machine, or
explain why I get the result that I do.

Here, type this: (sorry about the long line)

perl -e '$w=sprintf("%04X",-999);$x=hex($w)%2**31;$y=hex($w);$z=$y%2**31;print "$x
$y  $z\n"'

I get the result:

-999  4294966297  2147483647

So, why is $x not equal to $z?  And shouldn't the result of the mod
operator (%) *always* be positive?  So why did $x do what I wanted it to?
And $z didn't.

Thanks for any input,

-Nathan

p.s.

For want it's worth, here's "perl -V":

Summary of my perl5 (5.0 patchlevel 3 subversion 0) configuration:
  Platform:
    osname=solaris, osver=2.5, archname=sun4-solaris
    uname='sunos corona 5.5 generic sun4d sparc sunw,sparcserver-1000 '
    hint=recommended, useposix=true, d_sigaction=define
  Compiler:
    cc='/opt/SUNWspro/bin/cc', optimize='-O', gccversion=
    cppflags='-I/usr/local/include'
    ccflags ='-I/usr/local/include'
    stdchar='unsigned char', d_stdstdio=define, usevfork=false
    voidflags=15, castflags=0, d_casti32=define, d_castneg=define
    intsize=4, alignbytes=8, usemymalloc=y, randbits=15
  Linker and Libraries:
    ld='/opt/SUNWspro/bin/cc', ldflags =' -L/usr/local/lib -L/opt/gnu/lib'
    libpth=/usr/local/lib /opt/gnu/lib /lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldl -lm -lc -lcrypt
    libc=/lib/libc.so, so=so
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=, ccdlflags=' '
    cccdlflags='-Kpic', lddlflags='-G -L/usr/local/lib -L/opt/gnu/lib'

@INC: /opt/lib/perl5.003/sun4-solaris/5.003 /opt/lib/perl5.003
/opt/lib/perl5.003/site_perl/sun4-solaris /opt/lib/perl5.003/site_perl .




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

Date: 27 Jan 1998 18:37:50 GMT
From: enrold@aol.com (ENROLD)
Subject: READ THIS FIRST
Message-Id: <19980127183700.NAA07434@ladder02.news.aol.com>



                                     SPECIAL REPORT!

    Programmer's Report 1998. For all JAVA, C++, C programmers ONLY.
    EXCLUSIVE 1998 report by Applications & Programming Cap-Division, 
    sponsored by ENROLD PRODUCTIONS.  Order your copy Now!
    (You will not obtain this from java sun) 

     NOTE:Not for Eiffel or Ada programmers. For Java, C++, & C
     programmers only.  Send $1.00: 

                                    ENROLD PRODUCTIONS
                                    Department 1
                                    P.O. Box 4324 
                                    Long Island City, NY 11104-0324


    Check or money order must be made payable to Enrold Productions. 
    Orders outside U.S. send $1 U.S. dollar along with name & address. 
    CAUTION: For your protection be sure that your $1 U.S. dollar cannot
    be seen through your envelope. 


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

Date: Tue, 27 Jan 1998 12:15:05 -0500
From: Douglas Wilson <dgwilson@gte.net>
Subject: Re: Remove elements of array1 from array2.
Message-Id: <6al4k9$kul$1@gte1.gte.net>

Shaun Ledford wrote:
> 
> Is there a clean way of removing the elements of hash table 1 ( login
> name ) from hash table 2 ( names and password file )?
> 
> Thanks
> Shaun.

Here's what I've come up with:
#!/usr/local/bin/perl -w
#Remove h2 keys from h1
%h1=qw(a 1 b 2 c 3);
%h2=qw(a a b b);
$str=join("|",keys(%h2));
%h1=map {$_=>$h1{$_}} grep(!/^($str)$/,keys(%h1));
for (keys(%h1)) {
 print "$_=$h1{$_}\n";
}

Hope that helps (or at least I hope someone comes
up with something better),
Douglas Wilson


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

Date: Tue, 27 Jan 1998 17:48:43 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Remove elements of array1 from array2.
Message-Id: <adelton.885923323@aisa.fi.muni.cz>

Shaun Ledford <shaun@ms.com> writes:

> Is there a clean way of removing the elements of hash table 1 ( login
> name ) from hash table 2 ( names and password file )?

for (keys %hash_table_1)
	{ delete $hash_table_2{$_} if exists $hash_table_2{$_}; }

Hope this helps,

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: Tue, 27 Jan 1998 11:46:13 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: Remove elements of array1 from array2.
Message-Id: <34CE2B50.EACFF69D@5sigma.com>

In recent versions of perl,

  delete @hash2{keys %hash1};

will work.

Shaun Ledford wrote:
> 
> Is there a clean way of removing the elements of hash table 1 ( login
> name ) from hash table 2 ( names and password file )?
> 
> Thanks
> Shaun.

-- 
Joseph N. Hall, prop., 5 Sigma Productions       mailto:joseph@5sigma.com
Author, Effective Perl Programming . . . . . http://www.effectiveperl.com
Perl Training  . . . . . . . . . . . . . . .  http://www.perltraining.com


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

Date: Tue, 27 Jan 1998 05:21:58 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: Sending binary files on a Socket. There has to be a better way.
Message-Id: <6ajr19$e0e$1@cyprus.atlantic.net>

According to Worik Macky Stanton <w.stanton@auckland.ac.nz>:
>	my $l = length $data;
>	print $s $l . $EOT . $data; # $EOT is the 'end of transmission' marker

This makes a concatenated string before sending it.  I suggest saying

    print $s $l, $EOT, $data

>	for($i = 0; $i < $l; $i++){
>		$data .= $s->getc;
>	}
>
>I tried using...
>	$bytesGot = sysread $s, $data, $l;
>instead of the last loop using getc, but it didnot work at all.

So close, and yet so far!  Use read().
-- 
Chip Salzenberg               - a.k.a. -                <chip@pobox.com>
           ->  Ask me about Perl training and consulting  <-
                  "We can shower it with neutrons."
              "Or we can do the Neutron Dance!"  // MST3K


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

Date: Tue, 27 Jan 1998 10:05:35 -0600
From: Thomas Lockney <media@organizedmedia.com>
Subject: Re: ssh
Message-Id: <34CE05CF.3350AA4A@organizedmedia.com>

Jarkko Hietaniemi wrote:

> Wheel.  Reinvent.  Not.

Did I fail to mention that I also have to do all this through a socks
firewall? I never have been able to get rsync to work around this
problem. Using the runsocks command doesn't work. However, if I keep
everything within perl and proceed the replication script with the
runsocks "wrapper," it works fine -- for the none ssh systems. Now about
those ssh systems...

-Thomas


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

Date: 27 Jan 1998 17:45:34 +0000
From: Richard Caley <rjc@liddell.cstr.ed.ac.uk>
Subject: Re: Survival Of perl
Message-Id: <eyhzpkh6cap.fsf@liddell.cstr.ed.ac.uk>

In article <8ck9bo5mnn.fsf@gadget.cscaper.com>, Randal Schwartz (rs) writes:

rs> The web *did not exist* for anyone outside of CERN or NCSA until
rs> Mosaic was released publicly,

Er, I was using the web (via the CERN client) well before Mosaic
arived. 

Basides real men use telnet as their browser don't they?

-- 
rjc@cstr.ed.ac.uk			_O_
					 |<



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

Date: Tue, 27 Jan 1998 12:11:10 -0600
From: dg50@chrysler.com
To: tchrist@mox.perl.com
Subject: Re: Survival Of perl
Message-Id: <885924082.173670401@dejanews.com>

In article <6ajes3$o58$1@csnews.cs.colorado.edu>,
  tchrist@mox.perl.com (Tom Christiansen) wrote:

> The vast majority [of] Perl users need threads the way a five-year-old
> needs an Uzi.  Maybe even not that much.

You're right.

An UZI is a 9mm sub-machine gun, so it's subject to the limitations of all
low-velocity, high-mass pistol ammunition fored from a short barrel - most
noteably, a relatively short range, and inacurracy.

A five-year-old can't run very fast, and so needs a greater stand-off
distance to deal with large numbers of attackers and/or the reload time
associated with automatic weapons with a high rate of fire (and thus an
implied high rate of ammo consumption)

However, due to the average five-year-old's strength and mass, a heavy,
high-recoil weapon like an AK-47 or FN-FAL shooting 7.62mm probably isn't
suitable either.

The best tradeoff between weapon weight, range, accuracy, recoil, and
rate of fire would tend to indicate a weapon firing the NATO 5.56mm - I
suggest the Canadian C7, an M16 derivitive that lacks the "we can't
count" 3-shot burst mode of the latest American M16 and so can do
sustained automatic fire. (useful in those sticky temper tantrum
situations)

Just trying to help,

DG

[ Who's post should be taken as seriously as any other post that calls
the "survival" of Perl into question - and who wants threads, 'cause
they're K00l ]

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Tue, 27 Jan 1998 04:43:31 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: Survival Of perl
Message-Id: <6ajop5$drn$1@cyprus.atlantic.net>

According to abigail@fnx.com:
>I agree for 95%. :) 95% of the web is worthless. The idea of the web
>however excites me more than perl. It's just that Netscape and its
>followers has ruined it.

Hm, yes.  Kind of like TV.  And they're both financed by advertising
and corporate public relations.  Coincidence -- or *conspiracy*?!?!
-- 
Chip Salzenberg               - a.k.a. -                <chip@pobox.com>
           ->  Ask me about Perl training and consulting  <-
                  "We can shower it with neutrons."
              "Or we can do the Neutron Dance!"  // MST3K


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

Date: Tue, 27 Jan 1998 17:18:31 GMT
From: rick@marinweb.com (Rick Freeman)
Subject: Re: Text::ParseWords vs. Split
Message-Id: <34d2154f.1963279@nntp2.ba.best.com>

On Mon, 26 Jan 1998 18:20:50 -0800, Tom Phoenix
<rootbeer@teleport.com> wrote:

>On Mon, 26 Jan 1998, Rick Freeman wrote:
>
>> I'm reading files consisting of single lines that look like this
>> 
>> fname::rick::lname::smith::age::22::weight::250
>> 
>> and creating hashes.
>> 
>> I'm trying to determine if I should use split or Text::ParseWords.  Is
>> there an advantage to using the module over doing a simple split?
>
>In what way do the docs for the module (and for split) fail to make it
>clear what the differences are? 

Tom, 

As I'm sure you know, the docs are excellent!  Also, as I'm sure you
know, there is a big difference between reading the docs and having
the kind of grasp of all the issues that comes with experience.  Were
that not so, we could all spend a day reading the docs and become perl
wise ones, like you and a handful of others that contribute regularly
to this group.

I was just hoping to contribute a bit to my perl learning by seeing
what those more experienced than I have to say on this subject.  So
often I learn so much from reading posts on subjects that I thought I
already understood.  It seems a good thing to me to not assume I know
it all, just because I've ready the docs.

I'm very sure it wasn't your intent, but responses like that leave me
with the impression that learners are only welcome here if they are
prepared to "run the gauntlet."

Thanks, Tom, for all past and future aid and guidance.

Rick Freeman
Editor, MarinWeb

M a r i n W e b

Marin's Home on the World Wide Web
http://www.marinweb.com/

98 Main Street #453
Tiburon CA 94920
415-458-3201


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

Date: 27 Jan 1998 18:44:09 +0100
From: Marek.Rouchal@hl.siemens.de (Marek Rouchal)
Subject: Urgent: Perl & Solaris & facls & failure...
Message-Id: <6al6d9$4b3@buffalo.HL.Siemens.DE>
Keywords: Solaris facl getfacl setfacl permission

I'm dead stuck with the following problem: Consider a path like
/opt/foo/bar where bar has a facl (file access control list) set
so that "others" have no read access; user "yodah" (who is
"other" relative to the owner/group of bar) is granted access (rx)
by the facl. A "cd" works ok for yodah in his shell.
When yodah executes "test -r /opt/foo/bar ; echo $?" on the shell
prompt, he gets "0" (true). OTOH,
    perl -e 'print (-r "/opt/foo/bar" ? "yes" : "no");'
gives "no"!
Does anyone know why perl bypasses the facls? Or can somebody
point me to the perl source code where the file tests (-X) are
implemented? Thanks in advance for any help! (System:
SunOS 5.5.1 Generic sun4u sparc SUNW,Ultra-1, perl 5.00305 and
perl5.004_56). BTW, I've searched www.perl.com and the FAQs for
facl - nothing :-(

Regards,

Marek

+--------------------------------------------------------------------+
  Marek Rouchal
  SIEMENS AG               Phone : +49 89/636-25849
  HL CAD SYS               Fax   : +49 89/636-23650
  Balanstr. 73             mailto:Marek.Rouchal@hl.siemens.de
  81541 Muenchen           PCmail:Marek.Rouchal.PC@hl.siemens.de
+--------------------------------------------------------------------+




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

Date: Tue, 27 Jan 1998 09:31:56 +0000
From: Mike Noel <noel@integrityonline.com>
To: rjk@coos.dartmouth.edu
Subject: Re: using packages with perl on Windows (NT)?
Message-Id: <34CDA98C.F7404EA2@integrityonline.com>



Chipmunk wrote:

> [posted and mailed]
>
> Mike Noel wrote:
> >
> > use lib 'c:\\perl';
> >
> > Now my error message is:
> >
> > Can't locate lib.pm in @INC at Makefile.pl line 12.
> > BEGIN failed--compilation aborted at Makefile.pl line 12.
>
> hehe :-)
>
> > Well, lib.pm is in c:\perl on my system.  What do I do next?
>
> How did it end up there?  The default location for the library
> files is c:\perl\lib, not c:\perl.
> Try moving all your libraries down into the lib directory and
> see if that helps.
>
> Chipmunk

  OK.  I tried moving all the pm files into a lib directory and that
didn't help.  I dinked with the INC array as well and finally got
something to work.  It seems that whoever installed the perl libraries
on my system did it flat.  All the pm files are in one directory so when
the script is looking for ExtUtils\makemaker.pm it's not finding it.
After moving a bunch of pm files around I got it to run.

Now I discover that I need a bunch of other modules first. :-)

Lots of fun.

Thanks for your help.

_M_




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

Date: Tue, 27 Jan 1998 13:12:56 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: vcard.vcf
Message-Id: <fl_aggie-2701981312560001@aggie.coaps.fsu.edu>

In article <34CE0773.36E52214@fccj.cc.fl.us>, bill@astro.fccj.cc.fl.us wrote:

+ As far as MIME goes... Tuf
+ :-)

Well, don't be overly surprised if don't get any responses to MIME'd posts...

James

-- 
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>


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

Date: Tue, 27 Jan 1998 05:19:14 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: White Hats and Black
Message-Id: <6ajqs2$dvm$1@cyprus.atlantic.net>

According to Myles Barrett Williams <a@b.c.d>:
>It looks to me like Netscape is just trying to quit the browser
>business without anyone knowing.

More to the point, they're doing whatever it takes to keep Microsoft
from owning the Internet.  It's not altruism, or at least not most of
it.  Rather, it's a recognition that only the free software community
can save the Internet from doom.

"If we do not hang together, we shall surely all hang separately."
-- 
Chip Salzenberg               - a.k.a. -                <chip@pobox.com>
           ->  Ask me about Perl training and consulting  <-
                  "We can shower it with neutrons."
              "Or we can do the Neutron Dance!"  // MST3K


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

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

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