[28358] in Perl-Users-Digest
Perl-Users Digest, Issue: 9722 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 13 18:05:57 2006
Date: Wed, 13 Sep 2006 15:05:07 -0700 (PDT)
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, 13 Sep 2006 Volume: 10 Number: 9722
Today's topics:
Re: Boolean Regexp with perlre <nobull67@gmail.com>
Re: Boolean Regexp with perlre <1usa@llenroc.ude.invalid>
Re: Boolean Regexp with perlre <someone@example.com>
Re: Boolean Regexp with perlre <jl_post@hotmail.com>
Re: comparing modification times of files <nobull67@gmail.com>
Re: How to make only one thread sleep? <someone@example.com>
Re: How to put a single thread to sleep? <ralmoritz@gmail.com>
Re: How to put a single thread to sleep? <1usa@llenroc.ude.invalid>
Re: How to put a single thread to sleep? <syscjm@gwu.edu>
Re: Inserting into a database <nobull67@gmail.com>
Re: Inserting into a database <glennj@ncf.ca>
Re: Integrate Compress::Zlib seamlessly w/no compressio <1usa@llenroc.ude.invalid>
Re: Maximum number of sockets <angusma@attglobal.net>
Re: NTLM and LWP::UserAgent <mumebuhi@gmail.com>
Re: NTLM and LWP::UserAgent <mumebuhi@gmail.com>
Re: print cyriilic (UTF-8) characters with PERL on HTML <hjp-usenet2@hjp.at>
Re: Search and replace problem <tzz@lifelogs.com>
Re: String buffer instead of file handle? <danparker276@yahoo.com>
Re: String buffer instead of file handle? xhoster@gmail.com
Re: String buffer instead of file handle? xhoster@gmail.com
Re: String buffer instead of file handle? <nobull67@gmail.com>
Re: String buffer instead of file handle? <danparker276@yahoo.com>
Re: String buffer instead of file handle? <tadmc@augustmail.com>
Taint and memory usage xhoster@gmail.com
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 13 Sep 2006 11:07:39 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: Boolean Regexp with perlre
Message-Id: <1158170859.352829.62210@e63g2000cwd.googlegroups.com>
Kevin Crosbie wrote:
> I'm not sure if this is appropriate for this group, it's related to
> perlre rather than perl, if so, apologies and I'd appreciate a pointer
> to the right group.
I do not know how much of Perl REs are implemented by perlre so the
solutions I offer may not apply.
> I'm trying to find out if this is possible before I embark upon
> implementing a solution to my problem.
>
> I have a string with comma separated tags:
> "a, b, c, d, e, f"
>
> It's rather easy to write something to express a boolean OR:
> a OR b OR c = (^|,(\s)+)(a|b|c)
> What I would like to know is if there is a way to express AND or NOT:
> 1. (a OR b) AND c
/^(?=.*(^|,(\s)+)(c|d)(,|$)).*(^|,(\s)+)(a|b)(,|$)/
Note: if you want to trade efficiency for readbility you can make all
the capturing (...) into non-captureing (?:...)
Note: I've assumed your data contains no characters that don't match
the period regex.
> 3. (a OR b) AND NOT (c OR d)
/^(?!.*(^|,(\s)+)(c|d)).*(^|,(\s)+)(a|b)(,|$)/
> I imagine there is no nice way to do this without doing something like
> writing out your AND clause before and after whatever OR clause you are
> using, which would become really messy for more complicated expressions,
> but perhaps someone knows of some way to do this.
But REs are really the wrong tool for the job. If this were a real
Perl question I'd say change your API to take a CODE ref rather than a
regex.
------------------------------
Date: Wed, 13 Sep 2006 18:13:23 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Boolean Regexp with perlre
Message-Id: <Xns983D90B46BFC6asu1cornelledu@127.0.0.1>
Kevin Crosbie <caoimhinocrosbai_at@yahoo.com> wrote in news:45083f01$0
$19201$88260bb3@news.teranews.com:
> I'm not sure if this is appropriate for this group, it's related to
> perlre rather than perl,
It all depends on what you mean perlre. If you referring to regular
expressions as implemented in Perl, then it is the right group. However,
if somehow you are referring to some library that implements a regular
expression facility similar to Perl's, it is probably not.
> if so, apologies and I'd appreciate a pointer
> to the right group.
Don't know (see above).
> I'm trying to find out if this is possible before I embark upon
> implementing a solution to my problem.
>
> I have a string with comma separated tags:
> "a, b, c, d, e, f"
>
> It's rather easy to write something to express a boolean OR:
> a OR b OR c = (^|,(\s)+)(a|b|c)[,$]
Wait a second. That is not a valid expression!
#!/usr/bin/perl
use strict;
use warnings;
my $s = 'a,b,c';
if ($s =~ /(^|,(\s)+)(a|b|c)[,$]/) {
print "matched\n";
}
D:\UseNet\clpmisc> t66
Unmatched [ in regex; marked by <-- HERE in m/(^|,(\s)+)(a|b|c)[ <--
HERE ,5.008008/ at D:\UseNet\clpmisc\t66.pl line 8.
> What I would like to know is if there is a way to express AND or NOT:
> 1. (a OR b) AND c
> 2. (a OR b) AND NOT c
> 3. (a OR b) AND NOT (c OR d)
It is more efficient to write
if ( /a/ or /b/ or /c/ ) { ... }
than to write
if ( /a|b|c/ ) { ... }
> I imagine there is no nice way to do this without doing something like
> writing out your AND clause before and after whatever OR clause you
> are using, which would become really messy for more complicated
> expressions,
I am sure there is way of writing a really complicated, hard-to-read,
and inefficient regex one can write to do what you want, but it is not
worth the effort.
There is a reason Perl has logical operators.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Wed, 13 Sep 2006 18:30:12 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Boolean Regexp with perlre
Message-Id: <U6YNg.9539$Lb5.3061@edtnps89>
Kevin Crosbie wrote:
>
> I'm not sure if this is appropriate for this group, it's related to
> perlre rather than perl, if so, apologies and I'd appreciate a pointer
> to the right group.
>
> I'm trying to find out if this is possible before I embark upon
> implementing a solution to my problem.
>
> I have a string with comma separated tags:
> "a, b, c, d, e, f"
>
> It's rather easy to write something to express a boolean OR:
> a OR b OR c = (^|,(\s)+)(a|b|c)[,$]
>
> What I would like to know is if there is a way to express AND or NOT:
> 1. (a OR b) AND c
/a|b/ && /c/
> 2. (a OR b) AND NOT c
/a|b/ && !/c/
> 3. (a OR b) AND NOT (c OR d)
/a|b/ && !/c|d/
John
--
use Perl;
program
fulfillment
------------------------------
Date: 13 Sep 2006 11:43:21 -0700
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Re: Boolean Regexp with perlre
Message-Id: <1158173001.865579.111720@b28g2000cwb.googlegroups.com>
Kevin Crosbie wrote:
> I have a string with comma separated tags:
> "a, b, c, d, e, f"
>
> It's rather easy to write something to express a boolean OR:
> a OR b OR c = (^|,(\s)+)(a|b|c)[,$]
Um, I don't think the "[,$]" is doing what you think it should be
doing (in fact, I don't think that'll even compile). What you should
use in its place is "(,|$)".
> What I would like to know is if there is a way to express AND or NOT:
> 1. (a OR b) AND c
> 2. (a OR b) AND NOT c
> 3. (a OR b) AND NOT (c OR d)
>
> I imagine there is no nice way to do this without doing something like
> writing out your AND clause before and after whatever OR clause you are
> using, which would become really messy for more complicated expressions,
> but perhaps someone knows of some way to do this.
As far as I know, writing out your AND clause before and after
whatever OR clause you are using will be the simplest and most readable
solution. However, you can do what you want using more complicated
expressions, taking advantage of Perl's extended regular expressions.
(You can read "perldoc perlre" to find out more about them.)
Let me warn you, though, they can be rather "messy." For this
reason, instead of searching for commas (or the beginning/end of the
string) like you have, I'll just leave those out, as if all the
elements were one character long. This won't always be the case, of
course, but I figure that you'll be able to add the delimeter detection
in yourself later, but for now, I won't put it in for simplicity's
sake.
> 1. (a OR b) AND c
For this one, you basically want to search use (a|b), but you also
want to look for c, which may come before or after (a|b). So you can
use this regular expression:
m/(a|b).*c|c.*(a|b)/
> 2. (a OR b) AND NOT c
This one is trickier, because in order to verify that there is no
'c', you must search the entire line. If 'c' were just one character
long, we could get away with using the [^c] character class, like this:
m/^[^c]*(a|b)[^c]*$/
This searches for 'a' or 'b', but makes sure that ALL the characters
before AND after are NOT 'c'.
However, it's likely that your 'c' term won't be one character long.
In that case, you'll probably want to use a "negative look-ahead"
assertion (again, look it up in "perldoc perlre" if you want to read
details about it -- this is one of extended regular expressions I
mentioned earlier). That way we would have:
m/^((?!c).)*(a|b)((?!c).)*$/
This pattern is essentially the same as the previous one, except
instead of having "[^c]" (which assumes that 'c' is one character
long), we have "((?!c).)". What this pattern matches is any character
provided that 'c' is not immediately found at that spot.
To clarify, if 'c' was actually the string "car", you would write
the term as "((?!car).)". Notice that you still use one '.' even
though "car" is three letters long. That's because the '.' only
matches one character, but with the (?!car) in front of it it'll only
match if that character is not a 'c' that is followed by an 'a' and an
'r'.
(If you put three '.' instead of just one, then the "((?!car)...)*"
expression would match multiples of three characters, which is not what
you want.)
Of course, just as a '*' follows "[^c]", one should also follow
"((?!c).)" because you are necessarily searching through more than one
character (we'll assume that there is more than one character that
comes before and after "(a|b)").
> 3. (a OR b) AND NOT (c OR d)
This one is pretty much the same as the previous example, except
that instead of using "(?!c)" you'll replace it with "(?!c|d)", like
this:
m/^((?!c|d).)*(a|b)((?!c|d).)*$/
That's pretty much it. Are the expressions messy? Most people
would say yes, so you might want to seriously consider breaking out
each of the above regular expressions into more than one, if only for
readability's sake.
Another tip: Whenever you use a complicated regular expression,
consider putting a comment right above it that clearly states what it's
searching for. For example, you might write your code to look like:
# Look for (a OR b) AND NOT (c OR d):
if ($string =~ m/^((?!c|d).)*(a|b)((?!c|d).)*$/)
This will make your code easier to understand and to debug. Without
the comment, any maintainer that comes after you will have a puzzle to
solve in order to figure out what you really meant. And if for some
reason you (or a future maintainer) introduced a bug in your regular
expression, the comment can serve as a guide to determine whether or
not a bug actually exists in the regular expression (otherwise, it
would be difficult to know for sure).
I hope this helps, Kevin.
-- Jean-Luc
------------------------------
Date: 13 Sep 2006 11:13:45 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: comparing modification times of files
Message-Id: <1158171225.717039.234080@m73g2000cwd.googlegroups.com>
Nomen Nescio wrote:
> Is this the right way to compare file timestamps?
>
> if (-M $file >= -M $otherFile) {
> # $file is not newer than $otherFile
> }
>
> And I sometimes get *modified* and *changed* mixed up...contents get
> modified, permissions get changed, right?
Yes, that's not the whole story but its a fair mnemonic. At least on
POSIX-like OSs.
On other OSs the meaning of changed changes but iut is generally safe
to assume that the "modified" time is the primary timestamp that you'd
have on a filesystem that only had one.
------------------------------
Date: Wed, 13 Sep 2006 18:06:45 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: How to make only one thread sleep?
Message-Id: <VMXNg.9536$Lb5.4824@edtnps89>
Ralph Moritz wrote:
> I wrote:
>
>>My program is included below in it's entirety.
>
> Sorry, I forgot to include the program :-] Here it is:
use warnings;
> use strict;
> use threads;
> use threads::shared;
> use Thread::Semaphore;
> use Thread::Queue;
> use File::Copy;
> use Digest::MD5 qw(md5);
>
> # ------ Fallback config values ------------------
>
> # Path to application root directory
> our $root_dir = '/home/ralph/Sources/QMSv2';
>
> # Directory containing inbound files
> our $data_dir = "$root_dir/inbound";
>
> # Directory to put processed files
> our $result_dir = "$root_dir/processed";
>
> # Directory to put files containing errors
> our $error_dir = "$root_dir/errors";
>
> # Path to the log file
> our $logfile = "$root_dir/logs/monit.log";
>
> # Frequency to scan inbound directory (in seconds)
> our $scan_interval = 60;
>
> # File extensions to match against
> our $file_ext = qr/.txt$/;
our $file_ext = qr/\.txt$/;
The . will match any character, you need to escape it.
> # Maximum number of worker threads to create
> our $max_workers = 10;
>
> # -----------------------------------------------
>
> # HACK: hard-code path to config file
> my $config_file = '/home/ralph/Sources/QMSv2/config.pl';
> read_config($config_file);
>
> my $io_sem = Thread::Semaphore->new; # I/O semaphore
> my $th_sem = Thread::Semaphore->new($max_workers); # Thread semaphore
> my $queue = Thread::Queue->new; # Data queue
> my %files :shared;
>
> monitor_loop($data_dir);
>
> sub monitor_loop {
> log_msg('Entering monitor loop');
> my $factory = threads->create(\&factory_loop);
> $factory->detach;
>
> while (1) {
> log_msg('Woke up. Scanning for files...');
>
> opendir(my $indir, $data_dir) or
> log_msg("Error: failed to open directory $data_dir: $!")
> && exit 1;
> my @flist = grep { $_ = "$data_dir/$_" if /$file_ext/ }
> readdir($indir);
You probably want either:
my @flist = map /$file_ext/ ? "$data_dir/$_" : (), readdir($indir);
Or:
my @flist = map "$data_dir/$_", grep /$file_ext/, readdir($indir);
$_ is an alias to the current list element just like it is in for/foreach so
modifying $_ also propagates the changes back to the original list/array.
John
--
use Perl;
program
fulfillment
------------------------------
Date: 13 Sep 2006 11:18:02 -0700
From: "Ralph Moritz" <ralmoritz@gmail.com>
Subject: Re: How to put a single thread to sleep?
Message-Id: <1158171482.417964.61970@p79g2000cwp.googlegroups.com>
A. Sinan Unur wrote:
> "Ralph Moritz" <ralmoritz@gmail.com> wrote in
> news:1158155050.341951.191020@p79g2000cwp.googlegroups.com:
> > Q: How can I put just the current thread to sleep?
>
> You know, posting the same nitwit question in multiple threads is not a
> good way of eliciting help.
You're right, it was a mistake. Sorry.
> Don't thank me if you do not appreciate my help.
I do appreciate your help, it's just that I was (mistakenly)
convinced that sleep() was putting all threads in the process
to sleep. The actual problem was something else, of course.
> I see, you still haven't learned how to use a sig separator.
This is a bit anal, don't you think? My newsreader usually
inserts the sig seperator for me, but when I'm using Google,
Groups I sometimes forget to add the space. I don't think
it's something worth making a fuss about though.
--
Ralph Moritz
Ph: +27 84 626 9070
GPG Public Key: http://ralphm.info/me@ralphm.info.gpg
------------------------------
Date: Wed, 13 Sep 2006 18:24:46 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: How to put a single thread to sleep?
Message-Id: <Xns983D92A2876EBasu1cornelledu@127.0.0.1>
"Ralph Moritz" <ralmoritz@gmail.com> wrote in
news:1158171482.417964.61970@p79g2000cwp.googlegroups.com:
> A. Sinan Unur wrote:
>> "Ralph Moritz" <ralmoritz@gmail.com> wrote in
>> news:1158155050.341951.191020@p79g2000cwp.googlegroups.com:
>
>> > Q: How can I put just the current thread to sleep?
>>
>> You know, posting the same nitwit question in multiple threads is not
>> a good way of eliciting help.
>
> You're right, it was a mistake. Sorry.
Apology accepted.
>> Don't thank me if you do not appreciate my help.
>
> I do appreciate your help, it's just that I was (mistakenly)
> convinced that sleep() was putting all threads in the process
> to sleep. The actual problem was something else, of course.
Yes, and the first skeletal script I posted showed that. You did not
like my answer so you decided to start a new thread. Now that you seem
to have solution, it is considered common courtesy to share that
solution.
>> I see, you still haven't learned how to use a sig separator.
>
> This is a bit anal, don't you think?
No.
> My newsreader usually inserts the sig seperator for me,
My newsreader usually snips sigs for me. You are asking me to expend
time and energy manually doing something that could be done
automatically.
> but when I'm using Google, Groups I sometimes forget to add the space.
AFAIK, you can set GG to aumatically insert a properly formatted sig.
You are not willing to spend the time to do that. This is consistent
with your overall behavior.
> I don't think
> it's something worth making a fuss about though.
>
> --
> Ralph Moritz
Then why did you omit the space on purpose this time?
*PLONK*
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Wed, 13 Sep 2006 15:25:11 -0400
From: Chris Mattern <syscjm@gwu.edu>
Subject: Re: How to put a single thread to sleep?
Message-Id: <12ggmoqcrcqq325@corp.supernews.com>
Ralph Moritz wrote:
>
> This is a bit anal, don't you think? My newsreader usually
> inserts the sig seperator for me, but when I'm using Google,
> Groups I sometimes forget to add the space. I don't think
> it's something worth making a fuss about though.
>
It is an inconvenience; my mail reader (and many, many other
mail readers) recognize the sig standard and use it to make
your life easier. When I reply to a message with a properly
done sig, the reader automatically does not include the sig
in the quoted text. I had to delete it manually from yours
while replying to this post.
--
Christopher Mattern
"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
------------------------------
Date: 13 Sep 2006 11:39:47 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: Inserting into a database
Message-Id: <1158172787.259549.205380@p79g2000cwp.googlegroups.com>
MattJ83 wrote:
> Subject: Inserting into a database
> Current code (not working code because i think you need to have a
> database to understand the problem - and im not sure how placing
> working code (without database) would help!:
I think you have a serious problem parititioning problem. I strongly
doubt your problem has anything whatever to do with inserting to a
database. If you replaced the line of code that inserts the results of
your parsing operation into the database with a simple print statement
then your parser would still (miss-)behave exactly the same.
Also you code is erratically indented. This makes it very hard to
follow. I had to import it into an editor and hit auto-indent before I
stood a chance.
Please try it. If I'm right then please produce a mimimal but complete
(cleanly indented) program that doesn't need a database and post it
here with sample input.
------------------------------
Date: 13 Sep 2006 19:17:50 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: Inserting into a database
Message-Id: <slrneggmau.909.glennj@smeagol.ncf.ca>
At 2006-09-13 11:05AM, "MattJ83" wrote:
> my @filenames = </home/username/logs/*.log>;
> foreach my $filename (@filenames)
> {
[...]
> my $dbh = DBI ->connect("dbi:Oracle:server", "database", "password")
> or die "couldn't connect to database: $DBI::errstr\n";
>
> $dbh->do("INSERT INTO TEST2 (sfd, w, sdf, hfg, rt, bv, te)
> VALUES (?, ?, ?, ?, ?, ?, ?)", undef,
> $filename, $info, $elapsed1, $fast, $elapsed2, $inversions,
> $elapsed3);
>
> }
Why are you opening the db connection for each file? You should open it
once, prepare your sql statement, and then for each file execute the
statement with the values to insert.
--
Glenn Jackman
Ulterior Designer
------------------------------
Date: Wed, 13 Sep 2006 19:04:31 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Integrate Compress::Zlib seamlessly w/no compression?
Message-Id: <Xns983D995E17FF9asu1cornelledu@127.0.0.1>
peter.j.torelli@gmail.com wrote in
news:1158168042.654081.99040@e63g2000cwd.googlegroups.com:
[ Please do not top-post ]
> Paul Marquess wrote:
>> IO::Zlib or PerlIO::gzip are the best approaches to use at the
>> moment.
>>
>> if (want compressed file) {
>> $fh = IO::Zlib->new($filename, "wb9");
>> }
>> else {
>> $fh = open ">$filename";
>> }
...
> I really like your solution, it is very clean and fits with my style.
> Thank you.
>
> The idea of writing another abstraction layer to handle this simple
> case (IMHO) is preposterous
Hmmm ...
#!/usr/bin/perl
package My::Open;
use strict;
use warnings;
sub open {
my ($fn, $mode, $compress) = @_;
if ( $compress ) {
require IO::Zlib;
return IO::Zlib->new($fn, $mode) if $compress;
}
else {
open my ($fh), $mode, $fn;
return $fh;
}
}
package main;
my $fh1 = My::Open::open('test1.gz', 'wb', 1)
or die $!;
print $fh1 "This is a test\n" or die $!;
close $fh1 or die $!;
my $fh2 = My::Open::open('test2.txt', '>')
or die $!;
print $fh2 "This is a test\n" or die $!;
close $fh2 or die $!;
__END__
It all depends on how many times you need to write that conditional, or
if other programs could use such functionality.
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Wed, 13 Sep 2006 16:43:11 -0400
From: "A Ma" <angusma@attglobal.net>
Subject: Re: Maximum number of sockets
Message-Id: <45086d63@kcnews01>
"Sisyphus" <sisyphus1@nomail.afraid.org> wrote in message
news:4507bf76$0$11968$afc38c87@news.optusnet.com.au...
>
> "A Ma" <angusma@attglobal.net> wrote in message
> .
> .
>>
>> I suspect I have to recompile Perl but I am using ActiveState Perl and I
>> don't have the source. So I am not sure how I can do that. Any further
>> suggestions would be helpful.
>>
>
> You can get the source, too, from ActiveState ... or you can get the
> source
> from www.perl.org.
>
> Perl-5.8.8 builds easily from source on Win32 using the freely available
> MinGW (gcc) compiler - just read the instructions in the Readme.win32
> that's
> in the top level folder of the perl source.
>
> Looks like the source file you'll need to amend is
> win32\include\sys\socket.h.
>
> Cheers,
> Rob
>
Thanks for the suggestion. I downloaded the source from ActiveState
(AP819-source), MinGW (5.0.2) and dmake (4.5). I followed the instructions
in Readme.win32, ran dmake and got the following error.
In file included from perllib.c:43:
perlhost.h: In function `CPerlHost* IPerlMem2Host(IPerlMem*)':
perlhost.h:239: warning: invalid access to non-static data member
`CPerlHost::m_
hostperlMem' of NULL object
perlhost.h:239: warning: (perhaps the `offsetof' macro was used incorrectly)
perlhost.h: In function `CPerlHost* IPerlMemShared2Host(IPerlMem*)':
perlhost.h:244: warning: invalid access to non-static data member
`CPerlHost::m_
hostperlMemShared' of NULL object
perlhost.h:244: warning: (perhaps the `offsetof' macro was used incorrectly)
perlhost.h: In function `CPerlHost* IPerlMemParse2Host(IPerlMem*)':
perlhost.h:249: warning: invalid access to non-static data member
`CPerlHost::m_
hostperlMemParse' of NULL object
perlhost.h:249: warning: (perhaps the `offsetof' macro was used incorrectly)
perlhost.h: In function `CPerlHost* IPerlEnv2Host(IPerlEnv*)':
perlhost.h:254: warning: invalid access to non-static data member
`CPerlHost::m_
hostperlEnv' of NULL object
perlhost.h:254: warning: (perhaps the `offsetof' macro was used incorrectly)
perlhost.h: In function `CPerlHost* IPerlStdIO2Host(IPerlStdIO*)':
perlhost.h:259: warning: invalid access to non-static data member
`CPerlHost::m_
hostperlStdIO' of NULL object
perlhost.h:259: warning: (perhaps the `offsetof' macro was used incorrectly)
perlhost.h: In function `CPerlHost* IPerlLIO2Host(IPerlLIO*)':
perlhost.h:264: warning: invalid access to non-static data member
`CPerlHost::m_
hostperlLIO' of NULL object
perlhost.h:264: warning: (perhaps the `offsetof' macro was used incorrectly)
perlhost.h: In function `CPerlHost* IPerlDir2Host(IPerlDir*)':
perlhost.h:269: warning: invalid access to non-static data member
`CPerlHost::m_
hostperlDir' of NULL object
perlhost.h:269: warning: (perhaps the `offsetof' macro was used incorrectly)
perlhost.h: In function `CPerlHost* IPerlSock2Host(IPerlSock*)':
perlhost.h:274: warning: invalid access to non-static data member
`CPerlHost::m_
hostperlSock' of NULL object
perlhost.h:274: warning: (perhaps the `offsetof' macro was used incorrectly)
perlhost.h: In function `CPerlHost* IPerlProc2Host(IPerlProc*)':
perlhost.h:279: warning: invalid access to non-static data member
`CPerlHost::m_
hostperlProc' of NULL object
perlhost.h:279: warning: (perhaps the `offsetof' macro was used incorrectly)
perlhost.h: In function `int PerlProcFork(IPerlProc*)':
perlhost.h:1838: error: invalid conversion from `void*' to `HWND__*'
dmake: Error code 129, while making 'perllib.o'
Any ideas?
------------------------------
Date: 13 Sep 2006 11:07:47 -0700
From: "mumebuhi" <mumebuhi@gmail.com>
Subject: Re: NTLM and LWP::UserAgent
Message-Id: <1158170867.859399.226020@e3g2000cwe.googlegroups.com>
I am sure that the netloc argument is right.
my $ua = LWP::UserAgent->new(keep_alive => 1);
$ua->credentials('172.26.1.2:8080', '', 'username', 'password'); #
unsanitized version
I even tried (notice the single/double quotes and the domain name):
$ua->credentials('172.26.1.2:8080', '', "domain_name\\username",
'password');
$ua->credentials('172.26.1.2:8080', '', 'domain_name\username',
'password');
By the way, when do we need to specify a domain name?
Buhi
Aaron Sherman wrote:
> mumebuhi wrote:
> > I am having problems accessing any sites outside my organization using
> > LWP::UserAgent. My organization is using NTLM authentication.
>
> It looks like you get redirected by some internal system to an
> authentication page and then authentication fails. Check your
> credentials. Are you SURE the netloc field is right. You give a sample
> (which is clearly bogus, but you might have sanitized it for security
> reasons) of "host:8080". Did you verify with the people maintaining the
> outgoing proxy that the netloc you are using is correct?
>
> If the word "netloc" isn't familiar, start with "perldoc
> LWP::UserAgent" and search for "cred".
------------------------------
Date: 13 Sep 2006 13:20:08 -0700
From: "mumebuhi" <mumebuhi@gmail.com>
Subject: Re: NTLM and LWP::UserAgent
Message-Id: <1158178808.838616.326040@i3g2000cwc.googlegroups.com>
OK, I finally found the solution:
$ua->proxy(['http'] => 'http://username:password@172.26.1.2:8080');
Unfortunately, this is not explained in the LWP::UserAgent
documentation. I hope this might help others.
Thank you.
Buhi
------------------------------
Date: Wed, 13 Sep 2006 21:43:29 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: print cyriilic (UTF-8) characters with PERL on HTML page
Message-Id: <slrneggnr1.6v7.hjp-usenet2@yoyo.hjp.at>
On 2006-09-13 08:59, andipfaff <andreas.pfaff@swissonline.ch> wrote:
> beginners question: I have written a small website with a PERL script
The language is called "Perl", not "PERL".
> which can be viewed in 4 western european languages. Each text to be
> displayed is stored in arrays like
> $text1[1] = qq(Hallo);
> $text1[2] = qq(Salut);
> $text1[3] = qq(Saluti);
> $text1[4] = qq(Hello);
> and printed to STDOUT. Now I want to extend this with cyrillic
> characters (5th language: russian). Unfortunately I have no idea how to
> do that. I simply tried to cut&paste cyrillic letters from websites
> like wikipedia cyrillic aplphabet, but in my Editor (DZSoft) I just get
> a question mark when pasting. In Notepad pasting is OK, because he is
> capable of UTF-8.
So what's your problem? (Well, being forced to use notepad may count as
a problem, but it should be good enough for a short test script)
> What are the minimum requirements to print a cyrillic character with
> PERL into a website?
I don't think I understand the question.
> The PERL script is using CGI, but HTML code is written directly:
> print qq(Content-type: text/html\n\n
You need to declare the charset in the content-type:
print qq(Content-type: text/html; charset=utf-8\n\n
or you need to convert all non-latin-1 characters to entities.
> Does anybody can give me a simple script which I can test with Notepad
> as en editor?
#!/usr/bin/perl
use utf8;
use warnings;
use strict;
my $txt = "экранопла́н";
binmode STDOUT, ":utf8";
print "Content-Type: text/html; charset=utf-8\n";
print "\n";
print "<p>$txt</p>\n";
hp
--
_ | Peter J. Holzer | > Wieso sollte man etwas erfinden was nicht
|_|_) | Sysadmin WSR | > ist?
| | | hjp@hjp.at | Was sonst wäre der Sinn des Erfindens?
__/ | http://www.hjp.at/ | -- P. Einstein u. V. Gringmuth in desd
------------------------------
Date: Wed, 13 Sep 2006 15:49:50 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Search and replace problem
Message-Id: <g69ejufwnq9.fsf@CN1374059D0130.kendall.corp.akamai.com>
On 13 Sep 2006, nobull67@gmail.com wrote:
> You are not the first person to post here with substancially the same
> desire.
>
> Indeed at YAPC::Europe::2004 I gave a lightning talk about all the
> different varients of this thread that I'd come accross over the
> preceding couple of years.
So it's a QASFTBMGALTAI*
You could have just said "QASFTBMGALTAI" and everyone would know what
you meant. Geez, stop wasting bandwidth.
Ted
* Question Asked So Frequently That Brian McCauley Gave A Lightning
Talk About It
------------------------------
Date: 13 Sep 2006 11:10:10 -0700
From: "danparker276@yahoo.com" <danparker276@yahoo.com>
Subject: Re: String buffer instead of file handle?
Message-Id: <1158171010.654691.221150@b28g2000cwb.googlegroups.com>
Paul Lalli wrote:
> danparker276@yahoo.com wrote:
> > I have to connect to this module, and I usually send it a file handle,
> > or stdout. But I want to write it to a string. Is there a string
> > buffer or something I can use?
>
> Yes.
>
> > open (FILEO, ">test.txt");
> > $xw = MP3Com::XMLWriter->new (\*FILEO);
> >
> > or
> > $xw = MP3Com::XMLWriter->new (\*STDOUT);
> >
> > I want to do:
> > my $xmlstring
> > $xw = MP3Com::XMLWriter->new ($xmlstring);
>
> Check the documentation for the function you're using. In this case,
> that's open:
> perldoc -f open
> [snip]
> File handles can be opened to "in memory" files held
> in Perl scalars via:
>
> open($fh, '>', \$variable) || ..
This just opens a file called SCALAR(0x8a09e30)
> [snip]
>
> Paul Lalli
------------------------------
Date: 13 Sep 2006 18:31:25 GMT
From: xhoster@gmail.com
Subject: Re: String buffer instead of file handle?
Message-Id: <20060913143220.150$HD@newsreader.com>
"danparker276@yahoo.com" <danparker276@yahoo.com> wrote:
> I have to connect to this module, and I usually send it a file handle,
> or stdout. But I want to write it to a string. Is there a string
> buffer or something I can use?
I think this should do what you want, from perldoc -f open:
Since v5.8.0, perl has built using PerlIO by
default. Unless you've changed this (ie Configure
-Uuseperlio), you can open file handles to "in
memory" files held in Perl scalars via:
open($fh, '>', \$variable) || ..
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 13 Sep 2006 18:41:13 GMT
From: xhoster@gmail.com
Subject: Re: String buffer instead of file handle?
Message-Id: <20060913144208.058$vV@newsreader.com>
"danparker276@yahoo.com" <danparker276@yahoo.com> wrote:
> >
> > Check the documentation for the function you're using. In this case,
> > that's open:
> > perldoc -f open
> > [snip]
> > File handles can be opened to "in memory" files held
> > in Perl scalars via:
> >
> > open($fh, '>', \$variable) || ..
>
> This just opens a file called SCALAR(0x8a09e30)
what does perl -V give?
If your Perl is too old to support this, see IO::Scalar
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 13 Sep 2006 11:48:26 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: String buffer instead of file handle?
Message-Id: <1158173306.330141.172120@e3g2000cwe.googlegroups.com>
danparker276@yahoo.com wrote:
> Paul Lalli wrote:
> > Check the documentation for the function you're using. In this case,
> > that's open:
> > perldoc -f open
We really mean this!
> > [snip]
> > File handles can be opened to "in memory" files held
> > in Perl scalars via:
> >
> > open($fh, '>', \$variable) || ..
>
> This just opens a file called SCALAR(0x8a09e30)
Did you check the documentation for the function you're using? Note:
the function you are using is open() in the version of Perl that you
are using. This is evidently not as recent as the one Paul is using and
the feature you are looking for only became built-in [1] very recently.
[1] Actually it's not completely built-in, behind the curtain open()
actually loads a module IIRC. But please ignore the man behind the
curtain. :-)
------------------------------
Date: 13 Sep 2006 14:41:01 -0700
From: "danparker276@yahoo.com" <danparker276@yahoo.com>
Subject: Re: String buffer instead of file handle?
Message-Id: <1158183660.917292.298260@m73g2000cwd.googlegroups.com>
Brian McCauley wrote:
> danparker276@yahoo.com wrote:
> > Paul Lalli wrote:
> > > Check the documentation for the function you're using. In this case,
> > > that's open:
> > > perldoc -f open
>
> We really mean this!
>
> > > [snip]
> > > File handles can be opened to "in memory" files held
> > > in Perl scalars via:
> > >
> > > open($fh, '>', \$variable) || ..
> >
> > This just opens a file called SCALAR(0x8a09e30)
>
> Did you check the documentation for the function you're using? Note:
> the function you are using is open() in the version of Perl that you
> are using. This is evidently not as recent as the one Paul is using and
> the feature you are looking for only became built-in [1] very recently.
>
Yeah, the version on the machine is old, 5.6. I read the docs and
couldn't find anything. I'm more of a .net or java person. This code
just needs to be supported for the next year until it is replaced.
> [1] Actually it's not completely built-in, behind the curtain open()
> actually loads a module IIRC. But please ignore the man behind the
> curtain. :-)
------------------------------
Date: Wed, 13 Sep 2006 13:31:07 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: String buffer instead of file handle?
Message-Id: <slrneggjjb.b77.tadmc@magna.augustmail.com>
danparker276@yahoo.com <danparker276@yahoo.com> wrote:
> Paul Lalli wrote:
>> danparker276@yahoo.com wrote:
>> > I have to connect to this module, and I usually send it a file handle,
>> > or stdout. But I want to write it to a string. Is there a string
>> > buffer or something I can use?
>> Check the documentation for the function you're using.
Did you do that?
(obviously not...)
>> In this case,
>> that's open:
>> perldoc -f open
>> [snip]
>> File handles can be opened to "in memory" files held
>> in Perl scalars via:
>>
>> open($fh, '>', \$variable) || ..
Did _your_ docs say what was quoted above?
If not, then the quote does not apply to the version of perl that you have.
> This just opens a file called SCALAR(0x8a09e30)
Upgrade to a modern perl.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 13 Sep 2006 21:00:06 GMT
From: xhoster@gmail.com
Subject: Taint and memory usage
Message-Id: <20060913170101.445$Zp@newsreader.com>
Taint seems to nearly double the amount of memory my program takes. I
haven't see this side effect discussed in perldoc perlsec. This is
inconvenient, as sometimes I just don't have that much memory to spare.
Does anyone know of a work around for this (or of some more detailed
discussion about why it occurs).
This is under various subversions of 5.8, both 32 and 64 bit, for Linux.
$ perl taint_mem.pl
6768
$ perl -T taint_mem.pl
11884
$ cat taint_mem.pl
use strict;
use warnings;
{
## This step is not needed to show effect. if foo already
## exists you can skip it.
open my $fh, ">foo" or die $!;
foreach (1..10000) { print $fh join (",", ("asdadssdf")x10), "\n"};
close $fh;
}
my @x;
open my $fh, "<foo" or die $!;
while (<$fh>) {
push @x, [split /,/];
};
$ENV{PATH}="/bin";
warn +(`ps -p $$ -o rss `)[1];
Thanks,
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
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 9722
***************************************