[29150] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 394 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 1 09:10:09 2007

Date: Tue, 1 May 2007 06:09:06 -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           Tue, 1 May 2007     Volume: 11 Number: 394

Today's topics:
    Re: a problem about function returning point <havel.zhang@gmail.com>
    Re: Cant open a file with just a relative path <nikos1337@gmail.com>
    Re: Cant open a file with just a relative path <bik.mido@tiscalinet.it>
    Re: Cant open a file with just a relative path <nikos1337@gmail.com>
    Re: I find the perl syntax easier than python <mgjv@tradingpost.com.au>
        Perl threads in Object Oriented code <ecarlson@vmware.com>
    Re: Samba file access checking? <m@rtij.nl.invlalid>
    Re: Samba file access checking? <jaford@watford53.freeserve.co.uk>
    Re: UTF8 European characters in MySQL <check.sig@for.email.invalid>
    Re: UTF8 European characters in MySQL <john1949@yahoo.com>
    Re: Weird error after a configuration change <nikos1337@gmail.com>
    Re: Where are good places to post resumes? <perl4hire@softouch.on.ca>
    Re: Where are good places to post resumes? <stoupa@practisoft.cz>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 30 Apr 2007 09:08:54 -0700
From: "havel.zhang" <havel.zhang@gmail.com>
Subject: Re: a problem about function returning point
Message-Id: <1177949334.584223.304980@o5g2000hsb.googlegroups.com>

Thank u Klaus:

       Thank u for your point out my program line by line, thank you:)
       This program be wroten three years before when i first met
Perl. So, it's be designed so complex that not necessary. And without
using strict and warnings.
       Today i add 'using strict' and 'using warnings' and reduced
complex, the problem solved.
       Thank u.

Havel Zhang

On Apr 29, 11:40 pm, Klaus <klau...@gmail.com> wrote:
> On Apr 29, 4:00 pm, "havel.zhang" <havel.zh...@gmail.com> wrote:
>
> >     Today I came cross a strange problem about function returning
> > point.
>
> Like with every strange problem in Perl, first try the following, put
> the following two lines at the beginning of your program:
>
> use strict;
> use warnings;



------------------------------

Date: 30 Apr 2007 06:11:26 -0700
From: Nikos <nikos1337@gmail.com>
Subject: Re: Cant open a file with just a relative path
Message-Id: <1177938686.400125.62720@u30g2000hsc.googlegroups.com>

On Apr 29, 9:07 pm, Michele Dondi <bik.m...@tiscalinet.it> wrote:
> On 27 Apr 2007 04:26:58 -0700, skieros <nikos1...@gmail.com> wrote:
>
> >> And I find it annoying that someone posts the same question to multiple help
> >> forums without disclosing such.  It causes an unneeded waste of resources.
>
> >yes, Iam sorry, as i explained to pesonal mail i couldnt see those 2
> >thread on gougle groups up until today...dont know why....thats also
> >why i posted 2 times.
>
> This is a non sequitur: what did prevent you from writing something
> along the lines of
>
> : Also posted in PerlMonks at
> :
> :http://perlmonks.org/?node_id=611837
>
> in the first place?

actually posdte here first but couldne see my posts for several
days....



------------------------------

Date: Mon, 30 Apr 2007 16:25:51 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Cant open a file with just a relative path
Message-Id: <g2ub3393sijpn0nc3mt737htr920q7s4ub@4ax.com>

On 30 Apr 2007 06:11:26 -0700, Nikos <nikos1337@gmail.com> wrote:

>> :http://perlmonks.org/?node_id=611837
>>
>> in the first place?
>
>actually posdte here first but couldne see my posts for several
>days....

Now, that's strange. Personally, I don't trust you. You post from GG,
don't you? Well, that's a real PITA, but all the times I've *had* to,
it either didn't work altogether or messages did appear quite soon at
least in their archive. Then the usual caveat about USENET articles
propagation applies. Even in this case, in PM you may have written:
"also posted in clpmisc, but the message doesn't seem to appear, will
post a reference soon."


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


------------------------------

Date: 30 Apr 2007 07:54:32 -0700
From: Nikos <nikos1337@gmail.com>
Subject: Re: Cant open a file with just a relative path
Message-Id: <1177944872.906756.300200@q75g2000hsh.googlegroups.com>

On Apr 30, 5:25 pm, Michele Dondi <bik.m...@tiscalinet.it> wrote:

> Now, that's strange. Personally, I don't trust you. You post from GG,
> don't you? Well, that's a real PITA, but all the times I've *had* to,
> it either didn't work altogether or messages did appear quite soon at
> least in their archive. Then the usual caveat about USENET articles
> propagation applies. Even in this case, in PM you may have written:
> "also posted in clpmisc, but the message doesn't seem to appear, will
> post a reference soon."

You may dont trust me but thats the truth, i seen my 2 posts days
later in GG.
>From now and on i'll post either here or imore preferably on
Perlmonks which i get more efficient answers.



