[12270] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5871 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 3 09:21:11 1999

Date: Thu, 3 Jun 99 06:01:32 -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, 3 Jun 1999     Volume: 8 Number: 5871

Today's topics:
    Re: removings " "s from strings <hasant@trabas.co.id>
    Re: Return value from an associative array (Pat Traynor)
        Running expect script from CGI w/ params webmaster@man.amis.com
        sh2perl akluyskens@my-deja.com
    Re: Sorting Problem 2 david_jc_evans@my-deja.com
        Stupid Error 500 [Please Forgive Me... My First Post He spartanic1123@my-deja.com
    Re: Stupid Error 500 [Please Forgive Me... My First Pos <gellyfish@gellyfish.com>
    Re: The artistic license and perl: (Chris Nandor)
    Re: two questions, pls help jbell@263.net
    Re: uninitialized value? what am i doing wrong? <bill@fccj.org>
    Re: uninitialized value? what am i doing wrong? <office@asc.nl>
    Re: Using Perl to call DLL functions sbeaulieu@eprise.com
    Re: Variable concatenation <jdporter@min.net>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Wed, 2 Jun 1999 12:58:17 +0700 (JAVT)
From: Hasanuddin Tamir <hasant@trabas.co.id>
To: comp.lang.perl.misc@list.deja.com
Subject: Re: removings " "s from strings
Message-Id: <Pine.LNX.3.96.990602125540.4228F-100000@borg.intern.trabas.co.id>

On 25 May 1999, Eric The Read wrote:

emschwar] Date: 25 May 1999 11:24:30 -0600
emschwar] From: Eric The Read <emschwar@rmi.net>
emschwar] To: comp.lang.perl.misc@list.deja.com
emschwar] Subject: Re: removings " "s from strings
emschwar] Reply-To: comp.lang.perl.misc@list.deja.com
emschwar] Organization: hardly any to speak of
emschwar] 
emschwar] "Daniel Vesma" <daniel.vesma@thewebtree.com> writes:
emschwar] > > somebody whose name he didn't bother to attribute said:
emschwar] > >   The Perl Frequently Asked Questions (FAQ) are *included* with
emschwar] > >   the perl distribution.
emschwar] > 
emschwar] > Ahh, I don't seem to have them.
emschwar] 
emschwar] Then your distribution is broken.  Find your administrator, and beat them
emschwar] roundly about the head and shoulders until they agree to fix their broken 
emschwar] installation.
emschwar] 
emschwar] Not only is it faster than going to the web every time, but you also get
emschwar] useful search features with perldoc.

It's hard for me to undetstand why people
install Perl without all the docs.
Or remove all the docs after installation.

Save disk space?  What a reason!


-hasan-

+================================================================+
   Hasanuddin Tamir                <hasant@trabas.co.id>           
   TRABAS Technical Dept.          PT Meitraco Bahana Sejahtera   
   IT Solution Provider            http://www.trabas.co.id/        

   Surya Sumantri Blok B1 No. 35   Phone: +62-22-216660
   Setrasari Mall Bandung 40146    Fax  : +62-22-2007633
+================================================================+
     SORRY: I ignore most of attachments but plain text type
+================================================================+

"....bahkan mahasiswa yang memperjuangkan reformasi
 pun masih menempatkan wanita pada posisi inferior."
   --Sudjiwo Tejo (14/12/1998) menanggapi aksi mahasiswa
     yang mengirim ayam betina kepada Jaksa Agung




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

Date: Thu, 03 Jun 1999 11:36:49 GMT
From: pat@ssih.ssih.com (Pat Traynor)
Subject: Re: Return value from an associative array
Message-Id: <slrn7lcq6e.rla.pat@ssih.ssih.com>

