[13705] in Perl-Users-Digest
Perl-Users Digest, Issue: 1115 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 19 08:07:22 1999
Date: Tue, 19 Oct 1999 05:05:12 -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: <940334712-v9-i1115@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 19 Oct 1999 Volume: 9 Number: 1115
Today's topics:
Re: %hash array problem <kwantm@convertis.nl>
Re: %hash array problem <simon@cybersoft.com.sg>
Re: %hash array problem (Martien Verbruggen)
Re: *MY* answer... emlyn_a@my-deja.com
A question on Perl/Tk <lishans@evitech.fi>
Re: Baffled! (Martien Verbruggen)
Decoding mime attchs (jpg) in email <af778NOafSPAM@iname.com.invalid>
eBay <nospam@nospam.com>
Re: equiv. of nice & simple ksh syntax (Martien Verbruggen)
Re: fork (????) (Martien Verbruggen)
Re: fork (????) (Martien Verbruggen)
Re: help with substrings (Martien Verbruggen)
Re: help with substrings <gellyfish@gellyfish.com>
How to get the system time?? <abel.almazan@ogilvyinteractive.es>
Re: How to get the system time?? <gellyfish@gellyfish.com>
Re: isa_defs on Solaris2.6 <Luc.Veillon@orleans.ird.fr>
Re: making a directory <lr@hpl.hp.com>
Re: Monitoring the clicks of a banner <ceesbakk@casema.nl>
NT: How can I change drive within a perl script? <r.j.yates@open.ac.uk>
Re: Oh god! Not another Net::ftp question! <ralawrence@my-deja.com>
Perl and IIS issues w/ Perl [USE] command. <apage.net@usa.net>
PerlScript for ASP installation problem <devx@hotmail.com>
Re: Q: Truncate string length? emlyn_a@my-deja.com
Re: Q: Truncate string length? emlyn_a@my-deja.com
Re: Q: Truncate string length? emlyn_a@my-deja.com
Re: send mail in perl (Martien Verbruggen)
Re: sorting arrays (Martien Verbruggen)
Re: WHATS WRONG WITH THIS CODE? (Martien Verbruggen)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 19 Oct 1999 12:11:21 +0200
From: "Marc" <kwantm@convertis.nl>
Subject: Re: %hash array problem
Message-Id: <7uhg9a$2m2l$1@buty.wanadoo.nl>
Hi,
Very nice try to confuse me but I have solved the problem on my own.
foreach (keys %mydata)
{ print "$_ = $mydata{$_}\n"; }
this is the proper solution.
Abigail <abigail@delanet.com> wrote in message
news:slrn80oac8.e3k.abigail@alexandra.delanet.com...
> Marc (kwantm@convertis.nl) wrote on MMCCXL September MCMXCIII in
> <URL:news:7uh85i$25ns$1@buty.wanadoo.nl>:
> -- I have got a problem. I have a hash array named %users I do not know
what is
> -- in it and I want to print it. The following code I use:
> --
> -- foreach (keys(%users)
> -- { print (" ");
> -- }
> --
> -- What must I use in the print statement to print the contents of the
hash
> -- array???
>
>
> Look up the description of foreach, and you'll be enlightned.
>
>
> Abigail
> --
> $_ = "\x3C\x3C\x45\x4F\x54"; s/<<EOT/<<EOT/e; print;
> Just another Perl Hacker
> EOT
>
>
> -----------== Posted via Newsfeeds.Com, Uncensored Usenet News
==----------
> http://www.newsfeeds.com The Largest Usenet Servers in the World!
> ------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers
==-----
------------------------------
Date: Tue, 19 Oct 1999 18:22:28 +0800
From: "simon" <simon@cybersoft.com.sg>
Subject: Re: %hash array problem
Message-Id: <7uhgi7$spc$1@violet.singnet.com.sg>
Try this
foreach $key ( keys %users ) {
print "$key=$users{$key}";
}
This will print out the key and its corresponding value pair.
Marc <kwantm@convertis.nl> wrote in message
news:7uh85i$25ns$1@buty.wanadoo.nl...
> I have got a problem. I have a hash array named %users I do not know what
is
> in it and I want to print it. The following code I use:
>
> foreach (keys(%users)
> { print (" ");
> }
>
> What must I use in the print statement to print the contents of the hash
> array???
>
> Marc de Kwant
> (www.netvisit.nl)
>
>
------------------------------
Date: 19 Oct 1999 11:36:58 GMT
From: mgjv@wobbie.heliotrope.home (Martien Verbruggen)
Subject: Re: %hash array problem
Message-Id: <slrn80olvc.1vv.mgjv@wobbie.heliotrope.home>
[Please, put your answer _after_ the text you quote. This is not
Jeopardy]
On Tue, 19 Oct 1999 12:11:21 +0200,
Marc <kwantm@convertis.nl> wrote:
>
> Abigail <abigail@delanet.com> wrote in message
> news:slrn80oac8.e3k.abigail@alexandra.delanet.com...
> > Marc (kwantm@convertis.nl) wrote on MMCCXL September MCMXCIII in
> > <URL:news:7uh85i$25ns$1@buty.wanadoo.nl>:
> > -- I have got a problem. I have a hash array named %users I do not know
> what is
> > -- in it and I want to print it. The following code I use:
> > --
> > -- foreach (keys(%users)
> > -- { print (" ");
> > -- }
> > --
> > -- What must I use in the print statement to print the contents of the
> hash
> > -- array???
> >
> >
> > Look up the description of foreach, and you'll be enlightned.
> Very nice try to confuse me but I have solved the problem on my own.
She was not trying to confuse you. She was telling you to read the
documentation. In a friendly way. You've got a terribly thin skin, don't
you?
> foreach (keys %mydata)
> { print "$_ = $mydata{$_}\n"; }
>
> this is the proper solution.
For certain values of 'proper'.
Martien
--
Martien Verbruggen |
Interactive Media Division | I took an IQ test and the results
Commercial Dynamics Pty. Ltd. | were negative.
NSW, Australia |
------------------------------
Date: Tue, 19 Oct 1999 11:51:31 GMT
From: emlyn_a@my-deja.com
Subject: Re: *MY* answer...
Message-Id: <7uhm00$5hv$1@nnrp1.deja.com>
In article <spamfree-1810991239460001@d7.metropolis.net.au>,
spamfree@metropolis.net.au (Henry Penninkilampi) wrote:
> In article <7udpdp$jsc$1@nnrp1.deja.com>, emlyn_a@my-deja.com wrote:
>
> > I've encountered no other problems, although limiting the field
length
> > to 400 characters is something I'm working
>
> Is there some sort of issue with 400 characters?
>
> Henry.
>
No, not an issue, just a requirement: I only want the field to be
written with a maximum of 400 characters (I tell the users this before
they fill out a form), otherwise, I'm likely to get some enormous files
and/or unmanageable HTML printing...
Thanks for your help.
E.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 19 Oct 1999 14:51:04 +0200
From: Lishan Song <lishans@evitech.fi>
Subject: A question on Perl/Tk
Message-Id: <Pine.HPX.4.10.9910191439380.12275-100000@tamagoch.evitech.fi>
Could anyone help me out of the problem?
In my Perl/Tk script, I want to do something periodically (let's
say every 1 minute). But the MainLoop call will just sit in its
internal loop. I know this MainLoop waits for events, eg, button.
But is there a method for this call to work with sleep() so that
after sleep, I can do something?
Thanks
------------------------------
Date: 19 Oct 1999 11:06:54 GMT
From: mgjv@wobbie.heliotrope.home (Martien Verbruggen)
Subject: Re: Baffled!
Message-Id: <slrn80ok7t.1vv.mgjv@wobbie.heliotrope.home>
[Bad, bad subject line. Next time, please pick something more
desctriptive]
On 18 Oct 1999 15:42:21 +0200,
Bror Hellman <m8100@abc.se> wrote:
> I wrote this program...
>
> -- cut --
> #!/usr/bin/perl
no -w?
no use strict?
[snip]
> @barfoo = split('.',$incoming_name);
Uh-oh.
# perldoc -f split
=item split /PATTERN/,EXPR,LIMIT
=item split /PATTERN/,EXPR
=item split /PATTERN/
=item split
[snip]
See that /PATTERN/ at the start? Now, nowhere does it mention
specifically that if you put something there that doesn't _look_ like a
pattern,that it still will be treated as a pattern, but that's how it
is.
The first argument to split is _always_ a pattern, no matter how you
format it. (One special case ' ').
> print "Split name on <.>: <@barfoo>\n";
Nono.. That should read
print "Split name on </./>: <@barfoo>\n";
And we all know what a '.' in a regexp means, right? :)
# man perlre
You better get in the habit of always writing the first argument to
split with //, because that is a good visual reminder (apart from the
special case ' ', again)
> Steamboat Willie
Toot-toot
Martien
--
Martien Verbruggen |
Interactive Media Division | Begin at the beginning and go on till you
Commercial Dynamics Pty. Ltd. | come to the end; then stop.
NSW, Australia |
------------------------------
Date: Tue, 19 Oct 1999 04:45:16 -0700
From: AF778 <af778NOafSPAM@iname.com.invalid>
Subject: Decoding mime attchs (jpg) in email
Message-Id: <1415c574.d1261763@usw-ex0106-041.remarq.com>
I was searching for it in cpan with no luck until now, i found no clear
code or maybe i'm looking bad.
I need to decode an e-mail (residing in a PLAIN TEXT FILE, in the
Apache server /mail directory) with mime encoded JPG attachs in it.
I need a perl code to read the plain text file and when i find the mime
section, decode it and save it as a JPG file in some directory.
Can anybody give me a clue?
Thanks a lot!
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: Tue, 19 Oct 1999 07:54:52 -0400
From: "Corey Martin" <nospam@nospam.com>
Subject: eBay
Message-Id: <7uhmgk$fbi$1@nntp2.atl.mindspring.net>
Is it possible to receive a certain auction's current selling price from
eBay (without buying Anaconda for $120) in Perl? If so, what code do I use?
Thanks
--
Corey Martin
the web designer's centre
http://www.martin-web.com/centre/
------------------------------
Date: 19 Oct 1999 10:58:58 GMT
From: mgjv@wobbie.heliotrope.home (Martien Verbruggen)
Subject: Re: equiv. of nice & simple ksh syntax
Message-Id: <slrn80ojp1.1vv.mgjv@wobbie.heliotrope.home>
On Mon, 18 Oct 1999 17:58:06 +0100,
Mark Hamlin <mark@artdigital.co.uk> wrote:
> Below is the Korn script outline, how do I achieve this in Perl. I want to
> keep
> the simplicity of the Korn method, ie :
>
> 1) no external requirements such as modules - no DBI!,
> 2) readability,
>
> Here is the Korn version.
>
> #!/bin/ksh
>
> # korn business, assign variables
>
> sqlplus -s user/pass << END_OF_SQL | tee -a $log
>
> #sql business, maybe using variable assigned by korn
> commit;
> END_OF_SQL
If you don't want to use modules (one of the biggest strengths of
perl), then it is stupid to want to do it in perl. You'd end up with a
shell script written in perl. You'd still need to use the external
program. All you get is a heavier load on the system.
> # a bit more korn stuff
>
> 1) I know how to use backsticks, can I have a multiline thingy?
yes. See perldata. Search for 'here-doc'. Read example.
# man perldata
You can do other tricks to dup the tee, but I wouldn't bother. Let tee
do the job. if you're excaping to the shell, you might as well use it.
> 2) should I store the script as a multiline variable or as an array, with
> variables for interpolation embedded in the string (nasty.. ugghhh) then
> '$out = `sqlplus -s $myscript`
Whatever tickles your fancy. Since you're probably gonna process rows,
you migth as well keep it in an array. BYMMV
> 3) tie sqlplus into a filehandle thingy and then 'print SQLHANDLE << EO_SQL'
Yes, you could do that.
# perldoc -f open
# man perlopentut
# man IO::File
Other interesting literature
# man IPC::Open2
# man IPC::Open3
# man perlfaq5
[snip]
How do I print to more than one file at once?
[snip]
But again, it's probably not worth it. Shells do a good job at calling
external programs, in fact, that's what they're for. Perl does a good
job at glueing things together, but it doesn't really beat shells for
simplicity.
Martien
--
Martien Verbruggen |
Interactive Media Division | The world is complex; sendmail.cf reflects
Commercial Dynamics Pty. Ltd. | this.
NSW, Australia |
------------------------------
Date: 19 Oct 1999 11:13:35 GMT
From: mgjv@wobbie.heliotrope.home (Martien Verbruggen)
Subject: Re: fork (????)
Message-Id: <slrn80okke.1vv.mgjv@wobbie.heliotrope.home>
On Mon, 18 Oct 1999 19:53:21 -0700,
Tom Phoenix <rootbeer@redcat.com> wrote:
> On Mon, 18 Oct 1999, Dimitrios Kremmydas wrote:
>
> > I know how to make FTP or SMTP (Net::*) through Perl, but I don't know
> > how to make child processes (that means ... make something
> > simultaneously) ...
> > I know it has something to do with fork and pid and etc.
>
> Yes. Find a good book on programming on Unix systems. I'd recommend one,
> but I've never read any. :-)
Start at
# man man
work up to
# man -a intro
And continue from there :)
Martien
--
Martien Verbruggen |
Interactive Media Division | We are born naked, wet and hungry. Then
Commercial Dynamics Pty. Ltd. | things get worse.
NSW, Australia |
------------------------------
Date: 19 Oct 1999 11:18:50 GMT
From: mgjv@wobbie.heliotrope.home (Martien Verbruggen)
Subject: Re: fork (????)
Message-Id: <slrn80oku9.1vv.mgjv@wobbie.heliotrope.home>
On Mon, 18 Oct 1999 12:39:45 +0100,
Dimitrios Kremmydas <lzu99dk@rdg.ac.uk> wrote:
> I know it has something to do with fork and pid and etc.
> But since I cannot understand them very well, can somebody send me a
> simple examples, explaining what is going on on th code ? Even locations
> of Internet Resources would be happily acceptable ...
The documentation that comes with perl is a reasonable start
# man perlipc
There is unfortunately (for you) no simple and short explanation for
this. You'll just have to start working with it, using the examples, and
the understanding will start.
Of course, Tom's suggestion to buy a good book about Unix programming
might help. Try www.ugu.com. They've got a beginners starting point
which may have some pointers. Otherwise you may find interesting stuff
outside of the beginners area. The people at comp.unix.programmer might
be able to point you to a good book.
Martien
--
Martien Verbruggen |
Interactive Media Division |
Commercial Dynamics Pty. Ltd. | What's another word for Thesaurus?
NSW, Australia |
------------------------------
Date: 19 Oct 1999 10:43:50 GMT
From: mgjv@wobbie.heliotrope.home (Martien Verbruggen)
Subject: Re: help with substrings
Message-Id: <slrn80oisk.1vv.mgjv@wobbie.heliotrope.home>
On Mon, 18 Oct 1999 16:22:18 -0400,
Kevin Monroe <kpmonroe@unity.ncsu.edu> wrote:
> For some reason this relatively easy problem has been stumping me all
> day. Any help would be appreciated as I am beginning to lose my mind
>
> I have a comma deliminated text file such as
I almost thought you wrote laminated there.
> 121,Jimmy,Jones,0,1,21,555,89
> 1547,James,Johnson,155,87,6,1,301
> 14,Me,Again,12,197,0,22,1
> #!/usr/local/bin/perl -w
-w, good.
no use strict? bad.
use strict;
> open(NEW, "< /path/to/file.txt") or die "Can't open file.txt: $!";
Good check of open's return value. The < is unnecessary though.
> @data = <NEW>;
>
> foreach $element(@data){
> split(/,/, $line);
Where did that $line come from? That's where you get the warning from.
'use strict' would have prevented you from making this error. -w should
warn you that you only used $line once.
And do you know where the result of your split is ending up? I bet you
are also getting warnings about that.
# perldoc -f split
And do you realise that the last element still will contain the newline?
> print $element;
So.. Why do you print $element (which is the whole line) if you want the
first and third element of the array you just split into, and shouldn't
have?
> }
You are nopt telling us all the warning you are getting, or you are
using an old perl.
> close <NEW>;
All of the above is a bit more idiomatic, and correct like this:
my $file = '/path/to/file.txt';
open(NEW, $file) or die "Couldn't open $file for read: $!";
while (my $line = <NEW>)
{
chomp($line);
my @fields = split(/,/, $line);
print "$fields[0] - $fields[2] - $field[4]\n";
# or
# my ($f1, $f3, $f5) = (split(/,/, $line))[0,2,4];
# print "$f1 - $f3\n";
}
close(NEW);
This assumes that the data you shos us is representative, and that you
do not need to work with full-blown so-called CSV files.
> What I would like to be able to do here is get the say 1st,3rd and 5th
> entries following the comma. However $data[0] reveals the first full
> line commas and all. And since the length of each field varies using
> subst($line,0,1) will not work either
Huh? You had no $data[0] in your code. And what does 'following the
comma' mean? You have more than one 'the comma' in each line.
> any ideas???
Give the above a try. And read the documentation for split, and the
perldata documentation, maybe.
# perldoc -f split
# perldoc perldata
Martien
--
Martien Verbruggen |
Interactive Media Division | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: 19 Oct 1999 12:02:44 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: help with substrings
Message-Id: <380c4fd4_1@newsread3.dircon.co.uk>
Kevin Monroe <kpmonroe@unity.ncsu.edu> wrote:
> For some reason this relatively easy problem has been stumping me all
> day. Any help would be appreciated as I am beginning to lose my mind
>
> I have a comma deliminated text file such as
>
> 121,Jimmy,Jones,0,1,21,555,89
> 1547,James,Johnson,155,87,6,1,301
> 14,Me,Again,12,197,0,22,1
>
> and so on
> all Im trying to do is get say the first and the third fields after the
> comma
> I have tried to split it over and over again but no matter what I try I
> get "use of uninitialized valued at line"
>
> here is the code albeit very simple
>
> #!/usr/local/bin/perl -w
>
>
> open(NEW, "< /path/to/file.txt") or die "Can't open file.txt: $!";
>
> @data = <NEW>;
>
> foreach $element(@data){
> split(/,/, $line);
> print $element;
> }
>
> close <NEW>;
>
>
Right shall we take this again - where exactly was $line getting a value ?
foreach $row (@data)
{
@fields = split /,/,$line;
print "@fields[0,2]\n"
}
Although I would suggest if that if you are using the data like this then
you will be just as well to read the file a line at a time :
while ($row = <NEW>)
{
....
}
/J\
--
"I don't have access to the intelligence" - Michael Howard
------------------------------
Date: Tue, 19 Oct 1999 12:52:28 +0200
From: Abel =?iso-8859-1?Q?Almaz=E1n?= <abel.almazan@ogilvyinteractive.es>
Subject: How to get the system time??
Message-Id: <380C4D6C.FC213F2B@ogilvyinteractive.es>
I want to get the system time, if it's possible in the format :
hh:mm:ss
How can i do?? Exists a system call??
Thanks.
------------------------------
Date: 19 Oct 1999 12:22:41 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: How to get the system time??
Message-Id: <380c5481_1@newsread3.dircon.co.uk>
Abel Almazán <abel.almazan@ogilvyinteractive.es> wrote:
> I want to get the system time, if it's possible in the format :
>
> hh:mm:ss
perldoc -f gmtime
perldoc -f localtime
/J\
--
"Tony Blair is reported to be detained indefinitely under plans unveiled
by the Home Secretary" - Corrupt Teletext Page
------------------------------
Date: Tue, 19 Oct 1999 12:06:02 +0200
From: Luc VEILLON <Luc.Veillon@orleans.ird.fr>
Subject: Re: isa_defs on Solaris2.6
Message-Id: <380C4264.4F84A361@orleans.ird.fr>
You must use Perl5.005_003.
lsteinha6805@my-deja.com a écrit :
> Help! We have Solaris2.6 with perl5.005. We recently recompiled perl
> and upgraded the unix box to 2.6. After putting perl back out, we are
> now having problems with the isa_defs.h file dying. First, the h2ph
> put 2x double quotes in each die string. Fixing that, now there is no
> defined value for the isa_defs to fix on. Anyone have a solution?
>
> Lyle Steinhardt
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
Date: Tue, 19 Oct 1999 00:03:11 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: making a directory
Message-Id: <MPG.1275b7822221a67998a0ba@nntp.hpl.hp.com>
In article <slrn80o339.9r.efflandt@efflandt.xnet.com> on 19 Oct 1999
06:14:34 GMT, David Efflandt <efflandt@xnet.com> says...
> On 19 Oct 1999 02:47:53 GMT, Jimtaylor5 <jimtaylor5@aol.com> wrote:
> >I've been trying to make a directory with perl to no avail. I've read the perl
> >FAQ and tried all these variations but no directory is created. Anyone know
> >what I am doing wrong?
>
> Yes, you are failing to test why it failed as in:
> mkdir newone,0777 || die "can't mkdir: $!\n";
No, not that way, because of precedence. The error would never appear.
mkdir(newone, 0777) || die "can't mkdir: $!\n";
or
mkdir newone, 0777 or die "can't mkdir: $!\n";
> or
>
> unless (mkdir newone,0777) {
> # print some useful html that includes $! error msg
> }
And in all the above, newone had better be a subroutine or be quoted.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 19 Oct 1999 13:04:17 +0200
From: "Mark Bakker" <ceesbakk@casema.nl>
Subject: Re: Monitoring the clicks of a banner
Message-Id: <380c4ffe$0$19226@reader1.casema.net>
I think, you can make the script by buying the book:
SAMS Teach Yourself Perl Rather than asking for a pre-made
ommercial?!:-( script.
Bye the way the ISBN is: 0-672-31305-7
After reading the book you can ask some specific questions if you nead to!
With kind regards,
Mark Bakker
Kendar <heron@hell.com> schreef in berichtnieuws
380bef7e.75418546@news.supernews.com...
> Does anyone know of any script that would monitor
> the clicks on a given banner? I have CGI access.
> Thank you in advance!
>
> medusa@beaute.org
>
------------------------------
Date: Tue, 19 Oct 1999 12:07:54 +0100
From: Richard Yates <r.j.yates@open.ac.uk>
Subject: NT: How can I change drive within a perl script?
Message-Id: <380C510A.75863FC0@open.ac.uk>
or find out what drive I'm on "now".
I'm asking this on behalf of a colleague.........
Richard.
--
Erratic news-swerver! :. post+e-mail to be sure I get your msg.
The Open University is not responsible for content herein, which
may be incorrect and is used at reader's own risk.
------------------------------
Date: Tue, 19 Oct 1999 10:18:40 GMT
From: Richard Lawrence <ralawrence@my-deja.com>
Subject: Re: Oh god! Not another Net::ftp question!
Message-Id: <7uhghq$26i$1@nnrp1.deja.com>
In article <1415c574.c1df12f8@usw-ex0102-012.remarq.com>,
Tim Diller <t.dillerNOt.SPAM@xpres.com.invalid> wrote:
> In article <7ueu21$au9$1@nnrp1.deja.com>, Richard Lawrence
> <ralawrence@my-deja.com> wrote:
> > Q: This is great as long as I've actually found the site and been
> > able
> > to log in! Without resorting to Debug => 1 is there anyway I can
> > test
> > for the return of this connect, the "new" command and the "ls"
> > command
> > to see whether the site existed, whether I could log on and
> > whether the
> > file existed (I need to be able to distinguish between the three of
> > them and act accordingly)
Many thanks to those who helped. I just have one more question :o)
I now have the following working bit of code:
#!/usr/bin/perl -w
use strict;
my $site = "<site>";
my $uname = "<user name>";
my $password = "<password>";
my $path = "<file and path>";
my $resp;
use Net::FTP;
$ftp = Net::FTP->new($site);
die "no such site" if ($@);
$resp = $ftp->login($uname,$password);
die "bad uname/passwd" if (!$resp);
$resp = $ftp->ls($path);
die "no such file" if (!$resp);
$ftp->quit;
print "ok!\n";
the problem is that it reports busy FTP servers as having a bad
username or password. Is there any way I can make it report them as
busy instead?
Regards
Rich
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 19 Oct 1999 08:12:53 -0400
From: "Zowwie" <apage.net@usa.net>
Subject: Perl and IIS issues w/ Perl [USE] command.
Message-Id: <s0onhfqcr0185@corp.supernews.com>
Howdy all!
I really need someone help here... Cuz at this point,
I think I have been sitting in this chair so long that
I may be unable to wear pants without a belt.
"12 hours sitting will do it!"
Anyway folks... here is my Perl IIS Issue:
1) If I attempt to use a [use Net::Telnet] command
inside a Perl scipt under IIS 4.0, I get a message
from IIS that informs me that it is unable to locate
net/telnet.pm and it also states that @INC only
contains a period.
Why is IIS stripping the @INC array?
Is there a registry hack to this?
2) When I run the same scipt that is described in #1
from the DOS prompt... All runs fine, and the script
outputs its HTML as intended.
For curiosity.. I placed some print @INC statements
inside this script so I could see what was
happening... When I run it from DOS, the print
statements contain data, although when I run it under
IIS, @INC has no value other than a period.
I also executed the program from a remote directory
and another drive... perl.exe
e:\web\cgi-bin\sciptname.cgi
And all ran without incident.
3) Yes... I have other complex perl scipts running
under WinNT IIS, and have not had to many issues with
them... Other than having to specify absolute file
names for my open/read statements... Under Apache for
win32, absolutes where not needed. :(
4) I have re-installed Perl from Activestate twice,
and have reinstalled the Telnet module both manually,
and also with PPM without positive results.
I beg of you all.... PLEASE help me out on this one...
I can't find ANY documentation on this. :(
Am I only only id-10T out here that is missing
something?
Please reply not only to group (cuz I would hate to
see someone else suffer like I), but please post to my
email address also.
Thank you in advance for your time.
Snippets:
IIS Error:
CGI Error
The specified CGI application misbehaved by not
returning a complete set of HTTP headers. The headers
it did return are:
Can't locate Net/Telnet.pm in @INC (@INC contains: .)
at E:\web\cgi-bin\cisco675.pl line 147.
BEGIN failed--compilation aborted at
E:\web\cgi-bin\cisco675.pl line 147.
Snippet of Code:
use Net::Telnet(); ##NOTE: If I rem this lineout...
All functions well.
Thanks,
---------------
Zowwie
---------------
---------------------------------
T. Grant - ADSL Info:
zoomtowndsl.dyndns.org
zoomtown.apage.net
------------------------------
Date: Tue, 19 Oct 1999 11:31:35 +0100
From: "DeveloperX" <devx@hotmail.com>
Subject: PerlScript for ASP installation problem
Message-Id: <7uhh8d$dk3$1@starburst.uk.insnet.net>
After installing PerlScript, I placed a site on my web server (PWS)and
attempted to run it via a browser. I recieved the following error:
Active Server Pages error 'ASP 0124'
Missing Language attribute
/travel_planner/default.asp, line 1
The required Language attribute of the Script tag is missing
The scripts are fine, there is no problem with them as they run on a PWS
server with PerlScript already installed. It is a problem with the server,
perhaps that there should be more installation steps necessary. Does anyone
have any ideas?
-Tony
------------------------------
Date: Tue, 19 Oct 1999 11:49:27 GMT
From: emlyn_a@my-deja.com
Subject: Re: Q: Truncate string length?
Message-Id: <7uhls4$5g9$1@nnrp1.deja.com>
In article <380A8AFA.6DA0FBD3@vpservices.com>,
Jeff Zucker <jeff@vpservices.com> wrote:
> emlyn_a@my-deja.com wrote:
> >
> > I understand truncating files, but how does one truncate a string?
To
> > limit the length of a field to, say, 500 characters?
> > ...
> > substr($TheField, 0, 500) don't know what goes next
>
> I'm not being sarcastic when I say I truly don't understand what part
of
> that you don't understand. You've got the syntax of substr correct
and
> you've figured out that susbstr is the function you need. Is it that
> you don't understand what the substr function returns? If so, just
> print it out and see.
>
> print substr('abcdef',0,3);
>
> Is it that you don't know how to get the returned value into a
> variable? Just try experimenting with the assignment operator (=) and
> see what happens.
>
> my $the_field = 'abcdef';
> $the_field = substr($the_field,0,3);
> print $the_field;
>
> For me, if I don't understand something with a complex or large
example
> I try to break it into a smaller piece and experiment with that. This
> seems like something you ought to be able to experiment with on your
own
> rather than asking the newsgroup, but perhaps I still don't understand
> what you are having trouble with.
>
> --
> Jeff
>
I didn't know that you could actually make a $var = to a substr, and I
had typed that in after just seeing it somewhere else, but not thinking
it was correct. I'm glad I was on the right track.
E.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 19 Oct 1999 11:47:07 GMT
From: emlyn_a@my-deja.com
Subject: Re: Q: Truncate string length?
Message-Id: <7uhlno$58s$1@nnrp1.deja.com>
In article <s0mn8aur0186@corp.supernews.com>,
cberry@cinenet.net (Craig Berry) wrote:
> Ilya Zakharevich (ilya@math.ohio-state.edu) wrote:
> : <cberry@cinenet.net>],
> : who wrote in article <s0l9hfeer0160@corp.supernews.com>:
> : > You have it, right there...what do you think should go next? If
you mean
> : > how do you make it apply back to $TheField, just assign the value:
> : >
> : > $TheField = substr($TheField, 0, 500);
> :
> : I would think it is *ways* better do it the other way around:
> :
> : substr($TheField, 500) = "";
>
> Seemed plausible, but Benchmark disagrees with you:
>
> #!/usr/bin/perl -w
> # trunc - benchmark different ways of truncating a string
> # Craig Berry (19991018)
>
> use strict;
> use Benchmark;
>
> my $sample = 'a' x 1000;
>
> timethese(10000, {
> substr_rv => sub {
> $_ = $sample;
> $_ = substr($_, 0, 500);
> },
> substr_lv => sub {
> $_ = $sample;
> substr($_, 500) = '';
> },
> substitute => sub {
> $_ = $sample;
> s/(.{0,500}).*/$1/s;
> },
> match => sub {
> $_ = $sample;
> ($_) = m/(.{0,500})/;
> }
> });
>
> __END__
>
> Benchmark: timing 10000 iterations of match, substitute, substr_lv,
> substr_rv...
> match: 5 secs ( 4.99 usr 0.00 sys = 4.99 cpu)
> substitute: 12 secs ( 6.23 usr 0.00 sys = 6.23 cpu)
> substr_lv: 3 secs ( 2.51 usr 0.00 sys = 2.51 cpu)
> substr_rv: 3 secs ( 2.52 usr 0.00 sys = 2.52 cpu)
>
> --
> | Craig Berry - cberry@cinenet.net
> --*-- http://www.cinenet.net/users/cberry/home.html
> | "They do not preach that their God will rouse them
> a little before the nuts work loose." - Kipling
>
Very interesting - I'm glad the first one is the one I was going to use!
E.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 19 Oct 1999 11:48:17 GMT
From: emlyn_a@my-deja.com
Subject: Re: Q: Truncate string length?
Message-Id: <7uhlpv$591$1@nnrp1.deja.com>
In article <s0l9hfeer0160@corp.supernews.com>,
cberry@cinenet.net (Craig Berry) wrote:
> emlyn_a@my-deja.com wrote:
> : I understand truncating files, but how does one truncate a string?
To
> : limit the length of a field to, say, 500 characters?
> [snip]
> : Do I need to count from 0 to 500 the number of characters in the
string
> : and throw out the rest, or is there a way to just slice off anything
> : occurring past 500 without counting each one, like:
> :
> : substr($TheField, 0, 500) don't know what goes next
>
> You have it, right there...what do you think should go next? If you
mean
> how do you make it apply back to $TheField, just assign the value:
>
> $TheField = substr($TheField, 0, 500);
>
> --
> | Craig Berry - cberry@cinenet.net
> --*-- http://www.cinenet.net/users/cberry/home.html
> | "They do not preach that their God will rouse them
> a little before the nuts work loose." - Kipling
>
Yes! I didn't even know that what I had typed was the way to go! So now
I know how substr works...
E.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 19 Oct 1999 11:23:46 GMT
From: mgjv@wobbie.heliotrope.home (Martien Verbruggen)
Subject: Re: send mail in perl
Message-Id: <slrn80ol6l.1vv.mgjv@wobbie.heliotrope.home>
On Mon, 18 Oct 1999 22:28:07 -0700,
Michael Budash <mbudash@sonic.net> wrote:
> In article <380BFD06.C82A3F0A@hongkong.com>, danny ho <danda@hongkong.com>
> wrote:
> >where can i find perlfaq9?
> if unix, type 'perldoc perlfaq9' at the prompt.
If unix, type
# man perlfaq9
> if nt, my condolences...
if NT type
c:\promptje> perldoc perlfaq9
or look at the html documentation that came with your recent ActiveState
installation. But still, in this case, we all feel sorry for you :)
Martien
--
Martien Verbruggen |
Interactive Media Division | Make it idiot proof and someone will make a
Commercial Dynamics Pty. Ltd. | better idiot.
NSW, Australia |
------------------------------
Date: 19 Oct 1999 10:47:22 GMT
From: mgjv@wobbie.heliotrope.home (Martien Verbruggen)
Subject: Re: sorting arrays
Message-Id: <slrn80oj39.1vv.mgjv@wobbie.heliotrope.home>
On Mon, 18 Oct 1999 18:59:36 GMT,
secnarf@my-deja.com <secnarf@my-deja.com> wrote:
> I have the contents of a table in an array. I only want to sort the by
> the contents of the first line of the table row, which looks like -
This doesn't really parse very well. Arrays and tables have nothing in
common. But I'll just assume that you know what you're talking about,
even in we don't.
> <TR><TD>xxxx</TD>. Can I use sort for this? How can I set the <TR> as
> the delimiter? Is there an easier way to accomplish this?
>
> I really just need ideas.
And some documentation:
# man perlfaq4
[snip]
How do I sort an array by (anything)?
[snip]
# perldoc -q sort
=head1 Found in /usr/lib/perl5/5.00503/pod/perlfaq4.pod
=head2 How do I sort an array by (anything)?
Martien
--
Martien Verbruggen |
Interactive Media Division |
Commercial Dynamics Pty. Ltd. | What's another word for Thesaurus?
NSW, Australia |
------------------------------
Date: 19 Oct 1999 10:21:57 GMT
From: mgjv@wobbie.heliotrope.home (Martien Verbruggen)
Subject: Re: WHATS WRONG WITH THIS CODE?
Message-Id: <slrn80ohji.1vv.mgjv@wobbie.heliotrope.home>
What's wrong with this Subject:?
Subject: Re: WHATS WRONG WITH THIS CODE?
It's all in capitals. It's rude to shout.
It doesn't describe the problem.
It's missing an apostrophe.
On Mon, 18 Oct 1999 17:27:34 -0400,
Jim <golf@tfz.net> wrote:
> #!/usr/bin/perl
no -w
no use strict;
And even though this is trivial: no use CGI;
> print "Content-Type: text/html\n\n";
> print "<HTML><HEAD>\n";
> print "<TITLE>CGI Test</TITLE>\n";
> print "</HEAD>\n";
> print "<BODY><A HREF=\"http://someplace.com\">Click Here</A>\n";
> print "</BODY></HTML>";
6 print statements that could have been done with one.
use of a script when a static HTML file would have done fine.
Unnecessary backwhacking of double quotes, because it could have been
avoided, had you used a here-doc in the first place, or use single
quotes.
Unnecessary insertion of line feeds (not serious).
> It gives me a 500 error. All I want to know is if there are any errors in
> this code. thanks
Perl does not give 500 errors. All perl's error messages (or at least
almost all) are documented in the perldiag documentation.
Perl also comes with an FAQ, of which the abominable part 9 explains the
use of perl in CGI environments. The first one answers your question.
Please don't come back asking questions like this, question that are
answered in the FAQ or documentation, in non-obscure places and/or
manner.
People have spent a considerable amount of their time writing that
documentation, to give it to _you_ for free. Use it.
Martien
--
Martien Verbruggen |
Interactive Media Division | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
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 1115
**************************************