[16154] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3566 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 10 16:37:58 2000

Date: Mon, 10 Jul 2000 13:37:47 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <963261467-v9-i3566@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 10 Jul 2000     Volume: 9 Number: 3566

Today's topics:
        Help Me Format? <vivekvp@spliced.com>
    Re: Help Me Format? <pap@NOTHEREsotonians.org.uk>
    Re: Help Me Format? (Tad McClellan)
        help required with Expect module.... arran_isme@my-deja.com
        Help someone new <~~~pbarrett@onetelnet.fr~~~>
    Re: Help someone new (Jerome O'Neil)
    Re: Help someone new <care227@attglobal.net>
    Re: Help someone new <jraff@home.com>
    Re: Help someone new (Abigail)
    Re: Help someone new (Craig Berry)
    Re: Help someone new <~~~pbarrett@onetelnet.fr~~~>
    Re: Help someone new (Jerome O'Neil)
    Re: Help someone new <grrr@grrr.net>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sun, 09 Jul 2000 20:47:25 GMT
From: vivekvp <vivekvp@spliced.com>
Subject: Help Me Format?
Message-Id: <8kaocp$br0$1@nnrp1.deja.com>

 Hello,

I have a script that is suppose to take data from a file and
output/format it a certain way.

It will take and IP address and port, separate it in the format:

"xxx.xxx.xxx.xxx"=>"port",

Here is the script:

!#/usr/bin/perl

open(LIST,"ip.txt");

while ($line = <LIST>)
{
        ($a,$b)=split(/:/,$line);

                print "\"$a\"=>\"$b\",";
}

close (LIST);


The data in the ip.txt file looks like this:

147.1.193.193:6346
128.163.174.129:6346
24.64.220.215:6346
209.177.129.224:6346
216.150.213.167:8096
206.221.225.12:6346
134.129.101.212:6346


But after running the script - the data comes out like this:

"147.1.193.193"=>"6346
",
 "128.163.174.129"=>"6346
",
 "24.64.220.215"=>"6346
",
 "209.177.129.224"=>"6346
",
 "216.150.213.167"=>"8096


How do I get it format all on one line?

Thanks for your time!!!

V



--
He who fights and runs away, lives to run another day!


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 10 Jul 2000 00:07:31 +0000
From: "Paul Taylor" <pap@NOTHEREsotonians.org.uk>
Subject: Re: Help Me Format?
Message-Id: <RF7a5.1739$6W.274128@nnrp4.clara.net>

In article <8kaocp$br0$1@nnrp1.deja.com>, vivekvp <vivekvp@spliced.com>
wrote:
>  Hello,
> 
> I have a script that is suppose to take data from a file and
> output/format it a certain way.
> 
> It will take and IP address and port, separate it in the format:
> 
> "xxx.xxx.xxx.xxx"=>"port",
> 
> Here is the script:
> 
> !#/usr/bin/perl
> 
> open(LIST,"ip.txt");
> 
> while ($line = <LIST>)
> {
>         ($a,$b)=split(/:/,$line);
> 
>                 print "\"$a\"=>\"$b\",";
> }
> 
> close (LIST);
> 
> 
> The data in the ip.txt file looks like this:
> 
> 147.1.193.193:6346
> 128.163.174.129:6346
> 24.64.220.215:6346
> 209.177.129.224:6346
> 216.150.213.167:8096
> 206.221.225.12:6346
> 134.129.101.212:6346
> 
> 
> But after running the script - the data comes out like this:
> 
> "147.1.193.193"=>"6346
> ",
>  "128.163.174.129"=>"6346
> ",
>  "24.64.220.215"=>"6346
> ",
>  "209.177.129.224"=>"6346
> ",
>  "216.150.213.167"=>"8096
> 
> 
> How do I get it format all on one line?
> 
> Thanks for your time!!!
> 
> V

The newline at the end of each input line isn't being stripped.

When you do your 'split', it's winding up in the scalar $b.
Hence, when you print $b to some output or other, the newline
is breaking your output over several lines.

You should strip the newline from each line you read in.  

Check out :-

perldoc -f chomp

That should set you on your way.

Regards, 

Pap.


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

Date: Sun, 9 Jul 2000 19:53:37 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Help Me Format?
Message-Id: <slrn8mi441.sd5.tadmc@magna.metronet.com>

On Sun, 09 Jul 2000 20:47:25 GMT, vivekvp <vivekvp@spliced.com> wrote:
> Hello,
>
>I have a script that is suppose to take data from a file and
>output/format it a certain way.
>
>It will take and IP address and port, separate it in the format:
>
>"xxx.xxx.xxx.xxx"=>"port",
>
>Here is the script:
>
>!#/usr/bin/perl
 ^^
 ^^

You have three mistakes by this point in your program!

1) doesn't start with the right magic number

2) warnings not enabled

