[28803] in Perl-Users-Digest
Perl-Users Digest, Issue: 47 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 18 14:06:04 2007
Date: Thu, 18 Jan 2007 11:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 18 Jan 2007 Volume: 11 Number: 47
Today's topics:
Re: convert Vbscript to Perl code <tzz@lifelogs.com>
help problemes cgi and GD::Text <john.swilting@wanadoo.fr>
How to decode javascript encodeURI / encodeURIComponent <Cloink_Friggson@ntlworld.com>
Re: How to decode javascript encodeURI / encodeURICompo <rprp@gmx.net>
Re: How to decode javascript encodeURI / encodeURICompo <bik.mido@tiscalinet.it>
Re: How to decode javascript encodeURI / encodeURICompo <nobull67@gmail.com>
Re: How to decode javascript encodeURI / encodeURICompo <nobull67@gmail.com>
Re: How to decode javascript encodeURI / encodeURICompo <john@castleamber.com>
Re: I/O open() <mmccaws@comcast.net>
Re: need help with the tr and s/// <bik.mido@tiscalinet.it>
Re: need help with the tr and s/// <bik.mido@tiscalinet.it>
Perl + Java corrieknor@hotmail.com
Perl + Java corrieknor@hotmail.com
Perl + Java corrieknor@hotmail.com
Re: Perl + Java corrieknor@hotmail.com
Re: Perl + Java <mritty@gmail.com>
Re: Perl + Java <bik.mido@tiscalinet.it>
Re: Perl + Java <bik.mido@tiscalinet.it>
Re: Perl + Java xhoster@gmail.com
Re: regex problem <dollente@gmail.com>
Regexp for parsing windows filepath on Unix Milagro
Re: Regexp for parsing windows filepath on Unix <spamtrap@dot-app.org>
Re: Translation please <bik.mido@tiscalinet.it>
Re: Translation please <pleaselogout@gmail.com>
Re: Unable to find form <glex_no-spam@qwest-spam-no.invalid>
Re: Unable to find form <spamtrap@dot-app.org>
Re: Variable substitution <zen13097@zen.co.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 18 Jan 2007 11:23:47 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: convert Vbscript to Perl code
Message-Id: <g69tzyotib0.fsf@dhcp-65-162.kendall.corp.akamai.com>
On 18 Jan 2007, uri@stemsystems.com wrote:
> i am the mindless drone of your nightmare. please put yourself on the
> line of fools forming to the right ----------->
>
> anonymity is another way to make yourself ignored. cowards have no
> rights to attack others. this is not a court of law or where you need to
> be in the witless (sic) protection program. and the rule of not helping
> with perl also stands. have you helped an old lady with her perl today?
Uri, please stop flame-baiting and let this thread die (+killfile,
whatever works for you). You know better. This group is supposed to
be for technical discussions.
Ted
------------------------------
Date: Thu, 18 Jan 2007 19:52:31 +0100
From: "john.swilting" <john.swilting@wanadoo.fr>
Subject: help problemes cgi and GD::Text
Message-Id: <45afc1e6$0$27415$ba4acef3@news.orange.fr>
How to use GD::Text
The documentation says
my $gd_text = GD::Text->new(
text => 'Some text',
font => 'funny.ttf',
ptsize => 14,
);
And I have
#!/usr/bin/perl -w
use strict;
use diagnostics;
use GD;
##use GD::Text;
use CGI;
use CGI::Carp;
my $q = new CGI;
# create a new
my $im = new GD::Image(100,100);
# allocate some colors
my $white = $im->colorAllocate(255,255,255);
my $black = $im->colorAllocate(0,0,0);
my $red = $im->colorAllocate(255,0,0);
my $blue = $im->colorAllocate(0,0,255);
# make the background tra $im_pngnsparent and interlaced
$im->transparent($white);
$im->interlaced('true');
# put a black frame around the picture
$im->rectangle(0,0,99,99,$black);
# draw a blue oval
$im->arc(50,50,95,75,0,360,$blue);
# and fill it with red
$im->fill(50,50,$red);
print $q->header( -type => "image/png", -expires => "-1d");
binmode STDOUT;
print $im->png
How to make
So that both work together
------------------------------
Date: 18 Jan 2007 05:33:44 -0800
From: "Cloink" <Cloink_Friggson@ntlworld.com>
Subject: How to decode javascript encodeURI / encodeURIComponent ?
Message-Id: <1169127224.280238.254110@11g2000cwr.googlegroups.com>
Simply: How ?
I can't believe no-one's already done it, but I can't find any exact
mention of it on the tinterweb.
Closest I got was someone suggesting a custom javascript function to
encode a URI in the style that Perl expects - no way Jos=E9 - what's the
point in the W3C standardising this stuff for all our benefits if we go
and write custom functions instead.
So come on - I need a Perl function to decode a URL that has been
encoded with a javascript encodeURI() or encodeURIComponent() call.
Alternatively, I can write the Perl function myself if someone can
explain how the encoding works in the js funcs?
e=2Eg.
=E9 (e-acute) is encoded via encodeURIComponent to %C3%A9, which doesn't
obviously tie in with the Unicode specification 00E9. But the js
references I've read claim that it is Unicode compliant, so what am I
missing?
Cheers all.
Cloink
------------------------------
Date: Thu, 18 Jan 2007 16:03:37 +0100
From: Reinhard Pagitsch <rprp@gmx.net>
Subject: Re: How to decode javascript encodeURI / encodeURIComponent ?
Message-Id: <45af8c49$0$49207$14726298@news.sunsite.dk>
Cloink wrote:
> Simply: How ?
>
> I can't believe no-one's already done it, but I can't find any exact
> mention of it on the tinterweb.
>
> Closest I got was someone suggesting a custom javascript function to
> encode a URI in the style that Perl expects - no way José - what's the
> point in the W3C standardising this stuff for all our benefits if we go
> and write custom functions instead.
>
> So come on - I need a Perl function to decode a URL that has been
> encoded with a javascript encodeURI() or encodeURIComponent() call.
>
> Alternatively, I can write the Perl function myself if someone can
> explain how the encoding works in the js funcs?
>
> e.g.
> é (e-acute) is encoded via encodeURIComponent to %C3%A9, which doesn't
> obviously tie in with the Unicode specification 00E9. But the js
> references I've read claim that it is Unicode compliant, so what am I
> missing?
>
> Cheers all.
> Cloink
>
Maybe the following modules will help you:
CGI::Deurl and CGI::Enurl
regards
Reinhard
--
PM Mails an rpirpag <at> gmx dot at
------------------------------
Date: Thu, 18 Jan 2007 17:13:09 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: How to decode javascript encodeURI / encodeURIComponent ?
Message-Id: <is6vq2tlv5qdo6279uv3osleo38gn6tiep@4ax.com>
On 18 Jan 2007 05:33:44 -0800, "Cloink" <Cloink_Friggson@ntlworld.com>
wrote:
>I can't believe no-one's already done it, but I can't find any exact
>mention of it on the tinterweb.
What is the tinterweb?!?
>So come on - I need a Perl function to decode a URL that has been
>encoded with a javascript encodeURI() or encodeURIComponent() call.
URI::Escape would seem to be a good starting point...
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: 18 Jan 2007 09:45:04 -0800
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: How to decode javascript encodeURI / encodeURIComponent ?
Message-Id: <1169142304.924743.73230@11g2000cwr.googlegroups.com>
On Jan 18, 4:13 pm, Michele Dondi <bik.m...@tiscalinet.it> wrote:
> On 18 Jan 2007 05:33:44 -0800, "Cloink" <Cloink_Frigg...@ntlworld.com>
> wrote:
>
> >So come on - I need a Perl function to decode a URL that has been
> >encoded with a javascript encodeURI() or encodeURIComponent() call.
> URI::Escape would seem to be a good starting point...
The docs thereof point out that "The JavaScript encodeURI() function is
similar to uri_escape_utf8()".
Oddly, however there's no uri_unescape_utf8 provided by URI::Escape.
However combining URI::Escape::uri_unescape() and Encode::decode_utf8()
in one statement is not overly taxing.
use Encode;
use URI::Escape qw(uri_unescape);
my $decoded = decode_utf8 uri_unescape $encoded;
------------------------------
Date: 18 Jan 2007 09:54:50 -0800
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: How to decode javascript encodeURI / encodeURIComponent ?
Message-Id: <1169142890.248501.154860@s34g2000cwa.googlegroups.com>
On Jan 18, 1:33 pm, "Cloink" <Cloink_Frigg...@ntlworld.com> wrote:
> Simply: How ?
This is (almost) FAQ: "How do I decode or create those %-encodings on
the web?"
> I can't believe no-one's already done it, but I can't find any exact
> mention of it on the tinterweb.
But there is (almost) an exact mention in the FAQ.
> Closest I got was someone suggesting a custom javascript function to
> encode a URI in the style that Perl expects - no way Jos=E9 - what's the
> point in the W3C standardising this stuff for all our benefits if we go
> and write custom functions instead.
If you are going to mention a standard it's couresy to provide a link.
> So come on - I need a Perl function to decode a URL that has been
> encoded with a javascript encodeURI() or encodeURIComponent() call.
>
> Alternatively, I can write the Perl function myself if someone can
> explain how the encoding works in the js funcs?
Hang on, didn't you just say there was a W3C standard?
> e.g.
> =E9 (e-acute) is encoded via encodeURIComponent to %C3%A9, which doesn't
> obviously tie in with the Unicode specification 00E9. But the js
> references I've read claim that it is Unicode compliant, so what am I
> missing?
Unicode gives each character a "code point". That is a pure number. The
way that number is encoded as a byte sequence is another thing. Unicode
defines a number of such encodings. The way U+E9 is represented in the
most common Unicode encoding (utf8) is the byte seqence 0xC3,0xA9. So
it looks like encodeURIComponent is encoding the utf8 byte seqence.
------------------------------
Date: 18 Jan 2007 18:44:38 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: How to decode javascript encodeURI / encodeURIComponent ?
Message-Id: <Xns98BC81A224EAEcastleamber@130.133.1.4>
"Brian McCauley" <nobull67@gmail.com> wrote:
> Hang on, didn't you just say there was a W3C standard?
As far as I know there isn't such a thing as a W3C standard :-D.
--
John Experienced Perl programmer: http://castleamber.com/
Perl help, tutorials, and examples: http://johnbokma.com/perl/
------------------------------
Date: 18 Jan 2007 07:09:42 -0800
From: "mmccaws2" <mmccaws@comcast.net>
Subject: Re: I/O open()
Message-Id: <1169132982.814508.255680@m58g2000cwm.googlegroups.com>
Sherm Pendley wrote:
> "mmccaws2" <mmccaws@comcast.net> writes:
>
> > I'm trying to understand the I/O open function better.
>
> Have you read "perldoc perlopentut"?
>
> sherm--
>
> --
> Web Hosting by West Virginians, for West Virginians: http://wv-www.net
> Cocoa programming in Perl: http://camelbones.sourceforge.net
Thanks
That looks like the tutorial that I need.
Everybody, I'll be working through the rest of the recommendations
today. I know that I've had problems either with my ide on osx
recognizing net-dns module or installing it. I'll try running a script
outside the ide to see if that is the probem.
Mike
------------------------------
Date: Thu, 18 Jan 2007 12:19:05 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: need help with the tr and s///
Message-Id: <0dluq291m91l5ud1cgt43dsj49f4qu6ua2@4ax.com>
On Wed, 17 Jan 2007 19:21:15 -0700, Mark Donovan
<novafyre@hotmail.com> wrote:
>Find the trailing zeros on the first string, count them, remove trailing
>zeros from the second string, and append new trailing zeros to the second
>string.
>
>$s1 =~ m/(0*)\z/;
>$len = length $1;
>$s2 =~ s/(.*?)0*\z/$1/;
>$s2 .= '0' x $len;
This amounts to getting a string of zeroes, getting its length and
rebuild it based on this length, there's clearly an unnecessary
passage:
my ($pad) = $s1 =~ /(0*)\z/g;
$s2 =~ s/(.*?)0*\z/$1$pad/;
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Thu, 18 Jan 2007 13:57:34 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: need help with the tr and s///
Message-Id: <4gruq2lgmjf1gt4q5hk961bihal32c73gh@4ax.com>
On Thu, 18 Jan 2007 12:19:05 +0100, Michele Dondi
<bik.mido@tiscalinet.it> wrote:
>This amounts to getting a string of zeroes, getting its length and
>rebuild it based on this length, there's clearly an unnecessary
>passage:
>
> my ($pad) = $s1 =~ /(0*)\z/g;
> $s2 =~ s/(.*?)0*\z/$1$pad/;
Or even in a single s/// statement (not that I'd recommend it):
$s2 =~ s/(.*?)0*\z/$1 . do{($s1 =~ m|(0*)\z|g)[0]}/e;
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: 18 Jan 2007 05:06:04 -0800
From: corrieknor@hotmail.com
Subject: Perl + Java
Message-Id: <1169125564.845449.136310@11g2000cwr.googlegroups.com>
Is it possible to call a java program from within my perl code and use
the return value from the java program in my perl program?
Thanks in advance
Corrie
------------------------------
Date: 18 Jan 2007 05:06:03 -0800
From: corrieknor@hotmail.com
Subject: Perl + Java
Message-Id: <1169125563.630414.67950@m58g2000cwm.googlegroups.com>
Is it possible to call a java program from within my perl code and use
the return value from the java program in my perl program?
Thanks in advance
Corrie
------------------------------
Date: 18 Jan 2007 05:06:00 -0800
From: corrieknor@hotmail.com
Subject: Perl + Java
Message-Id: <1169125559.383186.7810@51g2000cwl.googlegroups.com>
Is it possible to call a java program from within my perl code and use
the return value from the java program in my perl program?
Thanks in advance
Corrie
------------------------------
Date: 18 Jan 2007 06:26:40 -0800
From: corrieknor@hotmail.com
Subject: Re: Perl + Java
Message-Id: <1169130400.575510.69920@m58g2000cwm.googlegroups.com>
Also: The Perl script should parse a paramter to the Java application
------------------------------
Date: 18 Jan 2007 06:55:28 -0800
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Perl + Java
Message-Id: <1169132127.997176.261730@11g2000cwr.googlegroups.com>
corrieknor@hotmail.com wrote:
> Is it possible to call a java program from within my perl code and use
> the return value from the java program in my perl program?
Yes.
perldoc -f system
Paul Lalli
------------------------------
Date: Thu, 18 Jan 2007 17:08:20 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Perl + Java
Message-Id: <jh6vq2l9ifnckpalhigcbrm4r3ltht1brv@4ax.com>
On 18 Jan 2007 05:06:04 -0800, corrieknor@hotmail.com wrote:
>Is it possible to call a java program from within my perl code and use
>the return value from the java program in my perl program?
Yes. More precisely you can use system() to run a program regardless
of the language it is written in, and inspect its return value to find
the exit status - remember that you will have to shift it right by
eight for the actual one.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Thu, 18 Jan 2007 17:08:22 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Perl + Java
Message-Id: <qq6vq257igkm6tq04v7npst0l3amnhsom3@4ax.com>
On 18 Jan 2007 06:26:40 -0800, corrieknor@hotmail.com wrote:
>Also: The Perl script should parse a paramter to the Java application
What does this mean?
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: 18 Jan 2007 17:17:30 GMT
From: xhoster@gmail.com
Subject: Re: Perl + Java
Message-Id: <20070118121829.434$EL@newsreader.com>
"Paul Lalli" <mritty@gmail.com> wrote:
> corrieknor@hotmail.com wrote:
> > Is it possible to call a java program from within my perl code and use
> > the return value from the java program in my perl program?
>
> Yes.
>
> perldoc -f system
Or Inline::Java
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 18 Jan 2007 10:09:23 -0800
From: "eldwin" <dollente@gmail.com>
Subject: Re: regex problem
Message-Id: <1169143763.341389.215230@q2g2000cwa.googlegroups.com>
> > 0|PROSTAFF|XX|Another approach is to use split to break up your line into the
> substrings that occur between pipe characters, modify every other
> substring, and put the line back together (untested):
>
> my @f = split(m{\|},$string);
> for( my $i = 1; $i <= $#f; $i += 2 ) {
> $f[$i] =~ s/^STAFF$/PROSTAFF/;
> }
> my $newstring = join('|',@f);
>
The split function did the trick. Thanks for your help.
------------------------------
Date: Thu, 18 Jan 2007 13:55:29 -0500
From: Milagro
Subject: Regexp for parsing windows filepath on Unix
Message-Id: <1169146656_191@news-east.n>
Hi,
I'm a fairly experienced perl programmer but am having problem with
what should be a very simple regular expression. Here's the problem.
I have a file coming into a Linux Box from a Win32 machine via Http.
I'm able to capture the file and move it over intact to my Linux box
with no problem. The problem comes when I try and check the filename
for invalid characters before accepting it.
I've discovered that when a user uploads the file with IE (not sure
what version), the entire path to the file is sent (as opposed to
FireFox which only returns the filename). So I'm left with something
like this in my input variable when someone uploads:
$fname = "C:\My Documents\My files\file1.doc";
I need to parse the line above so all I get is whatever is after the
last slash; in this case "file1.doc".
I've tried using various RegExp's but none of them work. I think I know
why though -- when I try and print out the $fname variable before
running any RegExp's on it, it prints back out without the slashes!
Since "\" is a typical esc character It won't print it out unless I
acually escape it first (C:\\My Documents\\My files\\file1.doc). I
can't do that though because this filepath is being returned to me, I'm
not creating it.
I've been trying many different things but so far none has worked.
Thanks for any help you can give me!
Mike
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
------------------------------
Date: Thu, 18 Jan 2007 14:03:36 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Regexp for parsing windows filepath on Unix
Message-Id: <m2ac0g2m47.fsf@Sherm-Pendleys-Computer.local>
Milagro writes:
> $fname = "C:\My Documents\My files\file1.doc";
>
> I need to parse the line above so all I get is whatever is after the
> last slash; in this case "file1.doc".
Have a look at the File::Basename standard module.
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: Thu, 18 Jan 2007 12:05:45 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Translation please
Message-Id: <d8kuq2hmme5u4o174ctm9aou10e0ej1io4@4ax.com>
On 17 Jan 2007 13:30:03 -0800, "Stan" <pleaselogout@gmail.com> wrote:
>Could someone please translate this into english please. This is part
>of obfuscation script
>
>thanks
>
>perl -n -i.bak -e "if (/([0-9]+\t)([A-Z0-9]*)(.*)$/) { print $1 .
>\"58\" x (length($2) / 2) . $3 . \"\n\"; } else { print; }"
>TBL_BlobData.dat
Not really obfuscated... and to translate it not exactly into English,
but into more expanded Perl you can use the -MO=Deparse cmd line
argument. Still, I don't understand why it uses -n and an
C<if>...C<else> with a pattern match where -p and a single C<s///>
would do:
perl -pi.bak -e "s/([0-9]+\t)([A-Z0-9]*)(.*)$/$1 . 58 x (length($2)/2)
. $3/e" TBL_BlobData.dat
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: 18 Jan 2007 07:17:42 -0800
From: "Stan" <pleaselogout@gmail.com>
Subject: Re: Translation please
Message-Id: <1169133461.322543.56570@38g2000cwa.googlegroups.com>
Jim Gibson wrote:
> In article <1169069403.480074.91640@l53g2000cwa.googlegroups.com>, Stan
> <pleaselogout@gmail.com> wrote:
>
> > Could someone please translate this into english please. This is part
> > of obfuscation script
> >
> > thanks
> >
> > perl -n -i.bak -e "if (/([0-9]+\t)([A-Z0-9]*)(.*)$/) { print $1 .
> > \"58\" x (length($2) / 2) . $3 . \"\n\"; } else { print; }"
> > TBL_BlobData.dat
> >
>
> 1. Start the Perl interpreter and execute a Perl program that does the
> following:
>
> 2. Open a temporary file for writing.
>
> 3. Open the file TBL_BlobData.dat for reading.
>
> 4. Read each line in the input file and do the following:
>
> 5. If the line contains one or more decimal digits followed by a tab
> character followed by zero or more decimal digits or upper-case English
> alphabet characters, write the first set of digits followed by the
> string "58" repeated one-half the number of times there are characters
> in the second digit-upper-case-character string followed by the rest of
> the original line and a newline to the output file. Otherwise, copy
> the original line (with its original newline) to the output file.
>
> 6. When all of the input file has been read, close both files, rename
> the original file to TBL_BlobData.dat.bak and rename the temporary file
> to TBL_BlobData.dat.
>
> 7. Quit
>
> HTH
>
> Posted Via Usenet.com Premium Usenet Newsgroup Services
> ----------------------------------------------------------
> ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----------------------------------------------------------
> http://www.usenet.com
Thank you, that really helped.
------------------------------
Date: Thu, 18 Jan 2007 11:13:17 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Unable to find form
Message-Id: <45afaa16$0$710$815e3792@news.qwest.net>
Nospam wrote:
> However I have tried it with $mech->form_number(1) with no result,
How helpful, to us, is "with no result"? You need to either show us
the HTML, errors, or something helpful.
$mech->content;
or
use Data::Dumper;
$mech->get( ... );
my $form = $mech->form_number( 1 );
print Dumper( $form );
> I also notice:
> $mech->get('http://swansea.gumtree.com/cgi-bin/add_posting.pl?action=enter_p
> assword');
> print $mech->uri . "\n";
>
> shortens the url to 'http://swansea.gumtree.com/cgi-bin/add_posting.pl
>
> obviously there is no form in there
It's the URI, not the content. Use $mech->content to get the content.
------------------------------
Date: Thu, 18 Jan 2007 12:26:49 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Unable to find form
Message-Id: <m2lkk02qli.fsf@Sherm-Pendleys-Computer.local>
"Nospam" <nospam@home.com> writes:
> However I have tried it with $mech->form_number(1) with no result, I also
> notice:
> $mech->get('http://swansea.gumtree.com/cgi-bin/add_posting.pl?action=enter_p
> assword');
> print $mech->uri . "\n";
>
> shortens the url to 'http://swansea.gumtree.com/cgi-bin/add_posting.pl
>
> obviously there is no form in there
The presence (or not) of arguments in the URI that's passed to get() has
nothing whatsoever to do with the presence of a form IN THE HTML that gets
fetched from that URI.
As for your claim that form_number(1) has no result is plainly wrong.
Sherm-Pendleys-Computer:~ sherm$ cat ./formtest.pl
#!/usr/bin/perl
use strict;
use warnings;
use WWW::Mechanize;
my $mech = new WWW::Mechanize;
my $url = 'http://swansea.gumtree.com/cgi-bin/add_posting.pl?action=enter_password';
$mech->get($url);
my $form = $mech->form_number(1);
print 'Action: ', $form->action, "\n";
print 'Method: ', $form->method, "\n\n";
print "Inputs:\n\n";
foreach ($form->inputs) {
print ' Name: ', $_->name, "\n";
print ' Type: ', $_->type, "\n\n";
}
Sherm-Pendleys-Computer:~ sherm$ ./formtest.pl
Action: http://swansea.gumtree.com/cgi-bin/add_posting.pl
Method: POST
Inputs:
Name: action
Type: hidden
Name: posting_id
Type: text
Name: password
Type: password
Name: continue
Type: submit
Name: email_password
Type: submit
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: 18 Jan 2007 15:10:52 GMT
From: Dave Weaver <zen13097@zen.co.uk>
Subject: Re: Variable substitution
Message-Id: <45af8dfc$0$2438$db0fefd9@news.zen.co.uk>
On 17 Jan 2007 06:19:37 -0800, Seb <sebastien.godier@gmail.com> wrote:
> Ok so here my complete script:
Here are some more observations.
> ##############
> #!C:\Perl\bin\perl.exe -w
use warnings;
is better than the -w switch.
use strict;
You should always "use strict;" in you perl programs, which forces you
to declare all your variables before you use them. This will allow
perl to detect typos in variable names, and other errors in your code
that might otherwise go unnoticed.
> # Read the list of computer to run the script against
> open(INPUTFILE,"computers.txt") || die ("File $INPUTFILE does not
> exist.");
Better written as:
open my $inputfile, '<', 'computers.txt'
or die "Can't open computers.txt : $!";
>
> # When a computer is unavailable, write it name to the log file.
> open(OUTPUTFILE,">errors.txt");
>
> # For debugging purpose
> open(DEBUGPING,">debug-ping.txt");
> open(DEBUGCOMMANDS,">debug-commands.txt");
Similar changes recommended for these open statements.
> system("cls");
> while (<INPUTFILE>) {
With the change of the open above, this would become:
while (<$inputfile>) {
> $debugping = `ping -n 1 $_ 2>&1`;
With 'use strict' in force, this would need to be:
my $debugping = `ping -n 1 $_ 2>&1`;
> if ( $? >> 8 == 1 )
> {
> # That means the computers is unreachable. Exporting the name of such
> computers to the log file.
> print OUTPUTFILE "$_";
Useless use of quotes:
print OUTPUTFILE $_;
See `perldoc -q quoting`
> # chomp remove the \n from $_ variable to print it correctly to
> STDOUT
> chomp($_);
> print "\n\t\t\t $_ FAILED.";
> }
> else
> {
> # The computer is on the network. Let's run the commands against it.
> open(DEBUGCOMMANDS,">>debug-commands.txt");
> print DEBUGCOMMANDS "$_\n";
You already opend debug-commands.txt above, and you've not closed it
since. Why open it again?
> system ("REG QUERY \"\\\\$cpname\\HKLM\\SOFTWARE\\MICROSOFT\\Internet
> Explorer\\Main\" /v \"Start Page");
If you had "use strict;" at the top, perl would have told you that
you're using an undeclared variable ($cpname) here.
You can use an alternaitve quoting opererator to remove the need to
escape quotes in your string Also (maybe intentionally) the string
you're printing here is missing a trailing quote:
system( qq(REG QUERY "\\\\$cpname\\HKLM\\SOFTWARE\\MICROSOFT\\Internet
Explorer\\Main" /v "Start Page) );
^
^no matching close qoute
> # chomp remove the \n from $_ variable to print it correctly to
> STDOUT
> chomp($_);
> print "\n$_ successfull.";
> }
------------------------------
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 47
*************************************