[25226] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7471 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 1 18:10:34 2004

Date: Wed, 1 Dec 2004 15:10:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 1 Dec 2004     Volume: 10 Number: 7471

Today's topics:
        Perl Books (Binny V A)
    Re: Perl Books <mritty@gmail.com>
    Re: Perl Books <uri@stemsystems.com>
    Re: Perl Books <richard@zync.co.uk>
    Re: Perl Books <spamtrap@dot-app.org>
    Re: Perl Books (Peter Scott)
        Problem parsing tcpdump tcp[13] output (Romain)
    Re: Problem parsing tcpdump tcp[13] output <tadmc@augustmail.com>
    Re: SMPT Connection Errors <simon.andrews@bbsrc.ac.uk>
    Re: SMPT Connection Errors <tadmc@augustmail.com>
    Re: SMPT Connection Errors <simon.andrews@bbsrc.ac.uk>
        Sockets, gui, threading questions <dad@linux.ban>
    Re: split function syntax (Mostafa)
    Re: suid-perl deprecated... why? <dmcbride@naboo.to.org.no.spam.for.me>
    Re: suid-perl deprecated... why? <nobull@mail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 1 Dec 2004 11:07:05 -0800
From: binnyva@hotmail.com (Binny V A)
Subject: Perl Books
Message-Id: <68cd8f94.0412011107.1f7cd47f@posting.google.com>

Hello Everyone,

I have written a tutorial and would like to suggest a couple of good
Perl related books. But since I have little knowledge of perl books, I
have to come to you for aid. Would you recommend some good books for a
perl beginner.

The said tutorial is available at
http://www.geocities.com/binnyva/code/perl/tutorial/index.html
If you have any comment or suggestions about that tutorial, please
send it to me or post it in this group.

Thanking You,
Binny V A
http://www.geocities.com/binnyva


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

Date: Wed, 01 Dec 2004 19:26:18 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Perl Books
Message-Id: <uVord.3993$8v3.586@trndny08>

"Binny V A" <binnyva@hotmail.com> wrote in message
news:68cd8f94.0412011107.1f7cd47f@posting.google.com...
> Hello Everyone,
>
> I have written a tutorial and would like to suggest a couple of good
> Perl related books. But since I have little knowledge of perl books, I
> have to come to you for aid. Would you recommend some good books for a
> perl beginner.

Have you seen http://learn.perl.org ?
Have you read `perldoc -q books` ?

In general, Programming Perl ("the Camel") is recommended as a
reference, and Learning Perl ("the Llama") and Learning Perl Objects,
References, and Modules are recommended as tutorials.   I, personally,
concur wholeheartedly with those recommendations.

> The said tutorial is available at
> http://www.geocities.com/binnyva/code/perl/tutorial/index.html
> If you have any comment or suggestions about that tutorial, please
> send it to me or post it in this group.

I started reading it, but had to stop after the first few paragraphs of
"Syntax".  Your spelling and grammar need a lot of work.  If I have to
re-read every other sentence just to figure out what the sentence is
saying, I'm not going to be able to learn the information the tutorial
is trying to give.

A few comments on what I did see:

    (Perl) is used as a CGI(Common Gateway Interface) language, Shell
Scripting Language, a programming language

No.  Perl is a programming language.  "CGI language" is rather
nonsensical.  CGI is exactly what it stands for - an interface.  *Any*
language can be used to implement that interface.  "Shell Scripting
language" is simply wrong.

     The #!/usr/local/bin/perl line. Put this in the most top of the
file. Line No 1. What does it do? You sure you want to know? Well it
tells the server that is running the script the locaiton of perl

What server?   What makes you think a server is needed to run perl?  Any
computer can run perl, whether it's used as a server or not.

    The second thing is the semi-colon or ;. Put it at the end of every
statment.

Unneeded in some cases, incorrect in others.  The semicolon is the
statement seperator, it is not needed at the last statement of a block.
Also, you haven't yet defined what a 'statement' is, so the absolute
beginner might believe semicolons are supposed to be placed after the }
of a block, for example.

    Include as many comments as possible