3) strict pragma not enabled:


   #!/usr/bin/perl -w
   use strict;


>open(LIST,"ip.txt");


You should always, yes *always*, check the return value from open:

   open(LIST, 'ip.txt') || die "could not open 'ip.txt'  $!";


>while ($line = <LIST>)

   while ( my $line = <LIST>)

   chomp $line;          # this is the ANSWER to your queston


>{
>        ($a,$b)=split(/:/,$line);

   my($a,$b) = split(/:/, $line);  # spaces are not a limited resource
                                   # no need to conserve them  :-)

>
>                print "\"$a\"=>\"$b\",";


   print qq/"$a"=>"$b",/;


>}
>
>close (LIST);

>How do I get it format all on one line?


By removing the newline.

   perldoc -f chomp


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Mon, 03 Jul 2000 20:28:25 GMT
From: arran_isme@my-deja.com
Subject: help required with Expect module....
Message-Id: <8jqt0l$3al$1@nnrp1.deja.com>

Hi all,

Im trying to automate an ftp session using a new client which has some
nifty features (so I cant use NET::FTP which I would normally do).  So
I figured since its command line based i could use the expect perl
module to do the job.  I couldnt find any help in the archives and have
got myself slightly confused reading thru the associated perldocs.

Anyways, my script works partially, ie it connects to the ftp server
using the client, and inputs the username and password.  At this point
however, expect seems to read in the password rather than letting it
pass thru to the server to authenticate it, and will eventually time out
(well at least thats what I think it does).

would apreciate feedback via email if possible.

my script is thus:

   $ftp = Expect->spawn("ftpclient ftpserver");
   $ftp->debug(1);
   $ftp->expect(4,"User name");
   print $ftp ("myuser\n");
   $ftp->expect(4,"Password:");
   print $ftp ("mypassword\n");
   $ftp->expect(10,"logged in.");
   print $ftp ("put testfile");
   print $ftp ("quit");
   $ftp->expect(10,"bye");


debug output (snipping some of the start):
        Match string: 'User name'
        After match string: ' (Enter = username)? '
Returning from expect successfully.
Accumulator: ' (Enter = username)? '
Beginning expect from spawn id(3).
Accumulator: ' (Enter = username)? '
Expect timeout time: 4 seconds.
expect: Pty=spawn id(3), time=962655618, loop_time=4
expect: handle spawn id(3) ready.
myusername                    <=====presenting username
expect: handle spawn id(3) ready.
331 Password required for myusername.
expect: handle spawn id(3) ready.
Password: Matched pattern 1 ('Password:')!
        Before match string: ' (Enter = myusername)? myusername\r\n331
Password required
 for arranp.\r\r\n'
        Match string: 'Password:'
        After match string: ' '
Returning from expect successfully.
Accumulator: ' '
Beginning expect from spawn id(3).
Accumulator: ' '
Expect timeout time: 10 seconds.
expect: Pty=spawn id(3), time=962655618, loop_time=10
expect: handle spawn id(3) ready.
mypassword               <==========presenting password
Returning from expect unsuccessfully. Error: 1:TIMEOUT.
Accumulator: ' mypassword\r\n'
Beginning expect from spawn id(3).
Accumulator: ' mypassword\r\n'
Expect timeout time: 10 seconds.
expect: Pty=spawn id(3), time=962655628, loop_time=10
Returning from expect unsuccessfully. Error: 1:TIMEOUT.
Accumulator: ' mypassword\r\n'



thanks

Arran
arranp@datamail.co.nz
My opinions my own etc etc etc


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 5 Jul 2000 21:41:50 +0200
From: "Peter Barrett" <~~~pbarrett@onetelnet.fr~~~>
Subject: Help someone new
Message-Id: <39638fd9@news-uk.onetel.net.uk>

Okay, I'm totally new to Perl, I want to write some simple CGI's .. I've
read through tutorials and browsed a book or two, but before I start, I need
to ask some questions.

The majority of the stuff out there speaks of UNIX. For example, I'm told
"If you don't know where the Perl interpreter on your system is, just type:
which perl" -- Now the problem is that I don't log in from a school or
university. I'm just an average guy logging in to a standard dial up ISP. I
don't /have/ a command line in which I can type 'which perl' from, let alone
see if it works. Hence my questions, and pardon my ignorance ...

Will an ordinary ISP that gives it subscribers a bit of web space allow them
to use CGI scripts? And would they have a Perl interpreter sitting around
for me to use? It just so happens I live in France and its hard to get any
technical staff on line. Sales persons yes, that is easy. But /real/
technical assistance? You've got to be kidding. :) So hence I thought I
would air my questions here and just see what you say, then I'll contact my
ISP again with a bit more information under my belt.

