[28979] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 223 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 14 21:09:53 2007

Date: Wed, 14 Mar 2007 18:09: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, 14 Mar 2007     Volume: 11 Number: 223

Today's topics:
    Re: Any daylight saving time issues lately? rmts9@hotmail.com
    Re: Any daylight saving time issues lately? <BLOCKSPAMwazoo@your-mailbox.com>
    Re: Counting occurences using a variable usenet@DavidFilmer.com
    Re: Counting occurences using a variable anno4000@radom.zrz.tu-berlin.de
    Re: Daylight Savings using timelocal() and localtime() rmts9@hotmail.com
        Index Value of a Button Widget in Perl/Tk <doni.sekar@gmail.com>
    Re: Installing librairies (window OS) <bart.lateur@pandora.be>
    Re: Llama book exercise <brian.d.foy@gmail.com>
    Re: Llama book exercise <persep@gmail.com>
    Re: patch for Mail::SendEasy <hjp-usenet2@hjp.at>
        Perl DBI/XML processing versus PHP ? <surfver@yahoo.com>
    Re: Perl DBI/XML processing versus PHP ? <ask-me@email.com>
    Re: Retrieving the value of an Selected Item from a Lis <doni.sekar@gmail.com>
    Re: Retrieving the value of an Selected Item from a Lis <attn.steven.kuo@gmail.com>
        Stupid question but its driving me nuts... sumitbee@gmail.com
    Re: Stupid question but its driving me nuts... sumitbee@gmail.com
    Re: Stupid question but its driving me nuts... <jurgenex@hotmail.com>
    Re: Stupid question but its driving me nuts... sumitbee@gmail.com
    Re: Stupid question but its driving me nuts... jgraber@ti.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 14 Mar 2007 15:02:44 -0700
From: rmts9@hotmail.com
Subject: Re: Any daylight saving time issues lately?
Message-Id: <1173909764.669104.35460@e1g2000hsg.googlegroups.com>

On Mar 13, 6:01 pm, Wazoo <BLOCKSPAMwa...@your-mailbox.com> wrote:
> I support some production systems running a big Perl app. The IT guys
> are complaining that there is some vague problem with things being an
> hour off. I'm still waiting for more details ... meanwhile are there any
> known Perl or CPAN issues with the recent daylight savings time change?

There is a hotfix from MS
 http://support.microsoft.com/kb/932590

localtime uses a dll that does not work correctly if the TZ variable
is set.



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

Date: Wed, 14 Mar 2007 15:38:55 -0700
From: Wazoo <BLOCKSPAMwazoo@your-mailbox.com>
Subject: Re: Any daylight saving time issues lately?
Message-Id: <BLOCKSPAMwazoo-6499B2.15385514032007@news.giganews.com>

In article <BLOCKSPAMwazoo-A784E2.18011913032007@news.giganews.com>,
 Wazoo <BLOCKSPAMwazoo@your-mailbox.com> wrote:

> I support some production systems running a big Perl app. The IT guys 
> are complaining that there is some vague problem with things being an 
> hour off. I'm still waiting for more details ... meanwhile are there any 
> known Perl or CPAN issues with the recent daylight savings time change?

For anyone else who has this problem ... here's the solution.

http://www.perlmonks.org/?node_id=593399

Turns out that if your code uses DateTime, you need a new timezone file.


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

Date: 14 Mar 2007 13:01:15 -0700
From: usenet@DavidFilmer.com
Subject: Re: Counting occurences using a variable
Message-Id: <1173902475.862498.160270@y66g2000hsf.googlegroups.com>

On Mar 14, 5:22 am, "jesse" <jesse_ha...@premierinc.com> wrote:
> The file looks like this;

So what's the problem with your code?  You don't say, but I assume the
problem is that the failure count is wrong (always shows 1).  That's
because you increment $seen{$elem} but next() out if the value is
defined (so it only will ever print one message).

However, the value of $seen{$elem} is being artificially inflated
because you're looping over @failures (and incrementing the count)
each time a new failure is found.

If you want to correctly report the total number of failures then you
must analyze all the data and THEN print the results.  You are
printing on-the-fly, which will only report the first occurance of the
failure.


