[26581] in Perl-Users-Digest
Perl-Users Digest, Issue: 8714 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 28 00:05:28 2005
Date: Sun, 27 Nov 2005 21:05: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, 27 Nov 2005 Volume: 10 Number: 8714
Today's topics:
Re: [UDP] Overide "source" addr/port ? <No_4@dsl.pipex.com>
Re: hash on private member variable robic0
Re: Hash's Regex Transformation with Map <tadmc@augustmail.com>
Re: Help: String search in Windows 2000 doesn't find t robic0
Re: Is passing by reference preferrable? <sdn.girths00869@zoemail.net>
Re: Is passing by reference preferrable? <comdog@panix.com>
log out to file using mp2 and apache2 on Fedora <tlviewer@yahoo.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 27 Nov 2005 23:55:05 +0000
From: Big and Blue <No_4@dsl.pipex.com>
Subject: Re: [UDP] Overide "source" addr/port ?
Message-Id: <6uadne8ehcjG2hfeRVnygw@pipex.net>
Stan R. wrote:
>
> Thank you. But are you sure it's not possible to write a raw packet
> yourself? I know I've seen NAT programs written in C before, that do it,
> unfortunately I don't know where to get it or what it was called.
Yes - you could (possibly) do that.
> If C could do it, why not Perl?
You could create a raw packet (with pack) and handle that. As to what
you could then do with it depends on your OS (so far unmentioned?).
Basically you want a SOCK_RAW socket. So, on Linux, look at "man 7
packet".
But it's not really a Perl issue (it's a network programming one, and
Perl happens to let you do network Programming, at least on Unices), and
(as has been mentioned elsewhere) there may be simpler ways to achieve teh
desired *outcome* by re-structuring what you do.
--
Just because I've written it doesn't mean that
either you or I have to believe it.
------------------------------
Date: Sun, 27 Nov 2005 16:56:12 -0800
From: robic0
Subject: Re: hash on private member variable
Message-Id: <l9kko1l6d2kqga3tbh4m4ouml6e9etipst@4ax.com>
On Mon, 28 Nov 2005 09:07:45 +1100, bsder <snort_sam@yahoo.com> wrote:
>
>A. Sinan Unur wrote:
>> sam <samwun@telpacific.com.au> wrote in news:4389ae12$1
>> @news.rivernet.com.au:
>>
>>
>>>I need to use hash on a private member variable.
>>>But I don't know how to make it happen. Here is the code:
>>
>>
>> 1. What does it mean to "use hash on a private member variable"?
>>
>Since this is OO style perl, its memeber variable is _map.
>I supposed use %_map thruout the entire perl code.
>eg.
>dbmopen($self->{%_map},$name,0666);
>
Yeah, it looks like you want "_map" to be the name of a hash
or reference to a hash or anonymous hash. Hard to tell.
Its not good to try to do everything in the constructor,
and in actuality things are added outsied of it.
'_map' => {}; ???
It could always be populated later ..
$self->{'_map'}->{'key1'} = $val;
There lots of ways, but you don't need to reserve the name
"_map" with undef. Do it when you do it. Somewhere along the line
it has to be initialized and populated. If you are going to pass
it to another module, it should be pre-typed and allocated as
above.
The _map var is just holding a reference, it could be to a
anonymous one or a globule private module one thats fixed/named.
%hmodule = (); #module global
$self = {'_map' => \%hmodule};
Either way the syntax is the same for passing it around.
And also it can be stored outside of the $self class this way.
>but this give me error.
>
>What is the correct syntax for that?
>
>Thanks
>Sam
>
>> 2. The code you posted does not compile.
>>
>> Please read the posting guidelines for this group to learn how you can
>> help yourself, and help others help you.
>>
>>
>>>sub new {
>>> my $class = shift;
>>> my $self = { _map => undef };
>>> bless ($self, $class);
>>> return $self;
>>>}
>>
>>
>> Are you saying you want $self->{_map} to be a reference to an anonymous
>> hash? Then, make it so:
>>
>> sub new {
>> my $class = shift;
>> my $self = { _map => { } };
>> bless ($self, $class);
>> return $self;
>> }
>>
>>
>>>sub gen_name()
>>
>>
>> Why are you using prototypes with method calls?
>>
>>
>>>{
>>> my $self = shift;
>>> localtime(time);
>>
>>
>> What do you think the line above does?
>>
>>
>>> return rand(time).".pl";
>>>}
>>
>>
>> If gen_name is invoked more than once in a second, this will return
>> identical filenames ... I have a feeling that will not be good for your
>> program. What are you trying to do?
>>
>>
>>>sub create()
>>>{
>>> my $self = shift;
>>> my ($name) = "/usr/local/code.dbm";
>>> dbmopen($self->{%_map},$name,0666);
>>> $file_name = $self->gen_name();
>>> $status = "0"; # 0 - not yet execute; 1 - had been executed.
>>> $val = join("\t",$file_name, ,$status);
>>> $map{$file_name} = $val;
>>
>>
>> ????
>>
>>
>> Sinan
------------------------------
Date: Sun, 27 Nov 2005 17:42:59 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Hash's Regex Transformation with Map
Message-Id: <slrndokh43.ohb.tadmc@magna.augustmail.com>
robic0 <> wrote:
> On 26 Nov 2005 19:13:32 GMT, Glenn Jackman <xx087@freenet.carleton.ca>
> wrote:
>
>>At 2005-11-26 08:30AM, robic0 <> wrote:
>>> Yeah but get the can't use global in "my ($k = $_)" since $_ is
>>> global and declared elsewhere (if strict).
>>
>>You want "(my $k = $_)" then.
> So the construct "my ($k = $z) =~ s/aaaa/asdf/g" would be ok then?
What happened when you tried it?
> It also seems odd that multiple single value assignments would cause
> a error also: "my $k=$z=0;" or I remember it gives me errors.
It would be a strict message, because you have not declared $z.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 27 Nov 2005 16:09:04 -0800
From: robic0
Subject: Re: Help: String search in Windows 2000 doesn't find text in Windows XP: MS Word document
Message-Id: <9fgko1h5sdafv9n3qq3gstdj29a1enq7jn@4ax.com>
On Sun, 27 Nov 2005 18:22:05 GMT, Bob Walton
<see.sig@rochester.rr.com> wrote:
>Barry Millman wrote:
>
>> Hi:
>>
>> I am using Perl 5 (I believe both machines are using ActivePERL 5)
>> on two machines with the same data files. One machine is Win 2000 the
>> other is Win XP. The files are MS Word 2000 documents e-mailed
>> (manually) from the Win 2000 machine to the XP machine.
>>
>> The program searches the MS Word Files (both created with MS Word
>> 2000) for the word HYPERLINK. The format for the HYPERLINK that I am
>> searching for in the document is:
>>
>> HYPERLINK "mydoc.doc"
> >
> > (I checked this on the XP machine in Notepad and it is OK.)
> >
>
>Note that MS Word documents are stored in a proprietary binary
>gibberish format. To assume that a given word in a document will
>actually always be stored in an ASCII string in the .doc file is
>assuming too much. For example, perhaps it is stored in Unicode?
> And maybe newer Notepad versions understand enough to present
>Unicode strings? Try looking at your files with an editor that
>you *know* won't munge the contents. I suggest VIM.
>
>It is a mystery why a document would get changed while emailing
>it from one system to another. Or did you perhaps open the
>document with Word after emailing it, and then save it? You
>don't say. Is it the same version of Word? And what email
>system are you using on each of the computers? Does the same
>thing happen if you zip the file, email the zipped version, and
>unzip it on the other system?
>
[--snip--]
Yeah, "propriatory binary" thats a phrase you don't hear much.
Comparing md5's or even checksums should resolve transmission
or open/save issues between versions/machines. Email? Maybe the AV
firewall did some elective stripping somewhere en-route.
You wasted your time on this, you should have tried to code
to discerne the "difference" between saves. In reality
thats what your are trying to do. Just because you can "see" some
discernable text sometimes doesen't mean its a text stream.
You can type out a ".exe" file too. What are the odds it reads
everything to the eof sequence? Pretty good. What are the odds
its got thousands of them in the file? Pretty good. Why?
You can't reliably code for strings in a binary stream unless
you already know the format and read the entire thing into
waiting structures. By that time your past stream processing.
Why do you think xml was invented, or yenc or uucp? Control
codes munge up stream processing. The binary file data are
sometimes control codes when read by consoles, editors and the like.
There is no solution to the OPs problem, there is none.
The approach is wrong. He made what engineers call "conceptual error".
"It worked once" is not proof of concept! Given binary structured data
files, it is absolutely, positively, impossible to treat it as
streaming text in ANY search capacity, unless controls can be
discerened from data at the search core api routines, and thats
not what it does. You can't monitor or change fast enough the api
concept of control codes. The attempt is a bridge to nowhere..
Its a good bridge but the traffic drives off the end.
>>
>> The output for a found HYPERLINK should look like this (it does on the
>> Win 2000 machine):
>>
>> mydoc.doc,(date of last update), in: otherdoc.doc
>>
>> On Win XP, the program cannot even find the word HYPERLINK (if I modify
>> the code to just search for that). The directories are valid, I can
>> have the program print a list of all files as it processes them.
>>
>> If I try this with a test program (the string to test is in the program
>> itself ) it works fine on the XP machine.
>>
>> There are no encryption issues, nor any file or directory problems.
>
>How exactly do you know this? Using a piece of garbage like
>Notepad won't definitively tell you this. I would trust Perl
>much further than Notepad.
>...
>> Barry Millman
------------------------------
Date: Sun, 27 Nov 2005 19:36:59 -0600
From: "Eric J. Roode" <sdn.girths00869@zoemail.net>
Subject: Re: Is passing by reference preferrable?
Message-Id: <Xns971BD1E48A7EFsdn.comcast@216.196.97.136>
Markus Dehmann <markus.dehmann@gmail.com> wrote in
news:3uu7ulF13a44kU1@individual.net:
> Is it preferrable to pass variables by reference, or does the perl
> interpreter optimize things so that it's not necessary?
>
> In other words, is the 2nd variant of the following two much more
> efficient?
>
> $a = "bla";
> $a = modify($a);
> print $a;
> sub modify { my $b = shift; $b =~ s/l/L/; return $b; }
>
> $a = "bla";
> modify(\$a);
> print $a;
> sub modify { my $bRef = shift; $$bRef =~ s/l/L/; }
In perl, *everything* is passed by reference.
$a = 'bla';
modify ($a);
print $a;
sub modify { $_[0] =~ s/l/L/ }
--
Eric
`$=`;$_=\%!;($_)=/(.)/;$==++$|;($.,$/,$,,$\,$",$;,$^,$#,$~,$*,$:,@%)=(
$!=~/(.)(.).(.)(.)(.)(.)..(.)(.)(.)..(.)......(.)/,$"),$=++;$.++;$.++;
$_++;$_++;($_,$\,$,)=($~.$"."$;$/$%[$?]$_$\$,$:$%[$?]",$"&$~,$#,);$,++
;$,++;$^|=$";`$_$\$,$/$:$;$~$*$%[$?]$.$~$*${#}$%[$?]$;$\$"$^$~$*.>&$=`
------------------------------
Date: Sun, 27 Nov 2005 21:11:53 -0600
From: brian d foy <comdog@panix.com>
Subject: Re: Is passing by reference preferrable?
Message-Id: <271120052111532202%comdog@panix.com>
In article <3uubk9F12r8bpU1@individual.net>, Markus Dehmann
<markus.dehmann@gmail.com> wrote:
> But then, time is rather unreliable of course, and the Benchmark module
> should be used here...
Actually, time(1) tends to be more reliable. A lot of numbers that
come out of Benchmark don't add up (literally) because there is
about a 7% error from the null-loop handling. The precision of
Benchmark.pm tends to be pretty low.
--
brian d foy, bdfoy@cpan.org
Subscribe to The Perl Review: http://www.theperlreview.com
------------------------------
Date: Mon, 28 Nov 2005 01:36:47 GMT
From: joe hacker <tlviewer@yahoo.com>
Subject: log out to file using mp2 and apache2 on Fedora
Message-Id: <pan.2005.11.28.01.38.29.714710@yahoo.com>
hello,
Fedora Core 4
Apache2
Mod_Perl 2.0.1
Perl 5.8.6
Sorry for the pitiful amount of Perl content, but someone here
will know the answer. Do I really need to do all this to log to
file in mp2/Apache2?
I have a cgi/web script that I run under the ModPerl::Registry handler. I
want to open a file handle and print info to that handle. I don't want to
use Apache's builtin abilities -- only the old fashion way.
It appears that Mod_perl scripts run under the same user as
Apache2, which is apache:apache. OK so far.
The first time I run my script, I run it in the console as root.
This creates the log file (mylog.dat) as root:root. I then do
chown apache:apache mylog.dat
chmod 0664 mylog.dat
After all that I can log normally. If I don't change the owner
of the log file, then the script dies when trying to open the log.
Is this approach optimal or necessary? I'm new to Linux.
thanks for your advice,
Mark
--
none
------------------------------
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 8714
***************************************