In article <j7a4j7.2ch.ln@magna.metronet.com>, Tad McClellan wrote:
>Pat Traynor (pat@ssih.ssih.com) wrote:
>
>: # This is where I'm lost:
>: 	if( $age{"dave"} ) {
>: 	    print "Dave's age is $age{"dave"}\n";
>                  ^                   ^
>                  ^                   ^ there is the end of the string!
>                  ^ there is the start of the string
>
>
>   It won't compile there. Guess that's what you meant with knowing
>   that it is incorrect?
>
>
>   First, you should use single quotes unless you need the
>   "extra" things that double quotes give you
>   (variable interpolation and backslash escapes).

I'm so sorry for bothering you all, and I appreciate everyone's
response.

Actually, the quotes weren't my problem.  My code is considerably more
complicated than the "age" snippet that I included, but I was trying to
simplify the situation as much as I could, and when I typed in the code
into my message there, I simply forgot to put the backslashes in front
of the interior quotes.  I do that a lot, but it's obvious when I try to
run it.

However in the clear-headed morning light, I discovered my problem,
which wasn't included in that code above.

I was reading data from a file and inserting the lines into a hash.
However, I forgot to chop the lines, and the newline at the end was
biting me.  So the hash was probably being initialized something like
this:

    $age{"bob\n"} = "35";
    $age{"mary\n"} = "28";
    if( $age{"bob"} {
        print "Found bob's age\n";
    }
    else {
        print "Error!  Error!\n";
    }

Wonderful language (perl).  I'll be glad once I'm not so new...

Thanks again for your help.

--pat--
--
Pat Traynor
pat@ssih.com


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

Date: Wed, 02 Jun 1999 13:46:37 GMT
From: webmaster@man.amis.com
Subject: Running expect script from CGI w/ params
Message-Id: <7j3cjq$jqu$1@nnrp1.deja.com>

I was wondering if anyone can help me. I have a CGI which will perform
vax authentication. We are on NT and I have installed Expect. My Perl
script looks like this:
***********************************
require "cgi-lib.pl";
&ReadParse(*args);
if ($args{vax_password}) {
	system("script.exp $args{username} \"$args{vax_password}\" ");
	if ($? >> 8) {
		$status = $? >>8;
		if ($status == 6) {
		print "Timeout\n";
		}
		elsif ($status == 5) {
		print "Unexpected exit mode\n";
		}
		elsif ($status == 3) {
		print "Invalid username/password\n";
		}
		elsif ($status == 2) {
		print "Expired VAX password\n";
		}
	}
}
******************************
The expect script I am trying to call is the ff:
set timeout 50
spawn telnet 172.16.101.2
match_max 100000
expect -exact "Username: "
send -- "[lindex $argv 0]\r"
expect -exact "Password: "
send -- "[lindex $argv 1]\r"
expect {
	-exact "\[c"
	{send -- "\[?1;0c";exp_continue}
	-exact "7\[255;255H\[6n8"
	{send -- "\[100;80R";exp_continue}
	"zation failure" 	{exit 3}
	"expired" 		{exit 2}
	"ora-mfg: " 		{send --
"logout:==logout\rlogout/brief\r";exit 0}
	timeout 		{exit 6}
}
expect eof
exit 5
**********************
My expect script works both on dos command shell and Tcl window. My
problem is it's not working from the Perl script. I am expecting an
output depending on the username/passwd combination entered into the
form by the user. This will be compared to the login acct in VAX. This
acct is distinct for every employee so it's kind of useful.
Please help me. Making this work will be all that I need to justify the
project.
Thanks in advance!


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Wed, 02 Jun 1999 12:39:38 GMT
From: akluyskens@my-deja.com
Subject: sh2perl
Message-Id: <7j38m9$ih6$1@nnrp1.deja.com>

I just downloaded the sh2perl program written by :

Randal L. Schwartz, C<merlyn@stonehenge.com>,
C<http://www.stonehenge.com/merlyn/>.

I tried to use it but it seemed buged. I also wonder how it is even
possible to write a sh 2 perl converter (except if it is a joke) because
the way the shell have access to OS commands is completly different than
the way you handle it in perl. Except using the system module I could
not find any other method for automatic conversion. Does someone already
succeeded in using this program?

Thank you for your help.

Regards

Anthoy Kluyskens


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Wed, 02 Jun 1999 08:48:04 GMT
From: david_jc_evans@my-deja.com
Subject: Re: Sorting Problem 2
Message-Id: <7j2r43$eqt$1@nnrp1.deja.com>

[mailed+posted]

@SORTKEYSBYKEY = sort keys %HASH;

@SORTKEYSBYVALUE = sort { $HASH{$a} <=> $HASH{$b} } keys %HASH;

Check: perldoc -f sort.
You can supply any block of code as the criteria for the sort, where
the items to be compared are called $a and $b.

In article <37533f51.5946440@news.inet.co.th>,
  ryanngi@hotmail.com (Ryan Ngi) wrote:
> give
>
> %HASH=( 'aim'=> 9, 'james' =>5 , 'cameron' => 7);
>
> how to sort by values and return keys after sorted.
>
> Here, I suppose for output "aim,cameron,james";
>
> could anyone show me?
>



Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Wed, 02 Jun 1999 04:48:57 GMT
From: spartanic1123@my-deja.com
Subject: Stupid Error 500 [Please Forgive Me... My First Post Here]
Message-Id: <7j2d3n$a4m$1@nnrp1.deja.com>

Hello, I am really, really sorry if a message
like this has been posted recently... Can you be
kind enough to answer this one for me?
Anyway...  My question has to do with the really
really dumb 500 Error that you get with cgi
scripts.  I have an account on Hypermart and I
have created a script that debugs error free (on
my computer), and when I try to use it, I get
this error:

exec of /data1/hypermart.net/spartsdesk/cgi-
bin/view.pl failed, reason: No such file or
directory (errno = 2)
[Tue Jun  1 21:31:42 1999] access to
/data1/hypermart.net/spartsdesk/cgi-bin/view.pl
failed for [Edited: IP], reason: Premature end of
script headers

Any help would be appreciated. =)





Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 3 Jun 1999 13:36:34 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Stupid Error 500 [Please Forgive Me... My First Post Here]
Message-Id: <375676d2@newsread3.dircon.co.uk>

spartanic1123@my-deja.com wrote:
> Hello, I am really, really sorry if a message
> like this has been posted recently... Can you be
> kind enough to answer this one for me?
> Anyway...  My question has to do with the really
> really dumb 500 Error that you get with cgi
> scripts.  I have an account on Hypermart and I
> have created a script that debugs error free (on
> my computer), and when I try to use it, I get
> this error:
> 

Have you read perlfaq9:

=head2 My CGI script runs from the command line but not the browser.   
      (500 Server Error)

> exec of /data1/hypermart.net/spartsdesk/cgi-
> bin/view.pl failed, reason: No such file or
> directory (errno = 2)

What does that say to you ?

Check what you have in your #! line is correct.


/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: Thu, 03 Jun 1999 12:01:14 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: The artistic license and perl:
Message-Id: <pudge-0306990801170001@192.168.0.77>

In article <yl7lpm56bc.fsf@windlord.stanford.edu>, Russ Allbery
<rra@stanford.edu> wrote:

# Chris Nandor <pudge@pobox.com> writes:
# > Russ Allbery <rra@stanford.edu> wrote:
# 
# >> The Artistic License is very badly written from a legal perspective,
# 
# > Thank God.
# 
# >> tends to make lawyers roll their eyes,
# 
# > Praise Allah.
# 
# Anyone who's serious about writing free software and yet ignores the
# actual legal implications of the license that they're using is being
# dangerously foolish.

Wel, legal implications are not ignored, they are just secondary.  For the
most part, to many of us, law is irrelevant.


# This is a tool of our trade.  The license on a free software package is
# it's *protection*.

But the Artistic License does protect, and protect well, for some values
of "protect" (the ones I care about).


# The Artistic License is self-contradictory, full of loopholes

Please show how.  I disagree that there are significant loopholes or
contradictions.


# > I simply disagree.  I don't see where there are signficant ambiguities.
# 
# You seriously cannot see them?  Wow.  Have you actually read the license
# in depth with an eye for strict interpretation by people who have no idea
# what free software is or how it works?  The whole "fair price" bit is a
# glaring example; the imprecision in the language and specification of just
# what's covered under it is another.  There are a whole host more.

I don't find those at all significant.  I don't see any way they can be
usurped to significantly hurt the language or its users.  If you can
demonstrate a way it could, by all means, do so.  But that is all I care
about: protection of the software and its users.  Not protection in the
GNU GPL sense, where they are "protected" by making sure that no one else
can use the software except under their terms, but protected in that
anyone can use the software freely and without fear.

So I understand if you can't say how the AL has caused specific legal
problems.  So if you please, give us examples of how it _could_ cause
problems.

-- 
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])


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

