[33048] in Perl-Users-Digest
Perl-Users Digest, Issue: 4324 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Dec 7 09:09:17 2014
Date: Sun, 7 Dec 2014 06:09:04 -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 Sun, 7 Dec 2014 Volume: 11 Number: 4324
Today's topics:
Re: Can you point me in the right direction - accessing <news@lawshouse.org>
Re: Dedup script is finished and works. Critiques? <whynot@pozharski.name>
Re: Dedup script is finished and works. Critiques? <news@todbe.com>
Perl script works fine in Cygwin, gets "bareword found" <davidmichaelkarr@gmail.com>
Re: Perl script works fine in Cygwin, gets "bareword fo <news@todbe.com>
Re: Perl script works fine in Cygwin, gets "bareword fo <davidmichaelkarr@gmail.com>
Re: Read/write specific lines? <hjp-usenet3@hjp.at>
Re: Read/write specific lines? <tuxedo@mailinator.com>
Re: Read/write specific lines? <gravitalsun@hotmail.foo>
Re: Read/write specific lines? <m@rtij.nl.invlalid>
Re: Read/write specific lines? <gravitalsun@hotmail.foo>
Re: Read/write specific lines? <m@rtij.nl.invlalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 06 Dec 2014 18:21:54 +0000
From: Henry Law <news@lawshouse.org>
Subject: Re: Can you point me in the right direction - accessing a website
Message-Id: <Z8ydnQnwQ-vf1B7JnZ2dnUVZ8oGdnZ2d@giganews.com>
On 05/12/14 21:43, John Black wrote:
> But it does
> not handle javascript.
Deliberately; at least that was the impression I got when I read the
section in the perldoc for WWW::Mechanize::FAQ. Essentially the
author's view is that JS is there to mess about checking arguments, URL
mangling and so forth, and that the results of that can all be achieved
(assuming you can understand what they are) by the Perl in the Mech
program. It's a valid position, though it could be argued that it's
unhelpful. As I said my earlier post (which also may have been
unhelpful) I had to resort to line tracing in some cases as the easiest
way of finding out what the javascript had done.
There's a module called WWW::Mechanize::Firefox which (AIUI) allows you
to use FF as the browser engine, but with Perl pulling its strings.
I've not tried it, but it might do what you want.
--
Henry Law Manchester, England
------------------------------
Date: Sat, 06 Dec 2014 16:31:31 +0200
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: Dedup script is finished and works. Critiques?
Message-Id: <slrnm864q3.fg8.whynot@orphan.zombinet>
with <m8-dnRjSztYPZR3JnZ2dnUVZ572dnZ2d@giganews.com> Robbie Hatley wrote:
*SKIP*
> sub get_character {
> system "stty cbreak </dev/tty >/dev/tty 2>&1";
> my $char = getc;
> system "stty icanon </dev/tty >/dev/tty 2>&1";
> return $char;
> }
If you really want to be portable then consider Term::ReadKey. I see
you want to go lines interacting with user T::RK handles them too.
Besides, minus two forks.
*CUT*
--
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom
------------------------------
Date: Sat, 06 Dec 2014 11:38:26 -0800
From: "$Bill" <news@todbe.com>
Subject: Re: Dedup script is finished and works. Critiques?
Message-Id: <m5vlv2$sco$1@dont-email.me>
On 12/6/2014 06:31, Eric Pozharski wrote:
> with <m8-dnRjSztYPZR3JnZ2dnUVZ572dnZ2d@giganews.com> Robbie Hatley wrote:
>
> *SKIP*
>> sub get_character {
>> system "stty cbreak </dev/tty >/dev/tty 2>&1";
>> my $char = getc;
>> system "stty icanon </dev/tty >/dev/tty 2>&1";
>> return $char;
>> }
>
> If you really want to be portable then consider Term::ReadKey. I see
> you want to go lines interacting with user T::RK handles them too.
> Besides, minus two forks.
Yes, that's a waste.
Readkey will let you do line editing and so forth, but if you just need
a simple {y|n|q} type response you can just print to STDERR and read a
line from STDIN and should be fine. You may need to unbuffer STDERR if
it isn't already.
------------------------------
Date: Fri, 5 Dec 2014 15:48:53 -0800 (PST)
From: David Karr <davidmichaelkarr@gmail.com>
Subject: Perl script works fine in Cygwin, gets "bareword found" on Linux
Message-Id: <476b3e57-c858-4636-8b32-9d092b5ccb88@googlegroups.com>
I have a Perl script that I haven't modified in a long time. It's been wor=
king on Cygwin for a long time. I recently installed it on a CentOS VM, an=
d now it's failing. This is likely some sort of configuration/infrastructu=
re problem, but I could use help narrowing it down.
The entire script is just this (which is called "filterLatestTime"):
-----------------------------------
#! /usr/local/bin/perl
use strict;
use Getopt::Long;
use POSIX qw( strftime );
my $opt_help;
my $opt_propname =3D "latestTime";
GetOptions("h|help" =3D> \$opt_help,
"p|property=3Ds" =3D> \$opt_propname);
while (my $line =3D <STDIN>) {
my $findexpr =3D '(^.*' . $opt_propname . '=3D")(\d+)(".*$)';
my $replexpr =3D $opt_propname . '=3D"(\d+)"';
if ($line =3D~ /$findexpr/) {
$line =3D~ s{$replexpr} {
strftime(qq/$opt_propname=3D"%Y-%m-%d %H:%M:%S"/,
localtime($1/1000))}aeg;
}
print $line;
}
-------------------
Again, this is working fine on Linux, but when I run it on the CentOS box i=
t gives me this:
-----------------
Bareword found where operator expected at .../filterLatestTime line 18, nea=
r "localtime($1/1000))}aeg"
(Might be a runaway multi-line {} string starting on line 16)
syntax error at .../filterLatestTime line 18, near "localtime($1/1000))}aeg=
"
Execution of .../filterLatestTime aborted due to compilation errors.
--------------
I've separately tested the strftime/localtime call, and that looks fine. I=
t seems like there's something wrong with how I'm doing the string replacem=
ent.
------------------------------
Date: Fri, 05 Dec 2014 16:15:41 -0800
From: "$Bill" <news@todbe.com>
Subject: Re: Perl script works fine in Cygwin, gets "bareword found" on Linux
Message-Id: <m5thr5$6c3$1@dont-email.me>
On 12/5/2014 15:48, David Karr wrote:
> I have a Perl script that I haven't modified in a long time. It's been working on Cygwin for a long time. I recently installed it on a CentOS VM, and now it's failing. This is likely some sort of configuration/infrastructure problem, but I could use help narrowing it down.
> $line =~ s{$replexpr} {
> strftime(qq/$opt_propname="%Y-%m-%d %H:%M:%S"/,
> localtime($1/1000))}aeg;
What's the a (in aeg) for ? 5.12 which I'm still stuck on doesn't have that option.
------------------------------
Date: Fri, 5 Dec 2014 16:39:16 -0800 (PST)
From: David Karr <davidmichaelkarr@gmail.com>
Subject: Re: Perl script works fine in Cygwin, gets "bareword found" on Linux
Message-Id: <51a0f174-8624-485f-b052-76389383c93e@googlegroups.com>
On Friday, December 5, 2014 4:15:53 PM UTC-8, $Bill wrote:
> On 12/5/2014 15:48, David Karr wrote:
> > I have a Perl script that I haven't modified in a long time. It's been=
working on Cygwin for a long time. I recently installed it on a CentOS VM=
, and now it's failing. This is likely some sort of configuration/infrastr=
ucture problem, but I could use help narrowing it down.
>=20
>=20
> > $line =3D~ s{$replexpr} {
> > strftime(qq/$opt_propname=3D"%Y-%m-%d %H:%M:%S"/,
> > localtime($1/1000))}aeg;
>=20
> What's the a (in aeg) for ? 5.12 which I'm still stuck on doesn't have t=
hat option.
Ah, ok, that appeared to be the difference. My Cygwin Perl is 5.14.4, and =
I have 5.10.1 on CentOS. Checking the man page for "perlre", I see that "a=
" was added in 5.14, which controls whether it will use Unicode. My use ca=
se won't have to deal with that, so I can safely ignore that.
Thanks.
------------------------------
Date: Sat, 6 Dec 2014 07:07:19 +0100
From: "Peter J. Holzer" <hjp-usenet3@hjp.at>
Subject: Re: Read/write specific lines?
Message-Id: <slrnm8578n.mpn.hjp-usenet3@hrunkner.hjp.at>
On 2014-12-05 17:51, George Mpouras <gravitalsun@hotmail.foo> wrote:
>>
>> Any examples or ideas would be much appreciated.
>>
>
> # what you asked
> open FILE, '+<', 'file.txt' or die "oups $!\n";
> my $previous = <FILE>;
> seek FILE, 0, 0;
> print FILE ++$previous;
> close FILE;
Now consider what happens if the first line contains the value "99".
hp
--
_ | Peter J. Holzer | Fluch der elektronischen Textverarbeitung:
|_|_) | | Man feilt solange an seinen Text um, bis
| | | hjp@hjp.at | die Satzbestandteile des Satzes nicht mehr
__/ | http://www.hjp.at/ | zusammenpaßt. -- Ralph Babel
------------------------------
Date: Sat, 6 Dec 2014 08:03:36 +0100
From: Tuxedo <tuxedo@mailinator.com>
Subject: Re: Read/write specific lines?
Message-Id: <m5u9o9$m3c$1@news.albasani.net>
George Mpouras wrote:
> >
> > I don't see through the code entirely. I
>
> operator +< is for read and write at the same time .
>
> read what you want either line by line or go directly where you want
> with seek , and then write whatever wherever you want with seek.
>
> With this trick you will open the file once for both read/write.
Thanks for the explanation, it's most useful to know.
Tuxedo
------------------------------
Date: Sat, 06 Dec 2014 10:02:48 +0200
From: George Mpouras <gravitalsun@hotmail.foo>
Subject: Re: Read/write specific lines?
Message-Id: <m5ud7a$2b5n$1@news.ntua.gr>
On 6/12/2014 08:07, Peter J. Holzer wrote:
>
> Now consider what happens if the first line contains the value "99".
>
> hp
>
my post was only a proof of concept. It can be adapted to a full working
solution but this was not my intention.
------------------------------
Date: Sat, 6 Dec 2014 11:37:13 +0100
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: Read/write specific lines?
Message-Id: <pr2blb-9db.ln1@news.rtij.nl>
On Sat, 06 Dec 2014 10:02:48 +0200, George Mpouras wrote:
> On 6/12/2014 08:07, Peter J. Holzer wrote:
>>
>> Now consider what happens if the first line contains the value "99".
>>
>> hp
>>
>>
> my post was only a proof of concept. It can be adapted to a full working
> solution but this was not my intention.
No it cannot.
M4
------------------------------
Date: Sat, 06 Dec 2014 12:50:42 +0200
From: George Mpouras <gravitalsun@hotmail.foo>
Subject: Re: Read/write specific lines?
Message-Id: <m5un20$smv$1@news.ntua.gr>
On 6/12/2014 12:37 μμ, Martijn Lievaart wrote:
> On Sat, 06 Dec 2014 10:02:48 +0200, George Mpouras wrote:
>
>> On 6/12/2014 08:07, Peter J. Holzer wrote:
>>>
>>> Now consider what happens if the first line contains the value "99".
>>>
>>> hp
>>>
>>>
>> my post was only a proof of concept. It can be adapted to a full working
>> solution but this was not my intention.
>
> No it cannot.
>
> M4
>
sorry for you . it can.
------------------------------
Date: Sat, 6 Dec 2014 16:49:38 +0100
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: Read/write specific lines?
Message-Id: <i5lblb-9db.ln1@news.rtij.nl>
On Sat, 06 Dec 2014 12:50:42 +0200, George Mpouras wrote:
> On 6/12/2014 12:37 μμ, Martijn Lievaart wrote:
>> On Sat, 06 Dec 2014 10:02:48 +0200, George Mpouras wrote:
>>
>>> On 6/12/2014 08:07, Peter J. Holzer wrote:
>>>>
>>>> Now consider what happens if the first line contains the value "99".
>>>>
>>>> hp
>>>>
>>>>
>>> my post was only a proof of concept. It can be adapted to a full
>>> working solution but this was not my intention.
>>
>> No it cannot.
>>
>> M4
>>
>>
> sorry for you . it can.
Well, then answer Peters question.
M4
------------------------------
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:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#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 4324
***************************************