------------------------------

Date: Mon, 30 Apr 2007 18:42:50 +1000
From: Martien verbruggen <mgjv@tradingpost.com.au>
Subject: Re: I find the perl syntax easier than python
Message-Id: <slrnf3bb0a.qio.mgjv@martien.heliotrope.home>

On 29 Apr 2007 22:08:41 -0700,
	grocery_stocker <cdalten@gmail.com> wrote:

> Versatility isn't always a good thing. Sometimes this can lead to
> stuff being inconsistent. Consider the following code I duped from a
> Google search -).
> #!/usr/bin/perl -w

> sub alter ($) {
>     $_[0]= $_[0] . " blub";
>
> }

> sub alter ($) {
>     my $string = shift;
>     $string = $string . " blub";
> }

I wouldn't call that inconsistent. I can understand that some people
find it unexpected -- and I could come up with other description for the
behaviour -- but it's not inconsistent for the following two reasons:

1 - The code is different, and alters different variables, so there is
    no consistency to violate. The code is not consistent, so there is
    no need for perl to behave in an identical, or even similar, way.

2 - It's documented to work this way (in perlsub).

The @_ array is 'magical' in subroutines, and its elements are aliased
to the scalar parameters to the subroutine call.

In the second subroutine, you create a lexically scoped local variable,
which you initialise by copying the contents of the first element of the
@_ array.


Note that this sort of aliasing behaviour occurs in only a few places,
and is documented that way. If you get surprised by it, get in the habit
never to modify variables unless you know they're local, or you intend
to modify a global variable.

Whether it's elegant/desirable for @_ to be aliased this way is a
separate discussion. For now, we're stuck with it.

Martien
-- 
                        | 
Martien Verbruggen      | Freudian slip: when you say one thing but
                        | mean your mother.
                        | 


------------------------------

Date: 30 Apr 2007 11:19:35 -0700
From: Eric <ecarlson@vmware.com>
Subject: Perl threads in Object Oriented code
Message-Id: <1177957175.145717.91220@e65g2000hsc.googlegroups.com>

Hello,

I have a Perl script that utilizes Perl threads to run a function
(time) on a list of entities. Using Perl threads will allow the code
to run in parallel (as opposed to serially) and therefore minimize the
time it takes to run through the list.

The code does something similar to what the following code is doing:

============= Perl script =============

#!/usr/bin/perl

use strict;
use warnings;

use threads;
use threads::shared;

my @clocks = ("clock1", "clock2", "clock3");

foreach my $clock (@clocks) {
    my $thr = threads->new(\&get);
    sleep 1;
}

for my $t (threads->list()) {
    my $result = $t->join;
}

sub get {
    my $time = shift;
    $time = time();
    print STDOUT "The time is: $time\n";
    return;
}
=======================================

Now, I want to get this script working in object oriented code. The
following scripts (plagiarized from a Perl book for the sake of
correctness) are doing something similar as the code above, but is
running the time function on the entities in serial, not parallel:

The Perl script is:

============= Perl script =============
#!/usr/bin/perl

use strict;
use warnings;

use Clock;

my @clocks = ("clock1", "clock2", "clock3");

foreach my $clock (@clocks) {
   my $clock = new Clock();
   sleep 1;
   print STDOUT "\$clock is: ". $clock->get(), "\n";
}
=======================================

And the Perl module being used is:

============= Perl module: Clock.pm =============
#!/usr/bin/perl

package Clock;

use strict;
use warnings;

sub new {
   my ($type) = @_;
   my $self = {};
   $self->{time} = time();
   bless $self, $type;
}

sub get {
    my ($self) = shift;
    return($self->{time});
}

1;
=======================================

Note the following line of code in the former (non OO) script:

    my $thr = threads->new(\&get);

This line is calling the 'get' sub. So, if I were to use the OO
scripts shown, how should I implement this?

I tried doing the obvious, which was to change the line to:

my $thr = threads->new($clock->get());

But I got the following error:

thread failed to start: Undefined subroutine &main::1177952602 called
at ./CC.pl line 19.

Other failed attempts were:

my $thr = threads->new(\&clock->get());
my $thr = threads->new(Clock::clock->get());
my $thr = threads->new($Clock::get());

Truthfully, I am not well versed at Object Oriented Perl (or anything
else). So at this point I was making guesses that weren't so educated.

Does anyone have a solution?

Thanks in advance to all that respond.

Eric



------------------------------

Date: Mon, 30 Apr 2007 16:19:47 +0200
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: Samba file access checking?
Message-Id: <pan.2007.04.30.14.20.24@rtij.nl.invlalid>

On Sun, 29 Apr 2007 18:45:34 +0000, Jim Ford wrote:

> I want to get the IP address of any machine accessing the files on my
> samba share. As I mentioned, I can do it by examining the output from
> smbstatus, but feel that there must be a better way.