Date: Wed, 02 Jun 1999 01:49:45 GMT
From: jbell@263.net
Subject: Re: two questions, pls help
Message-Id: <7j22jn$6tj$1@nnrp1.deja.com>



> > 1.
> > under unix(not during compilation), how do I change the default @ISA
> > library search paths?
> >
>
> push(@ISA, <some_path>)
>

Sorry I didn't make my point clear.  I mean how to change the default
@ISA for perl, not in a perl program.

> >
> > 2.my perl  files can only run with the command "perl MyFile", how
can I
> > make MyFile itself an excutable(without "perl" in front of it)?
> >
>
> chmod +x MyFile
>

I did that.  It works on some unix systems, but it doesn't work on some
other systems. I'm really confused.

Thanks again!

----
Regards,
Jim B.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 03 Jun 1999 07:25:57 -0400
From: "Bill Jones" <bill@fccj.org>
Subject: Re: uninitialized value? what am i doing wrong?
Message-Id: <37566664.0@usenet.fccj.cc.fl.us>

In article <7j5mi8$hk9$1@zonnetje.NL.net>, "Bastiaan S van den Berg" 
<office@asc.nl> wrote:


> what , about the coke?

You should really say no to snorting, you know?


>>         Running LinuxPPC RedHat 5.0 (Hurricane)
>
> that's pretty cewl :)
> you still use a powermac even though you say it's operating system sucks :)