Bad advice, IMO.  Comments should be used to clarify the code.  All too
often code is polluted with statements such as:

$i++;  #increment $i

If the code itself makes it obvious what is happening, it doesn't
require an explicit comment.  A better suggestion might be to comment
blocks or chunks of code, and comment individual statements only when
needed to ensure comprehension.  This of course, is general to
programming, not specific to Perl.

    You can use parentheses(brackets - ')')

Keep your terminology straight:  (parentheses) [brackets] {braces}

    Variables are words which has the '$' symbol at the start.

Imprecise.  Scalar variables start with $.  Other variables (array,
hash, typeglob) do not.


If you can get the spelling and grammar fixed, I might take another look
at the remainder of the tutorial.


Paul Lalli



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

Date: Wed, 01 Dec 2004 19:52:06 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Perl Books
Message-Id: <x7oehdpziy.fsf@mail.sysarch.com>

>>>>> "BVA" == Binny V A <binnyva@hotmail.com> writes:

  BVA> I have written a tutorial and would like to suggest a couple of
  BVA> good Perl related books. But since I have little knowledge of
  BVA> perl books, I have to come to you for aid. Would you recommend
  BVA> some good books for a perl beginner.

odd to have written a perl tutorial but not to have read any decent perl
books. what did you use to teach yourself perl?

  BVA> The said tutorial is available at
  BVA> http://www.geocities.com/binnyva/code/perl/tutorial/index.html
  BVA> If you have any comment or suggestions about that tutorial, please
  BVA> send it to me or post it in this group.

have you searched the web for other tutorials? have you noticed how bad
most of them are? i have read many and less than a handful are accurate
and well written.

ok, let's start with some quick comments.

you have done the common mistake of emphasizing perl is for cgi whereas
most perl coding is not cgi. shell programming is done with shells like
bourne, bash, etc. perl coding is NOT shell coding.

you do not need a 'server' to run perl scripts. that is cgi-centric
again which is wrongheaded.

most unix/linux platforms have perl but in many cases it is an outdated
version so recommending to install a fresh one would be a good idea.

you don't need syntax highlighting to edit perl. any decent text editor
will do. 

1) The #!/usr/local/bin/perl line. Put this in the most top of the
   file. Line No 1. What does it do? You sure you want to know? Well it
   tells the server that is running the script the locaiton of perl. Now
   there is a problem here. Some servers have perl in a different
   location. So you have to find where the perl is located in your
   server. Sometimes it will be #!/usr/bin/perl. Now if you are using
   ActivePerl in Windows, the script will run without this line. But
   just put it in anyway. Make it a habit.

again, perl does NOT NEED a server to run. stop saying that. and that
line is NOT perl syntax or anything to do with perl. it is a function of
unix and how it handles script files of which perl is just one type of
many.

3) Include as many comments as possible. One of the most noted
   disadvangtages of perl is it bad redability. So if you want to
   understand what you wrote today when you read it tommarow, you'd
   better put comments where ever you can. Comments can be inluded with
   the '#' charector. Rather harsh, don't you think? Sorry about the pun
   - could'nt resist. This is the example of a comment...

     # This is a comment
    print "Hell World"; # Everything after the '#' is a comment

spellchecking would help a great deal. that paragraph is
unreadable. maybe some comments would help? as for including plenty of
comments that is misleading. bad code can be written in any language and
all code needs commenting. rule: code is what, comments are why.

and if your world is hell, then i am not sure i want to read your
tutorial. :)

6) Variables are words which has the '$' symbol at the start. They need
   not be declared. But if you want a local scope varible use the
   keyword 'my'. You can learn more about variables later.

bah!! use strict is important and it requires variables to be
declared. and calling lexical scope 'local' and mentioning 'my' is
extremely confusing as there is a 'local' declarator as well.

        The second line shows how to output stuff. But what if we want
        to get user input? $var = ; This statment will get data from
        "Standard Input"(Keboard) and store the data in a variable
        called '$var'. Please not the STDIN must be in capital letters.

where did <STDIN> go? it is in the html source. you should know to
encode < and > as entities.

        The 'my' keyword can be used if you want a local variable. Don't
        know what a local variable is? That's bad. Local variable is the
        variable that exist only in the block that it is defined in.