Parse the samba logs. Maybe swatch can help. Otherwise a very simple 
perlscript will do the trick.

HTH,
M4


------------------------------

Date: Mon, 30 Apr 2007 17:28:38 GMT
From: Jim Ford <jaford@watford53.freeserve.co.uk>
Subject: Re: Samba file access checking?
Message-Id: <aHpZh.649$d9.0@newsfe6-gui.ntli.net>

Martijn Lievaart wrote:
> On Sun, 29 Apr 2007 18:45:34 +0000, Jim Ford wrote:
> 
>> I want to get the IP address of any machine accessing the files on my
>> samba share. As I mentioned, I can do it by examining the output from
>> smbstatus, but feel that there must be a better way.
> 
> Parse the samba logs. Maybe swatch can help. Otherwise a very simple 
> perlscript will do the trick.
> 

That's what I've been doing so far. I just thought there would be a more 
'direct' way of doing it - say through the proc fs (but there doesn't 
seem to be anything there an samba).

Thanks for the reply.

Jim Ford


------------------------------

Date: Mon, 30 Apr 2007 10:24:06 +0300
From: Alex <check.sig@for.email.invalid>
Subject: Re: UTF8 European characters in MySQL
Message-Id: <AQgZh.156037$fK1.15123@reader1.news.saunalahti.fi>

Sherm Pendley wrote:

> Did you try actually *reading* 'perldoc utf8'?

Yes.

> It makes Perl aware that your source code is utf8. It has nothing to do
> with your terminal.

Yes, I am aware of that and I didn't say it has. It does, however, have
an impact on how UTF-8 string are printed in the terminal (which uses
UTF-8).

-- 
Alex
e-mail: Domain is iki dot fi. Local-part is alext.
        local-part at domain


------------------------------

Date: Mon, 30 Apr 2007 15:40:05 +0100
From: "John" <john1949@yahoo.com>
Subject: Re: UTF8 European characters in MySQL
Message-Id: <j-idncZ3cMdeYqjbRVnyhAA@eclipse.net.uk>

Hi

I've got it working.

I've puilled out the key features for others who may have a similar problem.

<meta http-equiv='content-type' content='text/html; 
charset=ISO-8859-1'></meta>

# create table
 my $sql="SET CHARACTER SET utf8";
 $sql="SET NAMES utf8";
 $sql="CREATE TABLE $table (id integer auto_increment not null primary 
key,username varchar(40),";
 $sql.="CheckIn varchar(20),CheckOut varchar(20)"; etc etc
 $sql.="DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci";

# read table
use Encode;
$HotelName=decode_utf8($HotelName); # may contain accented characters

Regards
John





------------------------------

Date: 30 Apr 2007 06:12:20 -0700
From: Nikos <nikos1337@gmail.com>
Subject: Re: Weird error after a configuration change
Message-Id: <1177938740.416998.70900@l77g2000hsb.googlegroups.com>

On Apr 29, 11:00 pm, Michele Dondi <bik.m...@tiscalinet.it> wrote:
> On 27 Apr 2007 12:33:31 -0700, skieros <nikos1...@gmail.com> wrote:
>
> >Line 26 is the line with if.
> >All this happened when i deleted the d:\www\index.html file which was
> >pointing to d:\www\cgi-bin\index.pl and set apache to load /cgi-bin/
> >index.pl directly.
>
> http://perlmonks.org/?node_id=612668
>
> Michele
> --
> {$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
> (($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
> .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
> 256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,

ok



------------------------------

Date: Mon, 30 Apr 2007 04:08:35 -0400
From: Amer Neely <perl4hire@softouch.on.ca>
Subject: Re: Where are good places to post resumes?
Message-Id: <DrhZh.8455$WE.8156@read1.cgocable.net>

Sherm Pendley wrote:
> Okay, we all know <http://jobs.perl.org> is the place to post "help wanted"
> ads. So where do we post "will code for food" ads?
> 
> sherm--
> 

Try
http://sipgroup.org/

-- 
Amer Neely
w: www.softouch.on.ca/
Perl | MySQL programming for all data entry forms.
"We make web sites work!"


------------------------------

Date: Mon, 30 Apr 2007 15:16:57 +0200
From: "Petr Vileta" <stoupa@practisoft.cz>
Subject: Re: Where are good places to post resumes?
Message-Id: <f14ru2$4dt$1@ns.felk.cvut.cz>

"Sherm Pendley" <spamtrap@dot-app.org> píse v diskusním príspevku 
news:m2hcqylwvf.fsf@local.wv-www.com...
> Okay, we all know <http://jobs.perl.org> is the place to post "help 
> wanted"
> ads. So where do we post "will code for food" ads?

http://www.softpedia.com/user/submit.shtml

-- 

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail 
from another non-spammer site please.)




------------------------------

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 V11 Issue 394
**************************************


home help back first fref pref prev next nref lref last post