[30106] in Perl-Users-Digest
Perl-Users Digest, Issue: 1349 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 10 16:10:08 2008
Date: Mon, 10 Mar 2008 13:09:32 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 10 Mar 2008 Volume: 11 Number: 1349
Today's topics:
Re: how to read user's IP adress with Perl? <tzz@lifelogs.com>
How to submit an HTTP Request with XML <karinwalike@comcast.net>
Re: How to submit an HTTP Request with XML <glex_no-spam@qwest-spam-no.invalid>
Re: list of day/month names in all locales <someone@example.com>
Re: Net::SMTP - "Bad File Number" error ? <wheeledBobNOSPAM@yahoo.com>
Re: Net::SMTP - "Bad File Number" error ? <wheeledBobNOSPAM@yahoo.com>
Re: Pattern extraction <cwilbur@chromatico.net>
Re: Pattern extraction <abigail@abigail.be>
Re: Pattern extraction <jimsgibson@gmail.com>
Re: Recommendation for a SNMP module to collect asset d <not@home.net>
Re: Setting chmod <John.Smith@invalid.com>
Re: Setting chmod <joost@zeekat.nl>
Re: Setting chmod <John.Smith@invalid.com>
Re: Setting chmod <joost@zeekat.nl>
Re: Setting chmod <joost@zeekat.nl>
Re: Setting chmod <abigail@abigail.be>
Re: Setting chmod <joost@zeekat.nl>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 10 Mar 2008 09:52:09 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: how to read user's IP adress with Perl?
Message-Id: <86lk4qskbq.fsf@lifelogs.com>
On Mon, 10 Mar 2008 13:03:42 GMT "John W. Krahn" <someone@example.com> wrote:
JWK> vikram wrote:
>> On Mar 8, 1:51 pm, "Marthan" <mart...@csv.t-portal.cc> wrote:
>>> how to read user's IP adress with Perl?
>>
>> (\d)\.(\d)\.(\d)\.(\d)
>>
>> represents the ipaddress.
JWK> 66.94.234.13 is a valid IP address which won't be matched by that pattern.
You should at least mention Regexp::Common if you're correcting an IP
address pattern. I know the original question was not about that, but
it's still better to make a useful reply than just to point out a
counter-example.
Ted
------------------------------
Date: Mon, 10 Mar 2008 10:06:16 -0700 (PDT)
From: kwalike57 <karinwalike@comcast.net>
Subject: How to submit an HTTP Request with XML
Message-Id: <c7f21064-1138-4a21-9907-416fff9a4caa@p73g2000hsd.googlegroups.com>
Hello. I need to build a process in an existing Perl script the
submits an http request with some XML.
I have never done this in Perl and I need to know which modules to use
and how to compose the syntax in the script to send this request.
Here is what the fully composed request needs to look like:
http://ppld.corp.sprint.com/wlsapps2/livelink_wls/Upload91?control=<?xml
version="1.0" encoding="ISO-8859-1"?><LIVELINKUPLOAD ID="1"><LOADINFO
Host="DOC-SHARE" LOGIN="xxxxxxx" PASSWORD="xxxxxxx"
DELETESOURCE="TRUE" OUTPUT="XML" LOADTYPE="PATH"/><FILEINFO
FILENAME="TRS_926106383.pdf"
FTPFILENAME="926106383.pdf"><FOLDERPATH><FOLDER
FOLDERNAME="Information Technology"/></FOLDERPATH><FOLDERPATH><FOLDER
FOLDERNAME="IT Billing and Customer Care Systems (CBS)"/></
FOLDERPATH><FOLDERPATH><FOLDER FOLDERNAME="CBS - Customer Billing
Services"/></FOLDERPATH><FOLDERPATH><FOLDER FOLDERNAME="TRS Billing"/
></FOLDERPATH><FOLDERPATH><FOLDER FOLDERNAME="2007"/></
FOLDERPATH><FOLDERPATH><FOLDER FOLDERNAME="Invoices"/></FOLDERPATH></
FILEINFO></LIVELINKUPLOAD>
If I paste this request string into a browser from the host machine
where the Perl script will run from it executes perfectly, basically
taking the .pdf file named in the command and uploading it to an
online document library called Doc-Share where it is then viewable to
users who log in.
It also deletes the source .pdf file from an SFTP server where
the .pdf files reside prior to upload to Doc-Share.
Please let me know how I would add this automation to Perl.
I have already written the Perl to generate the XML containing the
name of each .pdf file that needs to upload. I have used the
XML:Simple to parse the XML string and hold it in a variable, "<?xml
version="1.0" encoding="ISO-8859-1"?><LIVELINKUPLOAD ID="1"><LOADINFO
Host="DOC-SHARE" LOGIN="xxxxxxx" PASSWORD="xxxxxxx"
DELETESOURCE="TRUE" OUTPUT="XML" LOADTYPE="PATH"/><FILEINFO
FILENAME="TRS_926106383.pdf"
FTPFILENAME="926106383.pdf"><FOLDERPATH><FOLDER
FOLDERNAME="Information Technology"/></FOLDERPATH><FOLDERPATH><FOLDER
FOLDERNAME="IT Billing and Customer Care Systems (CBS)"/></
FOLDERPATH><FOLDERPATH><FOLDER FOLDERNAME="CBS - Customer Billing
Services"/></FOLDERPATH><FOLDERPATH><FOLDER FOLDERNAME="TRS Billing"/
></FOLDERPATH><FOLDERPATH><FOLDER FOLDERNAME="2007"/></
FOLDERPATH><FOLDERPATH><FOLDER FOLDERNAME="Invoices"/></FOLDERPATH></
FILEINFO></LIVELINKUPLOAD>" .
I have the http request in a separate variable as "http://
ppld.corp.sprint.com/wlsapps2/livelink_wls/Upload91?control=".
I then plan on running the http request with the XML string for
each .pdf file, 46 .pdf files in all.
Let me know if I need to provide any additional info to better
describe the process.
Thanks for your help.
Karin Walike
------------------------------
Date: Mon, 10 Mar 2008 13:06:05 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: How to submit an HTTP Request with XML
Message-Id: <47d5788d$0$89870$815e3792@news.qwest.net>
kwalike57 wrote:
> Hello. I need to build a process in an existing Perl script the
> submits an http request with some XML.
>
> I have never done this in Perl and I need to know which modules to use
> and how to compose the syntax in the script to send this request.
[...]
To POST something via HTTP, you could start with LWP:
perldoc lwpcook
------------------------------
Date: Mon, 10 Mar 2008 13:41:15 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: list of day/month names in all locales
Message-Id: <%TaBj.75307$w57.69474@edtnps90>
myicq wrote:
> Do anyone have an idea about how to output day / month names
> in all known locales (for current system).
>
> This can be in array-form, or a simple list, such as
>
> Locale: Danish (DA_DK)
> man, tir, ons...
> jan, feb, mar
>
> Locale: Deutsch (DE)
> mon, die, mit
>
> Etc
>
> I can't find any information about how to list all available
> locales on the system, and query month / day names for that locale.
> Basically to iterate over all known locales.
>
> Can anyone help ?
perldoc perllocale
perldoc I18N::Langinfo
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
------------------------------
Date: Mon, 10 Mar 2008 19:57:16 GMT
From: still just me <wheeledBobNOSPAM@yahoo.com>
Subject: Re: Net::SMTP - "Bad File Number" error ?
Message-Id: <dc4bt3d72b8s9jmmf3d3bdsumse59qj67b@4ax.com>
On Sun, 09 Mar 2008 05:11:34 -0700, Joe Smith <joe@inwap.com> wrote:
>still just me wrote:
>> I'm using Net::SMTP to send mail from a perl program running on a web
>> server. Code is as follows:
>>
>> my $relay="smtp.example.com";
>> my $smtp = Net::SMTP->new($relay);
>> die "Could not open connection: $!" if (! defined $smtp);
>
>The docs for Net::SMTP does not say that it sets $!, so don't rely on that.
>
>Have you tried turning on debugging?
>
> $smtp = Net::SMTP->new(
> Host => 'smtp.example.com',
> Hello => 'my.mail.domain'
> Timeout => 30,
> Debug => 1,
> );
Interesting on the $! issue... it seems to throw the right error when
the connection is refused. As you noted, perhaps the other message is
not reliable.
What should the debug mode above do for me? I don't seem to get any
additional information when I incorporate it.
------------------------------
Date: Mon, 10 Mar 2008 20:01:00 GMT
From: still just me <wheeledBobNOSPAM@yahoo.com>
Subject: Re: Net::SMTP - "Bad File Number" error ?
Message-Id: <lp4bt31i7rdabulckkut41rnh41dunvlgu@4ax.com>
On Mon, 10 Mar 2008 19:57:16 GMT, still just me
<wheeledBobNOSPAM@yahoo.com> wrote:
>Interesting on the $! issue... it seems to throw the right error when
>the connection is refused. As you noted, perhaps the other message is
>not reliable.
>
>What should the debug mode above do for me? I don't seem to get any
>additional information when I incorporate it.
Whoops... ignore that question about the debug mode. Operator error
prevented me from seeing that it was dumping a message. I'll continue
studying the original issue.
Thanks,
------------------------------
Date: 10 Mar 2008 09:55:22 -0400
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: Pattern extraction
Message-Id: <87skyyu1it.fsf@mithril.chromatico.net>
>>>>> "D" == "Deepan <- M.Sc(SE) - 03MW06" <deepan.17@gmail.com>> writes:
D> I am having a string like below: $str="/a/b/c/"; (or) $str =
D> "/a/b/c/d/";
D> What i need is that i should always be able to extract "c" from
D> the above strings. I should not use split. Only by using
D> regular expressions i should be able to achieve this. Please
D> help me to solve this.
Split is the best way to solve this in Perl.
If this restriction is because that's what your teacher said, go ask
your teacher. He or she is being paid to teach you; we are not.
If this restriction is because you're using some language other than
Perl, which doesn't have a split function, ask in a forum appropriate
for that language.
Charlton
--
Charlton Wilbur
cwilbur@chromatico.net
------------------------------
Date: 10 Mar 2008 14:26:16 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: Pattern extraction
Message-Id: <slrnftah88.ec.abigail@alexandra.abigail.be>
_
Deepan - M.Sc(SE) - 03MW06 (deepan.17@gmail.com) wrote on VCCCV September
MCMXCIII in <URL:news:ae96a569-192c-49f4-a009-adc2052c15fd@d4g2000prg.googlegroups.com>:
"" I am having a string like below:
""
"" $str="/a/b/c/"; (or) $str = "/a/b/c/d/";
""
"" What i need is that i should always be able to extract "c" from the
"" above strings. I should not use split. Only by using regular
"" expressions i should be able to achieve this. Please help me to solve
"" this.
Easy piecy!
$str = "/a/b/c/"; # Or "/a/b/c/d/".
my $answer = substr $str, 5, 1;
say $answer;
#
# Dummy regexp to satisfy the homework requirements.
#
"" =~ /nananana/;
Abigail
--
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
print } sub __PACKAGE__ { &
print ( __PACKAGE__)} &
__PACKAGE__
( )
------------------------------
Date: Mon, 10 Mar 2008 10:34:13 -0700
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: Pattern extraction
Message-Id: <100320081034135766%jimsgibson@gmail.com>
In article <slrnftah88.ec.abigail@alexandra.abigail.be>, Abigail
<abigail@abigail.be> wrote:
> _
> Deepan - M.Sc(SE) - 03MW06 (deepan.17@gmail.com) wrote on VCCCV September
> MCMXCIII in
> <URL:news:ae96a569-192c-49f4-a009-adc2052c15fd@d4g2000prg.googlegroups.com>:
> "" I am having a string like below:
> ""
> "" $str="/a/b/c/"; (or) $str = "/a/b/c/d/";
> ""
> "" What i need is that i should always be able to extract "c" from the
> "" above strings. I should not use split. Only by using regular
> "" expressions i should be able to achieve this. Please help me to solve
> "" this.
>
>
> Easy piecy!
>
>
> $str = "/a/b/c/"; # Or "/a/b/c/d/".
> my $answer = substr $str, 5, 1;
>
> say $answer;
>
> #
> # Dummy regexp to satisfy the homework requirements.
> #
> "" =~ /nananana/;
But that doesn't use a regular expression. The OP insisted on using a
regular expression. Here is a regular expression that will extract a
'c' from any given string:
if( $string =~ /(c)/ ) {
print "$1\n";
}
:)
--
Jim Gibson
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
------------------------------
Date: Mon, 10 Mar 2008 16:19:34 +0100
From: Tom Brown <not@home.net>
Subject: Re: Recommendation for a SNMP module to collect asset data from Cisco devices
Message-Id: <2008031016193475249-not@homenet>
On 2008-03-01 09:29:13 +0100, Martijn Lievaart <m@rtij.nl.invlalid> said:
> I use Net::SNMP. It's simple, effective and seems to suit your needs.
>
> M4
Thanks Martijn for the suggestion. I didn't expect any other recomendation. ;-)
------------------------------
Date: Mon, 10 Mar 2008 16:12:59 +0200
From: John <John.Smith@invalid.com>
Subject: Re: Setting chmod
Message-Id: <1cgat3l0on337m5noe02h2kdm842g46nch@4ax.com>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
>Joost Diepenmaat wrote:
>> Gunnar Hjalmarsson <noreply@gunnar.cc> writes:
>>
>>> $ cat test.pl
>>> print "$^O\n";
>>> open(TEKST,">test.txt") or die $!;
>>> chmod 0600,*TEKST or die $!;
>>> $ perl test.pl
>>> linux
>>> No such file or directory at test.pl line 3.
>>> $ ls -l test.txt
>>> -rw-rw-r-- 1 gunnarh gunnarh 0 Mar 9 18:42 test.txt
>>> $
>>
>> Agh. I just checked and this code only runs as I described in perl 5.8.8
>> and higher. Older perls don't accept file handles as arguments to chmod.
>
>That explains it; I'm using v5.8.1.
I am confused.
So what should the chmod line have if I have Perl 5?
Some say it should be *TEKST, others something else.
------------------------------
Date: Mon, 10 Mar 2008 16:58:41 +0100
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: Setting chmod
Message-Id: <874pbe605q.fsf@zeekat.nl>
John <John.Smith@invalid.com> writes:
> Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> I am confused.
> So what should the chmod line have if I have Perl 5?
> Some say it should be *TEKST, others something else.
perl 5.8 and 5.10 are also perl 5s, but if you want to be compatible
with older perls, it's probably best to use the optional PERMS argument
to sysopen instead of combining open and chmod:
use Fctnl qw(O_WRONLY);
sysopen TEXT,"myfile.txt",O_WRONLY,0600 or die $!;
or, possibly, use the umask() function to change the default permissions
and then use open().
and only use chmod() if you want to change the permissions of files
you're not otherwise writing to.
See perldoc -f umask and perldoc -f sysopen
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
------------------------------
Date: Mon, 10 Mar 2008 20:49:48 +0200
From: John <John.Smith@invalid.com>
Subject: Re: Setting chmod
Message-Id: <rj0bt3dh8o5u3gt3ssv5gjq50215tnkq3g@4ax.com>
Joost Diepenmaat <joost@zeekat.nl> wrote:
>John <John.Smith@invalid.com> writes:
>
>> Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
>> I am confused.
>> So what should the chmod line have if I have Perl 5?
>> Some say it should be *TEKST, others something else.
>
>perl 5.8 and 5.10 are also perl 5s, but if you want to be compatible
>with older perls, it's probably best to use the optional PERMS argument
>to sysopen instead of combining open and chmod:
>
>use Fctnl qw(O_WRONLY);
>sysopen TEXT,"myfile.txt",O_WRONLY,0600 or die $!;
>
>or, possibly, use the umask() function to change the default permissions
>and then use open().
>
>and only use chmod() if you want to change the permissions of files
>you're not otherwise writing to.
>
>See perldoc -f umask and perldoc -f sysopen
OK I finally found what really works without using external library:
$sec=open(TEKST,">test.txt");
chmod 0600,"test.txt";
binmode(TEKST);
print TEKST ""hello world";
close TEKST;
0600 everytime.
------------------------------
Date: Mon, 10 Mar 2008 19:59:13 +0100
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: Setting chmod
Message-Id: <87fxuy4d8e.fsf@zeekat.nl>
John <John.Smith@invalid.com> writes:
> OK I finally found what really works without using external library:
>
> $sec=open(TEKST,">test.txt");
> chmod 0600,"test.txt";
> binmode(TEKST);
> print TEKST ""hello world";
> close TEKST;
>
> 0600 everytime.
Well, almost everytime: if someone else unlinks, overwrites, or moves
the file (possibly replacing it with another) between the open() and
chmod() call this won't do what you expect. Which is why using sysopen()
or umask() and open() (or using perl5.8.8+'s chmod HANDLE) is better if
you're working in a multi-tasking environment.
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
------------------------------
Date: Mon, 10 Mar 2008 20:01:58 +0100
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: Setting chmod
Message-Id: <878x0q4d3t.fsf@zeekat.nl>
John <John.Smith@invalid.com> writes:
> $sec=open(TEKST,">test.txt");
> chmod 0600,"test.txt";
Addendum:
You *really* should check the return values of those calls.
canonically:
open(TEXT,">test.txt") or die "Can't open test.txt for writing: $!";
chmod 0600,"test.txt" or die "Can't chmod test.txt: $!";
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
------------------------------
Date: 10 Mar 2008 19:21:44 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: Setting chmod
Message-Id: <slrnftb2i8.ec.abigail@alexandra.abigail.be>
_
Joost Diepenmaat (joost@zeekat.nl) wrote on VCCCV September MCMXCIII in
<URL:news:87fxuy4d8e.fsf@zeekat.nl>:
!! John <John.Smith@invalid.com> writes:
!!
!! > OK I finally found what really works without using external library:
!! >
!! > $sec=open(TEKST,">test.txt");
!! > chmod 0600,"test.txt";
!! > binmode(TEKST);
!! > print TEKST ""hello world";
!! > close TEKST;
!! >
!! > 0600 everytime.
!!
!! Well, almost everytime: if someone else unlinks, overwrites, or moves
!! the file (possibly replacing it with another) between the open() and
!! chmod() call this won't do what you expect. Which is why using sysopen()
!! or umask() and open() (or using perl5.8.8+'s chmod HANDLE) is better if
!! you're working in a multi-tasking environment.
Well, if someone else unlinks, overwrites or moves the file, the program
most likely doesn't do what you expect, regardless whether this happens
before, or after the chmod. And your program doesn't magically do what
you expect under such conditions if you use sysopen.
Abigail
--
perl -e '$a = q 94a75737420616e6f74686572205065726c204861636b65720a9 and
${qq$\x5F$} = q 97265646f9 and s g..g;
qq e\x63\x68\x72\x20\x30\x78$&eggee;
{eval if $a =~ s e..eqq qprint chr 0x$& and \x71\x20\x71\x71qeexcess}'
------------------------------
Date: Mon, 10 Mar 2008 20:29:29 +0100
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: Setting chmod
Message-Id: <873aqy4bty.fsf@zeekat.nl>
Abigail <abigail@abigail.be> writes:
> Well, if someone else unlinks, overwrites or moves the file, the program
> most likely doesn't do what you expect, regardless whether this happens
> before, or after the chmod. And your program doesn't magically do what
> you expect under such conditions if you use sysopen.
You're right, of course. It's just one of the things to
consider. Another is that in this case, the file is supposed to be
unreadable for anyone but the user writing it, but using
chmod($filename) after an open() leaves a short time window during which
someone else could possibly open the file for reading (or maybe even
read+write), which would give them access to the contents of the file as
long as they keep the handle.
Just saying, /if/ you need to specify restrictive permissions, you
probably want to do that it reliably as possible.
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 1349
***************************************