I also see commands like "chmod 755". Is this UNIX too? Sorry for the really
inept questions, but I've never seen, used or touched a UNIX machine in my
life so am pretty clueless. With the only communication channels to my ISP
that I know of being a browser window or ftp to my website, what chance do I
have of pulling off CGI at all? How on earth would I send commands like
chmod 755 etc.?

Learning the language doesn't look too bad, my problem is just knowing how
to set it up on my ISP in the first place.

Thank you in advance for any comments,
Peter Barrett.










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

Date: Wed, 05 Jul 2000 21:58:22 GMT
From: jerome@activeindexing.com (Jerome O'Neil)
Subject: Re: Help someone new
Message-Id: <2cO85.338$vG4.159840@news.uswest.net>

"Peter Barrett" <~~~pbarrett@onetelnet.fr~~~> elucidates:

> Will an ordinary ISP that gives it subscribers a bit of web space allow them
> to use CGI scripts?

Why not ask them and see?

> And would they have a Perl interpreter sitting around
> for me to use? 

Why not ask them and see?

> It just so happens I live in France and its hard to get any
> technical staff on line. Sales persons yes, that is easy. But /real/
> technical assistance? You've got to be kidding. :) 

I would bet there is more than one ISP in France.

> Learning the language doesn't look too bad, my problem is just knowing how
> to set it up on my ISP in the first place.

You should ask your ISP for assistance.

HTH!


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

Date: Wed, 05 Jul 2000 16:18:14 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Help someone new
Message-Id: <39639806.73773DBE@attglobal.net>

Peter Barrett wrote:
> 
> Okay, I'm totally new to Perl, I want to write some simple CGI's .. I've
> read through tutorials and browsed a book or two, but before I start, I need
> to ask some questions.

You should read the books you've browsed before you ask questions.
You will probably answer most of them by reading, and when you have
one which needs asking, you'll be able to ask a better question.
 
> Will an ordinary ISP that gives it subscribers a bit of web space allow them
> to use CGI scripts? And would they have a Perl interpreter sitting around
> for me to use? 

Its best to contact the ISP first and then come here with questions.
No one here can aswer questions about how your ISP sets up accounts 
and/or what they allow you to access.

> I also see commands like "chmod 755". Is this UNIX too? Sorry for the really
> inept questions, but I've never seen, used or touched a UNIX machine in my
> life so am pretty clueless. 

Many FTP clients allow commands like chmod, CuteFTP, I recall as being 
one.  If your ISP has given you space on a Unix server, take the time
to familiarize yourself with your environment before starting to write
programs for it.  You might also look into changing to a hosting 
company that allows telnet access.  It will make things alot easier.

> Learning the language doesn't look too bad, my problem is just knowing how
> to set it up on my ISP in the first place.

You might also want to take a few minutes in one of the newusers
groups here on Usenet.  There you might learn about making off topic
postings and why it is bad.  As is, this post was 100% off topic and
did not belong in this NG.


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

Date: Wed, 05 Jul 2000 20:50:19 GMT
From: "jraff" <jraff@home.com>
Subject: Re: Help someone new
Message-Id: <fcN85.48665$lU5.316536@news1.rdc1.nj.home.com>

Try this one;
http://free.prohosting.com/

I've used it for perl testing and such.
Just don't try to send e-mail. I got it working, but not without a LOT of
grief.
-----------------------------------------
"Peter Barrett" <~~~pbarrett@onetelnet.fr~~~> wrote in message
news:39638fd9@news-uk.onetel.net.uk...
> Okay, I'm totally new to Perl, I want to write some simple CGI's .. I've
> read through tutorials and browsed a book or two, but before I start, I
need
> to ask some questions.
>
> The majority of the stuff out there speaks of UNIX. For example, I'm told
> "If you don't know where the Perl interpreter on your system is, just
type:
> which perl" -- Now the problem is that I don't log in from a school or
> university. I'm just an average guy logging in to a standard dial up ISP.
I
> don't /have/ a command line in which I can type 'which perl' from, let
alone
> see if it works. Hence my questions, and pardon my ignorance ...
>
> Will an ordinary ISP that gives it subscribers a bit of web space allow
them
> to use CGI scripts? And would they have a Perl interpreter sitting around
> for me to use? It just so happens I live in France and its hard to get any
> technical staff on line. Sales persons yes, that is easy. But /real/
> technical assistance? You've got to be kidding. :) So hence I thought I
> would air my questions here and just see what you say, then I'll contact
my
> ISP again with a bit more information under my belt.
>
> I also see commands like "chmod 755". Is this UNIX too? Sorry for the
really
> inept questions, but I've never seen, used or touched a UNIX machine in my
> life so am pretty clueless. With the only communication channels to my ISP
> that I know of being a browser window or ftp to my website, what chance do
I
> have of pulling off CGI at all? How on earth would I send commands like
> chmod 755 etc.?
>
> Learning the language doesn't look too bad, my problem is just knowing how
> to set it up on my ISP in the first place.
>
> Thank you in advance for any comments,
> Peter Barrett.
>
>
>
>
>
>
>
>




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

Date: 05 Jul 2000 19:03:01 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Help someone new
Message-Id: <slrn8m7gmq.ibb.abigail@alexandra.delanet.com>

Peter Barrett (~~~pbarrett@onetelnet.fr~~~) wrote on MMD September
MCMXCIII in <URL:news:39638fd9@news-uk.onetel.net.uk>:
:) 
:) Learning the language doesn't look too bad, my problem is just knowing how
:) to set it up on my ISP in the first place.