I use a PowerMac, well, because I can run those
'lesser' OpSys like DOS and OS/2 and Windows NT,
then when I get real tired of it all - Just reboot
and viola!  Linux!  And on a G3/300MHz it kicks!

[WARNING:  Please do not try this on a lesser Intel box.]
-Sneex-  :]
______________________________________________________________________
Bill Jones  Data Security Specialist  http://www.fccj.org/cgi/mail?dss


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

Date: Thu, 3 Jun 1999 14:15:32 +0200
From: "Bastiaan S van den Berg" <office@asc.nl>
Subject: Re: uninitialized value? what am i doing wrong?
Message-Id: <7j5rnn$kic$1@zonnetje.NL.net>

>> what , about the coke?
>
>You should really say no to snorting, you know?


gheghe

*sniph* yeah man , i feel some negative vibes coming from you-ou-ou-ou..

>>>         Running LinuxPPC RedHat 5.0 (Hurricane)
>>
>> that's pretty cewl :)
>> you still use a powermac even though you say it's operating system sucks
:)
>
>
>I use a PowerMac, well, because I can run those
>'lesser' OpSys like DOS and OS/2 and Windows NT,
>then when I get real tired of it all - Just reboot
>and viola!  Linux!  And on a G3/300MHz it kicks!
>
>[WARNING:  Please do not try this on a lesser Intel box.]

tried it , did it , didn't like it , returned to winnt in no.time.at.all(tm)



but billy boy , i have a faint feeling that you might know the answer to the
question that i posted here ..

do you??

cul8r
buZz






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

Date: Wed, 02 Jun 1999 15:06:31 GMT
From: sbeaulieu@eprise.com
Subject: Re: Using Perl to call DLL functions
Message-Id: <7j3h9h$lhh$1@nnrp1.deja.com>

I've been working on this same problem except in NT.  I found some good
sample code at www.oreilly.com in the book Advanced Perl Programming.
They have all the examples from the book online.

>From what everyone else has told me and from what I've
experienced...try looking at the perlxs and perlxstut documentation.
It has some examples there that might help and most likely you will
have to learn how to use the perl utility h2xs or SWIG like was
suggested in a previous post.  Good luck.

Stephen


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Wed, 02 Jun 1999 13:16:32 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Variable concatenation
Message-Id: <7j3ar8$j8u$1@nnrp1.deja.com>

In article <7j30de$g6u$1@nnrp1.deja.com>,
  stupon@geocities.com wrote:
> I was trying to get the following to work:
>
>  $i = 1;
>  $value_{$i}=5; // This is where the problem lies
>  print($value_1);
>
> It prints nothing, where as I was hoping for 5.

You're close, but you need to understand what the curly braces are
really doing in variable names.  Put simply, $foo can be thought of
as a kind of shorthand for ${foo}, where the stuff in the curlies is
a string.  In the case of ${foo}, it's a very simple string, and perl
allows the "bareword" without complaining.  But it could be a more
complex string expression, such as  ${ 'value_' . $i }.
This is what is known as "symbolic references" -- when you have a
string which is used as a variable name by putting it inside ${},
@{}, %{}, etc.  Symbolic references are disallowed when strict 'refs'
is in effect.


> It looks kindof pointless like this, but basically
> it would be in a for loop, and would make things
> much easier if it worked this way.

Programming with maximum strictness (via "use strict") is generally
considered to be A Good Habit To Get Into.  I always do it.
And it would mean you couldn't do these symbolic references they way
you say you want to.  So the next lesson is: whenever you think you
want to use a symbolic reference (e.g. ${"foo"}), consider using a
hash instead.  Instead of having a variable ${"foo"}, which goes into
the symbol table as $foo, you would have a hash variable like
$quux{"foo"}.  It will probably give you all the capability you're
wanting.

Now, you would be well-advised to read the perlref document (type
"perldoc perlref" at you command prompt), and it will clear up
any remaining confusion you have on this topic.

--
John Porter
Put it on a plate, son.  You'll enjoy it more.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 12 Dec 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 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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