[25363] in Perl-Users-Digest
Perl-Users Digest, Issue: 7608 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 5 18:05:48 2005
Date: Wed, 5 Jan 2005 15:05:23 -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 Wed, 5 Jan 2005 Volume: 10 Number: 7608
Today's topics:
2-D graphical rendering/manipulation <h4cks4w@gmail.com>
Can You Figure Out This - Looping <hx_101@hotmail.com>
Re: cross-platform shell scripts <bik.mido@tiscalinet.it>
Re: Curses and getch problem <bik.mido@tiscalinet.it>
Re: Dummy regex question <not@home.net>
Re: Dummy regex question <sbryce@scottbryce.com>
Re: Dummy regex question <sven-thorsten.fahrbach@gmx.net>
Re: Dummy regex question <mritty@gmail.com>
Re: Dummy regex question <sven-thorsten.fahrbach@gmx.net>
Re: Dummy regex question <not@home.net>
Re: Dummy regex question <sbryce@scottbryce.com>
Re: FAQ 1.4: What are perl4 and perl5? <bik.mido@tiscalinet.it>
Re: file rename help <bik.mido@tiscalinet.it>
Having Trouble with a CGI login script WhiteFungus@gmail.com
How to set the baud rate on a serial port (Perl under c arkadyz1@yahoo.com
Re: How to set the baud rate on a serial port (Perl und <mritty@gmail.com>
Re: Moving to a new machine <mr@sandman.net>
Re: Need help sorting fixed length records lbeckm3@hotmail.com
Re: Need help sorting fixed length records <uri@stemsystems.com>
Re: Newbie question: "Get substring of line" <bik.mido@tiscalinet.it>
Re: Perl and TeX <bik.mido@tiscalinet.it>
Re: Perl and TeX <Jon.Ericson@jpl.nasa.gov>
sharing fileglobs <bachmanns@gmx.de>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 5 Jan 2005 13:43:18 -0800
From: "h4ck4w" <h4cks4w@gmail.com>
Subject: 2-D graphical rendering/manipulation
Message-Id: <1104961398.951167.99940@f14g2000cwb.googlegroups.com>
I'm trying to do some basic graphical manipulation in Perl. I am just
going to use 2-D images in some standard format (GIF, JPG, PNG, etc.).
Is there some simple module out there that can render, layer, move,
rotate, and perhaps draw basic lines, shapes, etc? I've been poking
around on CPAN, and was looking at OpenGL. This looks like it could do
the job, but is definatley much more than I need. Is there something
simpiler out there? Any and all input will be appreciated. Thanks.
------------------------------
Date: Wed, 05 Jan 2005 17:42:43 -0500
From: Digger <hx_101@hotmail.com>
Subject: Can You Figure Out This - Looping
Message-Id: <nhqot0lurfhjv4h6k9m68ifbqlj0ph0smb@4ax.com>
Ok...... I am new at perl, have been at it for a week or so now
learning.........
I am trying to do the following....
I have a log (url.log) file that contains various url's and some of
them have errors (indicated with a "FAILURE" in the log file).... Now
I want to extract these url's that have the "FAILURE".
log file format
date : error message : url
The problem is this file gets updated every 10 minutes, and in that
time the url could become valid.......
example:
2004-12-24 FAILURE www.bla.com
2004-12-24 SUCCESS www.bla.com
.........
So from the above example the url is valid and I would like a 0 sent
to a file........
2004-12-24 FAILURE www.bla.com
2004-12-24 SUCCESS www.aaa.com
2004-12-24 FAILURE www.aaa.com
2004-12-24 SUCCESS www.bla.com
2004-12-24 FAILURE www.123.com
2004-12-24 FAILURE www.bla.com
Now the url has failed and I would like a 1 sent to a file.....
So we are checking a log file for failed urls that have also not
corrected themselves......... Some sort of loop I would imagine, I
couldn't figure it out... lol
------------------------------
Date: Wed, 05 Jan 2005 21:23:27 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: cross-platform shell scripts
Message-Id: <4funt091k4jj9cg9b7ud4ljc8o755nivf4@4ax.com>
On Wed, 05 Jan 2005 00:18:13 GMT, "Jürgen Exner"
<jurgenex@hotmail.com> wrote:
>> Windows user _do_ have a shell installed. It's called explorer.exe.
>
>You may want to check your references.
>Explorer.exe is a web browser (with some added functionality). I certainly
I think this could get more into phylosophy than computer science. But
I'd call explorer a shell: a GUI-based shell. Of course it's not a
command line shell.
>wouldn't consider it a "shell".
>Actually, which script language to you use to for a shell script, that runs
>on explorer.exe?
I don't think a "shell" is charachterized by definition in terms of
"the possibility of using a script language for it". Or were you
referring to the subject of this thread?
However I'm sure there are hooks to allow one to interface his/her
program to it. A suitable such language is Perl with the appropriate
modules.
>Maybe you meant cmd.exe or command.com?
These are indeed cmd line shells.
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: Wed, 05 Jan 2005 21:23:20 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Curses and getch problem
Message-Id: <aeont0dneap8sg8g0m4ea9hgsi9uiu7aef@4ax.com>
On 4 Jan 2005 14:05:36 -0800, spambox@volja.net wrote:
>It seems like you haven't noticed the following from my first post:
>-----
>If you run it like "script.pl < somefile", pressing 'q' doesn't do
>anything, whereas if you run it like "script.pl somefile", it works as
>expected.
>----
Sorry, I misread your post.
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: Wed, 05 Jan 2005 19:23:40 GMT
From: "JayEs" <not@home.net>
Subject: Re: Dummy regex question
Message-Id: <09XCd.7294$F67.4801@newssvr12.news.prodigy.com>
> You can help others help you by correctly and fully describing the
> parameters of your questions. It looks like you would also benefit from
> getting an introductory Perl book and actually studying it.
Ok, I put a script together that displays the problem. It's rather lengthy,
but see what you (or anyone else) can make of this:
use warnings;
use WWW::Mechanize; # Use Andy Lester's Mech for navigation
use HTML::TokeParser; # Use TokeParser to parse the HTML
my $url =
'http://www.hotels.com/property.do?mtnHotelID=4348&page=info&numadults=1&numchildren=0&numrooms=1&CIDay=21&CIMonth=10&CIYear=2005&CODay=7&COMonth=11&COYear=2005&z_property=&gds=3&thisPageNumber=1&qKey=&roomTypeCode=-1';
my $agent = WWW::Mechanize->new();
$agent->get($url);
my $htmlpage = $agent->{content};
$out="c:/OpenPerl/HTML-TEST.html";
open OUT, ">$out" or die "Cannot open $out for write :$!";
print OUT "$htmlpage \n";
close OUT;
#my $htmlpage = $agent->{content};
my $stream = new HTML::TokeParser($out);
while (my $tag = $stream->get_tag("table")) {
if ($tag->[1]{class} and $tag->[1]{class} eq "matrix-bg") {
$stream->get_tag;
$stream->get_tag;
$stream->get_tag;
print 'DESCRIPTION: '.$stream->get_trimmed_text("/span")."\n"; # RATE
DESC.
$stream->get_tag;
$stream->get_tag;
$stream->get_tag;
$stream->get_tag;
$stream->get_tag;
$stream->get_tag;
$stream->get_tag;
$stream->get_tag;
$stream->get_tag;
$stream->get_tag;
$stream->get_tag;
$stream->get_tag;
$stream->get_tag;
#print $stream->get_trimmed_text("/span");
$rates = $stream->get_trimmed_text("/span");
print "ALL-$rates \n";
print "--- GOING TO SPLIT NOW --- \n";
my ($currency, $rate) = split /\s/, $rates;
print "--- DONE WITH SPLIT ---\n";
print "currency-$currency \n";
print "RATE-$rate \n";
$stream->get_tag;
if ($stream->get_trimmed_text("/td") =~ /\(max\)\*/i) { # RATE CHNG
DURING LOS
print 'max-change'; #MAX RATE WAS DISPLAYED
}
print "\n";
}
}
------------------------------
Date: Wed, 05 Jan 2005 13:45:02 -0700
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: Dummy regex question
Message-Id: <tZ-dnQhJYfRazEHcRVn-qg@comcast.com>
JayEs wrote:
> Ok, I put a script together that displays the problem. It's rather lengthy,
> but see what you (or anyone else) can make of this:
The problem is that the character separating the currency and the amount
is \xA0, which Perl does not recognize as white space.
If I change this line:
> my ($currency, $rate) = split /\s/, $rates;
to:
my ($currency, $rate) = split /[\xA0\s]/, $rates;
or:
my ($currency, $rate) = split /\xA0/, $rates;
I get the expected results.
I don't know if this solution is cross-platform. I am on Win98SE.
------------------------------
Date: Wed, 05 Jan 2005 22:00:29 -0800
From: Sven-Thorsten Fahrbach <sven-thorsten.fahrbach@gmx.net>
Subject: Re: Dummy regex question
Message-Id: <crhkd0$8gi$02$1@news.t-online.com>
JayEs wrote:
> Given a string that can be:
> "$ 12.00"
> "USD 187.54"
> "CAD 1.20"
> "??? 12.65"
>
> (the latter due to special characters not avail in ASCII)
>
> How do I split these strings into 2, separating the currency code and the
> value?
First, I'm new to this group, so, hi everybody.
I am (relatively) new to Perl but having worked my way through the Llama
Book, I think I can say that I'm at least somewhat Perl literate. So,
here's my suggestion...
I don't get why everyone tries to use split() here. I'd take a simple
regexp looking like
m/(.+)\s+(\d+\.\d+)/
my ($currency, $amount) = ($1, $2);
Now, if this is wrong as hell, don't flame me - I'm a newby after all
;-).
Hope this will come in handy...
------------------------------
Date: Wed, 05 Jan 2005 21:15:35 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Dummy regex question
Message-Id: <XNYCd.20462$He3.3833@trndny05>
"Sven-Thorsten Fahrbach" <sven-thorsten.fahrbach@gmx.net> wrote in
message news:crhkd0$8gi$02$1@news.t-online.com...
> I am (relatively) new to Perl but having worked my way through the
Llama
> Book, I think I can say that I'm at least somewhat Perl literate. So,
> here's my suggestion...
> I don't get why everyone tries to use split() here. I'd take a simple
> regexp looking like
>
> m/(.+)\s+(\d+\.\d+)/
I fail to see how that's more 'simple' than split /\s+/...
> my ($currency, $amount) = ($1, $2);
>
> Now, if this is wrong as hell, don't flame me - I'm a newby after all
> ;-).
This is, of course, perfectly valid (it doesn't actually help the OP,
because the OP didn't give accurate information about his problem). And
there are, of course, more than one ways to do it. In general however,
you should use split when you know what you want to throw away, and use
regexps when you know what you want to keep.
Paul Lalli
------------------------------
Date: Wed, 05 Jan 2005 22:33:23 -0800
From: Sven-Thorsten Fahrbach <sven-thorsten.fahrbach@gmx.net>
Subject: Re: Dummy regex question
Message-Id: <crhmal$ebm$00$1@news.t-online.com>
Paul Lalli wrote:
> "Sven-Thorsten Fahrbach" <sven-thorsten.fahrbach@gmx.net> wrote in
> message news:crhkd0$8gi$02$1@news.t-online.com...
>
>> I am (relatively) new to Perl but having worked my way through the
> Llama
>> Book, I think I can say that I'm at least somewhat Perl literate. So,
>> here's my suggestion...
>> I don't get why everyone tries to use split() here. I'd take a simple
>> regexp looking like
>>
>> m/(.+)\s+(\d+\.\d+)/
>
> I fail to see how that's more 'simple' than split /\s+/...
Okay, it's simpler *for me* since I can't recall ever having used
split. I always got away using some regexp or another in the past...
>> my ($currency, $amount) = ($1, $2);
>>
>> Now, if this is wrong as hell, don't flame me - I'm a newby after all
>> ;-).
>
> This is, of course, perfectly valid (it doesn't actually help the OP,
> because the OP didn't give accurate information about his problem). And
> there are, of course, more than one ways to do it. In general however,
> you should use split when you know what you want to throw away, and use
> regexps when you know what you want to keep.
Okay, I think this is worth reading more about. Thanks for the comment
anyway.
------------------------------
Date: Wed, 05 Jan 2005 21:41:17 GMT
From: "JayEs" <not@home.net>
Subject: Re: Dummy regex question
Message-Id: <1aZCd.7312$F67.5194@newssvr12.news.prodigy.com>
"Scott Bryce" <sbryce@scottbryce.com> wrote
> The problem is that the character separating the currency and the amount >
> is \xA0, which Perl does not recognize as white space.
how did you find that?? I guess I should have taken the script out of
OpenPerl (IDE) and exec from the command line. Although that gives me
ascii-whatever, which I still would not have interpreted as \xA0. Would
HTML::Entities have fixed this or this just an artifact of bein on a Win32
box (XP here)?
------------------------------
Date: Wed, 05 Jan 2005 14:58:22 -0700
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: Dummy regex question
Message-Id: <gIGdnfrsIe1l_0HcRVn-rQ@comcast.com>
JayEs wrote:
> "Scott Bryce" <sbryce@scottbryce.com> wrote
>
>
>>The problem is that the character separating the currency and the amount >
>>is \xA0, which Perl does not recognize as white space.
>
>
> how did you find that??
I looked at the output in a hex editor. I suspected something like this.
> Would HTML::Entities have fixed this
I doubt it.
> or this just an artifact of bein on a Win32 box (XP here)?
I don't know. It could be a "feature" of WWW::Mechanize. I suspect that
\xA0 is an ANSI non-breaking space. If so, it could be Win32 specific.
------------------------------
Date: Wed, 05 Jan 2005 21:23:19 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: FAQ 1.4: What are perl4 and perl5?
Message-Id: <jrnnt0l8b3b90boko4gejbfn89ddrttdp7@4ax.com>
On Wed, 5 Jan 2005 19:26:52 +1300, "Tintin" <tintin@invalid.invalid>
wrote:
>The are certainly enough questions as to what perl6 is (and when it is
>available) to qualify as a FAQ.
In fact qx/perldoc -q perl6/.
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: Wed, 05 Jan 2005 21:23:21 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: file rename help
Message-Id: <u7unt09d7esm09s1haqh7v4uu0sif9qm12@4ax.com>
On Tue, 4 Jan 2005 18:06:14 -0700, "Shawn" <spedwards@x.qwest.net>
wrote:
>> for (grep !/txt/, <f*>) {
>
>I will give this a try. Just trying to find all files that start with a f
>and don't have a txt extention.
Not exactly: "files that start with an f and don't contain 'txt'". I
wrote it so because this is what you wrote in the first place.
>> However what you wrote above takes the 9th char from each line of
>> $cfile and sorts with -u, so that you either get exactly one or zero
>> line(s) with '/' (or better: being exactly '/') according to wether
>> there's at least one line with '/' in 9th position or not. Or am I
>> mistaken?
>
>The purpose of the attempt to check if the 9th character is the '/', is
>because it identifies the
>file as belonging to one set of files or another. I think another post
>pointed out a error that
>is true. Instead of reading the entire file the first line should suffice.
>If its not in the first line
>then its not in the file at all.
Then some code like
if ((my $line=<$fh>) =~ m|^.{8}/|) {
# ...
}
should do the job.
>> Of course, since you read the contents of $cfile twice, then you'd
>> better open() it once and the either slurp it into an array all at
>> once (and then process it separately) if the file is small enough or
>> use two separate C<while> loops seek()ing in between them.
>
>Again I didn't even consider that fact that I was opening the stinking file
>twice.
Well, you were not _open()ing_ it directly. My cmt is referred to the
fact that I posted two somewhat self-contained code snippets that do
that, instead. But if you have to put them together than you'd better
qx/see above!/
>Here is the task. I receive file(s) from business partners which come in 3
>formats:
[snip rest]
This should do the job:
#!/usr/bin/perl
use strict;
use warnings;
sub ren;
my $new;
rename $_, ($new=ren $_) or
warn "Can't rename `$_' to `$new': $!\n"
for grep !/\.txt$/, <f*>;
sub ren {
local $_=shift;
return "$_.empty.txt" if -z;
open my $fh, '<', $_ or
die "Can't open `$_': $!\n";
my $ext;
for (my $line=<$fh>) {
chomp;
$ext=substr $_, 0,
m|^.{8}/| ? 6 : 13;
}
"$_.$ext.txt"
}
__END__
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: 5 Jan 2005 11:06:30 -0800
From: WhiteFungus@gmail.com
Subject: Having Trouble with a CGI login script
Message-Id: <1104951990.067980.17290@z14g2000cwz.googlegroups.com>
I am trying to script a program to autologin for me with the following
HTML code data. Although for some reason I can not seem to be able to
fill the password field properly with WWW::Mechanize. Is the some
hidden jewel of syntax structure I am not yet aware of? Any help
concerning this issue would be much appreciated! :)
-Thanks in advance.
_______________________________________________________________
#!usr/bin/perl
use WWW::Mechanize;
use WWW::Mechanize::FormFiller;
my $mech = WWW::Mechanize->new();
my $formfiller = WWW::Mechanize::FormFiller->new();
my $username = "user_name";
my $password = "password";
my $url = "http://www.myurl.com/default.aspx";
# Grab the home page, and click the login button to redirect to the
correct page(HTML listed below).
$mech->get($url);
$mech->click_button(number => 1);
# Set the username and password fields accordingly and submit.
$mech->set_visible( $username, [password => $password] ) ;
$mech->submit();
# Store new HTML content in a temporary file and open it for viewing.
$html = $mech->content();
open (OUT,">tmp.html");
print OUT $html;
close (OUT);
system("tmp.html");
_______________________________________________________________
<html>
<head>
<title>Login</title>
</head>
<body bgcolor="#FFFFFF">
<form id="frmLogin" name="frmLogin" method="post"
action="Login.aspx?__ufps=933290">
<input type="hidden" name="__VIEWSTATE"
value="aDxfX1A7QDw716znrKftnYTgo4csMTs+Oz6urRmZvy6aJZj20y+gGEkgSS1/NA==">
<input type="hidden" name="__EVENTTARGET" value="">
<input type="hidden" name="__EVENTARGUMENT" value="">
<script language=javascript><!--
function __doPostBack(target, argument){
var theform = document.frmLogin
theform.__EVENTTARGET.value = target
theform.__EVENTARGUMENT.value = argument
theform.submit()
}
// -->
</script>
<font size="-1" color="Black">Authorized users, please enter your
trading user ID and password:<br>
Please enter your user ID:<br>
<input name="txtUID" size="32"/><br>
Please enter your password:<br>
<input name="txtPWD" size="32" type="password"/><br>
<input name="cmdGo" type="image" src="Brand/00/go.gif" alt="Go"/><br>
<input name="cmdHomeFromfrmLogin" type="image" src="Brand/00/home.gif"
alt="Home"/></font></form></body></html>
_______________________________________________________________
------------------------------
Date: 5 Jan 2005 11:42:14 -0800
From: arkadyz1@yahoo.com
Subject: How to set the baud rate on a serial port (Perl under cygwin)?
Message-Id: <1104954134.833672.172170@z14g2000cwz.googlegroups.com>
I'm not sure if it's the right group for this question as it's very
environment-specific.
Actually, the subject "How to set the baud rate on a serial port (Perl
under cygwin)?" says it all.
Here is the more detailed description of the problem:
I have a device connected to my Windows 2000 PC's serial port. The
device might talk at different baud rates (19200, 38400, 57600,
115200). Before starting to work with the device I have to determine
its baud rate. The device has some predefined response to a certain
'command' sent its way so it should be easy enough to find out the baud
rate from a Perl script... if only I knew how to change the baud rate
of the open port! Intuitively, ioctl() seems to be the best bet but
perldoc -f ioctl is not very helpful, and, since I don't have any
"native" Windows development environment, there is no ioctl.h to h2ph.
As a side note:
I use
sysopen SERIAL, "COM${port}:", O_RDWR;
to open the port. Is it suitable for my purposes?
Thanks in advance,
Arkady.
------------------------------
Date: Wed, 05 Jan 2005 19:54:02 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: How to set the baud rate on a serial port (Perl under cygwin)?
Message-Id: <uBXCd.28547$EL5.2733@trndny09>
<arkadyz1@yahoo.com> wrote in message
news:1104954134.833672.172170@z14g2000cwz.googlegroups.com...
> I'm not sure if it's the right group for this question as it's very
> environment-specific.
> Actually, the subject "How to set the baud rate on a serial port (Perl
> under cygwin)?" says it all.
A search for 'SerialPort' at search.cpan.org turns up a number of likely
candidates. Have you seen any of those? Can you explain in what way
they do not meet your needs?
Paul Lalli
------------------------------
Date: Wed, 05 Jan 2005 20:35:26 +0100
From: Sandman <mr@sandman.net>
Subject: Re: Moving to a new machine
Message-Id: <mr-599237.20352605012005@individual.net>
In article <crhc44$bqa$1@mamenchi.zrz.TU-Berlin.DE>,
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
> Sandman <mr@sandman.net> wrote in comp.lang.perl.misc:
> > So I've ben using Perl for a couple of years on machine A, now I've bought
> > machine B which comes with a newer version of perl. I don't think there is
> > a
> > compatibility issue, but I do know that I've downnloaded and installed
> > several
> > modules from cpan on machine A, but I can't remember each one specifically.
> >
> > Is there a easy way to migrate user-installed perl modules to a new
> > installation?
>
> Basically you use CPAN, or CPANPLUS, to make a bundle of your old
> installation, take the bundle to the new machine and install it there.
> It's a simple process, see the docs.
Ok, thanks. I'll do that!
--
Sandman[.net]
------------------------------
Date: 5 Jan 2005 13:21:22 -0800
From: lbeckm3@hotmail.com
Subject: Re: Need help sorting fixed length records
Message-Id: <1104960082.659893.4690@f14g2000cwb.googlegroups.com>
Thanks Uri. The unix sort command did work, but I didn't find the
solution in any of the man pages (yes I did read them!) - found another
usenet post that got me on track. Everything there points to using
fields and delimiting the fields etc. and my records are fixed length.
Thanks for your proposed solution, I'll have a go with that and see if
it works since it may be more clean in the future to only sort on just
those two bytes.
-Lyle
------------------------------
Date: Wed, 05 Jan 2005 22:08:44 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Need help sorting fixed length records
Message-Id: <x74qhvmsut.fsf@mail.sysarch.com>
>>>>> "l" == lbeckm3 <lbeckm3@hotmail.com> writes:
l> Thanks Uri. The unix sort command did work, but I didn't find the
l> solution in any of the man pages (yes I did read them!) - found another
l> usenet post that got me on track. Everything there points to using
l> fields and delimiting the fields etc. and my records are fixed length.
l> Thanks for your proposed solution, I'll have a go with that and see if
l> it works since it may be more clean in the future to only sort on just
l> those two bytes.
then you didn't rtfm too well. find out what the field number is for the
state and then use that and optionally the character offset and
ending. the +POS -POS or -k POS,POS arguments control that. this is from
the gnu sort man page. the default field separator is between whitespace
and non-whitespace chars. figure out your fields and use the appropriate
POS args.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Wed, 05 Jan 2005 21:23:23 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Newbie question: "Get substring of line"
Message-Id: <scunt0t4krrr49uvtenu2okg26f0evm0fl@4ax.com>
On Tue, 4 Jan 2005 19:58:34 -0500, "Matt Garrish"
<matthew.garrish@sympatico.ca> wrote:
>> (my $str=$_) =~ s/.*=//; # e.g.
^^^^^^
^^^^^^
>Isn't that a little more work than is necessary? (And perhaps a bit greedy,
>though it's hard to say.)
>
>my ($str) = /[^=]+=(.*)/;
# e.g.
Also, rumors have that regexes using capturing imposes a cost,
although indeed this will be paid anyway if they're used somewhere
else in the script.
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: Wed, 05 Jan 2005 21:23:40 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Perl and TeX
Message-Id: <ldunt0tvai0dbku8bt7t7g1ekhlv724ofi@4ax.com>
On Wed, 05 Jan 2005 01:34:27 +0100, David Kastrup <dak@gnu.org> wrote:
>I don't see where. You are giving a few buzzwords about some areas
>which you think might be relevant to TeX, but don't point out why and
>where.
Well, I pointed out all that I knew. And it seemed to me to be
relevant. But due to your hugely superior knowledge (no joke
intended), well at least about TeX, I'll take your word for it. I
don't really know what I could add.
>You are free to code parts of TeX in Perl6 (like the TeX parser) to
>demonstrate the superiority of it for this task.
You bet I'd do it, if only I had the necessary skills and time and...
oh, but wait a minute: I will certainly do it - just gimme a working
Perl6 compiler!! ;-)
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: Wed, 05 Jan 2005 13:37:27 -0800
From: Jon Ericson <Jon.Ericson@jpl.nasa.gov>
Subject: Re: Perl and TeX
Message-Id: <rcg1xcz4kx4.fsf@Jon-Ericson.sdsio.prv>
Michele Dondi <bik.mido@tiscalinet.it> writes:
> First of all sorry for replying so late. I had originally
> crossposted to clpmisc to hear the cmts from other contributors
> there, but it seems it hasn't attracted much people for which I see
> two main reasons: (i) people there (here) are more concerned with
> how to do things in perl than in speculative issues about Perl, (ii)
> the subject line was not effective at all. So I changed it,
> something I should have done in the first place (interested readers
> can check the original thread for reference)...
Add: (iii) it's not entirely clear what is being proposed. I *think*
the idea is to implement the tex program in Perl6, in which case I'm
not sure what the advantage would be.
On the other hand, I can see an advantage in replacing (or at least
augmenting) the TeX macro system with something more perlish. But we
already have PerlTeX (on CTAN at macros/latex/contrib/perltex/), which
scratches that itch (at least for me).
Jon
------------------------------
Date: Wed, 5 Jan 2005 22:25:17 +0100
From: Sven Bachmann <bachmanns@gmx.de>
Subject: sharing fileglobs
Message-Id: <slrnctompu.45l.bachmanns@box.brookman.home>
Hello,
I'd like to use perl threads but I encountered a problem when I want to
share fileglobs stored in a hash.
Google only showed me, that sharing fileglobs isn't possible yet.
Maybe I don't need fileglobs. So I ask you if there is another
possibility to share open sockets (stored in a hash) with threads?
Thank you in advance.
Sven
------------------------------
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 V10 Issue 7608
***************************************