that is so badly written and misleading.

in the operators section you show all the numeric comparison ops but
only eq and ne for strings. 

you keep trying to make jokes but they are flat and inappropriate. stick
to accuracy and better writing first.

        For Loop

        This has been for long the favorite loop of many programmers I
        know. For, what wouldn't a programmer give for for.

        Syntax
        for(initialization ; condition ; next) {
        body
        }

most decent perl coders rarely use c style for loops. foreach loops are
generally what is wanted as they are usually cleaner, faster and more
direct. but you haven't learned that yet it seems. funny how most
perl tutorial authors on the web don't know perl that well. they learn
some, get to like it and think they should help others but they don't
have the proper skills to write a quality tutorial.

sub plus
{
 ...
}

	No Arguments! Does that mean that perl can't pass arguments? No,
	it don't. The arguments of perl are stored in an array '@_'. Now
	you will be asking what is '@_'. This is a predefined variable
	in perl. These things have special meaning to perl. For example,
	$_ will be used to store the arguments and default input. $!
	will be used for error codes. There are many more predefined
	variables in perl. As a matter of fact, most of the punctuation
	has special meaning for perl. In this case, @_ stores the
	arguments passed to the subroutine.

there is the usual misinformation about $_. why not at least point the
reader to perldoc perlvar? in fact you should always be referring the
reader to the perl docs for more (and accurate) info.

	Wow! Three lines of code, Two pages of explanation. Sometime I
	amaze even myself.

you amaze me all the time. terseness is a good writing skill to
learn. you cover so little of perl in so much verbiage.

        #Get the input
        if ($ENV{REQUEST_METHOD} eq 'POST') {
        read(STDIN, $query_string, $ENV{CONTENT_LENGTH});
        } else {
        $query_string = $ENV{QUERY_STRING};
        }

ok, that is the last straw. do you not even know about CGI.pm? do you
not realize the problems and bugs that homemade cgi parsers have? 


and this straw breaks the camel's back.

        Some places where great Perl Scripts are available...
        http://www.geocities.com/binnyva/code/perl/ 	My own collection of Perl scripts that I wrote over the ages
        http://cgi.resourceindex.com/ 	A huge collection of CGI Resources. CGI programs in perl and other languages.
        http://www.scriptarchive.com/ 	Matt's Script Archive. Offering free CGI scripts to the web community

matt's scripts are an unholy mess and even he says that. 

and i took a gander at your guestbook script. it has too many bugs and
too much bad code to even review. i will leave that to any others here
if they want the fun and glory.


i hope you had fun with this feedback and take it the right way. it
wasn't fun for me as i had to wade through another poor perl tutorial by
another self taught cgi kiddie. please get a some good books on perl and
study them as you have much to learn. using strict and CGI.pm are
probably the first things.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Wed, 01 Dec 2004 20:01:23 +0000
From: Richard Gration <richard@zync.co.uk>
Subject: Re: Perl Books
Message-Id: <pan.2004.12.01.20.01.23.88067@zync.co.uk>

On Wed, 01 Dec 2004 11:07:05 -0800, Binny V A wrote:

> Hello Everyone,
> 
> I have written a tutorial and would like to suggest a couple of good
> Perl related books. But since I have little knowledge of perl books, I
> have to come to you for aid. Would you recommend some good books for a
> perl beginner.
> 
> The said tutorial is available at
> http://www.geocities.com/binnyva/code/perl/tutorial/index.html
> If you have any comment or suggestions about that tutorial, please
> send it to me or post it in this group.
> 
> Thanking You,
> Binny V A
> http://www.geocities.com/binnyva

I'll leave it up to more knowledgeable people to critique your tutorial,
but I wanted to point out that when you mention <STDIN> you should write
it as &gt;STDIN&lt; in web pages.

Rich


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

Date: Wed, 01 Dec 2004 17:21:39 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Perl Books
Message-Id: <MIOdnXmlLLdp3jPcRVn-oA@adelphia.com>

Binny V A wrote:

