Re: a nice little perl utility
Re: a nice little perl utility
am 12.10.2007 19:39:28 von Michele Dondi
On Fri, 12 Oct 2007 11:15:35 -0700, "Wade Ward"
wrote:
>I find myself, as a perl learner on windows, always doing the same thing in
>order to get a script's output. I finally decided to remember some dos and
>automate the process with a batch file. You place it in the directory where
>windows always opens a dos window, go back to the root, then up to where
>perl.exe lives:
>perl1.bat:
>echo on
>cd ..
>cd ..
>cd perl
>cd bin
I'm ASTONISHED!! Why on hell do you need to do that?!?
>http://www.zaxfuuq.net/perl6.htm
You're assuming wrong that for all users the DOS windows will open in
that directory as you can set it to what you like. I, for one, set it
to C:\temp.
Incidentally you don't need 4 different cd's where one would suffice:
cd \perl\bin
this is also better in that it will not depend on the starting
directory to be "C:\Documents and Settings\Merl".
But then again, why do you need it at all? Since you like screenshots
I'll show you one portraying a minimal session out of a freshly opened
DOS prompt:
http://blazar.perlmonk.org/tmp/merl01.png
(Sorry for not wrapping a html page with my .sig around it, I suppose
you can survive.)
Note: for those that unlike our friend do *not* like screenshots, it's
simply as follows
Microsoft Windows XP [Versione 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\temp>wjed merl.pl
C:\temp>cat merl.pl
#!/usr/bin/perl -l
use strict;
use warnings;
my $adj=shift || 'freak';
print "Merl iz a $adj!";
__END__
C:\temp>merl crank
Merl iz a crank!
C:\temp>merl
Merl iz a freak!
C:\temp>
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^
..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
a nice little perl utility
am 12.10.2007 20:15:35 von merl the perl
I find myself, as a perl learner on windows, always doing the same thing in
order to get a script's output. I finally decided to remember some dos and
automate the process with a batch file. You place it in the directory where
windows always opens a dos window, go back to the root, then up to where
perl.exe lives:
perl1.bat:
echo on
cd ..
cd ..
cd perl
cd bin
http://www.zaxfuuq.net/perl6.htm
--
wade ward
"Nicht verzagen, Bruder Grinde fragen."
Re: a nice little perl utility
am 12.10.2007 20:31:33 von Bill H
On Oct 12, 1:39 pm, Michele Dondi wrote:
> On Fri, 12 Oct 2007 11:15:35 -0700, "Wade Ward"
> wrote:
>
> >I find myself, as a perl learner on windows, always doing the same thing in
> >order to get a script's output. I finally decided to remember some dos and
> >automate the process with a batch file. You place it in the directory where
> >windows always opens a dos window, go back to the root, then up to where
> >perl.exe lives:
> >perl1.bat:
> >echo on
> >cd ..
> >cd ..
> >cd perl
> >cd bin
>
> I'm ASTONISHED!! Why on hell do you need to do that?!?
>
> >http://www.zaxfuuq.net/perl6.htm
>
> You're assuming wrong that for all users the DOS windows will open in
> that directory as you can set it to what you like. I, for one, set it
> to C:\temp.
>
> Incidentally you don't need 4 different cd's where one would suffice:
>
> cd \perl\bin
>
> this is also better in that it will not depend on the starting
> directory to be "C:\Documents and Settings\Merl".
>
> But then again, why do you need it at all? Since you like screenshots
> I'll show you one portraying a minimal session out of a freshly opened
> DOS prompt:
>
> http://blazar.perlmonk.org/tmp/merl01.png
>
> (Sorry for not wrapping a html page with my .sig around it, I suppose
> you can survive.)
>
> Note: for those that unlike our friend do *not* like screenshots, it's
> simply as follows
>
> Microsoft Windows XP [Versione 5.1.2600]
> (C) Copyright 1985-2001 Microsoft Corp.
>
> C:\temp>wjed merl.pl
>
> C:\temp>cat merl.pl
> #!/usr/bin/perl -l
>
> use strict;
> use warnings;
>
> my $adj=shift || 'freak';
> print "Merl iz a $adj!";
>
> __END__
>
> C:\temp>merl crank
> Merl iz a crank!
>
> C:\temp>merl
> Merl iz a freak!
>
> C:\temp>
>
> Michele
> --
> {$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
> (($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^
> .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER
> 256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
I solved this a long time ago on XP by just downloading the XP power
toy that lets you right click on a folder and open command window
there and being sure perl is in the path. But there are some handy
perl utilities that I have written and used perl2exe on. Simple ones
like fixnames.exe that will take all the filenames in the current
directory and make them lowercase, remove spaces, extra puncuation
things like that. Another that takes a simple text file that I create
in the current directory called from.txt and creates an HTML form with
javascript checking to be sure all required input is included.
Bill H
Re: a nice little perl utility
am 12.10.2007 20:48:14 von h3xx
On Oct 12, 12:39 pm, Michele Dondi wrote:
> On Fri, 12 Oct 2007 11:15:35 -0700, "Wade Ward"
> wrote:
>
> >I find myself, as a perl learner on windows, always doing the same thing in
> >order to get a script's output. I finally decided to remember some dos and
> >automate the process with a batch file. You place it in the directory where
> >windows always opens a dos window, go back to the root, then up to where
> >perl.exe lives:
> >perl1.bat:
> >echo on
> >cd ..
> >cd ..
> >cd perl
> >cd bin
>
> I'm ASTONISHED!! Why on hell do you need to do that?!?
>
> >http://www.zaxfuuq.net/perl6.htm
>
> You're assuming wrong that for all users the DOS windows will open in
> that directory as you can set it to what you like. I, for one, set it
> to C:\temp.
Actually in Windows, if you have a bare batch file and you call it
either from Explorer or the "Run..." prompt, it executes from the
directory it's placed into. If you open the Properties dialog (right-
click menu in Explorer) you can change its default working directory
from there. Then all commands will execute relative to that directory.
>
> Incidentally you don't need 4 different cd's where one would suffice:
>
> cd \perl\bin
Or, as mentioned above, you could change the working directory of the
batch file using the Properties dialog to "C:\perl\bin" or whatever
drive you have it on. Heh. Drive letters.
>
> this is also better in that it will not depend on the starting
> directory to be "C:\Documents and Settings\Merl".
>
> But then again, why do you need it at all? Since you like screenshots
> I'll show you one portraying a minimal session out of a freshly opened
> DOS prompt:
>
> http://blazar.perlmonk.org/tmp/merl01.png
>
> (Sorry for not wrapping a html page with my .sig around it, I suppose
> you can survive.)
>
> Note: for those that unlike our friend do *not* like screenshots, it's
> simply as follows
>
> Microsoft Windows XP [Versione 5.1.2600]
> (C) Copyright 1985-2001 Microsoft Corp.
>
> C:\temp>wjed merl.pl
>
> C:\temp>cat merl.pl
> #!/usr/bin/perl -l
>
> use strict;
> use warnings;
>
> my $adj=shift || 'freak';
> print "Merl iz a $adj!";
>
> __END__
This last line is unnecessary. You'll hardly EVER see it unless
there's a data section below it, which I haven't seen but once.
>
> C:\temp>merl crank
> Merl iz a crank!
>
> C:\temp>merl
> Merl iz a freak!
>
> C:\temp>
>
> Michele
> --
> {$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
> (($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^
> .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER
> 256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
Re: a nice little perl utility
am 12.10.2007 23:27:00 von Jim Carlock
(1) Create a shortcut to the cmd.exe prompt.
(2) Set the Target: to, C:\WINDOWS\system32\cmd.exe /K CD /D
(3) It doesn't matter what you put in the Start in: box.
(4) Move the shortcut to the %userprofile%\sendto\.
(5) Right click inside any Explorer window on a folder, then
click upon SendTo..., then upon the newly created shortcut.
It will ALWAYS open in the folder that you tell it to open in.
If you want a default folder in case you don't click upon such,
then fill in the Start in: textbox.
The /D is a switch for the CHDIR command. It tells it to log on
to the drive first, in case you want to open a prompt on another
drive.
Hope this helps.
--
Jim Carlock
Swimming Pool, Spa And Water Feature Builders
http://www.aquaticcreationsnc.com/
Re: a nice little perl utility
am 12.10.2007 23:44:20 von merl the perl
"Michele Dondi" wrote in message
news:0cbvg3d3kcb4fj0m81rh1ml8m16ohu4e60@4ax.com...
> On Fri, 12 Oct 2007 11:15:35 -0700, "Wade Ward"
> wrote:
>
> I'm ASTONISHED!! Why on hell do you need to do that?!?
Here, on hell, I found myself doing the same things time and time again. It
saves 35 keystrokes to get to where my command window has to be.
> You're assuming wrong that for all users the DOS windows will open in
> that directory as you can set it to what you like. I, for one, set it
> to C:\temp.
No. My soln was to use cd .. to get to the root. Yours is obviously
better. I had forgotten that dos syntax.
> C:\temp>wjed merl.pl
>
> C:\temp>cat merl.pl
How do you get perl.exe to interpret these commands. Is temp in a child
directory?
> #!/usr/bin/perl -l
I take it, this is the appropriate shebang line for xp?
> C:\temp>merl crank
> Merl iz a crank!
>
> C:\temp>merl
> Merl iz a freak!
I'll take that as a compliment.
--
wade ward
"Nicht verzagen, Bruder Grinde fragen."
Re: a nice little perl utility and a minimal nntp client
am 13.10.2007 01:13:57 von merl the perl
Can you elaborate? If you'd be inclined to e-mail instaed, I'm
wade@zaxfuuq.net .
> (1) Create a shortcut to the cmd.exe prompt.
> (2) Set the Target: to, C:\WINDOWS\system32\cmd.exe /K CD /D
> (3) It doesn't matter what you put in the Start in: box.
> (4) Move the shortcut to the %userprofile%\sendto\.
> (5) Right click inside any Explorer window on a folder, then
> click upon SendTo..., then upon the newly created shortcut.
>
> It will ALWAYS open in the folder that you tell it to open in.
> If you want a default folder in case you don't click upon such,
> then fill in the Start in: textbox.
>
> The /D is a switch for the CHDIR command. It tells it to log on
> to the drive first, in case you want to open a prompt on another
> drive.
>
> Hope this helps.
I finally got the kinks worked out on this:
## minimal nntp client
## by Wade Ward
## Contributors: Michele Dondi, Gunnar Hjalmarsson
#!/usr/bin/perl -1
use strict;
use warnings;
use Net::NNTP;
use Date::Parse;
my $nsrv='newsgroups.comcast.net';
my $grp='comp.lang.perl.misc';
my $USER = '';
my $PASS = '';
my $nntp=Net::NNTP->new($nsrv) or die "Can't login to `$nsrv'$!\n";
$nntp->authinfo($USER,$PASS) or die $!;
my (undef, $first, $last, undef)=$nntp->group($grp)
or die "Can't access $grp\n";
my ($since, @arts)=time-10*60*60;
for (reverse $first..$last) {
my %hdr=map /^(\S[^:]+):\s(.*)$/g, @{$nntp->head($_)};
defined(my $date=$hdr{'NNTP-Posting-Date'}) or next;
defined(my $time=str2time $date)
or warn "Couldn't parse date for article $_ ($date)\n"
and next;
last if $time < $since;
unshift @arts, $_;
}
$nntp->article($_,\*STDOUT) for @arts;
__END__
Abridged output follows sig.
--
wade ward
#abridged output:
Path:
border1.nntp.dca.giganews.com!nntp.giganews.com!postnews.goo gle.com!i13g2000prf.googlegroups.com!not-for-mail
From: "comp.llang.perl.moderated"
Newsgroups: comp.lang.perl.misc
Subject: Re: LWP, Post, return data ?
Date: Fri, 12 Oct 2007 06:08:11 -0700
Organization: http://groups.google.com
Lines: 42
Message-ID: <1192194491.195360.190670@i13g2000prf.googlegroups.com>
References:
<1192156707.725636.162380@e34g2000pro.googlegroups.com>
NNTP-Posting-Host: 130.76.32.181
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
X-Trace: posting.google.com 1192194491 24799 127.0.0.1 (12 Oct 2007 13:08:11
GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 12 Oct 2007 13:08:11 +0000 (UTC)
In-Reply-To:
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12)
Gecko/20050915 Firefox/1.0.7 (CCK-Boeing),gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: i13g2000prf.googlegroups.com; posting-host=130.76.32.181;
posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0
Bytes: 2559
Xref: number1.nntp.dca.giganews.com comp.lang.perl.misc:639030
On Oct 11, 9:00 pm, still me wrote:
> On Thu, 11 Oct 2007 19:38:27 -0700, Paul Lalli
> wrote:
>
> ...
> >LWP::UserAgent::post() returns an HTTP::Response object.
>
> >http://search.cpan.org/~gaas/libwww-perl-5.808/lib/HTTP/Res ponse.pm
>
> > $response = $ua->request($request)
> > if ($response->is_success) {
> > print $response->content;
> > }
> > else {
> > print STDERR $response->status_line, "\n";
> > }
>
> >Paul Lalli
>
> I need a little more help. I also need to access the return headers
> that are sent back from the called cgi. I read this:
>
> http://search.cpan.org/~gaas/libwww-perl-5.808/lib/HTTP/Head ers.pm
>
> And I think I need to access this: $h->as_string( $eol )
>
> But I am having trouble making the logical jump as to how the code
> would actually look. It's clear enough when I want to create a new
> header object, but how do I get the return values from the "$response
> = $ua->request($request)" to populate the header object? Some detailed
> code would be very helpful.
>
print $response->headers_as_string;
* or, to pull a specific header:
eg, print $response->header("Client-Peer")
--
Charles DeRykus
....
wrote in message
news:1192199023.034893.245880@z24g2000prh.googlegroups.com.. .
> Introducing The Dhourties And The Dualdigers, Nudism? Nakedity?
> Aren't
> We Born Naked? Isn't Our Naked Skin Our Clothes? Is Being Born Naked
> A
> Crime By The Dhourties' Logic If Nudity In Public Is A Crime?
> You do not need under arm deodorant as it is filled with toxic
> animals
> that will destroy your body and eat up your organs animals. Use
> peanut
> oil for your underarms, and for your groin, and for your feet, and
> for
> your butt hole, and butt crack, if you are worried about unpleasant
> odors. You can also use any other nicely scented oil with flowers
> oils
> mixed in it, as I've mentioned, previously, how to press flowers for
> making perfume oils.
Maybe, but Max is still a bastard.
AC
....
> I'm ASTONISHED!! Why on hell do you need to do that?!?
>
> >http://www.zaxfuuq.net/perl6.htm
>
> You're assuming wrong that for all users the DOS windows will open in
> that directory as you can set it to what you like. I, for one, set it
> to C:\temp.
>
> Incidentally you don't need 4 different cd's where one would suffice:
>
> cd \perl\bin
>
> this is also better in that it will not depend on the starting
> directory to be "C:\Documents and Settings\Merl".
>
> But then again, why do you need it at all? Since you like screenshots
> I'll show you one portraying a minimal session out of a freshly opened
> DOS prompt:
>
> http://blazar.perlmonk.org/tmp/merl01.png
>
> (Sorry for not wrapping a html page with my .sig around it, I suppose
> you can survive.)
>
> Note: for those that unlike our friend do *not* like screenshots, it's
> simply as follows
>
> Microsoft Windows XP [Versione 5.1.2600]
> (C) Copyright 1985-2001 Microsoft Corp.
>
> C:\temp>wjed merl.pl
>
> C:\temp>cat merl.pl
> #!/usr/bin/perl -l
>
> use strict;
> use warnings;
>
> my $adj=shift || 'freak';
> print "Merl iz a $adj!";
>
> __END__
>
> C:\temp>merl crank
> Merl iz a crank!
>
> C:\temp>merl
> Merl iz a freak!
>
> C:\temp>
>
> Michele
> --
> {$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
> (($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^
> .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER
> 256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
I solved this a long time ago on XP by just downloading the XP power
toy that lets you right click on a folder and open command window
there and being sure perl is in the path. But there are some handy
perl utilities that I have written and used perl2exe on. Simple ones
like fixnames.exe that will take all the filenames in the current
directory and make them lowercase, remove spaces, extra puncuation
things like that. Another that takes a simple text file that I create
in the current directory called from.txt and creates an HTML form with
javascript checking to be sure all required input is included.
Bill H
Re: a nice little perl utility and a minimal nntp client
am 13.10.2007 01:45:49 von Jim Carlock
"Wade Ward" wrote...
: Can you elaborate? If you'd be inclined to e-mail instaed, I'm
: wade@zaxfuuq.net .
> I solved this a long time ago on XP by just downloading the XP
> power toy that lets you right click on a folder and open command
> window there and being sure perl is in the path.
What I posted is just an alternative way to open a cmd prompt in
an appropriate folder. It's quicker to use the CD command. But
sometimes if you're browsing things using Explorer and you want to
open a cmd prompt in a particular folder you see, you can right-
click upon the folder, click upon SendTo, and send the folder to
the cmd prompt shortcut in the SendTo folder. It doesn't really
send anything, except it does deliver this command line to the
cmd prompt:
C:\WINDOWS\system32\cmd.exe /K CD /D
Where the cmd prompt then opens, the /K switch tells it to stay
open instead of closing, the CD /D command tells it to log onto
the appropriate drive, and change to the identified folder. It's
quite handy at times.
--
Jim Carlock
Swimming Pool, Spa And Water Feature Builders
http://www.aquaticcreationsnc.com/
> (1) Create a shortcut to the cmd.exe prompt.
> (2) Set the Target: to, C:\WINDOWS\system32\cmd.exe /K CD /D
> (3) It doesn't matter what you put in the Start in: box.
> (4) Move the shortcut to the %userprofile%\sendto\.
> (5) Right click inside any Explorer window on a folder, then
> click upon SendTo..., then upon the newly created shortcut.
>
> It will ALWAYS open in the folder that you tell it to open in.
> If you want a default folder in case you don't click upon such,
> then fill in the Start in: textbox.
>
> The /D is a switch for the CHDIR command. It tells it to log on
> to the drive first, in case you want to open a prompt on another
> drive.
Re: a nice little perl utility and a minimal nntp client
am 13.10.2007 02:08:14 von Tad McClellan
> Abridged output follows sig.
Please do not put abridged output following sig.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
Re: a nice little perl utility and a minimal nntp client
am 13.10.2007 04:09:42 von merl the perl
"Jim Carlock" wrote in message
news:47100732$0$24281$4c368faf@roadrunner.com...
> C:\WINDOWS\system32\cmd.exe /K CD /D
>
> Where the cmd prompt then opens, the /K switch tells it to stay
> open instead of closing, the CD /D command tells it to log onto
> the appropriate drive, and change to the identified folder. It's
> quite handy at times.
>> (1) Create a shortcut to the cmd.exe prompt.
>> (2) Set the Target: to, C:\WINDOWS\system32\cmd.exe /K CD /D
>> (3) It doesn't matter what you put in the Start in: box.
>> (4) Move the shortcut to the %userprofile%\sendto\.
>> (5) Right click inside any Explorer window on a folder, then
>> click upon SendTo..., then upon the newly created shortcut.
>>
>> It will ALWAYS open in the folder that you tell it to open in.
>> If you want a default folder in case you don't click upon such,
>> then fill in the Start in: textbox.
>>
>> The /D is a switch for the CHDIR command. It tells it to log on
>> to the drive first, in case you want to open a prompt on another
>> drive.
I didn't do everything you have above, but what you had was enough for me to
muddle my way through. I right-clicked on my desktop, selected
new => shortcut
, pasted in the following:
C:\WINDOWS\system32\cmd.exe /K CD /D \perl\bin
, named it, and
voila, activating the shortcut creates a dos window that has perl.exe in its
directory. This is definitely in keeping with the perl virtue of laziness.
Thanks for your attention.
--
wade ward
"Nicht verzagen, Bruder Grinde fragen."
Re: a nice little perl utility
am 13.10.2007 08:52:18 von Christian Winter
h3xx wrote:
> On Oct 12, 12:39 pm, Michele Dondi wrote:
>>
>> Microsoft Windows XP [Versione 5.1.2600]
>> (C) Copyright 1985-2001 Microsoft Corp.
>>
>> C:\temp>wjed merl.pl
>>
>> C:\temp>cat merl.pl
>> #!/usr/bin/perl -l
>>
>> use strict;
>> use warnings;
>>
>> my $adj=shift || 'freak';
>> print "Merl iz a $adj!";
>>
>> __END__
>
> This last line is unnecessary. You'll hardly EVER see it unless
> there's a data section below it, which I haven't seen but once.
This last line is a de facto standard in Perl related newsgroups.
Many newsreaders have (or can be added) the functionality to
recognize and extract/run Perl scripts based on the shebang line,
so the __END__ marker can be used to determine the end of the
embedded code.
-Chris
Re: a nice little perl utility
am 13.10.2007 12:03:16 von Michele Dondi
On Fri, 12 Oct 2007 11:31:33 -0700, Bill H wrote:
>> Michele
>> --
>> {$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
>> (($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^
>> .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER
>> 256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
Did you need to quote the whole post .sig included?
>I solved this a long time ago on XP by just downloading the XP power
>toy that lets you right click on a folder and open command window
I have it. I've had it for ages. Funnily enough I thought it would
have been precious, but I've used it once or twice in a year. Point
is, unfortunately I don't like Exploder as a GUI shell and often
resort, however strange it may seem, to an old image viewer's file
browser instead, although admittedly each of them has some advantages
that the other one lacks. And opening a textual shell in the cwd is
fine but I miss a very fast keybinding (in case you wonder: yes, I
know 'bout the contextual menu key) to do so, but then I almost always
have some consoles opened anyway, and pressing cd doesn't doesn't hurt
either, especially now that Windows sports a half decent completion.
Seriously, I've often dreamt of and occasionally written about a
mythological beast that is a GUI file browser, along with a CLI
interface with a very fast way to switch between those modes which
will always run mostly in parallel except when you want to maximize
one at the expenses of the other...
Incidentally, I also installed the X-like virtual desktops powertoy,
but it does not come close to real X wm's facilities in this sense,
due to it being an afterthought. So its usability drops down to zero
for me and after a period of initial excitement it ended up unused,
even if it's still there. Under Xfce2, which is my preferred wm for
Linux now, I use virtual desktops all the time instead.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^
..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
Re: a nice little perl utility
am 13.10.2007 12:11:10 von Michele Dondi
On Fri, 12 Oct 2007 11:48:14 -0700, h3xx
wrote:
>> You're assuming wrong that for all users the DOS windows will open in
>> that directory as you can set it to what you like. I, for one, set it
>> to C:\temp.
>Actually in Windows, if you have a bare batch file and you call it
>either from Explorer or the "Run..." prompt, it executes from the
>directory it's placed into. If you open the Properties dialog (right-
>click menu in Explorer) you can change its default working directory
>from there. Then all commands will execute relative to that directory.
What does this have to do with my claim? I'm talking about a
completely different thing, namely the directory a DOS console starts
into when you click on its damned little icon e.g. from the start
menu.
>> __END__
>This last line is unnecessary. You'll hardly EVER see it unless
>there's a data section below it, which I haven't seen but once.
So what? I still like as it clearly marks the end of the program: to
put it like $Larry did in one of his natural languages' principles in
Perl speeches, it's much like a "bye" - just as much as the shebang
line is a "hello". So it's part of my template for new perl files.
That it is unnecessary doesn't mean that it is not useful, if not for
anything else, if I *do* want to add a DATA section, or for ease of
reading when pasting especially in text based media like USENET.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^
..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
Re: a nice little perl utility
am 13.10.2007 12:16:14 von Michele Dondi
On Fri, 12 Oct 2007 14:44:20 -0700, "Wade Ward"
wrote:
>> I'm ASTONISHED!! Why on hell do you need to do that?!?
>Here, on hell, I found myself doing the same things time and time again. It
>saves 35 keystrokes to get to where my command window has to be.
The point is, you should not need the 35 keystrokes in the first
place.
>> C:\temp>wjed merl.pl
>>
>> C:\temp>cat merl.pl
>How do you get perl.exe to interpret these commands. Is temp in a child
I don't. wjed is my text editor and cat a tiny utility, namely the
*NIX one, ported under Win32.
>directory?
\temp is a child directory of the root in my %HOMEDRIVE%.
>> #!/usr/bin/perl -l
>I take it, this is the appropriate shebang line for xp?
Any would do. I use this one since it will work both under Linux and
Windows. Of course under the latter it is not interpreted by the
kernel as under the former, but perl re-reads it anyway for switches,
so in this case uses -l.
>> C:\temp>merl crank
>> Merl iz a crank!
>>
>> C:\temp>merl
>> Merl iz a freak!
>I'll take that as a compliment.
You should take it as an example.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^
..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
Re: a nice little perl utility
am 13.10.2007 13:20:24 von spambait
In article , "Wade Ward" wrote:
>No. My soln was to use cd .. to get to the root. Yours is obviously
>better. I had forgotten that dos syntax.
Note that "CD .." goes to the *parent* directory, not to the root.
"CD \" goes to the root.
>
>> C:\temp>wjed merl.pl
>>
>> C:\temp>cat merl.pl
>How do you get perl.exe to interpret these commands. Is temp in a child
>directory?
temp is clearly a directory under the root.
>
>> #!/usr/bin/perl -l
>I take it, this is the appropriate shebang line for xp?
That would be the appropriate shebang line for perl.
--
Regards,
Doug Miller (alphageek at milmac dot com)
It's time to throw all their damned tea in the harbor again.
Re: a nice little perl utility
am 13.10.2007 13:52:18 von QoS
spambait@milmac.com (Doug Miller) wrote in message-id:
>
> In article , "Wade Ward" wrote:
>
> >No. My soln was to use cd .. to get to the root. Yours is obviously
> >better. I had forgotten that dos syntax.
>
> Note that "CD .." goes to the *parent* directory, not to the root.
>
> "CD \" goes to the root.
> >
> >> C:\temp>wjed merl.pl
> >>
> >> C:\temp>cat merl.pl
> >How do you get perl.exe to interpret these commands. Is temp in a child
> >directory?
>
> temp is clearly a directory under the root.
> >
> >> #!/usr/bin/perl -l
> >I take it, this is the appropriate shebang line for xp?
>
> That would be the appropriate shebang line for perl.
>
Yeah, no; XP does not pay attention to shebang lines.
Now IMHO what would be 'a nice little perl utility' is one that teaches
XP to utilize the shebang line .
Re: a nice little perl utility and a minimal nntp client
am 13.10.2007 15:06:40 von Michele Dondi
On Fri, 12 Oct 2007 16:13:57 -0700, "Wade Ward"
wrote:
>## minimal nntp client
>## by Wade Ward
>## Contributors: Michele Dondi, Gunnar Hjalmarsson
Funny!
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^
..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
Re: a nice little perl utility
am 13.10.2007 16:03:39 von 1usa
QoS@domain.invalid wrote in news:Sj2Qi.401$W22.260@trndny04:
>
> spambait@milmac.com (Doug Miller) wrote in message-id:
>
>
>>
>> In article , "Wade
>> Ward" wrote:
....
>> >> #!/usr/bin/perl -l
>> >I take it, this is the appropriate shebang line for xp?
>>
>> That would be the appropriate shebang line for perl.
>>
>
> Yeah, no; XP does not pay attention to shebang lines.
> Now IMHO what would be 'a nice little perl utility' is one that
> teaches XP to utilize the shebang line .
That would indeed be an appropriate shebang line on XP. While Windows
does not use the shebang line to figure out how to run the script, perl
does pay attention to switches specified on that line.
In addition, it makes it easier to transfer scripts between Windows and
*nix machines. On most systems I have used, /usr/bin/perl was a link to
the system default perl so unless you need to use a specific local
version of perl using that shebang line works perfectly.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
clpmisc guidelines:
Re: a nice little perl utility
am 13.10.2007 20:06:14 von Ben Morrow
Quoth Michele Dondi :
> On Fri, 12 Oct 2007 11:48:14 -0700, h3xx
> wrote:
>
< snip Win32 stuff >
This thread has drifted away from Perl and into OS configuration issues.
May I suggest you take it elsewhere?
> >> __END__
> >This last line is unnecessary. You'll hardly EVER see it unless
> >there's a data section below it, which I haven't seen but once.
>
> So what? I still like as it clearly marks the end of the program: to
> put it like $Larry did in one of his natural languages' principles in
> Perl speeches, it's much like a "bye" - just as much as the shebang
> line is a "hello".
Actually he said, in the Camel Book IIRC, that '#!/usr/bin/perl' is
'Once upon a time...' and '__END__' is '...and they all lived happily
ever after.' :)
Ben
Re: a nice little perl utility
am 14.10.2007 02:12:16 von merl the perl
"Michele Dondi" wrote in message
news:fe61h3h875jgp19btjts1crl9pfbgvd00e@4ax.com...
> On Fri, 12 Oct 2007 14:44:20 -0700, "Wade Ward"
> wrote:
>
>>> I'm ASTONISHED!! Why on hell do you need to do that?!?
>>Here, on hell, I found myself doing the same things time and time again.
>>It
>>saves 35 keystrokes to get to where my command window has to be.
>
> The point is, you should not need the 35 keystrokes in the first
> place.
I no longer do. I tried to use the komodo IDE but couldn't get anything off
the ground as a beginner. It was a huge waste of time for me. Not that the
product is necessarily bad; I'm just nowhere near where I can use something
like that yet.
>>> C:\temp>merl crank
>>> Merl iz a crank!
>>>
>>> C:\temp>merl
>>> Merl iz a freak!
>>I'll take that as a compliment.
>
> You should take it as an example.
I finally got my head around this and came up with another example:
http://www.zaxfuuq.net/perl7.htm
--
wade ward
"Nicht verzagen, Bruder Grinde fragen."
Re: a nice little perl utility
am 14.10.2007 18:27:08 von Cloink_Friggson
> >> #!/usr/bin/perl -l
> >I take it, this is the appropriate shebang line for xp?
>
> Any would do. I use this one since it will work both under Linux and
> Windows. Of course under the latter it is not interpreted by the
> kernel as under the former, but perl re-reads it anyway for switches,
> so in this case uses -l.
Um, I thought I'd better be a good boy and add the shebang as written
here (I'm on Windows), but it stopped my cgi-script working.
Eventually, I tracked down an error in my Apache error.log saying
"[Sun Oct 14 17:15:26 2007] [error] [client 127.0.0.1] (OS 3)The
system cannot find the path specified. : couldn't create child
process: 720003: xx.pl, referer: http://[etc]"
So that comment about it not affecting Windows isn't necessarily true.
Ok, I presume it's Apache interpreting the shebang line, not
Windows, but I'm still running on a Windows box (using localhost, so
as both client/server).
Re: a nice little perl utility
am 15.10.2007 14:29:46 von Michele Dondi
On Sat, 13 Oct 2007 17:12:16 -0700, "Wade Ward"
wrote:
>I no longer do. I tried to use the komodo IDE but couldn't get anything off
>the ground as a beginner. It was a huge waste of time for me. Not that the
>product is necessarily bad; I'm just nowhere near where I can use something
>like that yet.
Count me for another one who is nowhere near "where" he can use
something like that. And I don't particularly regret it! ;)
>I finally got my head around this and came up with another example:
>http://www.zaxfuuq.net/perl7.htm
Please, *please*, don't! What is the point of posting links to
screenshots (with the additional hassle for you to create and upload
them and for us to switch media to see them) when (i) it is not
necessary, (ii) being them about some pure text item it would be
easier and more communication-friendly to just paste it here directly?
I suggest you to go to DOS console's properties and enable fast
editing mode. Then dragging the mouse with left button pressed will
select, pressing return copy and right-clicking paste. This makes its
c&p somewhat more starnixish, although I still can't make sense of the
additional key required in the middle. M$teries! Another slight
difference is that it is rectangle basis, which is also annoying
sometimes.
Back to Perl -but not too much, really- your screenshot shows your
attempts to call a script. Note that you can do so with any of the
following:
perl script.pl [arguments]
script.pl [arguments]
In the former the extension need not be .pl and the latter assumes
that .pl has been associated with Perl, which ActivePerl's
installation automatically does - and I'm 99% confident you're using
AP. If you additionally add .pl to the %PATHEXT% env variable (which
AP's installation does *not* do), then you would be able to call the
script without specifying its extension. That is, if you have
script.pl you could also call it like
script [arguments]
Last, and on a very x 10 OT basis (already waiting for Ben to bash
me!) I seem to notice a "spurious" line on the left side of your last
screenshot. This suggests me that you're grabbin the whole screen with
PrtSc and cropping it with some image editing program - one more
reason to be astonished by your byzantine way of proceeding. But you
can just grab the window of a specific app in the first place, by
putting it in foreground and pressing Alt-PrtSc instead.
HTH,
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^
..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
Re: a nice little perl utility
am 15.10.2007 14:31:04 von Michele Dondi
On Sun, 14 Oct 2007 09:27:08 -0700, Cloink
wrote:
>Um, I thought I'd better be a good boy and add the shebang as written
>here (I'm on Windows), but it stopped my cgi-script working.
>Eventually, I tracked down an error in my Apache error.log saying
>
>"[Sun Oct 14 17:15:26 2007] [error] [client 127.0.0.1] (OS 3)The
>system cannot find the path specified. : couldn't create child
>process: 720003: xx.pl, referer: http://[etc]"
An entirely different problem. Since the OS cannot do it, the
webserver takes care of doing it. In that case it *does* want the
correct path.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^
..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
Re: a nice little perl utility
am 15.10.2007 17:38:37 von Ron Bergin
On Oct 15, 5:31 am, Michele Dondi wrote:
> On Sun, 14 Oct 2007 09:27:08 -0700, Cloink
>
> wrote:
> >Um, I thought I'd better be a good boy and add the shebang as written
> >here (I'm on Windows), but it stopped my cgi-script working.
> >Eventually, I tracked down an error in my Apache error.log saying
>
> >"[Sun Oct 14 17:15:26 2007] [error] [client 127.0.0.1] (OS 3)The
> >system cannot find the path specified. : couldn't create child
> >process: 720003: xx.pl, referer:http://[etc]"
>
> An entirely different problem. Since the OS cannot do it, the
> webserver takes care of doing it. In that case it *does* want the
> correct path.
>
> Michele
> --
Apache on Windows does not require the correct path in the shebang
line, as long as apache is configured "correctly".
Uncomment the following line in the httpd.conf file and it will use
the registry instead of the shebang line to find Perl.
ScriptInterpreterSource registry
Once that is "activated", you can use the exact same shebang line as
you use on *nix.
Re: a nice little perl utility
am 15.10.2007 18:00:09 von Ron Bergin
On Oct 15, 8:38 am, Ron Bergin wrote:
>
> Apache on Windows does not require the correct path in the shebang
> line, as long as apache is configured "correctly".
>
> Uncomment the following line in the httpd.conf file and it will use
> the registry instead of the shebang line to find Perl.
>
> ScriptInterpreterSource registry
>
> Once that is "activated", you can use the exact same shebang line as
> you use on *nix.
In addition to "activating" that line in the conf file, you could also
make a registry entry that assures that Perl will run all .cgi scripts
(without having to have a file type association) and will run in taint
mode.
Create and execute a cgi.reg file with the following:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.cgi]
[HKEY_CLASSES_ROOT\.cgi\Shell]
[HKEY_CLASSES_ROOT\.cgi\Shell\ExecCGI]
[HKEY_CLASSES_ROOT\.cgi\Shell\ExecCGI\Command]
@="C:\\Perl\\bin\\perl.exe -T"
Re: a nice little perl utility
am 15.10.2007 18:38:19 von Michele Dondi
On Mon, 15 Oct 2007 15:38:37 -0000, Ron Bergin wrote:
>> An entirely different problem. Since the OS cannot do it, the
>> webserver takes care of doing it. In that case it *does* want the
>> correct path.
>>
>> Michele
>> --
>
>Apache on Windows does not require the correct path in the shebang
>line, as long as apache is configured "correctly".
>
>Uncomment the following line in the httpd.conf file and it will use
>the registry instead of the shebang line to find Perl.
>
>ScriptInterpreterSource registry
>
>Once that is "activated", you can use the exact same shebang line as
>you use on *nix.
Thank you for the correction. Of course I didn't know and was just
guessing instead.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^
..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
Re: a nice little perl utility
am 15.10.2007 23:58:17 von Cloink_Friggson
> In addition to "activating" that line in the conf file, you could also
> make a registry entry that assures that Perl will run all .cgi scripts
> (without having to have a file type association) and will run in taint
> mode.
What on earth is 'taint' mode? I'm a perl scaredy cat, I know only the
essentials.
"perldoc [-q] taint" doesn't tell me much.
Thanks for the other advice.
Oh and how does one turn quoted text into one of those "- Show quoted
text -" links? Google's help didn't offer any obvious explanations.
Cheers.
Re: a nice little perl utility
am 16.10.2007 00:25:58 von Ron Bergin
On Oct 15, 2:58 pm, Cloink wrote:
> > In addition to "activating" that line in the conf file, you could also
> > make a registry entry that assures that Perl will run all .cgi scripts
> > (without having to have a file type association) and will run in taint
> > mode.
>
> What on earth is 'taint' mode? I'm a perl scaredy cat, I know only the
> essentials.
>
> "perldoc [-q] taint" doesn't tell me much.
>
> Thanks for the other advice.
http://perldoc.perl.org/perlsec.html
http://www.google.com/search?q=perl+taint+mode&ie=utf-8&oe=u tf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a
>
> Oh and how does one turn quoted text into one of those "- Show quoted
> text -" links? Google's help didn't offer any obvious explanations.
>
> Cheers.
It probably depends on your interface. I'm using google's web
interface and simply click on the Reply link.
Re: a nice little perl utility
am 16.10.2007 00:49:16 von Jim Gibson
In article <1192485497.948183.223620@i13g2000prf.googlegroups.com>,
Cloink wrote:
> > In addition to "activating" that line in the conf file, you could also
> > make a registry entry that assures that Perl will run all .cgi scripts
> > (without having to have a file type association) and will run in taint
> > mode.
It is nicer to include all attributions so we could tell who wrote the
above (it was Ron Bergin.)
>
> What on earth is 'taint' mode? I'm a perl scaredy cat, I know only the
> essentials.
>
> "perldoc [-q] taint" doesn't tell me much.
perldoc perlsec
or Google for 'perl taint mode'.
> Thanks for the other advice.
(Can't tell whom you are thanking without attributions.)
--
Jim Gibson
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Re: a nice little perl utility
am 16.10.2007 00:50:47 von Michele Dondi
On Mon, 15 Oct 2007 14:58:17 -0700, Cloink
wrote:
>What on earth is 'taint' mode? I'm a perl scaredy cat, I know only the
>essentials.
>
>"perldoc [-q] taint" doesn't tell me much.
perldoc perlsec
>Oh and how does one turn quoted text into one of those "- Show quoted
>text -" links? Google's help didn't offer any obvious explanations.
IIUC that's a little bit of AJAX related to presentation of text, but
you don't want to do what you want even if it were possible: clpmisc
is not a web forum, and GG is only an interface to it.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^
..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
Re: a nice little perl utility
am 20.10.2007 23:50:49 von someone
Michele Dondi wrote:
> On Fri, 12 Oct 2007 11:15:35 -0700, "Wade Ward"
> wrote:
>
>>I find myself, as a perl learner on windows, always doing the same thing in
>>order to get a script's output. I finally decided to remember some dos and
>>automate the process with a batch file. You place it in the directory where
>>windows always opens a dos window, go back to the root, then up to where
>>perl.exe lives:
>>perl1.bat:
>>echo on
>>cd ..
>>cd ..
>>cd perl
>>cd bin
>
> I'm ASTONISHED!! Why on hell do you need to do that?!?
>
>>http://www.zaxfuuq.net/perl6.htm
>
> You're assuming wrong that for all users the DOS windows will open in
> that directory as you can set it to what you like. I, for one, set it
> to C:\temp.
>
> Incidentally you don't need 4 different cd's where one would suffice:
>
> cd \perl\bin
>
> this is also better in that it will not depend on the starting
> directory to be "C:\Documents and Settings\Merl".
If I remember my DOS correctly (and it has been a while) that will change to
the \perl\bin directory on the current drive so if the current drive is E: for
example that will try to cd to E:\perl\bin.
The correct answer is to install Unix/Linux and don't worry about drive
letters. :-)
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
Re: a nice little perl utility
am 21.10.2007 03:48:40 von merl the perl
"John W. Krahn" wrote in message
news:ZKuSi.45435$%B2.13099@edtnps82...
> Michele Dondi wrote:
>> On Fri, 12 Oct 2007 11:15:35 -0700, "Wade Ward"
>> wrote:
>>
>>>I find myself, as a perl learner on windows, always doing the same thing
>>>in
>>>order to get a script's output. I finally decided to remember some dos
>>>and
>>>automate the process with a batch file. You place it in the directory
>>>where
>>>windows always opens a dos window, go back to the root, then up to where
>>>perl.exe lives:
>>>perl1.bat:
>>>echo on
>>>cd ..
>>>cd ..
>>>cd perl
>>>cd bin
>>
>> I'm ASTONISHED!! Why on hell do you need to do that?!?
>>
>>>http://www.zaxfuuq.net/perl6.htm
>>
>> You're assuming wrong that for all users the DOS windows will open in
>> that directory as you can set it to what you like. I, for one, set it
>> to C:\temp.
>>
>> Incidentally you don't need 4 different cd's where one would suffice:
>>
>> cd \perl\bin
>>
>> this is also better in that it will not depend on the starting
>> directory to be "C:\Documents and Settings\Merl".
>
> If I remember my DOS correctly (and it has been a while) that will change
> to
> the \perl\bin directory on the current drive so if the current drive is E:
> for
> example that will try to cd to E:\perl\bin.
>
> The correct answer is to install Unix/Linux and don't worry about drive
> letters. :-)
Why would I put C's red-headed stepchild on a completely clean xp
installation?
I've been working with the hints that have been given on how to make
ActivePerl, and I've got a long way to go.
I now put s cript at the end of a sript that becomes what I feed my dos
window. As in this:
I can't shake these warnings, and I don't know what they're coming from:
Use of uninitialized value in concatenation (.) or string at jabba5.pl line
65.
Use of uninitialized value in concatenation (.) or string at jabba5.pl line
67.
Use of uninitialized value in concatenation (.) or string at jabba5.pl line
75.
Here's the full script:
#!/usr/bin/perl
use strict;
use warnings;
use Net::NNTP ();
use constant NUMBER_OF_ARTICLES => 1;
use constant GROUP_NAME => 'comp.lang.perl.misc';
use constant SERVER_NAME => 'newsgroups.comcast.net';
use constant NNTP_DEBUG => 0;
my $nntp = Net::NNTP->new(SERVER_NAME, 'Debug' => NNTP_DEBUG) or die;
my $USER = '';
my $PASS = '';
$nntp->authinfo($USER,$PASS) or die $!;
my($article_count, $first_article, $last_article) =
$nntp->group(GROUP_NAME) or die;
# Which XOVER fields contain Subject: and From:?
my $count = 0;
my %xover_fmt = map( ($_, $count++), @{ $nntp->overview_fmt or die} );
die unless exists $xover_fmt{'Subject:'};
my $subject_offset = $xover_fmt{'Subject:'};
my $from_offset = $xover_fmt{'From:'};
my(@xover, $start_article);
RETRIEVE: while ($#xover+1 < NUMBER_OF_ARTICLES and $last_article >=
$first_article) {
# How many articles do we need? Stop retrieving if we have enough
my $articles_required = NUMBER_OF_ARTICLES - ($#xover+1) or last
RETRIEVE;
# Fetch overview information for the articles
$start_article = $last_article - ($articles_required-1);
$start_article = $start_article > $first_article ? $start_article :
$first_article;
my $xover_query = $start_article == $last_article ?
$start_article :
[$start_article, $last_article];
my $xover_ref = $nntp->xover($xover_query) or die;
# Store headers for the articles we've retrieved
foreach (sort {$b <=> $a} keys %$xover_ref) {
push @xover, $xover_ref->{$_};
}
} continue {
# Move the pointer forward to fetch previous articles
$last_article = $start_article - 1;
}
# Disconnect from the NNTP server
$nntp->quit;
# this isUseless use of a constant in void context at jabba5.pl line
#57.
#Use of uninitialized value in concatenation (.) or string at jabba5.pl
#line 64.
my $s4 = join("\n", map ($_->[$subject_offset],@xover));
# fucksyntax error at jabba4.pl line 59, near "fuck
print STDOUT " s4 is $s4\n";
my @words = split " ", $s4;
print STDOUT " first word is $words[1]";
print STDOUT " third word is $words[3]";
$words[0] = reverse $words[0];
print STDOUT " third word is $words[3]\n";
#Useless use of a constant in void context at jabba5.pl line 58.
#Use of uninitialized value in concatenation (.) or string at jabba5.pl
#line 65.
#big finish
print STDOUT " $words[1] $words[2]";
print STDOUT " $words[0] \n";
__END__
# perl jabba5.pl 2>text27.txt >text26.txt
Output is:
s4 is Re: perl standard
first word is perl third word is third word is
perl standard :eR
--
wade ward
--
wade ward
"Nicht verzagen, Bruder Grinde fragen."
Re: a nice little perl utility
am 21.10.2007 05:09:09 von Ron Bergin
On Oct 20, 6:48 pm, "Wade Ward" wrote:
>
[snip unrelated stuff]
> I've been working with the hints that have been given on how to make
> ActivePerl, and I've got a long way to go.
>
> I now put s cript at the end of a sript that becomes what I feed my dos
> window. As in this:
You do a very good job of making yourself incomprehensible.
>
> I can't shake these warnings, and I don't know what they're coming from:
> Use of uninitialized value in concatenation (.) or string at jabba5.pl line
> 65.
> Use of uninitialized value in concatenation (.) or string at jabba5.pl line
> 67.
> Use of uninitialized value in concatenation (.) or string at jabba5.pl line
> 75.
You need to clearly point out to us those lines of code so we can help
you.
>
> Here's the full script:
> #!/usr/bin/perl
>
> use strict;
> use warnings;
> use Net::NNTP ();
>
> use constant NUMBER_OF_ARTICLES => 1;
> use constant GROUP_NAME => 'comp.lang.perl.misc';
> use constant SERVER_NAME => 'newsgroups.comcast.net';
> use constant NNTP_DEBUG => 0;
>
> my $nntp = Net::NNTP->new(SERVER_NAME, 'Debug' => NNTP_DEBUG) or die;
> my $USER = '';
> my $PASS = '';
>
> $nntp->authinfo($USER,$PASS) or die $!;
>
> my($article_count, $first_article, $last_article) =
>
> $nntp->group(GROUP_NAME) or die;
>
> # Which XOVER fields contain Subject: and From:?
> my $count = 0;
> my %xover_fmt = map( ($_, $count++), @{ $nntp->overview_fmt or die} );
> die unless exists $xover_fmt{'Subject:'};
> my $subject_offset = $xover_fmt{'Subject:'};
> my $from_offset = $xover_fmt{'From:'};
>
> my(@xover, $start_article);
> RETRIEVE: while ($#xover+1 < NUMBER_OF_ARTICLES and $last_article >=
>
> $first_article) {
Why did you break up that while declaration across 3 lines? The only
reason that I can think of is that you wanted to keep the line length
below 80 characters, but then you would only need 2 lines, the blank
line in the middle doesn't make sense. If you wanted to keep the line
length below 80 chars, you could have put the label on its own line.
RETRIEVE:
while ($#xover+1 < NUMBER_OF_ARTICLES and $last_article >=
$first_article) {
>
> # How many articles do we need? Stop retrieving if we have enough
> my $articles_required = NUMBER_OF_ARTICLES - ($#xover+1) or last
>
> RETRIEVE;
>
> # Fetch overview information for the articles
> $start_article = $last_article - ($articles_required-1);
> $start_article = $start_article > $first_article ? $start_article :
>
> $first_article;
Here, you did the same type of line splitting and several more times
further down for no real good reason.
>
> my $xover_query = $start_article == $last_article ?
> $start_article :
> [$start_article, $last_article];
> my $xover_ref = $nntp->xover($xover_query) or die;
>
> # Store headers for the articles we've retrieved
> foreach (sort {$b <=> $a} keys %$xover_ref) {
> push @xover, $xover_ref->{$_};
> }} continue {
>
> # Move the pointer forward to fetch previous articles
> $last_article = $start_article - 1;
>
> }
>
> # Disconnect from the NNTP server
> $nntp->quit;
> # this isUseless use of a constant in void context at jabba5.pl line
>
> #57.
> #Use of uninitialized value in concatenation (.) or string at jabba5.pl
>
> #line 64.
> my $s4 = join("\n", map ($_->[$subject_offset],@xover));
> # fucksyntax error at jabba4.pl line 59, near "fuck
> print STDOUT " s4 is $s4\n";
>
> my @words = split " ", $s4;
>
> print STDOUT " first word is $words[1]";
> print STDOUT " third word is $words[3]";
> $words[0] = reverse $words[0];
> print STDOUT " third word is $words[3]\n";
> #Useless use of a constant in void context at jabba5.pl line 58.
> #Use of uninitialized value in concatenation (.) or string at jabba5.pl
>
> #line 65.
>
> #big finish
>
> print STDOUT " $words[1] $words[2]";
> print STDOUT " $words[0] \n";
>
> __END__
>
> # perl jabba5.pl 2>text27.txt >text26.txt
> Output is:
> s4 is Re: perl standard
> first word is perl third word is third word is
> perl standard :eR
> --
> wade ward
>
> --
Due to your addition of the comments after the fact that don't fully
correspond with the line numbers stated at the beginning, I can't be
sure, but I'd say that the printing of $words[3] is the cause of the
"Use of uninitialized value in concatenation". Your print statement
that outputs the $s4 var clearly shows that it holds 3 "words".
$words[3] would be the 4th word, if there was one.
Re: a nice little perl utility
am 21.10.2007 08:23:36 von merl the perl
"Ron Bergin" wrote in message
news:1192936149.250861.44970@e9g2000prf.googlegroups.com...
> On Oct 20, 6:48 pm, "Wade Ward" wrote:
>> I've been working with the hints that have been given on how to make
>> ActivePerl, and I've got a long way to go.
>>
>> I now put s cript at the end of a sript that becomes what I feed my dos
>> window. As in this:
>
> You do a very good job of making yourself incomprehensible.
It's Officially Okay to make large mistakes with a new syntax.
>> I can't shake these warnings, and I don't know what they're coming from:
>> Use of uninitialized value in concatenation (.) or string at jabba5.pl
>> line
>> 65.
>> Use of uninitialized value in concatenation (.) or string at jabba5.pl
>> line
>> 67.
>> Use of uninitialized value in concatenation (.) or string at jabba5.pl
>> line
>> 75.
> You need to clearly point out to us those lines of code so we can help
> you.
How did this have to do with the print statement?
> Due to your addition of the comments after the fact that don't fully
> correspond with the line numbers stated at the beginning, I can't be
> sure, but I'd say that the printing of $words[3] is the cause of the
> "Use of uninitialized value in concatenation". Your print statement
> that outputs the $s4 var clearly shows that it holds 3 "words".
> $words[3] would be the 4th word, if there was one.
You got it.
final version of this script for today:
#!/usr/bin/perl
#!/usr/bin/perl she still bangs
## jabba6.pl, 2007-10-20
##minimal nntp client
##manipulates strings in the subject lines
## contributors: Michele, Tad, Ron
use strict;
use warnings;
use Net::NNTP ();
use constant NUMBER_OF_ARTICLES => 1;
use constant GROUP_NAME => 'comp.lang.perl.misc';
use constant SERVER_NAME => 'newsgroups.comcast.net';
use constant NNTP_DEBUG => 0;
my $nntp = Net::NNTP->new(SERVER_NAME, 'Debug' => NNTP_DEBUG) or die;
my $USER = '';
my $PASS = '';
$nntp->authinfo($USER,$PASS) or die $!;
my($article_count, $first_article, $last_article) =
$nntp->group(GROUP_NAME) or die;
# Which XOVER fields contain Subject: and From:?
my $count = 0;
my %xover_fmt = map( ($_, $count++), @{ $nntp->overview_fmt or die} );
die unless exists $xover_fmt{'Subject:'};
my $subject_offset = $xover_fmt{'Subject:'};
my $from_offset = $xover_fmt{'From:'};
my(@xover, $start_article);
RETRIEVE: while ($#xover+1 < NUMBER_OF_ARTICLES and $last_article >=
$first_article) {
# How many articles do we need? Stop retrieving if we have enough
my $articles_required = NUMBER_OF_ARTICLES - ($#xover+1) or last
RETRIEVE;
# Fetch overview information for the articles
$start_article = $last_article - ($articles_required-1);
$start_article = $start_article > $first_article ? $start_article :
$first_article;
my $xover_query = $start_article == $last_article ?
$start_article :
[$start_article, $last_article];
my $xover_ref = $nntp->xover($xover_query) or die;
# Store headers for the articles we've retrieved
foreach (sort {$b <=> $a} keys %$xover_ref) {
push @xover, $xover_ref->{$_};
}
} continue {
# Move the pointer forward to fetch previous articles
$last_article = $start_article - 1;
}
# Disconnect from the NNTP server
$nntp->quit;
# this isUseless use of a constant in void context at jabba5.pl line
#57.
#Use of uninitialized value in concatenation (.) or string at jabba5.pl
#line 64.
my $s4 = join("\n", map ($_->[$subject_offset],@xover));
# fucksyntax error at jabba4.pl line 59, near "fuck
# this is line 60 pardon my french ^^^^^^^^^^^^^^
print STDOUT " s4 is $s4\n";
my @words = split " ", $s4;
$words[0] = reverse $words[0];
#big finish
print STDOUT " $words[1] $words[2] ";
print STDOUT " $words[0] \n";
__END__
# perl jabba6.pl 2>text28.txt >text29.txt
Cheers,
--
wade ward
"Nicht verzagen, Bruder Grinde fragen."
Re: a nice little perl utility
am 21.10.2007 14:19:28 von Michele Dondi
On Sat, 20 Oct 2007 23:23:36 -0700, "Wade Ward"
wrote:
>final version of this script for today:
^^^^^^^^^
^^^^^^^^^ :|
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^
..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,