[31565] in Perl-Users-Digest
Perl-Users Digest, Issue: 2824 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 18 16:09:28 2010
Date: Thu, 18 Feb 2010 13:09:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 18 Feb 2010 Volume: 11 Number: 2824
Today's topics:
(lack of) Helpfulness of Perl error messages. <justin.0911@purestblue.com>
Re: (lack of) Helpfulness of Perl error messages. <john@castleamber.com>
Re: (lack of) Helpfulness of Perl error messages. <sreservoir@gmail.com>
Re: (lack of) Helpfulness of Perl error messages. (Randal L. Schwartz)
benchmarks for perl? <bugbear@trim_papermule.co.uk_trim>
Re: ExcelPrepHTML.pm <catebekensail@yahoo.com>
Re: ExcelPrepHTML.pm <cartercc@gmail.com>
Re: File Position (Randal L. Schwartz)
Re: File Position sln@netherlands.com
Re: File Position <tzz@lifelogs.com>
Re: File Position sln@netherlands.com
libwww-perl authorization problem <ron.eggler@gmail.com>
Re: libwww-perl authorization problem <john@castleamber.com>
Re: libwww-perl authorization problem <ron.eggler@gmail.com>
Re: saving old versions of file <tzz@lifelogs.com>
Re: saving old versions of file <jurgenex@hotmail.com>
Re: Substitution with parameters and variable don't wor <KBfoMe@realdomain.net>
Re: Substitution with parameters and variable don't wor <tadmc@seesig.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 18 Feb 2010 16:15:13 -0000
From: Justin C <justin.0911@purestblue.com>
Subject: (lack of) Helpfulness of Perl error messages.
Message-Id: <6565.4b7d6791.84fe@zem>
As some of you are probably aware I often have difficulty with Perl and
I ask for help here usually about once a month. I try to help myself
where I can, and sometimes, when I'm preparing a minimal example for
posting here, I find the solution to my problem. That's just happened
again, but only due to an error message I received from my text editor
and not Perl directly.
I'm a Mac user, and code using TextMate <URL:http://macromates.com/>, it
has the ability to run code, I don't know how it does it, though, and
it's error message gave me the clue to the solution of my problem. The
error message on my Debian box was non-helpful.
What is likely to be the cause of the non-helpful error message? Is the
version of Perl on my Mac likely more recent - I've just checked and on
my Debian box it's 5.10.0, while on the Mac it's 5.8.8. Does TextMate
have a built in Perl interpreter that gives better error messages?
The error I saw on Debian:
Not a HASH reference at ... line...
The error I saw from TextMate:
Can't coerce array into hash at ... line...
I prepared a minimal code example, so here's the broken code, I'm sure
most of you will know what the problem is at a glance, unfortunately it
wasn't obvious to me, and as there are 3 references to hashes on that line
I didn't know where to start. I erroneously spent quite a while looking
at the part of the line that was fine, just because there was only one
error, and not two - obviously the program halted before checking
further, as it would with an error as opposed to a warning.
e strict;
use warnings;
use Data::Dumper;
my $data = read_in_data();
# print Dumper $data;
foreach my $style ( sort keys %{$data}) {
foreach my $item ( sort { $data->{$style}{$a}{1} cmp $data->{$style}{$b}{1} } keys %{$data->{$style}} ) {
printf("%-20s %-40s %5d\n", $item, @{$data->{$style}{$item}}[0], @{$data->{$style}{$item}}[1]);
}
}
sub read_in_data {
my %data;
while (<DATA>) {
my ($style, $item, $desc, $qty) = split /:/, $_;
$data{$style}{$item} = [$desc, $qty];
}
return \%data;
}
__DATA__
TS:TS/ZEP/HERMIT/D:LED ZEPPELIN hermit TSXL:6
TS:TS/MET/MASTERO/D:METALLICA master of puppets TSXL:5
TS:TS/AC/CLASSIC/B:AC/DC classic red logo TS M:12
TS:TS/MET/MASTERO/C:METALLICA master of puppets TS L:7
BB:BB/MET/MASTERO:METALLICA master of puppets BB Cap:17
BB:BB/AC/LOGO:AC/DC logo BB Cap:10
Justin.
--
Justin C, by the sea.
------------------------------
Date: Thu, 18 Feb 2010 11:10:04 -0600
From: John Bokma <john@castleamber.com>
Subject: Re: (lack of) Helpfulness of Perl error messages.
Message-Id: <87635ujwr7.fsf@castleamber.com>
Justin C <justin.0911@purestblue.com> writes:
> foreach my $item ( sort { $data->{$style}{$a}{1} cmp
> $data->{$style}{$b}{1
^ you want a [ ] there, since sou assign
to "item" a ref to an array with 2 elements. And that's what the error
you got complained about: you try to treat a ref to an array like it's a
ref to a hash.
> sub read_in_data {
> my %data;
> while (<DATA>) {
> my ($style, $item, $desc, $qty) = split /:/, $_;
> $data{$style}{$item} = [$desc, $qty];
> }
> return \%data;
> }
--
John Bokma j3b
Hacking & Hiking in Mexico - http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development
------------------------------
Date: Thu, 18 Feb 2010 12:16:19 -0500
From: sreservoir <sreservoir@gmail.com>
Subject: Re: (lack of) Helpfulness of Perl error messages.
Message-Id: <hljsli$ud$1@speranza.aioe.org>
On 2/18/2010 11:15 AM, Justin C wrote:
> As some of you are probably aware I often have difficulty with Perl and
> I ask for help here usually about once a month. I try to help myself
> where I can, and sometimes, when I'm preparing a minimal example for
> posting here, I find the solution to my problem. That's just happened
> again, but only due to an error message I received from my text editor
> and not Perl directly.
>
> I'm a Mac user, and code using TextMate<URL:http://macromates.com/>, it
> has the ability to run code, I don't know how it does it, though, and
> it's error message gave me the clue to the solution of my problem. The
> error message on my Debian box was non-helpful.
>
> What is likely to be the cause of the non-helpful error message? Is the
> version of Perl on my Mac likely more recent - I've just checked and on
> my Debian box it's 5.10.0, while on the Mac it's 5.8.8. Does TextMate
> have a built in Perl interpreter that gives better error messages?
>
> The error I saw on Debian:
> Not a HASH reference at ... line...
>
> The error I saw from TextMate:
> Can't coerce array into hash at ... line...
the two messages are equally helpful if you think about it. The second
doesn't even explicitly tell you it's a reference problem. If you need
to, you can use diagnostics; alternatively, grep perldiag.
As for the line references, you can twiddle with your code so that all
of the references aren't on a single line.
--
"Six by nine. Forty two."
"That's it. That's all there is."
"I always thought something was fundamentally wrong with the universe"
------------------------------
Date: Thu, 18 Feb 2010 09:07:59 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: (lack of) Helpfulness of Perl error messages.
Message-Id: <86eikicw0g.fsf@blue.stonehenge.com>
>>>>> "Justin" == Justin C <justin.0911@purestblue.com> writes:
This...
Justin> foreach my $item ( sort { $data->{$style}{$a}{1} cmp $data->{$style}{$b}{1} } keys %{$data->{$style}} ) {
Does not match this...
Justin> $data{$style}{$item} = [$desc, $qty];
which is why you're getting an error. I got suspicious when I saw {1}...
that's a hash element selection, not an array element.
I think you want that to be $data->{$style}{$a}[1] -- note the square
brackets, since you have an array there, not a hash.
"perldoc perlreftut" might help. And we cover this stuff pretty
thoroughly in "Intermediate Perl" (the Alpaca book).
print "Just another Perl hacker,"; # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
------------------------------
Date: Thu, 18 Feb 2010 16:25:33 +0000
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: benchmarks for perl?
Message-Id: <j8OdnWeEAuNg9ODWnZ2dnUVZ8nhi4p2d@brightview.co.uk>
No, I'm not starting yet another perl vs C thread.
I have some concerns about the performance
of perl varying more than I would expect
between different installations I'm maintaining
(and running my perl code on)
Is there a standard benchmark, used (perhaps)
when people port Perl to different CPUs/OS/compilers?
I tried to search, but google gave me loads
of perl VS Python (etc...) pages/flamewars.
BugBear
------------------------------
Date: Thu, 18 Feb 2010 04:32:35 -0800 (PST)
From: cate <catebekensail@yahoo.com>
Subject: Re: ExcelPrepHTML.pm
Message-Id: <e2336324-d707-4a42-8b4e-bf9449289be8@e1g2000yqh.googlegroups.com>
On Feb 17, 7:05=A0pm, John Bokma <j...@castleamber.com> wrote:
> cate <catebekens...@yahoo.com> writes:
> > misc - this has got to be the place.
>
> > Sorry if this is outside the limits of a perl question, but has anyone
> > ever worked with HTML, preparing it for an Excel HTML import? =A0We are
> > sending HTML to the client via
>
> > $Response->AddHeader("Content-Type","application/vnd.ms-excel");
> > $Response->AddHeader("Content-
> > Disposition","attachment;filename=3DExport2Excel_${filename}.xls");
> > $Response->BinaryWrite($postContent);
>
> > But the rendering in Excel is terrible. =A0Is there a perl
> > ExcelPrepHTML.pm out there? =A0I wish I knew more about the Excel impor=
t
> > rules, but I don't. =A0Hoping someone else does; then stuck it all in a
> > module.
>
> > I see some code out there that use OLE to manipulate the workbook, but
> > this is strictly a hand off.
>
> Does it have to be HTML?
>
> --
> John Bokma =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 j3b
>
> Hacking & Hiking in Mexico - =A0http://johnbokma.com/http://castleamber.c=
om/- Perl & Python Development
No, but I'd rather just scoot over what I'm given. It's basically the
tables we're after. I suppose we could strip it down but we never
know exactly what we're getting.
------------------------------
Date: Thu, 18 Feb 2010 06:35:50 -0800 (PST)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: ExcelPrepHTML.pm
Message-Id: <5fa22217-c1d3-417c-9fd6-12bb33826629@q29g2000yqn.googlegroups.com>
On Feb 17, 7:43=A0pm, cate <catebekens...@yahoo.com> wrote:
> But the rendering in Excel is terrible. =A0Is there a perl
> ExcelPrepHTML.pm out there? =A0I wish I knew more about the Excel import
> rules, but I don't. =A0Hoping someone else does; then stuck it all in a
> module.
The xlsx format is pure XML. This means that you can write a script
that generates ASCII and Excel 2007 will render it natively.
To see what I mean, take an Excel file, change the xlsx extension to a
zip extension, and then unzip the file.
Obviously, generating an Excel file this way is extremely difficult,
but it IS possible. Better IMO is to generate files in simple CSV
format which Excel also opens natively -- except that this excludes
formatting and formulas.
CC
------------------------------
Date: Thu, 18 Feb 2010 05:38:14 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: File Position
Message-Id: <863a0yekah.fsf@blue.stonehenge.com>
>>>>> "Jürgen" == Jürgen Exner <jurgenex@hotmail.com> writes:
Jürgen> Now, that is the critical clue. seek() is based on bytes, so you need a
Jürgen> position in bytes in order to use seek().
Historical fact: fseek(3) was originally based on ftell(3)-"cookies", where
the stdio lib didn't promise to be able to return to any position that it
hadn't originally handed you from a tell. As it turns out, those "cookies"
were always byte positions on every operating system *I* saw stdio implemented
on.
print "Just another Perl hacker,";
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
------------------------------
Date: Thu, 18 Feb 2010 08:13:22 -0800
From: sln@netherlands.com
Subject: Re: File Position
Message-Id: <jlpqn5l8r9d4ofpo8a21sro7fnct9e5k8g@4ax.com>
On Thu, 18 Feb 2010 06:22:51 +0100, Peter Makholm <peter@makholm.net> wrote:
>mud_saisem <mud_saisem@hotmail.com> writes:
>
>> Does anybody know how to read through a file searching for a word and
>> printing the file position of that word ?
>
>If your file contains plain ascii, iso-8859, or another 8bit charset
>it should be easy. The tell() function gives you the current location
>in the file, pos() gives you the location of regexp match, and
>index() directly gives you the location.
>
>So this should work (untested though)
>
> my $offset = 0;
> while (<$fh>) {
> if (/word/) {
> say "Found 'word' at location ", $offset + pos();
> }
> $offset = tell $fh;
> }
>
>If you file contains a variable width uniode encoding (like utf-8) it
>gets a lot harder.
^^^
But probably not impossible.
-sln
------------------------
use strict;
use warnings;
use Encode;
binmode(STDOUT, ':encoding(UTF-8)');
my $word = "wo\x{2100}rd";
my $octet_search = encode('UTF-8', $word);
my @FileLocations = ();
my $filedata = encode ('UTF-8', "
This $word \x{2100} is a $word puzzle
It is not in this line,
but $word is in this one.
End.
");
open my $fh, '<', \$filedata or die "can't open memory file: $!";
my $linelength = 0;
print "\n";
while (<$fh>)
{
my $octet_dataline = $_;
while ( /($octet_search)/g )
{
my ($byte_offset, $byte_len) = (
$linelength + pos() - length($octet_search),
length $1
);
print "Found $word at $byte_offset\n";
print "Byte length is $byte_len, byte string is '$1'\n";
push @FileLocations, $byte_offset, $byte_len;
}
$linelength += length ($octet_dataline);
}
close $fh;
# To reconstitute,
# seek to the offsets, and read length bytes
#
print "\nFile offset/length's:\n";
while (my ($offset,$len) = splice(@FileLocations, 0,2)) {
print "$offset, $len\n";
}
__END__
Found woGäÇrd at 7
Byte length is 7, byte string is 'wo+ó-ä-Çrd'
Found woGäÇrd at 24
Byte length is 7, byte string is 'wo+ó-ä-Çrd'
Found woGäÇrd at 69
Byte length is 7, byte string is 'wo+ó-ä-Çrd'
File offset/length's:
7, 7
24, 7
69, 7
------------------------------
Date: Thu, 18 Feb 2010 11:10:56 -0600
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: File Position
Message-Id: <87y6iqv59b.fsf@lifelogs.com>
On Wed, 17 Feb 2010 20:21:19 -0800 (PST) mud_saisem <mud_saisem@hotmail.com> wrote:
ms> Does anybody know how to read through a file searching for a word and
ms> printing the file position of that word ?
Besides the great Perl solutions posted here, you may want to consider
`grep -b' which will print the byte offset of each match, depending on
your needs of course.
Ted
------------------------------
Date: Thu, 18 Feb 2010 12:38:33 -0800
From: sln@netherlands.com
Subject: Re: File Position
Message-Id: <88uqn5lc9k6tkb1c84m48g9vnahhbfm5lq@4ax.com>
On Thu, 18 Feb 2010 08:13:22 -0800, sln@netherlands.com wrote:
>On Thu, 18 Feb 2010 06:22:51 +0100, Peter Makholm <peter@makholm.net> wrote:
>
>>mud_saisem <mud_saisem@hotmail.com> writes:
>>
>>> Does anybody know how to read through a file searching for a word and
>>> printing the file position of that word ?
>>
>>If your file contains plain ascii, iso-8859, or another 8bit charset
>>it should be easy. The tell() function gives you the current location
>>in the file, pos() gives you the location of regexp match, and
>>index() directly gives you the location.
>>
>>So this should work (untested though)
>>
>> my $offset = 0;
>> while (<$fh>) {
>> if (/word/) {
>> say "Found 'word' at location ", $offset + pos();
>> }
>> $offset = tell $fh;
>> }
>>
>>If you file contains a variable width uniode encoding (like utf-8) it
>>gets a lot harder.
> ^^^
>But probably not impossible.
>
>-sln
>
I guess I'll keep this around as a curiosity,
not knowing the particulars of how/if Perl auto-promotes
byte strings to utf8 in the regex process.
If I try it out on different encodings, it seems to work.
The only problem is with any BOM (byte order mark) as this would
require adjusting the offset because of the bom/seek bug.
Depending on the OS, an endian'es won't map correctly to utf8.
For this reason, I left out the 16/32 LE's, because it prints to
STDOUT, which is binmode to utf-8. But otherwise, all the endian's
work as far as getting offsets.
Same realestate, different code.
Btw, this may be a much faster way to do regex on
Unicode. Reading/processing regular expressions on a file opened
in utf-8 mode and that happens to be very large, significantly
slows down the regex engine (by several magnitudes).
-sln
--------------------
# Rx_Bytes_Unicode_misc1.pl
# -sln, 2/10
use strict;
use warnings;
use Encode;
binmode(STDOUT, ':encoding(UTF-8)');
## Try some encodings
#
for my $UTF ('ascii', 'UTF-8', 'UTF-16BE', 'UTF-32BE')
{
## Create pattern in encoded bytes
#
my $word = "wo\x{2100}rd";
my $octet_pattern = encode($UTF, $word."|End|one");
print "\n",'-'x20,"\nEncoding: $UTF\nPattern: '$octet_pattern'\n";
## Create file data in encoded bytes
#
my $filedata = encode ($UTF,
"This $word \x{2100} is a $word puzzle
It is not in this line,
but $word is in this one.
The End."
);
## Open a memory buffer in byte mode
#
open my $fh, '<', \$filedata
or die "Can't open memory buffer for read: $!";
print "\n";
## Process file data
#
my @FileLocations = ();
my ($filepos, $line_count, $byte_offset, $byte_len) = (0,0);
while (<$fh>)
{
++$line_count;
while ( /($octet_pattern)/g )
{
$byte_len = length $1;
$byte_offset = $filepos + pos() - $byte_len;
print "(line $line_count) Found '",decode($UTF,$1),
"' (fpos= $byte_offset), byte string ",
"(len= $byte_len) is '$1'\n";
# save offset/length of matched item
push @FileLocations, $byte_offset, $byte_len;
}
# $filepos += length;
# or ->
$filepos = tell ($fh);
}
## Reconstitute file data.
## Seek to offsets, read length bytes
#
if ( @FileLocations ) {
print "\nFile offset/length:\n";
my $buf = '';
while (my ($offset,$len) = splice(@FileLocations, 0,2)) {
seek ($fh, $offset, 0);
read ($fh, $buf, $len);
print "$offset, $len, ",
"$UTF: '$buf', UTF-8 string: '",
decode($UTF, $buf), "'\n";
}
}
close $fh;
}
__END__
--------------------
Encoding: ascii
Pattern: 'wo?rd|End|one'
(line 3) Found 'one' (fpos= 96), byte string (len= 3) is 'one'
(line 4) Found 'End' (fpos= 115), byte string (len= 3) is 'End'
File offset/length:
96, 3, ascii: 'one', UTF-8 string: 'one'
115, 3, ascii: 'End', UTF-8 string: 'End'
--------------------
Encoding: UTF-8
Pattern: 'wo+ó-ä-Çrd|End|one'
(line 1) Found 'woGäÇrd' (fpos= 5), byte string (len= 7) is 'wo+ó-ä-Çrd'
(line 1) Found 'woGäÇrd' (fpos= 22), byte string (len= 7) is 'wo+ó-ä-Çrd'
(line 3) Found 'woGäÇrd' (fpos= 85), byte string (len= 7) is 'wo+ó-ä-Çrd'
(line 3) Found 'one' (fpos= 104), byte string (len= 3) is 'one'
(line 4) Found 'End' (fpos= 123), byte string (len= 3) is 'End'
File offset/length:
5, 7, UTF-8: 'wo+ó-ä-Çrd', UTF-8 string: 'woGäÇrd'
22, 7, UTF-8: 'wo+ó-ä-Çrd', UTF-8 string: 'woGäÇrd'
85, 7, UTF-8: 'wo+ó-ä-Çrd', UTF-8 string: 'woGäÇrd'
104, 3, UTF-8: 'one', UTF-8 string: 'one'
123, 3, UTF-8: 'End', UTF-8 string: 'End'
--------------------
Encoding: UTF-16BE
Pattern: ' w o! r d | E n d | o n e'
(line 1) Found 'woGäÇrd' (fpos= 10), byte string (len= 11) is ' w o! r d '
(line 1) Found 'woGäÇrd' (fpos= 36), byte string (len= 11) is ' w o! r d '
(line 3) Found 'woGäÇrd' (fpos= 158), byte string (len= 11) is ' w o! r d '
(line 3) Found 'one' (fpos= 192), byte string (len= 6) is ' o n e'
(line 4) Found 'End' (fpos= 230), byte string (len= 7) is ' E n d '
File offset/length:
10, 11, UTF-16BE: ' w o! r d ', UTF-8 string: 'woGäÇrd'
36, 11, UTF-16BE: ' w o! r d ', UTF-8 string: 'woGäÇrd'
158, 11, UTF-16BE: ' w o! r d ', UTF-8 string: 'woGäÇrd'
192, 6, UTF-16BE: ' o n e', UTF-8 string: 'one'
230, 7, UTF-16BE: ' E n d ', UTF-8 string: 'End'
--------------------
Encoding: UTF-32BE
Pattern: ' w o ! r d | E n d | o n e'
(line 1) Found 'woGäÇrd' (fpos= 20), byte string (len= 23) is ' w o ! r
d '
(line 1) Found 'woGäÇrd' (fpos= 72), byte string (len= 23) is ' w o ! r
d '
(line 3) Found 'woGäÇrd' (fpos= 316), byte string (len= 23) is ' w o ! r
d '
(line 3) Found 'one' (fpos= 384), byte string (len= 12) is ' o n e'
(line 4) Found 'End' (fpos= 460), byte string (len= 15) is ' E n d '
File offset/length:
20, 23, UTF-32BE: ' w o ! r d ', UTF-8 string: 'woGäÇrd'
72, 23, UTF-32BE: ' w o ! r d ', UTF-8 string: 'woGäÇrd'
316, 23, UTF-32BE: ' w o ! r d ', UTF-8 string: 'woGäÇrd'
384, 12, UTF-32BE: ' o n e', UTF-8 string: 'one'
460, 15, UTF-32BE: ' E n d ', UTF-8 string: 'End'
------------------------------
Date: Thu, 18 Feb 2010 11:47:57 -0800 (PST)
From: cerr <ron.eggler@gmail.com>
Subject: libwww-perl authorization problem
Message-Id: <2f27754c-dc6b-4989-93b7-9804e92a9540@s36g2000prh.googlegroups.com>
Hi There,
I'm trying to login to a ssl encrypted webinterface with authrization
uing LWP but I don't get authorized for some reason and i can't figure
out why not.
My code:
my $url = 'https://192.168.167.166/'; # Yes, HTTPS!
my $browser = LWP::UserAgent->new;
$browser->credentials(
'https://192.168.167.166',
'Configuration Software',
'admin' => 'admin'
);
my $response = $browser->get($url);
print $response->header('WWW-Authenticate')."\n";
die "Error at $url\n ", $response->status_line, "\n Aborting"
unless $response->is_success;
print "Whee, it worked! I got that ",
$response->content_type, " document!\n";
and i keep getting following in my console:
Basic realm="Configuration Software"
Error at https://192.168.167.166/
401 Authorization Required
Aborting at ./login.pl line 40.
What's the problem? I can log-in just fine using a browser...
Thanks,
roN
------------------------------
Date: Thu, 18 Feb 2010 14:30:28 -0600
From: John Bokma <john@castleamber.com>
Subject: Re: libwww-perl authorization problem
Message-Id: <87pr42i8wr.fsf@castleamber.com>
cerr <ron.eggler@gmail.com> writes:
> Hi There,
>
> I'm trying to login to a ssl encrypted webinterface with authrization
> uing LWP but I don't get authorized for some reason and i can't figure
> out why not.
> My code:
> my $url = 'https://192.168.167.166/'; # Yes, HTTPS!
> my $browser = LWP::UserAgent->new;
> $browser->credentials(
> 'https://192.168.167.166',
^^^ AFAIK this must be a domain not a URL (try remove
https:// and try again)
> 'Configuration Software',
> 'admin' => 'admin'
> );
--
John Bokma j3b
Hacking & Hiking in Mexico - http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development
------------------------------
Date: Thu, 18 Feb 2010 13:05:08 -0800 (PST)
From: cerr <ron.eggler@gmail.com>
Subject: Re: libwww-perl authorization problem
Message-Id: <c90de395-261f-447c-8bc7-ef8aaa5b2774@b1g2000prc.googlegroups.com>
On Feb 18, 12:30=A0pm, John Bokma <j...@castleamber.com> wrote:
> cerr <ron.egg...@gmail.com> writes:
> > Hi There,
>
> > I'm trying to login to a ssl encrypted webinterface with authrization
> > uing LWP but I don't get authorized for some reason and i can't figure
> > out why not.
> > My code:
> > =A0 my $url =3D 'https://192.168.167.166/';=A0 # Yes, HTTPS!
> > =A0 my $browser =3D LWP::UserAgent->new;
> > =A0 $browser->credentials(
> > =A0 =A0 'https://192.168.167.166',
>
> =A0 =A0 =A0 ^^^ AFAIK this must be a domain not a URL (try remove
> =A0 =A0 =A0 https:// and try again)
almost, setting it to '192.168.167.166:443' let me in! Sweet!
Thanks!
>
> > =A0 =A0 'Configuration Software',
> > =A0 =A0 'admin' =3D> 'admin'
> > =A0 =A0 );
--
roN
------------------------------
Date: Thu, 18 Feb 2010 11:07:04 -0600
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: saving old versions of file
Message-Id: <873a0ywk07.fsf@lifelogs.com>
On Tue, 16 Feb 2010 10:29:27 -0500 Jarmo <jampe@darkbusstop.com> wrote:
J> I have a problem and I was hoping someone could help me. I have a program
J> that every time it runs it saves a log file with same name about the changes
J> it did on that particular run. Result is that old file gets overwritten and
J> lost. I would like to create "virtual file" so that every time foobar.log is
J> written I actually end up with a file that has date and time added to it.
J> In other words:
J> I run application that writes to "foobar.log" and I want the file actually
J> go to "~/foobarlogs/foobarYYYY-MM-DD-HH-MM-SS.log" instead.
J> I know I did something similar years ago with perl but my
J> programming/scripting skills are too rusty to accomplish it anymore on my
J> own. I would greatly appreciate the help.
You may want to just use the `logrotate' utility as part of your
application's startup. Much easier than symlinks and custom code.
Ted
------------------------------
Date: Thu, 18 Feb 2010 09:32:43 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: saving old versions of file
Message-Id: <artqn5hggouqhtd8jac47dajin3r93tddn@4ax.com>
Frank Seitz <devnull4711@web.de> wrote:
>Jürgen Exner wrote:
>> Jarmo <jampe@darkbusstop.com> wrote:
>>> I have a problem and I was hoping someone could help me. I have a program
>>> that every time it runs it saves a log file with same name about the changes
>>> it did on that particular run. Result is that old file gets overwritten and
>>> lost.[...]
>> Not a Perl solution but what about running a cron job at midnight which
>> does a
>> ln -s foobar.log foobar[whateverthenewdayis]
>
>A symlink is obviously not a solution, because the file
>gets overwritten with every run.
You are right, I misread the original question.
If the application is really this misbehaved, then the OP has a whole
slew of other problems, too, e.g. what happens if two instances of the
application are running concurrently? Will they both write into the same
log file, stepping on each other's feet and destroying whatever the
other instance just wrote?
I would strongly suggest to fix the application. Even embedding the call
into a wrapper script which renames the log file immediately as
suggested by others won't fix all problems.
jue
------------------------------
Date: Thu, 18 Feb 2010 13:48:30 -0600
From: "Kyle T. Jones" <KBfoMe@realdomain.net>
Subject: Re: Substitution with parameters and variable don't work s/$search/$replace/i
Message-Id: <hlk5ig$b1b$1@news.eternal-september.org>
Joan Interactive Bussiness wrote:
> Very easy sample:
>
> # line to translate
> $line = 'var varchar2(10)';
>
> # I hope to answer: var number(10)
>
> # With replace Variable, not OK
> $find = 'varchar2\((.+)\)';
> $replace = 'number($1)';
>
You're using single quotes '' instead of double quotes "" so the
variable ($1) isn't being interpolated. If you're using variables or
special characters (like \n) you need to use double-quotes.
my $name="Joe";
print "$name is a genius.\n";
print "He loves perl.\n";
Output:
Joe is a genuis.
He loves perl.
my $name='Joe';
print '$name is a genius.\n';
print 'He loves perl.\n';
Output:
$name is a genius.\nHe loves perl.\n
Cheers.
------------------------------
Date: Thu, 18 Feb 2010 14:55:35 -0600
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Substitution with parameters and variable don't work s/$search/$replace/i
Message-Id: <slrnhnra3a.sqd.tadmc@tadbox.sbcglobal.net>
Kyle T. Jones <KBfoMe@realdomain.net> wrote:
> Joan Interactive Bussiness wrote:
>> Very easy sample:
>>
>> # line to translate
>> $line = 'var varchar2(10)';
>>
>> # I hope to answer: var number(10)
>>
>> # With replace Variable, not OK
>> $find = 'varchar2\((.+)\)';
>> $replace = 'number($1)';
>>
>
> You're using single quotes '' instead of double quotes "" so the
> variable ($1) isn't being interpolated.
Which is perfect for the OP's situation.
Not much point in trying to interpolate $1 when it has not even
been set yet...
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
------------------------------
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 2824
***************************************