--
The best way to get a good answer is to ask a good question.
David Filmer (http://DavidFilmer.com)



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

Date: 14 Mar 2007 21:14:52 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Counting occurences using a variable
Message-Id: <55r6ucF24d68vU1@mid.dfncis.de>

jesse <jesse_hardy@premierinc.com> wrote in comp.lang.perl.misc:
> I have a master file that gets added to everyday, with backup
> failures.  The file has server name and what failed. I want to open
> the file and read the first line then check the rest of the file for
> any more occurrences of that exact failure.  Then I want to move to
> the second line and repeat the proccess until I have read through the
> entire file.  When I move down the file I want to ignore lines that
> have already been counted.  I would also like to be able to ignore
> lines if the failure didn't occur the day I am checking for, ie if it
> failed today but didn't fail tomorrow then I don't want it to show up
> on my report(this is a like to have but it's not mandatory). The file
> looks like this;
> 
> server2 c:\\
> server1 d:\\
> server5 e:\\
> server1 d:\\
> 
> This is the meat of the script that I have that of course is not
> working right;
> 
>   while (<FAILED>){
>         chomp;
>         s/#.*//;
>         next if /^(\s)*$/;
>         push @failures, $_;
>                 foreach $elem ( @failures ){
>                 next if $seen{$elem}++;
>                         print OUTPUT "$elem has failed $seen{$elem}
> times\n";
>         }
> 
> }

That's a job for a hash.  Read the file, accumulating the counts.  Then
print a report:

    my %count;
    while ( <DATA> ) {
        chomp;
        ++ $count{ $_};
    }

    printf(
        "%s has failed %d time%s\n",
        $_, 
        $count{ $_}, 
        $count{ $_} == 1 ? '' : 's', # grammar matters!
    ) for sort keys %count;

    __DATA__
    server2 c:\\
    server1 d:\\
    server5 e:\\
    server1 d:\\

Anno


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

Date: 14 Mar 2007 15:06:27 -0700
From: rmts9@hotmail.com
Subject: Re: Daylight Savings using timelocal() and localtime()
Message-Id: <1173909987.087711.170840@l77g2000hsb.googlegroups.com>



The problem is a dll that works incorrectly when the TZ variable is
set see
 http://support.microsoft.com/kb/932590
of course there is no hot fix for win2k



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

Date: 14 Mar 2007 15:23:08 -0700
From: "doni" <doni.sekar@gmail.com>
Subject: Index Value of a Button Widget in Perl/Tk
Message-Id: <1173910988.573825.191970@p15g2000hsd.googlegroups.com>

Hi,

Can anyone point me how can I retrieve the index value or any value to
indicate that a specific button is selected. Can anyone let me know
how can I proceed with this.
Actuall, based upon the selected button I want to pass the command to
a specific subroutine for carrying out specific logic. But right now,
any selected button will pass the control to the same subroutine

Thanks,
doni

Here is the test code.

#!/usr/bin/perl

use strict;
use Tk;

my @received_hello; my @sending_rupd; my @changing_l2; my
@received_nreg; my @received_nreg_new;
my @sending_nreg_ack; my @received_nd; my @received_nd_ack; my
@sending_nd; my @removing_l2;

my $mw = MainWindow->new;
$mw->configure(-title => 'Test Tool', -background => 'white', -width
=> "700", -height => "500");

my $lbox1 = $mw->Scrolled('Listbox', -scrollbars => 'osoe');
$lbox1->configure(-height => 8, -width => 20);
$lbox1->configure(-selectmode => 'browse');
$lbox1->pack(-anchor => 'e');

my $btn1 = $mw->Button(-text => "RFROUTED",
                       -command => \&rfrouted_button)->pack(-side =>
'right', -anchor => 'e');
my $btn2 = $mw->Button(-text => "GWD",
                       -command => \&gwd_button)->pack(-side =>
'right', -anchor => 'e');
my $btn3 = $mw->Button(-text => "Exit",
                       -command => sub{exit})->pack(-side => 'right', -
anchor => 'e', -after => $btn1);
my $fr   = $mw->Frame(-background => 'cyan')->pack(-side => 'top', -
fill => 'x');
my $t    = $mw->Scrolled("Text")->pack(-side => 'bottom', -fill =>
'both', -expand => '1');
MainLoop();

sub rfrouted_button {
    repack();
   foreach (qw/rcvd_hello sendg_rupd chng_l2 rcvd_nreg rcvd_nreg_new
sendg_nreg_ack rcvd_nd rcvd_nd_ack sendg_nd rmvg_l2/) {
        ##### Any selected button passes control to rcvd_hello
subroutine
        $fr->Button(-text => $_, -command => \&rcvd_hello, -width =>
'12')->pack(-anchor => 'e');
    }
}

sub gwd_button {
    repack();
    foreach (qw/new_device route_update/) {
        $fr->Button(-text => $_, -width => '12')->pack(-anchor =>
'w');
        no_of_times(@new_device);
    }
}

sub repack {
    $btn1->packForget();
    $btn2->packForget();
    $lbl1->packForget();
    $lbl2->packForget();
}

sub rcvd_hello {
    my @list = ("00:13:50:00:05:19", "00:13:50:00:05:bd",
"00:13:50:00:04:f9", "00:13:50:00:05:cb");
    $lbox1->insert('end', @list);
    $lbox1->bind('<<ListboxSelect>>',
sub{ display_lb_curselection($lbox1) });
}

sub display_lb_curselection {
    my $lbox1 = shift;
    my @cs = $lbox1->curselection();
    my $selection = $lbox1->selectionSet(@cs);
    print "Current choices: ", $selection;
    print "\n";
}



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

Date: Wed, 14 Mar 2007 22:23:19 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Installing librairies (window OS)
Message-Id: <rdtgv294b73c2n3uvcv5g7ab81i60uesq4@4ax.com>

ernond_paul@yahoo.fr wrote:

>I'm currently having trouble installaing librairies under a window OS.
>first, I've developped a perl Gtk application under linux (it's works
>well) ; and I would like to run it in window os. This application use
>Gnome2, Gnome2::Canvas, Gtk2::GladeXML (and others one).
>
>Under win (xp) I've first install ActivePerl (5.8.? => I don't
>remember exactly ;-) )
>Next, I've tryed to run ppm (the little user interface to install
>packages) but Gnome2::Canvas isn't into the repository...