That is a question only your ISP can answer. There's no "typical ISP", all
ISPs have different policies. 

However, if you want to run CGI programs, and don't get shell access, I
recommend you find a different ISP.



Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
 .qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
 .qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'


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

Date: Wed, 05 Jul 2000 23:20:27 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Help someone new
Message-Id: <sm7glrcngas156@corp.supernews.com>

Jerome O'Neil (jerome@activeindexing.com) wrote:
: I would bet there is more than one ISP in France.

And, what's more, there's no reason to limit yourself to French ISPs.  For
dialup access, yes; but you can get a cheap no-dialup (telnet/ftp only)
account anywhere in the world for less than $20/month.

-- 
   |   Craig Berry - http://www.cinenet.net/users/cberry/home.html
 --*--  "Beauty and strength, leaping laughter and delicious
   |   languor, force and fire, are of us." - Liber AL II:20


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

Date: Thu, 6 Jul 2000 23:01:02 +0200
From: "Peter Barrett" <~~~pbarrett@onetelnet.fr~~~>
Subject: Re: Help someone new
Message-Id: <3964f3e5@news-uk.onetel.net.uk>

Thank you for your answers, they were most helpful.

As for your latter point about being 100% off topic, I can only say that I
see no FAQ stating this newsgroup's topic limits, indeed I point you to the
word 'misc' at the end of comp.lang.perl.misc. I consider my posting was
definately a 'miscellaneous issue'. There are only a finite number of Perl
related newgroups available and I had to pick one so as to get access to an
audience that would have knowledge of the subject that I had problems with.
Indeed perhaps you could tell me which newsgroup would be better suited to
such a question? If you feel strongly about the off topic issue I suggest
you and perhaps others of the group, create the FAQ so that the unintiated
can know in advance, before posting. I admit this reply is off topic,
however one does have the right to defend one's self and one's motives
against a complaint aired in public.

Though I would like to thank once again for the other information, I
appreciate it.

Yours sincerely,
Peter Barrett.




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

Date: Fri, 07 Jul 2000 00:33:01 GMT
From: jerome@activeindexing.com (Jerome O'Neil)
Subject: Re: Help someone new
Message-Id: <1z995.758$di5.178265@news.uswest.net>

"Peter Barrett" <~~~pbarrett@onetelnet.fr~~~> elucidates:
> Thank you for your answers, they were most helpful.
> 
> As for your latter point about being 100% off topic, I can only say that I
> see no FAQ stating this newsgroup's topic limits, indeed I point you to the
> word 'misc' at the end of comp.lang.perl.misc. I consider my posting was
> definately a 'miscellaneous issue'.

Then perhaps you should have asked it in alt.quilting.misc, or
rec.sport.nascar.misc, where it would have been more on topic.

> There are only a finite number of Perl
> related newgroups available and I had to pick one so as to get access to an
> audience that would have knowledge of the subject that I had problems with.

Your problem was with your ISP, not with Perl.

> Indeed perhaps you could tell me which newsgroup would be better suited to
> such a question? 

Your ISP's customer support services.

> If you feel strongly about the off topic issue I suggest
> you and perhaps others of the group, create the FAQ so that the unintiated
> can know in advance, before posting. 

There is a FAQ.  However, the comp.lang.perl name of the newsgroup
should be enough to prevent such pedantry.

> Though I would like to thank once again for the other information, I
> appreciate it.

You're welcome!


> 
> Yours sincerely,
> Peter Barrett.
> 
> 


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

Date: Fri, 07 Jul 2000 11:23:54 -0700
From: Grrr <grrr@grrr.net>
Subject: Re: Help someone new
Message-Id: <3966203A.7F336D25@grrr.net>

Peter Barrett wrote:
[ snip ]

> ...and I had to pick one so as to get access to an
> audience that would have knowledge of the subject that I had problems with.

You just proved you didn't read news.announce.newusers, lurk for a while and
read existing posts, or even surf to www.perl.com just to see what would
happen...


< grrr >




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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 3566
**************************************


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