> The said tutorial is available at

(URL deleted to protect the innocent.)

First off - kudos for the intent. I mean that. You obviously want to 
help people, and that's a good thing.

As for the execution, well, that leaves a lot to be desired. To be 
honest, you - and more importantly, the people you want to help - would 
be better off *learning* more Perl before you attempt to teach anyone. 
Your tutorial is *loaded* with misconceptions, vagaries, and downright 
errors.

If you *really* want to help people, take your tutorial down, and 
replace it with a simple link to <http://learn.perl.org>.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Wed, 01 Dec 2004 23:01:56 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: Perl Books
Message-Id: <E3srd.401988$nl.60244@pd7tw3no>

In article <68cd8f94.0412011107.1f7cd47f@posting.google.com>,
 binnyva@hotmail.com (Binny V A) writes:
>Hello Everyone,
>
>I have written a tutorial and would like to suggest a couple of good
>Perl related books. But since I have little knowledge of perl books, I
>have to come to you for aid. Would you recommend some good books for a
>perl beginner.
>
>The said tutorial is available at
>http://www.geocities.com/binnyva/code/perl/tutorial/index.html
>If you have any comment or suggestions about that tutorial, please
>send it to me or post it in this group.

Wanting to be a writer and to teach Perl are two honorable
goals (notwithstanding retorts of "Well, you *would* say that, 
wouldn't you?" :-).  Unfortunately you have so far to go in
meeting either one that commenting on specific technical
inaccuracies in your opus is not what you need most right now.

First of all, become a lot more proficient in English prose,
or use a language you're more fluent in.  Teaching is an act
of communication and you can't be a good teacher without
communicating well at all levels.
Secondly, learn more about Perl so you don't make so many
technical mistakes.  Get the fundamentals down cold.
Understand the terminology and be ruthless about using
it correctly. 

So before you ask what Perl-related books you should be
recommending, you should be reading a bunch of them,
and in the meantime, replace your tutorial with a
pointer to something that's already acknowledged to be
a useful resource for beginners.

-- 
Peter Scott
http://www.perldebugged.com/
*** NEW *** http://www.perlmedic.com/


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

Date: 1 Dec 2004 08:44:09 -0800
From: romain.lorenzini@laposte.net (Romain)
Subject: Problem parsing tcpdump tcp[13] output
Message-Id: <ed07a1c9.0412010844.32d9bfc3@posting.google.com>

Hi,

I wrote a little script to log the network traffic on a firewall and I
used the tcpdump command.
The script works very well when the command is a classic tcpdump one
like "tcpdump -vvni eth0 host 192.168.0.10 and port 21" but as soon as
I use this command "tcpdump -vvni eth0 tcp[13] == 18" to log only SYN
ACK packets it doesn't work.

Here is the beginning of my script:

#!/usr/bin/perl

$command = 'tcpdump -vvni eth0 tcp[13] == 18'
($pid = open(PIPE,"$command |")) or die "Error: $!\n";
(kill 0, $pid) or die "tcpdump failed\n";
while (defined($line = <PIPE>))
{
     print $line;
}

It doesn't print anything although tcpdump catured packets.
if I set the $command to 'tcpdump -vvni eth0', it works fine.
I supposed that the problem comes from the [] that I use in the
command.

Could anyone help me about that?

Thanks.


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

Date: Wed, 1 Dec 2004 11:22:48 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Problem parsing tcpdump tcp[13] output
Message-Id: <slrncqrvf8.84q.tadmc@magna.augustmail.com>

Romain <romain.lorenzini@laposte.net> wrote:

> Here is the beginning of my script:
> 
> #!/usr/bin/perl


   use warnings;
   use strict;

Ask for all the help you can get!

Doubly so when attempting debugging!


> $command = 'tcpdump -vvni eth0 tcp[13] == 18'
> ($pid = open(PIPE,"$command |")) or die "Error: $!\n";


   syntax error at ./temp line 4, near "("


> It doesn't print anything 


'course not, it doesn't even compile...


> although tcpdump catured packets.


That's a real trick.

An unbelievable trick actually, how can tcpdump captur packets when
the program that launches it doesn't even compile?


> Could anyone help me about that?


Show us your real code.

Have you seen the Posting Guidelines that are posted here frequently?


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


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

Date: Wed, 01 Dec 2004 14:32:51 +0000
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: Re: SMPT Connection Errors
Message-Id: <cokkh9$eon$1@south.jnrs.ja.net>

Simon Andrews wrote:
> I have a strange strange problem setting up some CGI scripts on a new 
> webserver which seem to boil down to the way that different modules 
> connect to an SMTP server.
> 
> I have two scripts which send email.  One uses Mail::Sendmail and the 
> other uses MIME::Lite (which itself uses Net::SMTP for the connection). 
>  The Mail::Sendmail script works fine, both from a commandline and when 
> run as a CGI script.  The MIME::Lite script works fine from the command 
> line, but fails when run as a CGI.

As always, having wrestled with this all morning we find the answer 
within 5 mins of posting to the newsgroups!

It turns out that the reason it was failing was that the webserver user 
didn't have read access to c:\Windows\System32\drivers\etc\protocol 
which is just a list of protocols and port numbers.  I don't know 
exactly where this access attempt comes from (IO::Socket?), but this 
causes the failure even if we explicity set a port number in the 
Net::SMTP connect statement.

Hopefully this will be useful for someone else in the future.

Cheers

Simon.


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

Date: Wed, 1 Dec 2004 08:49:58 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: SMPT Connection Errors
Message-Id: <slrncqrmgm.7op.tadmc@magna.augustmail.com>

Simon Andrews <simon.andrews@bbsrc.ac.uk> wrote:
> 
> other uses MIME::Lite (which itself uses Net::SMTP for the connection). 
                                           ^^^

> use NET::SMTP;
> 
> $NET::SMTP::Debug = 1;
   ^^^


   s/NET/Net/g;   # ??


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


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

Date: Wed, 01 Dec 2004 16:04:13 +0000
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: Re: SMPT Connection Errors
Message-Id: <cokpsi$g98$1@south.jnrs.ja.net>

Tad McClellan wrote:
> Simon Andrews <simon.andrews@bbsrc.ac.uk> wrote:
> 
>>other uses MIME::Lite (which itself uses Net::SMTP for the connection). 
> 
>                                            ^^^
> 
> 
>>use NET::SMTP;
>>
>>$NET::SMTP::Debug = 1;
> 
>    ^^^
> 
>    s/NET/Net/g;   # ??
> 

Hmm. Interesting (and thanks for pointing it out!).

As per my other post that wasn't the actual cause, but I'm surprised it 
didn't mess things up in other ways.  I know that Windows can get away 
with the initial use having the wrong case due to the insensitive file 
system, but I'd have thought I'd have got a "Can't locate method new via 
package..." when I tried to create an object of that class?  Running my 
test script now with NET rather than Net, everything works just fine!?

Simon.






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

Date: Wed, 01 Dec 2004 21:34:31 GMT
From: Dad <dad@linux.ban>
Subject: Sockets, gui, threading questions
Message-Id: <pan.2004.12.01.21.33.53.601811@linux.ban>

I'm really new to Perl so any help or direction on where to look is
welcomed.

I used the server example from the Perl Cookbook and modified it to accept
SNMP trap messages from a Linksys router on UDP port 162, process the
message as inbound, outbound, or unknown and store in the appropriate
mysql database table.  I want to add a gui to the application and display
real-time statistics about traffic, etc.  I used QTDesigner to build the
gui seprately and puic to create the final Perl code.  The gui now works
great but only without the "server" code to get/process the traps.  I'm
using IO::Socket for the network interface.

My problem seems to be the while ($sock->receive($trap,$MAX)) loop is
blocking and the program hangs until a trap comes in and the buttons on
the gui are essentially useless.  Is there a better way to handle incoming
udp messages?  How can I multi-thread so that the gui continues to
function and the displays are updated when a message is received?  Is
there a call-back feature I can use?

Thanks,


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

Date: 1 Dec 2004 11:24:16 -0800
From: mohammad.munir@gmail.com (Mostafa)
Subject: Re: split function syntax
Message-Id: <c3c09310.0412011124.6e6caa03@posting.google.com>

"A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in message news:<Xns95B1E9DD6A3D7asu1cornelledu@132.236.56.8>...
> mohammad.munir@gmail.com (Mostafa) wrote in 
> news:c3c09310.0411301924.236c76ee@posting.google.com:
> 
> I don't see
> 
> use strict;
> use warnings;
> 
> > open(PH,"customers.txt") or die "Cannot open customers.txt: $!\n";
> > while(<PH>) {
> >     chomp;
> >     ($number, $email) = ( split(/\s+/, $_) )[1,2];
> 
> my ($number, $email) = ( split(/\s+/, $_) )[1,2];
> 
> >     
> >     $Phone{$number} = $_;
> >     $Email{$email} = $_;
> > }
> > close(PH);
> 
> ...
> 
> > i couldn't find what does this expression means in split function
> > [1,2]
> 
> ..
> 
> [1,2] is not an argument to the split function. The syntax is for selecting 
> array slices. For example:
> 
> my @ary = qw(a b c d);
> print join "\n", @ary[1,2];
> 
> Now, in the code above, you are creating hash tables that allow you to look 
> up the full record by phone number and email. I am assuming that is what 
> you want but do look at the resulting data structures using Data::Dumper to 
> make sure that is indeed what you want.
> 
> use strict;
> use warnings;
> 
> my %Phone;
> my %Email;
> 
> while(<DATA>) {
>     chomp;
>     my ($number, $email) = ( split /\s+/, $_ )[1,2];
>     $Phone{$number} = $_;
>     $Email{$email} = $_;
> }
> 
> use Data::Dumper;
> print Dumper \%Phone, \%Email;
> 
> __DATA__
> Hunter,Apryl  (810)-555-3029 april@showers.org
> Stewart,Pat  (405)-555-8710 pats@starfleet.co.uk
> Ching,Iris   (305)-555-0919 iching@zen.org
> __END__
> 
> C:\Home> ph
> $VAR1 = {
>  '(405)-555-8710' => 'Stewart,Pat  (405)-555-8710 pats@starfleet.co.uk',
>  '(305)-555-0919' => 'Ching,Iris   (305)-555-0919 iching@zen.org',
>  '(810)-555-3029' => 'Hunter,Apryl  (810)-555-3029 april@showers.org'
> };
> 
> $VAR2 = {
>  'iching@zen.org' => 'Ching,Iris   (305)-555-0919 iching@zen.org',
>  'april@showers.org' => 'Hunter,Apryl  (810)-555-3029 april@showers.org',
>  'pats@starfleet.co.uk' => 'Stewart,Pat  (405)-555-8710 
> pats@starfleet.co.uk'
> };
> 
> 
> > i guess [1,2 ]somehow saves phone and email column to $number and
> > $email , nnow if i want to retrive name from the  .txt file , then
> > should i do like below---
> 
> I still don't see:
> 
> use strict;
> use warnings;
> 
> > open(PH,"customers.txt") or die "Cannot open customers.txt: $!\n";
> > while(<PH>) {
> >     chomp;
> >     ($name, $number, $email) = ( split(/\s+/, $_) )[0,1,2];
> 
> my ($name, $number, $email) = ( split(/\s+/, $_) )[0,1,2];
> 
> Well, this time you don't really need to explicitly select the elements of 
> the returned array.
> 
> >     $Name{name} = $_;
> >     $Phone{$number} = $_;
> >     $Email{$email} = $_;
> > }
> > close(PH);
> 
> ...
> 
> > i did but it's not working
> 
> That is not a helpful description of the problem you are experiencing. have 
> you read the posting guidelines posted here regularly?
> 
> use strict;
> use warnings;
> 
> my %Phone;
> my %Email;
> my %Name;
> 
> while(<DATA>) {
>     chomp;
>     my ($name, $number, $email) = split /\s+/, $_;
>     $Phone{$number} = $_;
>     $Email{$email} = $_;
>     $Name{$name} = $_;
> }
> 
> use Data::Dumper;
> print Dumper \%Phone, \%Email, \%Name;
> 
> __DATA__
> Hunter,Apryl  (810)-555-3029 april@showers.org
> Stewart,Pat  (405)-555-8710 pats@starfleet.co.uk
> Ching,Iris   (305)-555-0919 iching@zen.org
> __END__
> 
> 
> C:\Home\asu1> ph
> $VAR1 = {
>   '(405)-555-8710' => 'Stewart,Pat  (405)-555-8710 pats@starfleet.co.uk',
>   '(305)-555-0919' => 'Ching,Iris   (305)-555-0919 iching@zen.org',
>   '(810)-555-3029' => 'Hunter,Apryl  (810)-555-3029 april@showers.org'
> };
> $VAR2 = {
>   'iching@zen.org' => 'Ching,Iris   (305)-555-0919 iching@zen.org',
>   'april@showers.org' => 'Hunter,Apryl  (810)-555-3029 april@showers.org',
>   'pats@starfleet.co.uk' => 'Stewart,Pat  (405)-555-8710 
> pats@starfleet.co.uk'
> };
> $VAR3 = {
>   'Hunter,Apryl' => 'Hunter,Apryl  (810)-555-3029 april@showers.org',
>   'Ching,Iris' => 'Ching,Iris   (305)-555-0919 iching@zen.org',
>   'Stewart,Pat' => 'Stewart,Pat  (405)-555-8710 pats@starfleet.co.uk'
> };
>  
> > any clue?????????
> 
> Depending on exactly what you are trying to accomplish, you might benefit 
> from using DBI with DBD::CSV.

*************************************************************************
thanks a lot it's working;
but i am getting some warnings , how can i get rid of this warnings .
i also add following codes with my program ---
use strict;

my %Name;
my %Phone;
my %Email;
my $name;
my $number;
my $email;
my $address;


i am giving u the list of warnings for the line 17,18,19. i add those
lines right  below the warnings.------

C:\mp>perl customer.pl
Use of uninitialized value in hash element at customer.pl line 17,
<PH> line 2.
Use of uninitialized value in hash element at customer.pl line 18,
<PH> line 2.
Use of uninitialized value in hash element at customer.pl line 19,
<PH> line 2.
Use of uninitialized value in hash element at customer.pl line 17,
<PH> line 4.
Use of uninitialized value in hash element at customer.pl line 18,
<PH> line 4.
Use of uninitialized value in hash element at customer.pl line 19,
<PH> line 4.
Use of uninitialized value in hash element at customer.pl line 17,
<PH> line 6.
Use of uninitialized value in hash element at customer.pl line 18,
<PH> line 6.
Use of uninitialized value in hash element at customer.pl line 19,
<PH> line 6.
Use of uninitialized value in hash element at customer.pl line 17,
<PH> line 8.
Use of uninitialized value in hash element at customer.pl line 18,
<PH> line 8.
Use of uninitialized value in hash element at customer.pl line 19,
<PH> line 8.
Use of uninitialized value in hash element at customer.pl line 17,
<PH> line 10.

Use of uninitialized value in hash element at customer.pl line 18,
<PH> line 10.

Use of uninitialized value in hash element at customer.pl line 19,
<PH> line 10.

Use of uninitialized value in hash element at customer.pl line 17,
<PH> line 12.

Use of uninitialized value in hash element at customer.pl line 18,
<PH> line 12.

Use of uninitialized value in hash element at customer.pl line 19,
<PH> line 12.

Use of uninitialized value in hash element at customer.pl line 17,
<PH> line 14.

Use of uninitialized value in hash element at customer.pl line 18,
<PH> line 14.

Use of uninitialized value in hash element at customer.pl line 19,
<PH> line 14.

Use of uninitialized value in hash element at customer.pl line 17,
<PH> line 16.

Use of uninitialized value in hash element at customer.pl line 18,
<PH> line 16.

Use of uninitialized value in hash element at customer.pl line 19,
<PH> line 16.

Use of uninitialized value in hash element at customer.pl line 17,
<PH> line 18.

Use of uninitialized value in hash element at customer.pl line 18,
<PH> line 18.

Use of uninitialized value in hash element at customer.pl line 19,
<PH> line 18.

Use of uninitialized value in hash element at customer.pl line 17,
<PH> line 20.

Use of uninitialized value in hash element at customer.pl line 18,
<PH> line 20.

Use of uninitialized value in hash element at customer.pl line 19,
<PH> line 20.

Use of uninitialized value in hash element at customer.pl line 17,
<PH> line 22.

Use of uninitialized value in hash element at customer.pl line 18,
<PH> line 22.

Use of uninitialized value in hash element at customer.pl line 19,
<PH> line 22.
******************************************************************************
17    $Name{$name} = $_;
18    $Phone{$number} = $_;
19    $Email{$email} = $_;
************************************************************************
so how can i initialize this value ---

***************************************************************************


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

Date: Wed, 01 Dec 2004 15:11:41 GMT
From: Darin McBride <dmcbride@naboo.to.org.no.spam.for.me>
Subject: Re: suid-perl deprecated... why?
Message-Id: <Nalrd.399926$nl.140620@pd7tw3no>

chris-usenet@roaima.co.uk wrote:

> Hi folks,
> 
> Perl 5.6.1 from debian "testing" (aka "sarge" for those who like
> to know). According to debian's package installation manager, the
> corresponding suid-perl is deprecated and is likely to be removed in some
> (unspecified) later release.
> 
> perlsec doesn't appear to explain why it's deprecated, although it
> does give the expected dire warnings about writing secure scripts,
> and it offers a sample C wrapper (see the section "Security Bugs").
> Google has a couple of threads from which I infer that it may be related
> to a vulnerability with no-suid filesystems. However, I cannot find any
> concrete details.
> 
> What's the score with perl scripts that really do need to be setuid? Do
> I go back to using a C wrapper for each, or is there a supported secure
> but "more elegant" solution?
> 
> This is perl. I don't want to have to go back to writing C :-P

My solution:

my $apache_user = 'wwwrun';
my $apache = getpwnam($apache_user);

unless ($< == $apache->uid())
{
    if ($ARGV[0])
    {
        print "Gotta run this as the apache user, $apache_user\n";
        exit 1;
    }

    exec(qw(sudo -u), $apache_user, $0, qw(1));
}

And then, in /etc/sudoers, I have:
ALL ALL=(wwwrun) NOPASSWD: /path/to/my/script



This, obviously, allows any user to run this script as one specific
user, and only that specific user.  Since /etc/sudoers is only writable
by root, it means that even if someone manages to hack my script, it
still can't become anyone else.

Feel free to adapt to your own situation which is probably only
tangentially similar to mine ;-)


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

