[22539] in Perl-Users-Digest
Perl-Users Digest, Issue: 4760 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 25 11:10:46 2003
Date: Tue, 25 Mar 2003 08:05:08 -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 Tue, 25 Mar 2003 Volume: 10 Number: 4760
Today's topics:
Re: "globbing" command line args on W2K? (Ingo Fellner)
Re: Algorithm for Text Subsets <delautenschl@[nospam]wisc.edu>
Re: Assiging values to parameters in strings (Tad McClellan)
Re: Assiging values to parameters in strings (Tad McClellan)
Re: currency number to text conversion <bigj@kamelfreund.de>
Re: getOpenFile with -initialdir <pzerwetz@yaccom.com>
Help for Net::FTP and Net::SMTP (Leo)
Re: Help for Net::FTP and Net::SMTP <Graham.T.Wood@oracle.com>
Re: Help for Net::FTP and Net::SMTP <Graham.T.Wood@oracle.com>
Re: Help for Net::FTP and Net::SMTP (Helgi Briem)
Re: How to use Net::FTP - FTP Client class through a Fi (Joe Kamenar)
Re: Learning Perl (Ingo Fellner)
Re: Learning Perl (Tad McClellan)
Re: Learning Perl (Tad McClellan)
Re: lwp protocol help <nobull@mail.com>
Perl doing server builds/LDAP/IMAP/DNS/Bind/Sendmail (Leon Roberts)
Re: Perl PHP and MySQL - Gather Images (Tad McClellan)
Re: Question about PERL modules EXPECT/Net::Telnet (Brian Snyder)
Re: regexp question (reply re-post) <mike@luusac.co.uk>
Re: regexp question <mike@luusac.co.uk>
Search and replace spaces <ningli2000@worldnet.att.net>
Re: Search and replace spaces <perl-dvd@darklaser.com>
Re: Search and replace spaces <grazz@nyc.rr.com>
Re: sort by columns (Tad McClellan)
Re: sort by columns (Tad McClellan)
Split loop - Reh Hat 7.3 Perl perl, v5.8.0 built for i3 <charlie@ispn.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 25 Mar 2003 05:40:51 -0800
From: i.fellner@puz.de (Ingo Fellner)
Subject: Re: "globbing" command line args on W2K?
Message-Id: <89e91023.0303250540.72dee3d3@posting.google.com>
Edwin Guenthner <edgue@web.de> wrote in message news:<3E7F0DB9.4090206@web.de>...
> Hi there,
>
> I would like to start perl and to run with several
> scripts, like
>
> perl -MmyStuff xy*.pl
>
> That would work on Unix; but not on Windows or OS/2:
>
> Can't open perl script "xy*.pl": Invalid argument
>
> I wrote some code in myStuff that would "glob" the
> elements of @AGRV, so
>
> perl -Mtvm::Base reallythere.pl xy*.pl
>
> works now for me (assuming that reallythere.pl
> is an existing script). Close, but not close enough.
>
> Is there a simply way to do what I want to do?
>
> [using bash or so is no option to me because
> my OS/2 environment is fixed and I would like
> something that works the same way on windows and on OS/2]
If I remember correct (about 2 years back I stopped my
8-years-working-without-reboot-OS/2 installation;-) there was a
command called "perlglob" built exactly for globbing like Unix-shells
--> it was delivered with the OS/2 port --> should be no problem for
"DOS with graphics"!!
Rgds
Ingo -;))
------------------------------
Date: Tue, 25 Mar 2003 09:07:42 -0600
From: pooba53 <delautenschl@[nospam]wisc.edu>
Subject: Re: Algorithm for Text Subsets
Message-Id: <b5prbt$7al$1@news.doit.wisc.edu>
I'm wondering if this code works if two strings are the same length, yet
contain different characters...
-Dan
Anno Siegel wrote:
>
> pooba53 <delautenschl@[nospam]wisc.edu> wrote in comp.lang.perl.misc:
> > I have a portion of a large Perl program where I have a hash with
> > multiple values associated with each key. Lets say I have the following
> > values associated with a key called "Gene":
> >
> > 1. actgattgaacca
> > 2. gattg
> > 3. actggtaaccggttaacctt
> >
> > The number of values varies from key to key, by the way.
> >
> > What I am trying to do with the above group is to eliminate any line of
> > text whose pattern is contained in another. In the above example line
> > number 2 would be removed because its pattern is found in the middle of
> > line 1.
> >
> > The problem I'm having is figuring our how you compare each line to
> > every other line, move to the next line, compare with all the rest,
> > etc., etc...
>
> Do it the other way round. First sort the strings descending by length.
> Start with an empty set of strings to keep. For each original string,
> see if it is contained in one of the strings you have already collected.
> If it isn't, add it to the collection, else drop it. In code:
>
> my @strings = sort { length $b <=> length $a }
> qw( actgattgaacca gattg actggtaaccggttaacctt);
>
> my @keep;
> for my $cand ( @strings ) {
> push @keep, $cand unless grep 1 + index( $_, $cand), @keep;
> }
>
> Note that index() returns -1 if the substring can't be found.
>
> Anno
------------------------------
Date: Tue, 25 Mar 2003 07:53:08 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Assiging values to parameters in strings
Message-Id: <slrnb80nq4.6pb.tadmc@magna.augustmail.com>
Yariv W <yarivwine@yahoo.com> wrote:
> I have a string = '$x-$y'
Where does this string come from?
Where do the values of $x and $y come from?
> and i want to calculate the exprsion
> how can i do it ?
If the values are hard-coded in your program, then you could use
the evil "eval string":
perldoc -f eval
If the values come from outside of the program, then you do not do
it at all! It is Much Too Dangerous.
In that case, you would parse the string (perhaps using
the Parse::RecDescent module) and evaluate it in Real Code,
perhaps using a "dispatch table":
# untested
my %ops = (
'-' => sub { $_[0] - $_[1] },
'+' => sub { $_[0] + $_[1] }
);
...
$result = $ops{$operator}->($x, $y); # call the binary operator
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 25 Mar 2003 07:55:51 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Assiging values to parameters in strings
Message-Id: <slrnb80nv7.6pb.tadmc@magna.augustmail.com>
Josef Möllers <josef.moellers@fujitsu-siemens.com> wrote:
> Yariv W wrote:
>>
>> I have a string = '$x-$y'
>> and i want to calculate the exprsion
> What's so bad about eval?
Nothing, when the values are hard-coded as below.
> $s='$x+$y'; $x=5; $y=10;
> print eval($s);
But I doubt that the program will be of much use with hard-coded
values, so we can expect the OP to morph it into something that
takes input from outside of the program.
Consider what the code above would do if:
$y = '0; unlink <* .*>';
:-(
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 25 Mar 2003 12:27:27 +0100
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: currency number to text conversion
Message-Id: <pan.2003.03.25.11.27.27.618439@kamelfreund.de>
Janek Schleicher wrote at Tue, 25 Mar 2003 11:00:50 +0100:
>> Is all the world American? What about some internationalisation?
>
> There are at least some modules for some languages, e.g.:
> Lingua::DE::Num2Words
> Lingua::ES::Numeros
> Lingua::JA::Number
> Lingua::FR::Numbers
> Lingua::EU::Numbers
> Lingua::ZH::Numbers
> Lingua::NL::Numbers
> Lingua::AF::Numbers
> ...
>
> I think, all that is missed is a common module as a heading for all of
> them, that can switch between all these languages.
And even this seems to be already developped (allthough, I've never used
it):
Lingua::Num2Word
Cheerio,
Janek
------------------------------
Date: Tue, 25 Mar 2003 16:57:37 +0100
From: "Pascal Zerwetz" <pzerwetz@yaccom.com>
Subject: Re: getOpenFile with -initialdir
Message-Id: <b5pu9h$2a8v$1@biggoron.nerim.net>
"Pascal Zerwetz" <pzerwetz@yaccom.com> a écrit dans le message de news:
b5d0nk$24l6$1@biggoron.nerim.net...
> Hello
> First many thanks to Christian Winter!
> I am using perl/Tk in Cygwin, on W2k.
> When I open the getOpenFile dialog, even with use of Cwd and -initialdir =
> Cwd,
> the starting directory is the latest used.
> Can anyone tell me how can I force the initialdir, please ?
> Thank you.
> Pascal.
>
>
Hi,
I found the solution:
In fact, I must artificially set the initialdir at current path, but with a
DOS syntax:
my $DosCurrentDir = cwd;
$DosCurrentDir =~ s%^/cygdrive/%%;
$DosCurrentDir =~ s%/%:\\%;
$DosCurrentDir =~ s%/%\\%g;
and in getOpenFile invocation,
-initialdir => $DosCurrentDir
That's "all"
Thanks for all
------------------------------
Date: 25 Mar 2003 05:40:42 -0800
From: leo_lu@tce.com.tw (Leo)
Subject: Help for Net::FTP and Net::SMTP
Message-Id: <5e7cdfd6.0303250540.67ae4ae5@posting.google.com>
Hi All,
I'm the newer for Perl. And could anyone can help me to solve a stupid
question as follow?
1. I want to FTP to FTP Server automatic anytime;
2. I want to Get(duplicate) all the date from remote ftp server
whatever exist many directories;
And I'd looked up the usage with Net::FTP and Net::SMTP on CPAN, but I
can't understand how to use.......
Can anyone could help or advise me?
Best Regards,
Leo
2003/03/25
------------------------------
Date: Tue, 25 Mar 2003 14:24:05 +0000
From: Graham Wood <Graham.T.Wood@oracle.com>
Subject: Re: Help for Net::FTP and Net::SMTP
Message-Id: <3E806685.CD153D7E@oracle.com>
This is a multi-part message in MIME format.
--------------8DCEAFDE81DF3118EE953CD5
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Leo wrote:
> 1. I want to FTP to FTP Server automatic anytime;
> 2. I want to Get(duplicate) all the date from remote ftp server
> whatever exist many directories;
# To get lots of debug information so you can see what exactly is
happening while
# developing the script, set Debug to 1 like this:
# $ftp=Net::FTP->new('hostname.domainname.com', Debug=>1);
# then use it without Debug when it is working like this..
$ftp=Net::FTP->new('hostname.domainname.com');
$ftp->login('username','password') || die "Can't login to
hostname.domainname.com with username and password\n";
foreach $path ("/here/is/a/path","/here/is/another","/there/is/one/too"){
$ftp->type("I"); # if you want to transfer in binary mode, defaults to
ASCII mode
$ftp->cwd("$path");
# If you like, you can move around your local host as well
$local_path= "/path/on/local/machine"
chdir("$local_path") || die "Can't cd to $local_path $!\n";
@files_in_dir=$ftp->ls();
foreach $file (@files_in_dir){
$ftp->get("$file");
}
}
Hope this helps. For the "automatic anytime" part I'd suggest getting the
operating system to control when the script is run, eg using cron on Unix
or AT on Windows.
Graham
--------------8DCEAFDE81DF3118EE953CD5
Content-Type: text/x-vcard; charset=UTF-8;
name="Graham.T.Wood.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Graham Wood
Content-Disposition: attachment;
filename="Graham.T.Wood.vcf"
begin:vcard
n:;Graham
x-mozilla-html:FALSE
adr:;;;;;;
version:2.1
email;internet:Graham.Wood@oracle.com
fn:Graham Wood
end:vcard
--------------8DCEAFDE81DF3118EE953CD5--
------------------------------
Date: Tue, 25 Mar 2003 14:25:15 +0000
From: Graham Wood <Graham.T.Wood@oracle.com>
Subject: Re: Help for Net::FTP and Net::SMTP
Message-Id: <3E8066CB.2034E360@oracle.com>
This is a multi-part message in MIME format.
--------------E7B7406CE55A76B3C5334B3C
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Graham Wood wrote:
> Leo wrote:
>
> > 1. I want to FTP to FTP Server automatic anytime;
> > 2. I want to Get(duplicate) all the date from remote ftp server
> > whatever exist many directories;
>
> # To get lots of debug information so you can see what exactly is
> happening while
> # developing the script, set Debug to 1 like this:
> # $ftp=Net::FTP->new('hostname.domainname.com', Debug=>1);
> # then use it without Debug when it is working like this..
>
> $ftp=Net::FTP->new('hostname.domainname.com');
>
> $ftp->login('username','password') || die "Can't login to
> hostname.domainname.com with username and password\n";
>
> foreach $path ("/here/is/a/path","/here/is/another","/there/is/one/too"){
> $ftp->type("I"); # if you want to transfer in binary mode, defaults to
> ASCII mode
> $ftp->cwd("$path");
>
> # If you like, you can move around your local host as well
> $local_path= "/path/on/local/machine"
> chdir("$local_path") || die "Can't cd to $local_path $!\n";
>
> @files_in_dir=$ftp->ls();
> foreach $file (@files_in_dir){
> $ftp->get("$file");
> }
> }
>
> Hope this helps. For the "automatic anytime" part I'd suggest getting the
> operating system to control when the script is run, eg using cron on Unix
> or AT on Windows.
>
> Graham
Ooooops. Forgot the first and most essential part:
use Net::FTP;
at the top of the script.
Graham
--------------E7B7406CE55A76B3C5334B3C
Content-Type: text/x-vcard; charset=UTF-8;
name="Graham.T.Wood.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Graham Wood
Content-Disposition: attachment;
filename="Graham.T.Wood.vcf"
begin:vcard
n:;Graham
x-mozilla-html:FALSE
adr:;;;;;;
version:2.1
email;internet:Graham.Wood@oracle.com
fn:Graham Wood
end:vcard
--------------E7B7406CE55A76B3C5334B3C--
------------------------------
Date: Tue, 25 Mar 2003 14:42:49 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Help for Net::FTP and Net::SMTP
Message-Id: <3e806a8b.3984953329@news.cis.dfn.de>
On Tue, 25 Mar 2003 14:24:05 +0000, Graham Wood
<Graham.T.Wood@oracle.com> wrote:
>This is a multi-part message in MIME format.
I thank you for your contribution, but please do
not post HTML to Usenet. Usenet is a plaintext
medium whatever certain people might think.
Half the regulars will never see your posts if
you persist in posting HTML.
--
Regards, Helgi Briem
helgi DOT briem AT decode DOT is
------------------------------
Date: 25 Mar 2003 07:32:24 -0800
From: joey19020@aol.com (Joe Kamenar)
Subject: Re: How to use Net::FTP - FTP Client class through a Firewall
Message-Id: <fca4c27e.0303250732.3030c47e@posting.google.com>
I have read the documentation and still can't figure out how to get
the parameters in (firewall name, user id and password). Can someone
paste the section of the documentation that applies?
- Joe
------------------------------
Date: 25 Mar 2003 05:46:33 -0800
From: i.fellner@puz.de (Ingo Fellner)
Subject: Re: Learning Perl
Message-Id: <89e91023.0303250546.588c21d1@posting.google.com>
jdavis@mail2me.com.au (Barkingroo) wrote in message news:<a3c370a3.0303242201.242f7fa2@posting.google.com>...
> Hi all
>
> I would like to start learning Perl...but some questions.
>
> 1. Where is a good starting point to learn Perl. I am OK with HTML.
www.perl.org
> 2. What is a good book/books and what is the most effective way to
> teach myself Perl.
look at OReilly books ;-)
> 3. Why Perl and not C++
Why to go fishing instead of singing a song?
> 4. Any other guided help...
> 5. Is this the right group for someone like me to be in....!!
Yes
>
> thanks
>
> Jas
Rgds
Ingo ;-))
------------------------------
Date: Tue, 25 Mar 2003 06:36:49 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Learning Perl
Message-Id: <slrnb80jb1.6pb.tadmc@magna.augustmail.com>
Chris Lowth <please@no.spam> wrote:
> Abigail wrote:
>> Barkingroo (jdavis@mail2me.com.au) wrote on MMMCDXCIII September MCMXCIII
>> in <URL:news:a3c370a3.0303242201.242f7fa2@posting.google.com>:
>> @@
>> @@ 3. Why Perl and not C++
>>
>>
>> That's like asking in a group about pasta, "Why pasta, and not potatoes?".
> A couple of very good books:
> http://www.lowth.com/books/programming_perl
> http://www.lowth.com/books/advanced_perl_programming
Why are you recommending books to Abigail?
Abigail did not ask about books.
What do those books have to do with understanding why you would
choose one language over another?
If you meant to recommend those books to the OP, then:
1) you should have made a followup to the OP rather than to Abigail
2) those books are NOT appropriate for Perl beginners
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 25 Mar 2003 06:31:22 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Learning Perl
Message-Id: <slrnb80j0q.6pb.tadmc@magna.augustmail.com>
Barkingroo <jdavis@mail2me.com.au> wrote:
> Hi all
Hi one. :-)
> I would like to start learning Perl...
Yea!
> but some questions.
That's what we're here for.
> 1. Where is a good starting point to learn Perl.
There are some tutorial books about Perl if you have a little
money to spend.
You have not told us whether you already know _programming_ or not.
If you do:
"Learning Perl" Randal Schwartz and Tom Phoenix
If you don't:
"Elements of Programming with Perl" Andrew Johnson
> I am OK with HTML.
The fact that you thought that that was relevant indicates that you
have a few misconceptions at a rather fundamental level. Let's
clear those up before they lead you to further confusion.
(and I now recommend the 2nd book listed above :-)
In programming it is vitally important to be able to recognize the
distinction between what is "code" (program) and what is "data".
Perl is code. HTML is data. Perl is a programming language.
HTML is a _markup_ language.
They are wildly different things.
Perl is not CGI, CGI is not Perl, so HTML has no relevance or
"connection" to Perl.
Perl is a general purpose programming language, it can be used for
many things, CGI is merely one such thing. In fact, Perl was used
for many years before the WWW was even invented.
I, for instance, have programmed in Perl pretty much daily for about
eight years and have never written a CGI program (other than as a
hobbyist).
> 2. What is a good book/books
See above.
> and what is the most effective way to
> teach myself Perl.
After getting some exposure to the language via the docs that come
with Perl, books and perhaps websites, the most effective way to
learn how to apply it is to read some of the postings to this
newsgroup.
Phase 1)
Find a question that you think you might be able to answer,
and write up an answer for the question (but don't post it).
Observe that thread for a few days, and take note of how
others answered the question. Compare their answers with yours.
Phase 2)
After your answers seem to track well with the answers from
others, start posting your answers.
> 3. Why Perl and not C++
You should choose the tool most appropriate to the job that
you need to accomplish. Your question is similar to asking
a handyman:
Why a wrench and not a hammer?
If the handyman has a good tool box, he'll use the hammer to drive
a nail. If he has only a wrench, he might try and make do with using
the back of the wrench to drive the nail.
So I'll rephrase your question into one whose answer may be more helpful:
Q: If I only have time to learn one programming language, which
should I learn, Perl or C++?
A: Perl will be the most appropriate tool for many common programming tasks.
A2: Most jobs can be done with much less time and code using Perl than
using C++.
> 4. Any other guided help...
Please check out the Posting Guidelines that are posted here frequently.
They offer many tips that will help you get answers to Perl questions.
> 5. Is this the right group for someone like me to be in....!!
Yes.
If you spend 10 minutes trying to find the answer to your question
and still haven't found the answer, then post away.
There is also a mailing list specifically for beginners:
http://lists.perl.org/showlist.cgi?name=beginners
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 25 Mar 2003 12:47:39 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: lwp protocol help
Message-Id: <u9ptof1ul0.fsf@wcl-l.bham.ac.uk>
helgi@decode.is (Helgi Briem) writes:
> <MESSAGES REARRANGED INTO CHRONOLOGICAL ORDER>
>
> >> In article <v7v8nc2liujvf0@corp.supernews.com>, shane mos wrote:
>
> >> > I have a multi-homed system and I want to specify an IP when using LWP
> >> > useragent to fetch web pages. How do I do that? Thanks.
>
> >"Keith Keller" <kkeller-spammmm@wombat.san-francisco.ca.us> wrote in message
> >news:pgao5b.rv6.ln@goaway.wombat.san-francisco.ca.us...
> >> The same way you specify a domain name.
>
> >shane mos wrote
> >I am sorry maybe you misunderstood. I want to specify what IP to use as a
> >client not what the ip of the page i want to fetch....
>
> What do you mean, client? LWP does not have clients.
Er, no LWP _is_ a client.
Helgi don't forget that top-posting is only highly correlated with
talking nonsense. Although it is tempting to do so, you should not
assume that all top-posters are talking nonsense - a sigificant
minority are not.
Use the source, Keith.
Having glanced at the source I'd guess:
@LWP::Protocol::http::EXTRA_SOCK_OPTS = ( LocalAddr => $my_ip );
Note: AFAIK this is not part of the documented LWP API so may not
work in future versions.
Perhaps you should submit a patch to allow per-instance
extra socket options in LWP.
------------------------------
Date: Wed, 26 Mar 2003 00:24:03 +1000
From: nikkirob-7spams@nospamzar.com.au (Leon Roberts)
Subject: Perl doing server builds/LDAP/IMAP/DNS/Bind/Sendmail
Message-Id: <3e8056c5_1@bn.ar.com.au>
I have joined an ISP as a junior Perl programmer. "Junior" in the sense
that I know Perl quite well, but it will be used heavily in a Unix admin
environment, which is rather outside my experience at the moment.
I'm wondering whether there's one or two books which may cover my needs,
or a particularly suitable reference on the internet.
This ISP is big on doing
- 'automatic server builds'
- using huge Perl hashes to store config information (stored with Tied
variables, I think)
- protocols like IMAP, LDAP, SMTP
Other work will involve DNS and Bind, and Sendmail.
I have used sockets and IPC with Perl (no expert by any means) - this
seemed important in getting this role.
My question is, is there a reference that shows Perl being used in
practical situations like this?
I have only a very, very basic knowledge of IMAP and LDAP, and even if
I knew them better, I'd have trouble knowing what to use them for
(particularly LDAP).
I have little practical experience with DNS and therefore BIND.
The interviewer seemed to want me to know things like IMAP, LDAP, and
SMTP, down to being able to sketch out how the protocols work. I've never
read a full RFC, but the ability to do so seemed to be desirable.
(I wasn't the perfect candidate obviously, but something must have clicked)
I've seen some thick O'Reilly books for Sendmail, and for DNS/BIND, and
others publishers' books for LDAP. And of course there's many references
to each of these, separately, on the internet.
I hope I can find something which help me understand why Perl was so
important
for this particular role - it sounds more like a heavy admin role to me.
--
L.R.
------------------------------
Date: Tue, 25 Mar 2003 07:29:46 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Perl PHP and MySQL - Gather Images
Message-Id: <slrnb80mea.6pb.tadmc@magna.augustmail.com>
news.sympatico.ca <patrick@eganconsulting.com> wrote:
> I want to fetch those images and either save them in blobs in my MySQL DB or
> save them to a folder on my server with a reference to the file in the
> MySQL.
>
> We can parse out the links no problem, it is getting the images from an HTTP
> page to the other server that seems to be the problem.
That is not a problem.
If you have the Uniform Resource Locator, all you have to do is
request that resource:
use LWP::Simple;
... determine URL and desired filename here
getstore $URL, $pic_filename;
> This is a sample piece of code to grab the links...
But you said that that part was no problem, so we do not need to see it.
Have you seen the Posting Guidelines that are posted here frequently?
You should try and reduce your problem before posting. Something like:
I have the URL to an image. How can I fetch the image and
store it to a file?
> require 'web.pl'; # file with parseURL routine
Danger Will Robinson!
Most "roll your own" URL-decoding attempts do it incorrectly and/or
introduce the opportunity for security exploits.
You should use a tried-and-true module to do that for you rather
than reinventing that wheel.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 25 Mar 2003 07:35:01 -0800
From: bsnyder030174@yahoo.com (Brian Snyder)
Subject: Re: Question about PERL modules EXPECT/Net::Telnet
Message-Id: <668c9529.0303250735.21283562@posting.google.com>
"Vladimir P." <vladimir@NoSpamPLZ.net> wrote in message news:<Fw2ea.36601$8q2.558324@weber.videotron.net>...
> On 18 Mar 2003 11:43:33 -0800, Brian Snyder wrote:
> > Hi all,
> >
> > I am coding a perl script that will be responsible for kicking off a
> > couple different telnet sessions and capturing their output. I
> > believe I will get teh script to kick off multiple sessions
> > simultaneously by making use of the fork() command.
>
> Why use telnet if you can have your communication secured?
> Try Net::SSH::Perl instead.
Unfortunatly I dont have that option. I am talking to an embedded
device that only has a telnet server in it. This part of the project
is not mine to own, I just have to use what they offer. In any other
circumstance, id agree with you, I never use telnet.
------------------------------
Date: Tue, 25 Mar 2003 13:31:45 -0000
From: "Mike" <mike@luusac.co.uk>
Subject: Re: regexp question (reply re-post)
Message-Id: <0XYfa.2426$N73.18173@newsfep4-glfd.server.ntli.net>
Hi,
yes that did the trick - thanks very much !
Mike
"Michael Budash" <mbudash@sonic.net> wrote in message
news:mbudash-00A986.10305122032003@typhoon.sonic.net...
> In article <mbudash-0C7331.10271322032003@typhoon.sonic.net>,
> Michael Budash <mbudash@sonic.net> wrote:
>
> > In article <LK0fa.439$842.133@newsfep4-winn.server.ntli.net>,
> > "Mike" <mike@luusac.co.uk> wrote:
> >
> > > "Jürgen Exner" <jurgenex@hotmail.com> wrote in message
> > > news:wF%ea.15046$IM3.7673@nwrddc03.gnilink.net...
> > > >
> > > > Mike wrote:
> > > > >
> > > > > But what I want is to assign the contents to a hash (which I
> > > > > understand is a 2 dimensional array in perl ?).
> > > >
> > > > No, it's not. An array is a mapping from natural numbers to scalars.
A
> > > > hash is a mapping from arbitrary strings to scalars.
> > >
> > > Well the ID that I am trying to match (in the first regexp) is
numerical,
> > > but no calculations are done with it - it just acts as an identifier
of a
> > > string, so is a hash what I want ?
>
> note: this is a re-post of my earlier reply, which had several
> mis-spellings:
>
> who knows? you started this thread with one idea, now you've moved on to
> another. please re-state the problem along with a minimally complete
> example of the pertinent data.
>
> with seeing your data, instead based on your comments, i'm gonna go out
> on a limb and propose that this code is [at least closer to] what you
> want:
>
> use strict;
>
> my %hash;
>
> open (D,'data') or die "....: $!";
> while (<D>) {
> if (/ID\: (\d\d\d\d)/) {
> my $key = $1; # save the key match
> while (<D>) { # search second pattern
> if (/#$/) {
> chomp (my $val = scalar <D>);
> $hash{$key} = $val; # enter result into hash
> last;
> }
> }
> }
> }
> close D;
>
> while (my ($k, $v) = each %hash) {
> print "$k=>$v\n";
> }
>
> # or print the hash sorted:
> foreach (sort keys %hash) {
> print "$_=>$hash{$_}\n";
> }
>
> hope this helps
------------------------------
Date: Tue, 25 Mar 2003 13:33:43 -0000
From: "Mike" <mike@luusac.co.uk>
Subject: Re: regexp question
Message-Id: <RYYfa.2427$N73.18158@newsfep4-glfd.server.ntli.net>
Hi Bart,
thanks for the response.
Mike
"Bart Lateur" <bart.lateur@pandora.be> wrote in message
news:9hbq7v8efcmp5o4mfjpo8ios5q47r2bvj9@4ax.com...
> Mike wrote:
>
> >if I have
> >
> >Line 1:<start>Hello World#
> >Line 2:This is what I want
> >Line 3: blah
> >Line 4: blah blah
> >Line 5:<stop>
> >Line 6:<start>Hello Again#
> >Line 7: I want this too !
> >Line 8: blah
> >Line 9: blah blah
> >Line 10:<stop>
> >
> >etc
> >
> >So that I know the content I want will always be preceded by a line which
> >ends in a '#'. Is it possible to do it this way, or will I have to read
in
> >/ slurp the whole file and then parse it ?
>
> May I suggest looking into the ".." range operator? For example:
>
> while(<>) {
> if(my $count = (/^<start>/ .. /^<stop>/)) {
> print "Found: $_" if $count == 2;
> }
> }
>
> Actually, it's quite interresting to see how $count correlates to the
> input data, so maybe change the print line to:
>
> print "$count: $_";
>
> which results in:
>
> 1: <start>Hello World#
> 2: This is what I want
> 3: blah
> 4: blah blah
> 5E0: <stop>
> 1: <start>Hello Again#
> 2: I want this too !
> 3: blah
> 4: blah blah
> 5E0: <stop>
>
> Note the special format of the value at the last line of the condition.
> And just for fun, insert some other lines between the <stop> and the
> next <start>.
>
> p.s. Sorry I didn't focus on your starting point. I though your data had
> some more interesting qualities than just "the first line ends in '$'".
> :)
>
> --
> Bart.
------------------------------
Date: Tue, 25 Mar 2003 15:11:03 GMT
From: "Ning li" <ningli2000@worldnet.att.net>
Subject: Search and replace spaces
Message-Id: <bk_fa.49281$S%3.1684509@bgtnsc04-news.ops.worldnet.att.net>
Hi,
I am new to Perl and I have used awk and sed before. I would like to know
how I can use Perl to do the equivilent of the sed command to remove the
empty spaces at the end of the line: sed 's/ *$//g' filename?
Thanks in advance.
Nick
------------------------------
Date: Tue, 25 Mar 2003 15:35:05 GMT
From: "David" <perl-dvd@darklaser.com>
Subject: Re: Search and replace spaces
Message-Id: <JG_fa.14$xC2.8850@news-west.eli.net>
"Ning li" <ningli2000@worldnet.att.net> wrote in message
news:bk_fa.49281$S%3.1684509@bgtnsc04-news.ops.worldnet.att.net...
> Hi,
>
> I am new to Perl and I have used awk and sed before. I would like
to know
> how I can use Perl to do the equivilent of the sed command to remove
the
> empty spaces at the end of the line: sed 's/ *$//g' filename?
You got it. That's exactly how you do it, only you need to run your
regex on the var that contains your value, like so:
$line =~ s/ *$//g;
Regards,
David
perl -e'print for map chr$_+1,"111100113107044099117099132"=~/(.{3})/g'
------------------------------
Date: Tue, 25 Mar 2003 15:46:24 GMT
From: Steve Grazzini <grazz@nyc.rr.com>
Subject: Re: Search and replace spaces
Message-Id: <kR_fa.2$Ny3.4845@twister.nyc.rr.com>
Ning li <ningli2000@worldnet.att.net> wrote:
>
> I am new to Perl and I have used awk and sed before. I would
> like to know how I can use Perl to do the equivilent of the
> sed command to remove the empty spaces at the end of the line:
> sed 's/ *$//g' filename?
>
That substitution will work in Perl as well. There is a slightly
nicer example (using the "+" quantifier) in the FAQ
$ perldoc -q "blank spaces"
And if you want Perl to behave like sed, just add the -p command
line switch.
$ perl -pe 's/ +$//' filename
--
Steve
------------------------------
Date: Tue, 25 Mar 2003 06:55:52 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: sort by columns
Message-Id: <slrnb80keo.6pb.tadmc@magna.augustmail.com>
Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>>>>>> "Gilles" == Gilles <gproulx@tva.ca> writes:
>Gilles> I need to sort a file that contain 13 columns in the following format :
>
> (And someone else in this thread will probably attach something with
> my namesake in it... :)
OK. :-)
Here's a Schwartzian Transform to obtain the desired order:
----------------------------------
#!/usr/bin/perl
use strict;
use warnings;
my @data = <DATA>;
my @sorted = map { $_->[0] }
sort { $a->[1] <=> $b->[1] || # year
$a->[2] <=> $b->[2] || # month
$a->[3] <=> $b->[3] || # day
$a->[4] cmp $b->[4] || # 1st column
$a->[5] <=> $b->[5] # 8th column
}
map { [ $_, (split)[3,4,5,0,7] ] } @data;
print for @sorted;
__DATA__
PSPIU -5.10 80.60 2003 03 22 16.000 -999 285 3.0 -999.0 -999.00 700.0
CYMAI -5.80 81.20 2003 03 23 8.000 273 285 2.0 -999.0 -999.00 300.0
AAAAA -5.80 81.20 2003 03 20 12.000 273 285 2.0 400.0 -999.00 300.0
CYMAI -5.80 81.20 2003 03 20 12.000 273 285 2.0 -999.0 -999.00 300.0
AAAAA -5.80 81.20 2003 03 20 12.000 273 285 2.0 -999.0 -999.00 300.0
----------------------------------
I ignored column 7 because I do not know what it is, so I don't
know what order to impose on it.
(plus the sample data does not contain a case where that is the only
difference. ie. the test suite is deficient, so the program is too :-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 25 Mar 2003 06:51:49 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: sort by columns
Message-Id: <slrnb80k75.6pb.tadmc@magna.augustmail.com>
Gilles <gproulx@tva.ca> wrote:
> I need to sort a file
> - The date must be in increasing order (columns 4-7)
> - for each date, the field in the first column must be in increasing
> order
> - for each date and for each 1 row, the columns 8 must be also sorted in
> increasing order
>
> in the previous example, I must get something like
>
> AAAAA -5.80 81.20 2003 03 20 12.000 273 285 2.0 -999.0 -999.00 300.0
> AAAAA -5.80 81.20 2003 03 20 12.000 273 285 2.0 400.0 -999.00 300.0
Those 2 lines do not differ in any of the columns that you
want to examine, so can we assume that you don't care what order
they come out in?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 25 Mar 2003 15:41:39 GMT
From: "Charlie Brenneman" <charlie@ispn.net>
Subject: Split loop - Reh Hat 7.3 Perl perl, v5.8.0 built for i386-linux-thread-multi
Message-Id: <OM_fa.48$9d.25726@news.randori.com>
Looking for any suggestions to the following problem. I have downloaded a
script from a site to check the number of users on a systems and then report
them with MRTG but I keep getting this error.
root@mrbig root]# /usr/bin/perl userchk.pl
Split loop at userchk.pl line 19.
[root@mrbig root]# vi userchk.pl
**************This is the script*********************************
# All Rights Reserved
#
# Permission is given for derivitive works to be freely distributed provided
# Original Author is acknowledged, and this copywrite remains intact
#
# DISCLAIMER: Your milage may vary. NO WARRANTY provided. USE, Enjoy, but if
# it blows up , or suchlike, badluck. Author Assumes NO responsibility for
# this work
#
# outputs number of users currently on the sustem using 'uptime', as well as
# the number of unique users on the system
# 9:46PM up 22 days, 10:27, 54 users, load averages: 0.38, 0.16, 0.16
$tmp = `uptime`;
$tmp =~ s/,//g;
@utime = split /\s/, $tmp;
$uniq = `users | wc -w`;
[root@mrbig root]# /usr/bin/perl userchk.pl
Split loop at userchk.pl line 19.
[root@mrbig root]# vi userchk.pl
# Permission is given for derivitive works to be freely distributed provided
# Original Author is acknowledged, and this copywrite remains intact
#
# DISCLAIMER: Your milage may vary. NO WARRANTY provided. USE, Enjoy, but if
# it blows up , or suchlike, badluck. Author Assumes NO responsibility for
# this work
#
# outputs number of users currently on the sustem using 'uptime', as well as
# the number of unique users on the system
# 9:46PM up 22 days, 10:27, 54 users, load averages: 0.38, 0.16, 0.16
$tmp = `uptime`;
$tmp =~ s/,//g;
@utime = split /\s/, $tmp;
$uniq = `users | wc -w`;
$uniq =~ s/\s//g;
#print "$utime[6]\n";
print "$uniq\n";
print "$uniq\n";
print "$utime[3] days $utime[6] hours\n";
print "\n";
[root@mrbig root]#
I am not all that familiar with Perl and don't have a good idea on where to
go from here. Any help would be great.
Thanks,
Charlie
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 4760
***************************************