Take a look at
<http://live.gnome.org/GTK2-Perl/FrequentlyAskedQuestions>

I think you can find links to whatever you need there.

-- 
	Bart.


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

Date: Wed, 14 Mar 2007 11:29:02 -0700
From: brian d  foy <brian.d.foy@gmail.com>
Subject: Re: Llama book exercise
Message-Id: <140320071129027616%brian.d.foy@gmail.com>

In article <1173775129.066451.39040@q40g2000cwq.googlegroups.com>,
PerseP <persep@gmail.com> wrote:

> On Mar 12, 10:11 pm, brian d  foy <brian.d....@gmail.com> wrote:
> 
> > $_ is a global variable. Instead of getting into the bad habit of using
> > it when you don't need it, we suggest that you use your own variable
> > for the foreach. It might seem a bit silly for the simple exercise, but
> > it's never too early to start good coding practices. :)

> thanks for answering.The answer is a bit contradictory as there are
> other examples in the book that use the $_ instead of a private
> variable thus not being examples of good coding but as there are only
> short examples there's nothing wrong with that.


It's not contradictory, it's just that we made an additional point in
that particular exercise. For most of the book we ignore most of the
things that we *could* talk about to focus on the thing that we want
you to learn. :)

-- 
Posted via a free Usenet account from http://www.teranews.com



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

Date: 14 Mar 2007 13:33:27 -0700
From: "PerseP" <persep@gmail.com>
Subject: Re: Llama book exercise
Message-Id: <1173904407.689423.244780@p15g2000hsd.googlegroups.com>


> It's not contradictory, it's just that we made an additional point in
> that particular exercise. For most of the book we ignore most of the
> things that we *could* talk about to focus on the thing that we want
> you to learn. :)
>
> --
> Posted via a free Usenet account fromhttp://www.teranews.com

Ok, I understand. Thanks



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

Date: Wed, 14 Mar 2007 22:28:43 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: patch for Mail::SendEasy
Message-Id: <slrnevgq8b.tlt.hjp-usenet2@yoyo.hjp.at>

On 2007-03-14 07:01, Yakov <iler.ml@gmail.com> wrote:
> I fixed something [1] in Mail::SendEasy and I emailed the author but
> his email bounces.
> How can I submit my patches ?

You could try via rt.cpan.org:
http://rt.cpan.org/Public/Dist/Display.html?Name=Mail-SendEasy

However, there are two year old "important" bugs still in state "new",
so I suspect that the maintainer doesn't check RT either. The package
may be unmaintained. I think there is a procedure to claim
maintainership of an unmaintained package on CPAN, but that will have to
explained by somebody else.

	hp


-- 
   _  | Peter J. Holzer    | Blaming Perl for the inability of programmers
|_|_) | Sysadmin WSR       | to write clearly is like blaming English for
| |   | hjp@hjp.at         | the circumlocutions of bureaucrats.
__/   | http://www.hjp.at/ |	-- Charlton Wilbur in clpm


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