Date: Wed, 1 Dec 2004 21:56:34 -0000
From: "Brian McCauley" <nobull@mail.com>
Subject: Re: suid-perl deprecated... why?
Message-Id: <coledf$36l$1@sun3.bham.ac.uk>

(Sorry for the formatting - I'm having trouble with NNTP clients)

chris-usenet@roaima.co.uk wrote:


Perl 5.6.1 from debian "testing" (aka "sarge" for those who like
to know). According to debian's package installation manager, the
corresponding suid-perl is deprecated and is likely to be removed in some
(unspecified) later release.

perlsec doesn't appear to explain why it's deprecated, although it
does give the expected dire warnings about writing secure scripts,
and it offers a sample C wrapper (see the section "Security Bugs").
Google has a couple of threads from which I infer that it may be related
to a vulnerability with no-suid filesystems. However, I cannot find any
concrete details.


suid scripts are the subject of religious wars.

For what it's worth the the check for no-suid filesystems
(S_fd_on_nosuid_fs()) is certainly present in bleedperl and 5.8.5 and was
also in 5.6.1.

I can't say for certain it works.


What's the score with perl scripts that really do need to be setuid? Do
I go back to using a C wrapper for each, or is there a supported secure
but "more elegant" solution?


There are two ways to do suid scripts.  Both are to some extent a kluge.
One is a user-space kluge the other a kernel-space kludge.  I'm of the
school of thought that says a the user-space kludge is more elegant.




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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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