[23316] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5536 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Sep 21 11:05:50 2003

Date: Sun, 21 Sep 2003 08:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 21 Sep 2003     Volume: 10 Number: 5536

Today's topics:
        Appropriate File Permissions <ducott_99@yahoo.com>
    Re: Appropriate File Permissions <pilsl_usenet@goldfisch.at>
    Re: Appropriate File Permissions <me@privacy.net>
    Re: Appropriate File Permissions (Tad McClellan)
        debugger not steping into the sub <samj2@austarmetro.com.au>
    Re: debugger not steping into the sub <pilsl_usenet@goldfisch.at>
    Re: Difficulty removing element from array (David Efflandt)
    Re: Difficulty removing element from array <REMOVEsdnCAPS@comcast.net>
    Re: Intermediate Page w/ CGI Script (Randal L. Schwartz)
        passing values to a sub <samj2@austarmetro.com.au>
    Re: passing values to a sub <tassilo.parseval@rwth-aachen.de>
    Re: passing values to a sub (Sam Holden)
    Re: passing values to a sub <samj2@austarmetro.com.au>
    Re: passing values to a sub <samj2@austarmetro.com.au>
    Re: passing values to a sub <pilsl_usenet@goldfisch.at>
    Re: passing values to a sub (Tad McClellan)
    Re: passing values to a sub <samj2@austarmetro.com.au>
    Re: passing values to a sub <ict@eh.org>
    Re: passing values to a sub <rm@no-mail.com>
    Re: passing values to a sub <thens@NOSPAMti.com>
    Re: program not being run <kevin@vaildc.net>
    Re: program not being run <samj2@austarmetro.com.au>
    Re: program not being run <me@privacy.net>
    Re: Sending html mail with inline images <zentara@highstream.net>
    Re: troubles with unicode (incorrect sorting and basic  <flavell@ph.gla.ac.uk>
    Re: Trying to change ID value in @array <kuujinbo@hotmail.com>
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 21 Sep 2003 04:30:15 GMT
From: "Robert TV" <ducott_99@yahoo.com>
Subject: Appropriate File Permissions
Message-Id: <rP9bb.1005355$3C2.22450831@news3.calgary.shaw.ca>

Hello,

Several of my scripts read and write data to text files located the cgi-bin
or my server. I'm curious as to the correct file permissions I should be
using. No outside sources access the text file data, only the perl scripts
in thier directory. I have been using 755 for all my perl scripts and 777
for all text files that get read and written to. I ask these questions for
security purposes, as some of the text files contain sensitive data. Should
I be using 755 for perl scripts and 777 for the text files? Thanx!

RTV




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

Date: Sun, 21 Sep 2003 11:05:07 +0200
From: peter pilsl <pilsl_usenet@goldfisch.at>
Subject: Re: Appropriate File Permissions
Message-Id: <3f6d6a7f$1@e-post.inode.at>

Robert TV wrote:

> Hello,
> 
> Several of my scripts read and write data to text files located the
> cgi-bin or my server. I'm curious as to the correct file permissions I
> should be using. No outside sources access the text file data, only the
> perl scripts in thier directory. I have been using 755 for all my perl
> scripts and 777 for all text files that get read and written to. I ask
> these questions for security purposes, as some of the text files contain
> sensitive data. Should I be using 755 for perl scripts and 777 for the
> text files? Thanx!
> 

depends on your server.  777 for files with sensitive data is rarely a good 
idea. 
If only the http-server needs to access the textfiles I would let your 
http-server create the files and give 600 as permission. (textfiles dont 
need to be executed).

peter


-- 
peter pilsl
pilsl_usenet@goldfisch.at
http://www.goldfisch.at



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

Date: Sun, 21 Sep 2003 19:46:51 +1200
From: "Tintin" <me@privacy.net>
Subject: Re: Appropriate File Permissions
Message-Id: <bkjq4p$2d96a$2@ID-172104.news.uni-berlin.de>


"Robert TV" <ducott_99@yahoo.com> wrote in message
news:rP9bb.1005355$3C2.22450831@news3.calgary.shaw.ca...
> Hello,
>
> Several of my scripts read and write data to text files located the
cgi-bin
> or my server. I'm curious as to the correct file permissions I should be
> using. No outside sources access the text file data, only the perl scripts
> in thier directory. I have been using 755 for all my perl scripts and 777
> for all text files that get read and written to. I ask these questions for
> security purposes, as some of the text files contain sensitive data.
Should
> I be using 755 for perl scripts and 777 for the text files? Thanx!

Would the content of your question be any different if you had written the
scripts in python?




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

Date: Sun, 21 Sep 2003 06:45:09 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Appropriate File Permissions
Message-Id: <slrnbmr3q5.1hm.tadmc@magna.augustmail.com>

Robert TV <ducott_99@yahoo.com> wrote:

> Several of my scripts read and write data to text files located the cgi-bin
> or my server. I'm curious as to the correct file permissions I should be
> using. No outside sources access the text file data, only the perl scripts
> in thier directory. I have been using 755 for all my perl scripts and 777
> for all text files that get read and written to. I ask these questions for
> security purposes, as some of the text files contain sensitive data. Should
> I be using 755 for perl scripts and 777 for the text files? Thanx!


What is your Perl question?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sun, 21 Sep 2003 08:37:15 GMT
From: Sam <samj2@austarmetro.com.au>
Subject: debugger not steping into the sub
Message-Id: <3F6D6508.6060205@austarmetro.com.au>

Hello
$perl -d test.pl
DB<19> n
main::(perl.pl:44) 
		@Mk = ma_calc(@field, $Mk);
DB<19>
it goes not actually going into my subroutine which is at line 55 of my 
perl.pl

any hint is appriciated.
thanks



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

Date: Sun, 21 Sep 2003 11:01:46 +0200
From: peter pilsl <pilsl_usenet@goldfisch.at>
Subject: Re: debugger not steping into the sub
Message-Id: <3f6d69b9@e-post.inode.at>

Sam wrote:

> Hello
> $perl -d test.pl
> DB<19> n
> main::(perl.pl:44)
> @Mk = ma_calc(@field, $Mk);
> DB<19>
> it goes not actually going into my subroutine which is at line 55 of my
> perl.pl
> 
> any hint is appriciated.
> thanks
> 


try s instead of n if you want to enter subroutines .. 

s [expr]    Single step.  Executes until the beginning of another 
statement, descending into subroutine calls.  If an
                   expression is supplied that includes function calls, it 
too will be single-stepped.
 
n [expr]    Next.  Executes over subroutine calls, until the beginning of 
the next statement.  If an expression is sup­
                   plied that includes function calls, those functions will 
be executed with stops before each statement.

peter

-- 
peter pilsl
pilsl_usenet@goldfisch.at
http://www.goldfisch.at



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

Date: Sun, 21 Sep 2003 14:03:23 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Difficulty removing element from array
Message-Id: <slrnbmrbta.nim.efflandt@typhoon.xnet.com>

On Sun, 21 Sep 2003 02:07:53 GMT, Robert TV <ducott_99@yahoo.com> wrote:
> Hi ... I'm loosing much hair over this array element removal problem i'm
> having. I will describe my setup. I have a web form with a single text box
> named "recipient" ... on submit, the data is passed to my delete.pl script.
> In the same folder, there is a text file called "addresses.txt" This file
> contains the following data:
> 
> Gerald Genry|jdpower@assoc.com
> Gerry Smith|smith@yahoo.com
> Robert TV|rtv@shaw.ca
> Terry Valcourt|mail@viator.com
> Dan Perterson|simple@yahoo.com
> James Smiley|happy@hotmail.com
> 
> These are names and email addresses separated by a "|" symbol. Here is the
> delete script I have so for that is not functional:
> 
> #############
> 
> #!/usr/bin/perl
> 
> use Fcntl qw(:DEFAULT :flock);
> use CGI::Carp qw(fatalsToBrowser);
> 
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> @pairs = split(/&/, $buffer);
> foreach $pair (@pairs) {
>   ($name, $value) = split(/=/, $pair);
>   $value =~ tr/+/ /;
>   $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>   $form{$name} = $value;
> }
> 
> open (ADDRESSES, "<addresses.txt") or die "Can't open file: $!";

If you are trying to remove a recipient from the stored list, try this 
here instead (filter as you read them):

while (<ADDRESSES>) {
    chomp;
    push @entrys,$_ if $_ ne $form{'recipient'};
}
close ADDRESSES;
# add code to print them back to addresses.txt
print "Content-type: text/plain\n\n";
foreach (@entrys) { print "$_\n"; }

-- 
David Efflandt - All spam ignored  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Sun, 21 Sep 2003 09:37:39 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Difficulty removing element from array
Message-Id: <Xns93FD6C1231797sdn.comcast@206.127.4.25>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

"Robert TV" <ducott_99@yahoo.com> wrote in
news:ZJ7bb.1004827$3C2.22437921@news3.calgary.shaw.ca: 

> Hi ... I'm loosing much hair over this array element removal problem
> i'm having. I will describe my setup. I have a web form with a single
> text box named "recipient" ... on submit, the data is passed to my
> delete.pl script. In the same folder, there is a text file called
> "addresses.txt" This file contains the following data:
> 
> Gerald Genry|jdpower@assoc.com
> Gerry Smith|smith@yahoo.com
> Robert TV|rtv@shaw.ca
> Terry Valcourt|mail@viator.com
> Dan Perterson|simple@yahoo.com
> James Smiley|happy@hotmail.com
> 
> These are names and email addresses separated by a "|" symbol. Here is
> the delete script I have so for that is not functional:
> 
> #############
> 
> #!/usr/bin/perl
> 
> use Fcntl qw(:DEFAULT :flock);
> use CGI::Carp qw(fatalsToBrowser);
> 
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> @pairs = split(/&/, $buffer);
> foreach $pair (@pairs) {
>   ($name, $value) = split(/=/, $pair);
>   $value =~ tr/+/ /;
>   $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>   $form{$name} = $value;
> }
> 
> open (ADDRESSES, "<addresses.txt") or die "Can't open file: $!";
>   @entrys=<ADDRESSES>;
> close(ADDRESSES);
> 
> foreach $entry (@entrys) {
>   $count++;
>   if ($entry eq $form{'recipient'}) {
>     $count--;
>     splice(@entrys, $count, 1);
>   }
> }
> 
> print  @entrys;
> exit;
> 
> #############
> 
> If I type "Terry Valcourt|mail@viator.com" in the web form and submit,
> nothing happens. When @entrys prints, it still contains all entires
> read from the text file. It's the same for any name and email address
> grouping entered. To match the form input to the array element, I used
> the "eq" operator. It is my belief that there is no successful
> matching because there is a "\n" at the end of each "$entry".

It is my belief that there is no successful matching because you're 
trying to match the recipient to the whole line of name and | and email 
address and newline.  But that's only a guess, because you don't tell us 
what the "recipient" field contains.

I would strongly recommend that you reorganize your program.  You have 
boilerplate code that parses out the CGI parameters.  I'll bet you have 
that same code in every one of your CGI programs.  Why not move it to a 
subroutine, so you don't have to copy/paste so much code everywhere?  
Also, if you should need to change the code, you'll only need to change 
it once in the subroutine module, rather than in every single program 
file.  (There are at least three bugs in the code that you posted).

Better yet, use the CGI.pm module.  Why code by hand that which has been 
done excellently already?

Also, I would encourage you to move your database handling code to a 
module.  You have a simple flat-file database model.  Why not write 
routines to add, update, delete, and look up records, and then just 
invoke those routines everywhere you use the database, instead of writing 
and debugging code to do those functions everywhere?

- -- 
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBP223oWPeouIeTNHoEQJe7gCbBNy05RZ8J68eNxedjWSCYD4UhakAn0jI
H9lR+mcMVWcqdF3ymaNHIuMQ
=j0++
-----END PGP SIGNATURE-----


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

Date: Sun, 21 Sep 2003 12:46:39 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Intermediate Page w/ CGI Script
Message-Id: <5cf344d37f742e2d263b6d8c70753437@news.teranews.com>

>>>>> "Pete" == Pete Butler <pmbutler@attbi.com> writes:

Pete> I'm working on a CGI application using Perl.  My client would like the
Pete> user to get some sort of "processing request" page immediately upon
Pete> clicking "Submit", because right now, he occasionally sees a delay
Pete> between clicking "Submit" and getting the results page.  Is there a
Pete> good way to do this with CGI?

I've done this in a couple of different ways...

<http://www.stonehenge.com/merlyn/WebTechniques/col20.html>
<http://www.stonehenge.com/merlyn/LinuxMag/col39.html>

print "Just another Perl hacker," # and web whacker...
-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Sun, 21 Sep 2003 09:22:48 GMT
From: Sam <samj2@austarmetro.com.au>
Subject: passing values to a sub
Message-Id: <3F6D6FB5.9010008@austarmetro.com.au>

Hello
I am not able to pass the values I want to a sub.


@Mm = ma_calc(@MyArr,$Mm);


sub ma_calc {
   my @list = shift;
   my $value = shift;
 ...

regards



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

Date: 21 Sep 2003 09:35:22 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: passing values to a sub
Message-Id: <bkjrcq$fab$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Sam:

> Hello
> I am not able to pass the values I want to a sub.
> 
> 
> @Mm = ma_calc(@MyArr,$Mm);
> 
> 
> sub ma_calc {
>    my @list = shift;
>    my $value = shift;
> ...

You have to be aware that any arguments you pass to Perl-subroutines are
flattened to one large indistinguishable list. So

    @a = (1, 2, 3),
    $s = "foobar";
    func(@a, $s);

    # roughly becomes

    func(1, 2, 3, "foobar");

That means you have no real chance to separate the arguments again. You
have two choices. You can choose a clever calling-convention where
scalars are passed before list-alike data-structures. However, you can
only pass one list that way (it has to be at the end of the argument
list for obvious reasons):

    ma_calc( $Mn, @MyArr );
    sub ma_calc {
        my ($value, @list) = @_;
        ...
    }

Or you always pass scalar values. An array therefore would have to be
passed as a reference:

    ma_calc ( \@MyArr, $Mn );
    sub ma_calc {
        my @list    = @{ shift }; # dereference
        my $value   = shift;
        ...
    }

It works just the same for hashes since they are flattened to a list as
well:

    ma_calc (\@MyArr, \%MyHash );
    sub ma_calc {
        my @list = @{ shift };
        my @hash = %{ shift };
        ...
    }

All the above is explained in detail in 'perldoc perlsub'.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: 21 Sep 2003 10:07:30 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: passing values to a sub
Message-Id: <slrnbmqu32.q4v.sholden@flexal.cs.usyd.edu.au>

On Sun, 21 Sep 2003 09:22:48 GMT, Sam <samj2@austarmetro.com.au> wrote:
> Hello
> I am not able to pass the values I want to a sub.
> 
> 
> @Mm = ma_calc(@MyArr,$Mm);
> 
> 
> sub ma_calc {
>    my @list = shift;
>    my $value = shift;
> ...

Maybe instead of asking abunch of questions which are all answered
in the documentation that comes with perl, you could try reading
the documentation.

-- 
Sam Holden



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

Date: Sun, 21 Sep 2003 10:37:41 GMT
From: Sam <samj2@austarmetro.com.au>
Subject: Re: passing values to a sub
Message-Id: <3F6D8143.5080708@austarmetro.com.au>

Sam Holden wrote:
> On Sun, 21 Sep 2003 09:22:48 GMT, Sam <samj2@austarmetro.com.au> wrote:
> 
>>Hello
>>I am not able to pass the values I want to a sub.
>>
>>
>>@Mm = ma_calc(@MyArr,$Mm);
>>
>>
>>sub ma_calc {
>>   my @list = shift;
>>   my $value = shift;
>>...
> 
> 
> Maybe instead of asking abunch of questions which are all answered
> in the documentation that comes with perl, you could try reading
> the documentation.
> 

I wish one day it would be easy to ready those documents, every time I 
open one to read it I get lost between terms, refrences to terms, 
location ...etc. I some times which that it would contain hyperlinks for 
abstract terms as well so it would be easy to understand for a slow to 
understand person like me.




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

Date: Sun, 21 Sep 2003 10:42:02 GMT
From: Sam <samj2@austarmetro.com.au>
Subject: Re: passing values to a sub
Message-Id: <3F6D8248.8020601@austarmetro.com.au>

Tassilo v. Parseval wrote:
> Also sprach Sam:
> 
> 
>>Hello
>>I am not able to pass the values I want to a sub.
>>
>>
>>@Mm = ma_calc(@MyArr,$Mm);
>>
>>
>>sub ma_calc {
>>   my @list = shift;
>>   my $value = shift;
>>...
> 
> 
> You have to be aware that any arguments you pass to Perl-subroutines are
> flattened to one large indistinguishable list. So
> 
>     @a = (1, 2, 3),
>     $s = "foobar";
>     func(@a, $s);
> 
>     # roughly becomes
> 
>     func(1, 2, 3, "foobar");
> 
> That means you have no real chance to separate the arguments again. You
> have two choices. You can choose a clever calling-convention where
> scalars are passed before list-alike data-structures. However, you can
> only pass one list that way (it has to be at the end of the argument
> list for obvious reasons):
> 
>     ma_calc( $Mn, @MyArr );
>     sub ma_calc {
>         my ($value, @list) = @_;
>         ...
>     }
> 
> Or you always pass scalar values. An array therefore would have to be
> passed as a reference:
> 
>     ma_calc ( \@MyArr, $Mn );
>     sub ma_calc {
>         my @list    = @{ shift }; # dereference
>         my $value   = shift;
>         ...
>     }
> 
> It works just the same for hashes since they are flattened to a list as
> well:
> 
>     ma_calc (\@MyArr, \%MyHash );
>     sub ma_calc {
>         my @list = @{ shift };
>         my @hash = %{ shift };
>         ...
>     }
> 
> All the above is explained in detail in 'perldoc perlsub'.
> 
> Tassilo

@Mm = ma_calc ( \@MyArr, $Mm );

sub ma_calc {
   my @list = @{ shift };
   my $value = shift;

Ambiguous use of @{shift} resolved to @shift at 
/home/usrname/perl-programs/test.pl line 56.
Global symbol "@shift" requires explicit package name at 
/home/usrname/perl-programs/test.pl line 56.
Execution of /home/usrname/perl-programs/test.pl aborted due to 
compilation errors.

Compilation exited abnormally with code 255 at Sun Sep 21 20:46:29



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

Date: Sun, 21 Sep 2003 13:23:18 +0200
From: peter pilsl <pilsl_usenet@goldfisch.at>
Subject: Re: passing values to a sub
Message-Id: <3f6d8ae4@e-post.inode.at>

Sam wrote:

> 
> I wish one day it would be easy to ready those documents, every time I
> open one to read it I get lost between terms, refrences to terms,
> location ...etc. I some times which that it would contain hyperlinks for
> abstract terms as well so it would be easy to understand for a slow to
> understand person like me.
> 

Imho its very hard to learn a new programming-language without 
purchasing/borrowing/stealing a book that helps you along with the first 
steps. Later the mentioned docs will be extremely useful, but by now a book 
that guides you through the most basic tasks might help you to avoid lot of 
lost time and frustration. 

best,
peter


-- 
peter pilsl
pilsl_usenet@goldfisch.at
http://www.goldfisch.at



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

Date: Sun, 21 Sep 2003 06:44:19 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: passing values to a sub
Message-Id: <slrnbmr3oj.1hm.tadmc@magna.augustmail.com>

Sam <samj2@austarmetro.com.au> wrote:
> Sam Holden wrote:
>> On Sun, 21 Sep 2003 09:22:48 GMT, Sam <samj2@austarmetro.com.au> wrote:


>>>@Mm = ma_calc(@MyArr,$Mm);
>>>
>>>
>>>sub ma_calc {
>>>   my @list = shift;
>>>   my $value = shift;
>>>...
>> 
>> 
>> Maybe instead of asking abunch of questions which are all answered
>> in the documentation that comes with perl, you could try reading
>> the documentation.
>> 
> 
> I wish one day it would be easy to ready those documents, every time I 
> open one to read it I get lost between terms, refrences to terms, 
> location ...etc. 


If you don't understand the docs, post a question about the docs
here, and we will help explain it for you. Note that this is
different from not reading the docs...  :-)


> I some times which that it would contain hyperlinks for 
> abstract terms as well so it would be easy to understand for a slow to 
> understand person like me.


The second paragraph in the docs for subroutines answers your question:

   perldoc perlsub

   ...
   The Perl model for function call and return values is simple: all
   functions are passed as parameters one single flat list of scalars, and
   all functions likewise return to their caller one single flat list of
   scalars.  Any arrays or hashes in these call and return lists will
   collapse, losing their identities


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sun, 21 Sep 2003 11:49:26 GMT
From: Sam <samj2@austarmetro.com.au>
Subject: Re: passing values to a sub
Message-Id: <3F6D9215.8070502@austarmetro.com.au>

peter pilsl wrote:
> Sam wrote:
> 
> 
>>I wish one day it would be easy to ready those documents, every time I
>>open one to read it I get lost between terms, refrences to terms,
>>location ...etc. I some times which that it would contain hyperlinks for
>>abstract terms as well so it would be easy to understand for a slow to
>>understand person like me.
>>
> 
> 
> Imho its very hard to learn a new programming-language without 
> purchasing/borrowing/stealing a book that helps you along with the first 
> steps. Later the mentioned docs will be extremely useful, but by now a book 
> that guides you through the most basic tasks might help you to avoid lot of 
> lost time and frustration. 
> 
> best,
> peter
> 
> 

thanks Peter
I had Element of programming with Perl, also have Programming Perl, as 
well as a copy of Perl in a nutshell, I just need some practical 
examples and doing it myself to make it more of a reality instead of 
theory and some examples. it will come be time. as new as I am to linux 
3 month only with life wasted to M$ it is a steep curve but not 
impossible. thanks for all the help I get from all of you.



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

Date: 21 Sep 2003 23:41:56 +1000
From: Iain Truskett <ict@eh.org>
Subject: Re: passing values to a sub
Message-Id: <slrnbmrb2t.4eh.ict@dellah.org>

* Sam <samj2@austarmetro.com.au>:

[...]
> I wish one day it would be easy to ready those documents,
> every time I open one to read it I get lost between terms,
> refrences to terms, location ...etc. I some times which
> that it would contain hyperlinks for abstract terms as
> well so it would be easy to understand for a slow to
> understand person like me.

When you do get around to understanding the docs, remember
what you just wrote and contribute back to the perl project
by revising the documentation to make it easier for people
to understand.



cheers,
-- 
Iain.                                          <http://eh.org/~koschei/>


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

Date: Sun, 21 Sep 2003 23:04:04 +0900
From: Roy Marteen <rm@no-mail.com>
Subject: Re: passing values to a sub
Message-Id: <20030921230404.79005006.rm@no-mail.com>

On Sun, 21 Sep 2003 10:42:02 GMT
Sam <samj2@austarmetro.com.au> wrote:

> sub ma_calc {
>    my @list = @{ shift };
>    my $value = shift;
> 
> Ambiguous use of @{shift} resolved to @shift at 
> /home/usrname/perl-programs/test.pl line 56.
> Global symbol "@shift" requires explicit package name at 
> /home/usrname/perl-programs/test.pl line 56.

Try:

sub ma_calc {
  my @list = @{ shift() };
  my $value = shift();
  ...
}



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

Date: Sun, 21 Sep 2003 19:34:02 +0530
From: Thens <thens@NOSPAMti.com>
Subject: Re: passing values to a sub
Message-Id: <20030921193402.6ccd784a.thens@NOSPAMti.com>

On Sun, 21 Sep 2003 10:42:02 GMT
Sam <samj2@austarmetro.com.au> wrote:

# @Mm = ma_calc ( \@MyArr, $Mm );
# 
# sub ma_calc {
#    my @list = @{ shift };
#    my $value = shift;
# 
# Ambiguous use of @{shift} resolved to @shift at 
# /home/usrname/perl-programs/test.pl line 56.
# Global symbol "@shift" requires explicit package name at 
# /home/usrname/perl-programs/test.pl line 56.

  Here the perl interpreter is confused as to whether it is a variable
name or a code to be executed. You can help it by adding a + in front.

    my @list = @{ +shift };

Regards,
Thens.


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

Date: Sun, 21 Sep 2003 00:21:29 -0400
From: Kevin Michael Vail <kevin@vaildc.net>
Subject: Re: program not being run
Message-Id: <kevin-BCEADF.00212921092003@news101.his.com>

In article <3F6D2292.9070505@austarmetro.com.au>,
 Sam <samj2@austarmetro.com.au> wrote:

> Sam wrote:
>  > Hello
>  > I am getting this message every thim I try
>  > <gdb> s
>  > The program is not being run.
>  >
>  > thanks
>  >
> 
> This GDB was configured as "i386-linux"..."/home/username/perl/test.pl":
> not in exeutable format: File format not recognized
> (gdb)s
> The program is not being run
> (gdb)
> 

I don't believe you can use gdb to debug a Perl script.  Look at perldoc 
perldebug to find out how to debug a script.
-- 
Kevin Michael Vail | Dogbert: That's circular reasoning.
kevin@vaildc.net   | Dilbert: I prefer to think of it as no loose ends.
http://www.vaildc.net/kevin/


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

Date: Sun, 21 Sep 2003 04:37:06 GMT
From: Sam <samj2@austarmetro.com.au>
Subject: Re: program not being run
Message-Id: <3F6D2CB9.2080205@austarmetro.com.au>

Kevin Michael Vail wrote:
 > In article <3F6D2292.9070505@austarmetro.com.au>,
 >  Sam <samj2@austarmetro.com.au> wrote:
 >
 >
 >>Sam wrote:
 >> > Hello
 >> > I am getting this message every thim I try
 >> > <gdb> s
 >> > The program is not being run.
 >> >
 >> > thanks
 >> >
 >>
 >>This GDB was configured as "i386-linux"..."/home/username/perl/test.pl":
 >>not in exeutable format: File format not recognized
 >>(gdb)s
 >>The program is not being run
 >>(gdb)
 >>
 >
 >
 > I don't believe you can use gdb to debug a Perl script.  Look at perldoc
 > perldebug to find out how to debug a script.

it was not my choice, I just click on the tool bar of xemacs that says
Debug. am I getting at it the wrong way?




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

Date: Sun, 21 Sep 2003 19:45:47 +1200
From: "Tintin" <me@privacy.net>
Subject: Re: program not being run
Message-Id: <bkjq3a$2d96a$1@ID-172104.news.uni-berlin.de>


"Sam" <samj2@austarmetro.com.au> wrote in message
news:3F6D2292.9070505@austarmetro.com.au...
> Sam wrote:
>  > Hello
>  > I am getting this message every thim I try
>  > <gdb> s
>  > The program is not being run.
>  >
>  > thanks
>  >
>
> This GDB was configured as "i386-linux"..."/home/username/perl/test.pl":
> not in exeutable format: File format not recognized
> (gdb)s
> The program is not being run
> (gdb)

gdb is for debugging binary files.

To debug Perl programs, use (not surprisingly) the Perl debugger.

perldoc -q debug




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

Date: Sun, 21 Sep 2003 10:44:08 -0400
From: zentara <zentara@highstream.net>
Subject: Re: Sending html mail with inline images
Message-Id: <5bdrmvoppcr864t1f3f5edfjc8pl7docrg@4ax.com>

On Sat, 20 Sep 2003 20:50:28 +0200, "Sebastian Scholz"
<mcbass@lightsphere.de> wrote:

>Hi
>
> I wrote a small script to send a html mail with inline images using
>mail:sender. Sending html mails without the images works fine, but when I
>try to have the images sent with the mail I only get the html and the image
>attached to the mail. I used the example for the mail:sender module but that
>did not work. Here is my code snippet :

To have the image shown inline, you need to use the ID tag and cid: tag
as demonstrated in the script below. You probably can work them into
your code.

#!/usr/bin/perl
use MIME::Lite;                 # Standard CPAN module
my $from_address = 'selector@selectorweb.com';
my $to_address = 'selector@selectorweb.com';

my $subject = 'MIME test - HTML with image';
my $mime_type = 'multipart/related';

# Create the message headers
my $mime_msg = MIME::Lite->new(
   From => $from_address,
   To   => $to_address,
   Subject => $subject,
   Type => $mime_type
   )
  or die "Error creating MIME body: $!\n";

# Attach the HTML content
my $message_body = '<html><body><H3>Hello world!
   <img src="cid:myid.gif"></H3></body></html>';

$mime_msg->attach(Type => 'text/html',
                  Data => $message_body);

# Attach the image
$mime_msg->attach(
   Type => 'image/gif',
   Id => 'myid.gif',
   Encoding => 'base64',
   Path => 'pikachu.jpg');

$mime_msg->send;

__END__


Our body's 20 milligrams of beta radioactive Potassium 40
emit about 340 million neutrinos per day, which go at
lightspeed to the ends of the universe!..even thru the earth. 


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

Date: Sun, 21 Sep 2003 15:05:49 +0100
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: troubles with unicode (incorrect sorting and basic understandingproblems)
Message-Id: <Pine.LNX.4.53.0309211451380.15155@ppepc56.ph.gla.ac.uk>


On Sat, Sep 20, peter pilsl inscribed on the eternal scroll:

> Ok - I tried to reduce the problem and wrote a small script that simply
> reads the content from a webform (textarea), lowercase and sorts the lines
> in it and print out the sorted line.

Excellent, thanks.

I'm only sorry that I don't have a complete answer for you, but I
think I've found a number of issues that are relevant and may help to
get you there.

First some general issues:

- earlier versions of CGI.pm evidently deliver the data as just a
bunch of bytes, even when they're utf-8.  One doesn't notice this
externally, since the bytes get written as-is to standard output and
HTML gets told they are utf-8 and so the expected correct result is
seen on the browser.  However, any actual character-level processing
that's attempted in Perl will be unsuccessful, since it will treat
each byte as an individual character.

I got this effect for example with the CGI.pm version that came with a
recent ActivePerl (CGI.pm 2.81, I think it was).  Make a practice of
printing $CGI::VERSION somewhere in your output, so that you know
what you're getting.  Install a private copy of a recent version and
access it via "use lib ...".

According to the notes, http://stein.cshl.org/WWW/software/CGI/#new ,
it appears that this was changed in version 2.92, and one can (if
using a recent enough Perl, of course) expect to get genuine Perl
Unicode characters as data now in this situation.  I haven't had time
to go into the details of how it relates to your specific problem,
sorry.

The other issue is that while reading about Unicode support in
relation to "use locale", there are dark hints that there may be
problems.  Since you're evidently aiming to do language-specific
sorting (though quite what it'll do when you ask it to sort Greek and
Cyrillic according to German language rules, I don't know), you
may want to follow this up, at least if you get problems:
http://www.perldoc.com/perl5.8.0/pod/perlunicode.html#Locales

> My question now is : How can I tell perl (inside my script) that it should
> use "german" conventions for sorting and lowering. Is this possible at all ?

The answer to that appears to be
http://www.perldoc.com/perl5.8.0/pod/perllocale.html#The-use-locale-pragma
(et seq.)

> The source is below. If I also print out the length of the string using the
> length()-function I notice that each german umlaut  increases length() by
> two,

This is indicative, I think, that you are using an older version of
CGI.pm.  Your particular character occupies 2 bytes in utf-8, and Perl
is counting two bytes instead of one character.  Worse, if I try to
lower-case the *character* then it can produce garbage, because Perl
attempts to lower-case each byte separately!

> Maybe I should need to transform the text that is delivered by CGI-module
> to "real" unicode before or whatever.

I think that would be a possible workaround[1], but I think the
correct solution should be to use a corrected version of CGI.pm.
However, I haven't had time to try it, so YMMV.

[1] See e.g my reply in message-id
<Pine.LNX.4.53.0308081113340.31714@lxplus007.cern.ch>
(that should give the spammers something to chomp on - it's amusing
how often I see mail logs refusing mail addressed to a usenet
message-id  ;-)

Remember, if you decide to actually use Perl's native unicode support,
then you will need to apply the :utf8 layer to your output also (for
standard output, which is already open, you'd do that with binmode).

Now to some specifics...

> #!/usr/local/bin/perl
>
> use CGI;
> use strict;

(I don't see 'warnings'...  myself I'd tend also to use -T as a matter
of course in any CGI situation.)

> my $query = new CGI;
> my $charset = 'UTF-8';
>
> # print header
> print  $query->header(-type=>'text/html;
> charset='.$charset),

CGI.pm recognises -charset=>$charset here, you don't need to smuggle
it into the -type: see http://stein.cshl.org/WWW/software/CGI/#header

> $query->start_html(-title=>'Unicodetest');

This is rather unfortunate: looking at the generated result (with that
earlier version of CGI.pm, anyway), it seems it defaults to iso-8859-1
for its (X)HTML generation, and indeed this is what the documentation
says it will do:

 The -encoding argument can be used to specify the character set for
 XHTML. It defaults to iso-8859-1 if not specified.

Why it wouldn't default to the charset that you supplied on the
header() call, I don't know.


Does that get you any further?  I hope so.  Must get back to worm
fighting now, there's a bunch of bogus virus alerts hitting our users
from misguided virus scanners out there, as a byproduct of the current
worm crop (Gibe-F a.k.a Swen).  It's always less work to catch those
bogus alerts in the mailer, than to calm the distressed users down
afterwards.  The worms themselves are by comparison easy to block!

-- 

(I thought my usual news server had recovered, but it seems not, so
I'm repeating the posting here:  again, my apologies to the group if
the earlier posting attempt shows up after all...)


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

Date: Sun, 21 Sep 2003 12:52:39 +0900
From: ko <kuujinbo@hotmail.com>
Subject: Re: Trying to change ID value in @array
Message-Id: <bkj7d1$8l2$1@pin3.tky.plala.or.jp>

Robert TV wrote:

[snip]
> $inputentry = $form{'recipient'};

In your previous post, you had:

	$inputentry = "$form{'name'}|$form{'email'}";

This will be the key entry for the hash you build next. Add that 
statement back to build/use the hash.

> chomp foreach @entrys;
> @entrys{@entrys} = ();
> delete $entrys{$inputentry} if exists $entrys{$inputentry};

The elements of @entrys are not affected. They only supply the keys to 
the hash, except for the entry that you want to delete. So you have to 
write the *hash* to your textfile, *not* the array:

print join("\n", keys %entrys);

I probably should have called the hash something other than '%entrys' 
to make it clearer...

HTH - keith



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

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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.

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 V10 Issue 5536
***************************************


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