Date: 14 Mar 2007 16:26:56 -0700
From: "surfivor" <surfver@yahoo.com>
Subject: Perl DBI/XML processing versus PHP ?
Message-Id: <1173914816.457971.224720@d57g2000hsg.googlegroups.com>

I may be involved in a data migration project involving databases and
creating XML feeds. Our site is PHP based, so I imagine the team might
suggest PHP, but I had a look at the PHP documentation for one of the
Pear modules for creating XML and it didn't look like much. I've used
Perl XML:Twig and I have the impression that there is more Perl stuff
available as well as the Perl stuff being well documented as I have a
Perl DBI book, a Perl XML, a Perl data munging book and so on. Alot of
the PHP books seem to be mainly on building sites and connecting to
databases, but I haven't checked them all and I have most of the Perl
books. One problem is that some of the Perl stuff is hard to get on
Activestate Perl for windows, so I may have to try to explain to them
why I think it should be done in Perl and why I need a linux login to
do it, etc. I'm not that familiar with PHP, but am looking for
comments on this.



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

Date: Thu, 15 Mar 2007 10:53:25 +1100
From: Hendri Kurniawan <ask-me@email.com>
Subject: Re: Perl DBI/XML processing versus PHP ?
Message-Id: <12vh2nmgi8kj8da@corp.supernews.com>

surfivor wrote:
> I may be involved in a data migration project involving databases and
> creating XML feeds. Our site is PHP based, so I imagine the team might
> suggest PHP, but I had a look at the PHP documentation for one of the
> Pear modules for creating XML and it didn't look like much. I've used
> Perl XML:Twig and I have the impression that there is more Perl stuff
> available as well as the Perl stuff being well documented as I have a
> Perl DBI book, a Perl XML, a Perl data munging book and so on. Alot of
> the PHP books seem to be mainly on building sites and connecting to
> databases, but I haven't checked them all and I have most of the Perl
> books. One problem is that some of the Perl stuff is hard to get on
> Activestate Perl for windows, so I may have to try to explain to them
> why I think it should be done in Perl and why I need a linux login to
> do it, etc. I'm not that familiar with PHP, but am looking for
> comments on this.
> 

I've used both. Once you have your understanding of PHP, it won't be
as hard as you imagine. PHP handles XML very well too IMHO.

Hendri


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

Date: 14 Mar 2007 11:23:41 -0700
From: "doni" <doni.sekar@gmail.com>
Subject: Re: Retrieving the value of an Selected Item from a Listbox widget
Message-Id: <1173896621.032118.106090@e1g2000hsg.googlegroups.com>

I was able to retrieve the value of the item selected from the Listbox
widget using get option.
Can anyone suggest me how can I do multiple selections from Listbox
widget..

On Mar 14, 10:48 am, "doni" <doni.se...@gmail.com> wrote:

> I would like to know how can I retrieve the value of the selected item
> from the Listbox widget. I tried different options in Listbox widget
> (<Double-ButtonPress-1>, <Return>) but I was not able to retrieve the
> expected results.
> Can anyone let me know how can I do this.
>
> sub rcvd_hello {
>     my @list = ("00:13:50:00:05:19", "00:13:50:00:05:bd",
> "00:13:50:00:04:f9", "00:13:50:00:05:cb");
>     $lbox1->insert('end', @list);
>     $lbox1->bind('<<ListboxSelect>>',
> sub{ display_lb_curselection($lbox1) });
>
> }
>
> sub display_lb_curselection {
>     my $lbox1 = shift;
>     my @cs = $lbox1->curselection();
>     my $selection = $lbox1->selectionSet(@cs);

Here is the change I made to the above line:
       my $selection = $lbox1->get(@cs);

Thanks,
doni




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

Date: 14 Mar 2007 12:00:17 -0700
From: "attn.steven.kuo@gmail.com" <attn.steven.kuo@gmail.com>
Subject: Re: Retrieving the value of an Selected Item from a Listbox widget
Message-Id: <1173898817.308224.254450@n59g2000hsh.googlegroups.com>

On Mar 14, 11:23 am, "doni" <doni.se...@gmail.com> wrote:
> I was able to retrieve the value of the item selected from the Listbox
> widget using get option.
> Can anyone suggest me how can I do multiple selections from Listbox
> widget..
>

(snipped)


use Tk;


my $mw = MainWindow->new;
my $lbox = $mw->Scrolled(
    'Listbox',
    -scrollbars => 'osoe',
    # -selectmode => 'browse',
    -selectmode => 'multiple',
    -exportselection => 0,
)->pack(
    -side => 'top'
);

my @choices = qw/eeny meeny miny moe/;
$lbox->insert('end', @choices);

$lbox->bind(
    '<ButtonRelease-1>',
    sub {
        my $curselection = $lbox->curselection;
        if ($curselection) {
            my @slice = @choices[ @$curselection ];
            print "You chose: ";
            print join ", " => @slice;
            print "\n";
        } else {
            print "Nothing selected?\n";
        }
    }
);

MainLoop();

--
Hope this helps,
Steven



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

Date: 14 Mar 2007 11:16:14 -0700
From: sumitbee@gmail.com
Subject: Stupid question but its driving me nuts...
Message-Id: <1173896174.105473.214170@l77g2000hsb.googlegroups.com>

I am trying to do a simple substitution, but there is something wrong
and I cant ut my finger on it...

$cl_IP = "10.0.4.*";
print $cl_IP."\n";
$cl_IP = s/\*/\\\\\*/;
print $cl_IP."\n";

I am perplexed why this is not giving 10.0.4.\\*



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

Date: 14 Mar 2007 11:22:44 -0700
From: sumitbee@gmail.com
Subject: Re: Stupid question but its driving me nuts...
Message-Id: <1173896564.182533.296250@l75g2000hse.googlegroups.com>

On Mar 14, 12:16 pm, sumit...@gmail.com wrote:
> I am trying to do a simple substitution, but there is something wrong
> and I cant ut my finger on it...
>
> $cl_IP = "10.0.4.*";
> print $cl_IP."\n";
> $cl_IP = s/\*/\\\\\*/;
> print $cl_IP."\n";
>
> I am perplexed why this is not giving 10.0.4.\\*

Sorry all, I need glasses....



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

Date: Wed, 14 Mar 2007 18:23:49 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Stupid question but its driving me nuts...
Message-Id: <V4XJh.7565$vV3.3684@trndny09>

sumitbee@gmail.com wrote:
> I am trying to do a simple substitution, but there is something wrong
> and I cant ut my finger on it...
>
> $cl_IP = "10.0.4.*";
> print $cl_IP."\n";
> $cl_IP = s/\*/\\\\\*/;
> print $cl_IP."\n";
>
> I am perplexed why this is not giving 10.0.4.\\*

You are missing
    use strict;
    use warnings;

Had you used them then Perl would have told you what's wrong:
    Use of uninitialized value in substitution (s///) at C:\tmp\t.pl line 7.

jue

Hint: which variable does s/// work on by default?





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

Date: 14 Mar 2007 11:28:23 -0700
From: sumitbee@gmail.com
Subject: Re: Stupid question but its driving me nuts...
Message-Id: <1173896903.341965.129140@d57g2000hsg.googlegroups.com>

On Mar 14, 12:23 pm, "J=FCrgen Exner" <jurge...@hotmail.com> wrote:
> sumit...@gmail.com wrote:
> > I am trying to do a simple substitution, but there is something wrong
> > and I cant ut my finger on it...
>
> > $cl_IP =3D "10.0.4.*";
> > print $cl_IP."\n";
> > $cl_IP =3D s/\*/\\\\\*/;
> > print $cl_IP."\n";
>
> > I am perplexed why this is not giving 10.0.4.\\*
>
> You are missing
>     use strict;
>     use warnings;
>
> Had you used them then Perl would have told you what's wrong:
>     Use of uninitialized value in substitution (s///) at C:\tmp\t.pl line=
 7.
>
> jue
>
> Hint: which variable does s/// work on by default?

Thank you Jue for your help!



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

Date: 14 Mar 2007 13:22:36 -0500
From: jgraber@ti.com
Subject: Re: Stupid question but its driving me nuts...
Message-Id: <yvntzwnn0r7.fsf@famous02.dal.design.ti.com>


sumitbee@gmail.com writes:
> I am trying to do a simple substitution, but there is something wrong
> and I cant ut my finger on it...
> 
> $cl_IP = "10.0.4.*";
> print $cl_IP."\n";
> $cl_IP = s/\*/\\\\\*/;
> print $cl_IP."\n";
> 
> I am perplexed why this is not giving 10.0.4.\\*

use strict;
use warnings;
my $cl_IP = "10.0.4.*";
print $cl_IP."\n";
$cl_IP = s/\*/\\\\\*/;  # line 5
print $cl_IP."\n";

10.0.4.*
If you had use warnings;  you would have seen this
Use of uninitialized value in substitution (s///) at temp.pl line 5.

$cl_IP =~ s/\*/\\\\\*/;  # line 5
#      ^^

10.0.4.*
10.0.4.\\*

-- 
Joel


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

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 223
**************************************


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