[25509] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7753 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 8 11:05:56 2005

Date: Tue, 8 Feb 2005 08:05:20 -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           Tue, 8 Feb 2005     Volume: 10 Number: 7753

Today's topics:
    Re: [OT] Re: Perl - permute? <phaylon@dunkelheit.at>
    Re: [OT] Re: Perl - permute? <tadmc@augustmail.com>
        A question on output of flip flop operator (part 2) (justme)
    Re: A question on output of flip flop operator (part 2) <phaylon@dunkelheit.at>
        A question on output of flip flop operator (justme)
    Re: A question on output of flip flop operator <phaylon@dunkelheit.at>
    Re: A question on output of flip flop operator <1usa@llenroc.ude.invalid>
    Re: Array reference not consistently interpolating <evillen@innocent.com>
        copy directory structure without files ioneabu@yahoo.com
    Re: copy directory structure without files <phaylon@dunkelheit.at>
    Re: copy directory structure without files ioneabu@yahoo.com
    Re: Exception handling in class: question <mjl69mjl69@myaccmyacc.net>
        fields pragma (Lee Goddard)
    Re: Learning Perl - resources and ideas <tadmc@augustmail.com>
    Re: Perl - permute? <phaylon@dunkelheit.at>
    Re: Perl - permute? <jurgenex@hotmail.com>
    Re: Perl - permute? <phaylon@dunkelheit.at>
    Re: Perl - permute? <do-not-use@invalid.net>
    Re: Perl - permute? <phaylon@dunkelheit.at>
    Re: Perl - permute? <tadmc@augustmail.com>
    Re: Perl - permute? <phaylon@dunkelheit.at>
    Re: Perl - permute? <do-not-use@invalid.net>
    Re: ptk_steal <zentara@highstream.net>
    Re: ptk_steal <JiggaHertz@nospam.com>
    Re: Regular expression woes (News)
    Re: should be simple..but eh  Can you help <1usa@llenroc.ude.invalid>
    Re: To compare dates in a script <mothra@nowhereatall.com>
    Re: To compare dates in a script <phaylon@dunkelheit.at>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 08 Feb 2005 12:05:15 +0100
From: phaylon <phaylon@dunkelheit.at>
Subject: Re: [OT] Re: Perl - permute?
Message-Id: <pan.2005.02.08.11.05.15.728944@dunkelheit.at>

John Bokma wrote:

> Only lamers brag about their killfiles.

Scorefile *again* adjusted.

-- 
http://www.dunkelheit.at/

The first rule of project mayhem is: you do not ask questions.
                              -- Fight Club



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

Date: Tue, 8 Feb 2005 07:06:37 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: [OT] Re: Perl - permute?
Message-Id: <slrnd0heat.u40.tadmc@magna.augustmail.com>

Bernard El-Hagin <bernard.el-haginDODGE_THIS@lido-tech.net> wrote:
> John Bokma <postmaster@castleamber.com> wrote:
> 
>> Alan J. Flavell wrote:
>> 
>>> incidents which produce killfile entries ;-)
>> 
>> Only lamers brag about their killfiles.
> 
> 
> Then I happily join their ranks.


Because only lamers earn a killfile entry in the first place.

No, that isn't correct.

Only some who are killfiled are lame.


Only lamers whine about the consequences of their actions.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 8 Feb 2005 07:18:19 -0800
From: mik3l3374@gmail.com (justme)
Subject: A question on output of flip flop operator (part 2)
Message-Id: <e3202a16.0502080718.7bd1f701@posting.google.com>

hi

i have a text file with some info like this:

[local]
/home/user
[files]
test1.txt
test1.htm
[dest]
/home/dest
[server]
127.0.0.1
[end]

[local]
/home/user1
[files]
test1.dat
test2.txt
[dest]
/home/dest1
[server]
127.0.0.1
[end]

Actually i am doing an ftp configuration file where the perl sript
will go through this file and pick up the definitions between [local]
and [end]
and then using Net::FTP module to transfer files from local directory
to destination at server defined by [server] until [end] and then
start transferring the next section from [local] to [end]

Am i going the correct way by doing the incomplete code below ? If not
any better way to do that...thanks

while(<FILE>)
{
        if (/\[local\]/ .. /\[files\]/ ) {
                next if ( $_ =~ /\[local\]/ or $_ =~  /\[files\]/ ) ;
                $localdir = $_;  #get the line after [local]
        }
        if ( /\[files\]/ .. /\[dest\]/ )
        {
                print "files = $_\n";
                next if ( $_ =~ /\[files\]/ or $_ =~ /\[dest\]/ );
                push(@files, "$_");
        }
        if (/\[dest\]/ .. /\[server\]/ )
        {
               next if ( /\[dest\]/ or $_ =~ /\[server\]/ );
               $dest = $_;  #get dest directory to put @files
        }
        
        .....
        ......
}

print "local is $localdir\n";
print "files are = @files\n";
print "dest is = $dest\n";


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

Date: Tue, 08 Feb 2005 16:48:59 +0100
From: phaylon <phaylon@dunkelheit.at>
Subject: Re: A question on output of flip flop operator (part 2)
Message-Id: <pan.2005.02.08.15.48.58.716804@dunkelheit.at>

justme wrote:

> i have a text file with some info like this:

Why are you opening another thread? I've got your last one facing this
topic right on second line.
 
> Am i going the correct way by doing the incomplete code below ? If not
> any better way to do that...thanks

It is *a* way to do that[1]. But you have to keep it exactly in this
order. Another approach may be to use the range operator (C<..>) to find
out if you are in the local/end section and then process each line.
Below's a quick example which also builds a little data structure you may
find useful.

hth,
phay

( [1] I haven't read your code complete, so I'm just talking about the
      *way of doing it.* )

#!/usr/bin/perl
use warnings;
use strict;
use Data::Dumper;
 
my(@data, $section);
my $count = 0;
 
line: while( <DATA> ) {
    if( /^\[local\]$/i .. /^\[end\]$/i ) {
        chomp;
 
        #-- skip empty lines
        next line if /^\s*$/;
 
        #-- find current section
        $section = $1 and next line
          if /^\[(files|dest|server|local|end)\]$/i;
 
        #-- end means, we're out of any section, next line
        next line if $section eq lc 'end';
 
        #-- everything but files seems to be one-value
        $data[ $count ]{ $section } .= $_
          and next line
          unless $section eq lc 'files';
 
        #-- push files entry
        push @{$data[ $count ]{ $section }}, $_;
    }
    else {
        $count++;
    }
}
print Dumper \@data;
 
__DATA__
[local]
/home/user
[files]
test1.txt
test1.htm
[dest]
/home/dest
[server]
127.0.0.1
[end]
 
[local]
/home/user1
[files]
test1.dat
test2.txt
[dest]
/home/dest1
[server]
127.0.0.1
[end]
__END__

-- 
http://www.dunkelheit.at/
bellum omnium pater.



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

Date: 8 Feb 2005 06:32:51 -0800
From: mik3l3374@gmail.com (justme)
Subject: A question on output of flip flop operator
Message-Id: <e3202a16.0502080632.1a6926b2@posting.google.com>

hi

i have a text file with some info like this:

[local]
/home/user
[files]
test1.txt
test1.htm
[dest]
/home/dest
[server]
127.0.0.1


i want to get the line between [local] and [files] so i did a small code

open(FILE , "<$input") or die "Cannot open $input for reading!: $!\n";
while(<FILE>)
{
        print if (/\[local\]/ .. /\[files\]/ );

}


but i get the output :
[local]
/home/user
[files]

i only want to get "/home/user" and not the [local] and [files] 
how can i do that?
thanks


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

Date: Tue, 08 Feb 2005 15:46:19 +0100
From: phaylon <phaylon@dunkelheit.at>
Subject: Re: A question on output of flip flop operator
Message-Id: <pan.2005.02.08.14.46.18.247160@dunkelheit.at>

justme wrote:

> i only want to get "/home/user" and not the [local] and [files] how can i
> do that?

That's mentioned in »perldoc perlre«, look out for the ( .. ) brackets.
Should be enough examples in there. Also it would sure be a good idea to
take a complete look through the Perl documentation which you can call by
»perldoc perl«.

hth,
phay

-- 
http://www.dunkelheit.at/
thou shallst fear...



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

Date: Tue, 08 Feb 2005 14:56:21 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: A question on output of flip flop operator
Message-Id: <Xns95F76527C85CEasu1cornelledu@127.0.0.1>

mik3l3374@gmail.com (justme) wrote in news:e3202a16.0502080632.1a6926b2
@posting.google.com:

> Re: A question on output of flip flop operator

It is the print statement that generates the output.

> i have a text file with some info like this:
> 
> [local]
> /home/user
> [files]
> test1.txt
> test1.htm
> [dest]
> /home/dest
> [server]
> 127.0.0.1

It is preferable to put the data in the __DATA__ section of the scripts 
you post so others can run your script with minimal effort. Please see 
the posting guidelines for an explanation of this.

> i want to get the line between [local] and [files] so i did a small
> code
> 
> open(FILE , "<$input") or die "Cannot open $input for reading!: $!\n";

I tend to prefer lexical filehandles (because they are limited to the 
current lexical scope instead of being global) and the three-argumen 
form of open:

open my $file, '<', $input or die "Cannot open $input: $!";

The value of not suppressing the error line is debatable. It is probably 
a good idea to keep it during development.

> while(<FILE>)
> {
>         print if (/\[local\]/ .. /\[files\]/ );
> 
> }
> 
> but i get the output :
> [local]
> /home/user
> [files]
> 
> i only want to get "/home/user" and not the [local] and [files] 
> how can i do that?

One way would be to choose not to print [local] and [files]:

use strict;
use warnings;

my $start = '\[local\]';
my $end   = '\[files\]';

while(<DATA>) {
    if ( /$start/ .. /$end/ ) {
        print unless /$start/ or /$end/;
    }
}

__DATA__
[local]
/home/user
[files]
test1.txt
test1.htm
[dest]
/home/dest
[server]
127.0.0.1

__END__

Sinan


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

Date: 8 Feb 2005 04:43:11 -0800
From: "evillen@innocent.com" <evillen@innocent.com>
Subject: Re: Array reference not consistently interpolating
Message-Id: <1107866591.176771.239540@c13g2000cwb.googlegroups.com>

Gunnar Hjalmarsson wrote:
> evillen@innocent.com wrote:
> > I am trying to pass an array reference to a subroutine but get the
> > error:
> >
> > "Not an ARRAY reference at array_ref_test.txt line 14."
>
> You did not pass any array reference, to start with.
>
> > ## Please remove line numbers!
>
> Please don't include line numbers!
>
> Is this what you are trying to do:
>
>      my %symbols_and_data;
>      hash_sym( \@symbol_data );
>
>      sub hash_sym {
>          $symbols_and_data{ shift @{ $_[0] } } = $_[0];
>          foreach my $key ( keys %symbols_and_data ) {
>              print "\$key is: $key\n";
>              print "Elements in this hash key are: " .
>                join( ', ', @{ $symbols_and_data{$key} } ) . "\n";
>          };
>      }
>
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl

Thanks for your help Gunnar

After a bit of tweaking I got this code to work with the rest of my
program:

#! perl
use strict;
use warnings;

my @symbol_data = (
     'CONN_UMP_3MM_SMT',
     'sym.req:0554',
     'lib.name:conn_ump_3mm_smt',
     'height:3.00mm',
     'used:01ATiss1/WhitneyRF',
     'rev:2,NJH,26/05/04',
);

hash_sym( \@symbol_data );

sub hash_sym {
	my %symbols_and_data;
	$symbols_and_data{ shift @{ $_[0] } } = $_[0];
        foreach my $key ( keys %symbols_and_data ) {
	        print "\$key is: $key\n";
		print "Elements in this hash key are: " .
               join( ', ', @{ $symbols_and_data {$key} } ) . "\n";
		}; 
	}

___END___



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

Date: 8 Feb 2005 05:58:01 -0800
From: ioneabu@yahoo.com
Subject: copy directory structure without files
Message-Id: <1107871081.809139.271500@g14g2000cwa.googlegroups.com>

This will copy whole directory structure with files (Thanks Sherm! -
from old post).

#!/usr/bin/perl

use strict;
use warnings;

use File::NCopy;

my $copier = new File::NCopy(recursive=>1, force_write=>1);
$copier->copy('dir1', 'dir2'); #important: dir2 must exist first

QUESTION:  What if I want to copy the directory structure but not the
files?

I am putting together a photo album and will be using ImageMagick to
convert from huge size to 640x480 but I want to copy my original photo
directory structure first and then use ImageMagick to convert the
pictures and copy them to the new directories.

Thanks!

wana



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

Date: Tue, 08 Feb 2005 15:03:07 +0100
From: phaylon <phaylon@dunkelheit.at>
Subject: Re: copy directory structure without files
Message-Id: <pan.2005.02.08.14.03.07.101634@dunkelheit.at>

ioneabu wrote:

> use File::NCopy;
>  ...
> QUESTION:  What if I want to copy the directory structure but not the
> files?

In the docs I could'nt find (am I the only one getting »bad request« at
search.cpan.org?) any option which could do this. I don't know what the
original Thread was, so just the question: Why aren't you making this with
your shell? 'find', 'xargs' and 'mkdir' should be enough. It shouldn't
also be a great problem to do this in Perl with File::Find.

hth,
phay

-- 
http://www.dunkelheit.at/

The first rule of project mayhem is: you do not ask questions.
                              -- Fight Club



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

Date: 8 Feb 2005 07:37:05 -0800
From: ioneabu@yahoo.com
Subject: Re: copy directory structure without files
Message-Id: <1107877025.424513.214530@c13g2000cwb.googlegroups.com>


phaylon wrote:
> ioneabu wrote:
>
> > use File::NCopy;
> >  ...
> > QUESTION:  What if I want to copy the directory structure but not
the
> > files?
>
> In the docs I could'nt find (am I the only one getting =BBbad
request=AB at
> search.cpan.org?) any option which could do this. I don't know what
the
> original Thread was, so just the question: Why aren't you making this
with
> your shell? 'find', 'xargs' and 'mkdir' should be enough. It
shouldn't
> also be a great problem to do this in Perl with File::Find.

That's true.  I just thought it would make a great option to
File::NCopy and I was hoping there was a trivial way to do it.  I'll
get to work on doing it that way.  Like this?

use strict;
use warnings;
use File::Find;
use File::Path;

my ($source, $target) =3D @ARGV;
my @paths;
find sub {push @paths, "$target/$File::Find::name" if -d and not
/^\.{1,2}/;}, $source;
mkpath "$_" for @paths;

>
> hth,
> phay
>
> --
> http://www.dunkelheit.at/
>
> The first rule of project mayhem is: you do not ask questions.
>                               -- Fight Club



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

Date: 8 Feb 2005 14:22:26 GMT
From: mjl69 <mjl69mjl69@myaccmyacc.net>
Subject: Re: Exception handling in class: question
Message-Id: <36s092F56o6moU1@individual.net>


> When looking at this, I think that a BLOCK-eval wouldn't be that bad
> afterall.  What people like to forget is that die/croak's argument
> doesn't have to be a string. It may also be an object which will then be
> in $@.  So if 'meth' is this:
> 
>     package Class;
>     ...
>     sub meth {
> 	my $self = shift;
> 	...
> 	if (BAD_THING) {
> 	    croak Class::Exception->new(STRING);
> 	}
>     }
>     
>     package Class::Exception;
>     sub new { my ($class, $msg) = @_; bless \$msg => __PACKAGE__ }
>     sub msg { ${$_[0]} }
>     
> This could become:
> 
>     my @result = eval { $obj->meth };
>     if ($@) {
> 	die $@->msg;
>     }
> 
> The advantage besides mimicking the exception handling seen in other
> languages is that '$obj' does not need an additional '_error' slot. It's
> always nice not to have to change the structure of existing code.
> 
> Tassilo

I think I have a feeling for the overall problem here, but please correct me if I'm wrong. It seems that exception handling
is a form of error handling and that's where the confusion comes up.  A class could be set up to generate error messages
and put them somewhere, or, it could return undef or an error code (like 'system', which creates logic problems), or it could
generate an exception which will propagate up until it is handled or not handled.  In Java, exception handling is an integral
part of the language.  In many cases, you are forced to handle exceptions, even if your handling involves just passing them
along.  In a language like Perl, where there are so many different ways to do things and things are done in so many different
ways, there is no real standard to error handling by all.  For example, if I do this:

my @result = eval { $dbh->do($query) };
if ($@) 
{
   die "DBI error: $dbh->errstring();
}

the die function will never be called because DBI objects do not throw exceptions.  Which leads back to my original question.
If I make my class fail-proof and it never fails, it may mess up someone else's error handling who wants to use my class.

mjl


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

Date: 8 Feb 2005 06:06:22 -0800
From: leegee@gmail.com (Lee Goddard)
Subject: fields pragma
Message-Id: <30da21ec.0502080606.27ee9ced@posting.google.com>

Is it possible to use the fields pragma to specify the type of each
object member/field?

If not, is there a modulelist module which allows this to be done?

tia
lee


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

Date: Tue, 8 Feb 2005 07:10:59 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Learning Perl - resources and ideas
Message-Id: <slrnd0hej3.u40.tadmc@magna.augustmail.com>

Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> AnOvercomer02@webtv.net (Cody Houston) wrote:


> The subject is totally 
> off topic in the groups rec.photo.digital and rec.photo.equipment.35mm, 
> which you had stated in a Followup-To: header,


Off to the killfile he goes...


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Tue, 08 Feb 2005 12:07:27 +0100
From: phaylon <phaylon@dunkelheit.at>
Subject: Re: Perl - permute?
Message-Id: <pan.2005.02.08.11.07.27.797256@dunkelheit.at>

John Bokma wrote:

> At least I don't do it as an anonymous carrion bird.

Yeah, anonymous, right, good Joke. You've realized you're in the Internet,
right?

-- 
http://www.dunkelheit.at/
I want, therefore I can.



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

Date: Tue, 08 Feb 2005 12:05:41 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Perl - permute?
Message-Id: <pW1Od.22665$uc.17072@trnddc09>

phaylon wrote:
> Yeah, anonymous, right, good Joke. You've realized you're in the
> Internet, right?

Really? I thought CLPM was Usenet? Amazing, there is always something new to 
learn.

jue 




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

Date: Tue, 08 Feb 2005 13:10:17 +0100
From: phaylon <phaylon@dunkelheit.at>
Subject: Re: Perl - permute?
Message-Id: <pan.2005.02.08.12.10.17.32364@dunkelheit.at>

Jürgen Exner wrote:

> Really? I thought CLPM was Usenet? Amazing, there is always something new
> to learn.

I don't get it.

-- 
http://www.dunkelheit.at/
That is not dead, which can eternal lie,
and with strange aeons even death may die.
		-- H.P. Lovecraft



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

Date: 08 Feb 2005 13:17:20 +0100
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: Perl - permute?
Message-Id: <yzd1xbr4567.fsf@invalid.net>


phaylon <phaylon@dunkelheit.at> writes:
> John Bokma wrote:
> 
> > At least I don't do it as an anonymous carrion bird.
> 
> Yeah, anonymous, right, good Joke. You've realized you're in the Internet,
> right?

You do have a name, don't you?


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

Date: Tue, 08 Feb 2005 13:19:36 +0100
From: phaylon <phaylon@dunkelheit.at>
Subject: Re: Perl - permute?
Message-Id: <pan.2005.02.08.12.19.36.174440@dunkelheit.at>

Arndt Jonasson wrote:

> You do have a name, don't you?

Jep. I have. 

-- 
http://www.dunkelheit.at/
sapere aude.



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

Date: Tue, 8 Feb 2005 07:08:25 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Perl - permute?
Message-Id: <slrnd0hee9.u40.tadmc@magna.augustmail.com>

phaylon <phaylon@dunkelheit.at> wrote:
> Jürgen Exner wrote:
> 
>> Really? I thought CLPM was Usenet? Amazing, there is always something new
>> to learn.
> 
> I don't get it.


Usenet is but one of the many services that comprise The Internet.

ie. it is a subset of The Internet


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Tue, 08 Feb 2005 14:13:44 +0100
From: phaylon <phaylon@dunkelheit.at>
Subject: Re: Perl - permute?
Message-Id: <pan.2005.02.08.13.13.44.874774@dunkelheit.at>

Tad McClellan wrote:

> Usenet is but one of the many services that comprise The Internet.
> 
> ie. it is a subset of The Internet

Yeah, that's wonderful clear and obvious, so I thought didn't get
Jürgen's joke.


p

-- 
http://www.dunkelheit.at/
That is not dead, which can eternal lie,
and with strange aeons even death may die.
		-- H.P. Lovecraft



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

Date: 08 Feb 2005 15:04:43 +0100
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: Perl - permute?
Message-Id: <yzdwttj2lms.fsf@invalid.net>


Tad McClellan <tadmc@augustmail.com> writes:
> phaylon <phaylon@dunkelheit.at> wrote:
> > Jürgen Exner wrote:
> > 
> >> Really? I thought CLPM was Usenet? Amazing, there is always something new
> >> to learn.
> > 
> > I don't get it.
> 
> 
> Usenet is but one of the many services that comprise The Internet.
> 
> ie. it is a subset of The Internet

And once even that wasn't true.


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

Date: Tue, 08 Feb 2005 09:50:38 -0500
From: zentara <zentara@highstream.net>
Subject: Re: ptk_steal
Message-Id: <a7kh019213h8kk7j26402fvjuobio97730@4ax.com>

On Mon, 07 Feb 2005 10:03:47 -0500, JiggaHertz <JiggaHertz@nospam.com>
wrote:

>I'm trying to use the ptk_steal script that I found on the 
>comp.lang.perl.tk group and I'm getting 2 individual windows instead of 
>an xterm inside of a tk frame.  Here's the output of xwininfo for those 
>windows:

From what you are saying, you want an xterm in a Tk window. The script
you refer to does something different.

Here is what you want:
#!/usr/bin/perl -w
use strict;
use Tk;

# Idea ripped from a script by Christophe Mertz of the 
# Tk::Zinc module, to work with a plain canvas. 
# The Zinc module has much more flexibility in how 
# you can hide windows. I had to mask the xterm with a 
# toplevel to hide it in the plain old canvas. 
#  

my $mw = MainWindow->new();

my $canv = $mw->Canvas(-bg => 'lightsteelblue',
     -relief => 'sunken',
     -width => 550,
     -height => 350)->pack(-expand => 1, -fill => 'both');

my $xtermWidth = 400;
my $xtermHeight = 300;

## this Frame is needed for including the xterm in Tk::Canvas 
my $xtermContainer = $canv->Frame(-container => 1);
my $xtid = $xtermContainer->id();
# converting the id from HEX to decimal as xterm requires a decimal Id 
my ($xtId) = sprintf hex $xtid;

my $dcontitem = $canv->createWindow(275,175,
   -window => $xtermContainer,
   -width => $xtermWidth+100,
   -height => $xtermHeight,
   -state => 'normal');

my $label = $canv->createText( 275,10,
       -text => "Hide xterm",
       );

$canv->Tk::bind("<Button-1>", \&hideShow);

my $width = $xtermWidth;
my $height = $xtermHeight;

$mw->Button(-text => "Exit", -command => [sub{Tk::exit}] )->pack(  );

my $tl; #used to mask xterm 
system("xterm -into $xtId &");

MainLoop();

sub hideShow {
    if ($canv->itemcget($label, -text) =~ /Hide/) {
             $canv->itemconfigure($label,
                    -fill => 'white',
                    -text => "Show xterm");

             $tl = $mw->Toplevel(-use=>$xtId );
           } else {
             $canv->itemconfigure($label,
                    -fill => 'black',
                    -text => "Hide xterm");
             $tl->withdraw;
        }
}
__END__


-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html


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

Date: Tue, 08 Feb 2005 10:23:51 -0500
From: JiggaHertz <JiggaHertz@nospam.com>
Subject: Re: ptk_steal
Message-Id: <bQ4Od.88$cr2.74@llnews.ll.mit.edu>

zentara wrote:
> On Mon, 07 Feb 2005 10:03:47 -0500, JiggaHertz <JiggaHertz@nospam.com>
> wrote:
> 
> 
>>I'm trying to use the ptk_steal script that I found on the 
>>comp.lang.perl.tk group and I'm getting 2 individual windows instead of 
>>an xterm inside of a tk frame.  Here's the output of xwininfo for those 
>>windows:
> 
> 
> From what you are saying, you want an xterm in a Tk window. The script
> you refer to does something different.
> 
> Here is what you want:
> #!/usr/bin/perl -w
<code removed>
> system("xterm -into $xtId &");
<code removed>

The xterm on my system doesn't allow a -into command line switch.  Also 
I was hoping to generalize this to embed other application windows.

Thanks for your help,
JH


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

Date: 8 Feb 2005 07:06:19 -0800
From: "Mark (News)" <news@mail.adsl4less.com>
Subject: Re: Regular expression woes
Message-Id: <1107875179.397295.104110@c13g2000cwb.googlegroups.com>

The if (! some-test) { ... } has the negation as part of the if
statement (I may have erroneously called this negation "using the
shell", whereas it might have been more precise to say "part of the if
statement"). What I was challenging was to achieve the same result, but
keeping any negations inside the RE: if(some-re-test). Hope that makes
sense. My actual requirements are to enjoy solving this challenge -
nothing more. :-)



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

Date: Tue, 08 Feb 2005 12:18:38 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: should be simple..but eh  Can you help
Message-Id: <Xns95F74A69FCF28asu1cornelledu@127.0.0.1>

"Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net> wrote in 
news:Xns95F758BBEEE99elhber1lidotechnet@62.89.127.66:

> "A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote:
> 
> [...]
> 
>> By the way, minor but important point
> 
> Can something be minor *and* important? ;-)

Ooops! Thanks for the correction. 

Sinan.


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

Date: Tue, 8 Feb 2005 06:32:30 -0800
From: "mothra" <mothra@nowhereatall.com>
Subject: Re: To compare dates in a script
Message-Id: <4208cce2$1@usenet.ugs.com>


<clearguy02@yahoo.com> wrote in message
news:1107813544.944788.294170@c13g2000cwb.googlegroups.com...
> Hi all,
>
> Below is the scenario.
>
> I have a file that has two entrees (a name and a date) seperated by a
> tab. I need to get only all those names in the file if the date on the
> each line is greater than a certain date, 12-31-2004.
>
Something like this might work. It uses DateTime

use strict;
use warnings;
use DateTime;
use DateTime::Format::Strptime;

#target date
my $dt1 = DateTime->new(
  year  => 2004,
  month => 12,
  day   => 31,
);

my $Strp = new DateTime::Format::Strptime(
  pattern => '%d-%b-%y',
);
while (<DATA>) {
    chomp;
    my ( $file, $date ) = split /\s+/;
    my $dt2 = $Strp->parse_datetime($date);

    if ( $dt1 > $dt2 ) { print "Date from file is before\n"; }
    if ( $dt1 == $dt2 ) { print "Dates are the same\n"; }
    if ( $dt1 < $dt2 ) { print "Date from file is after\n"; }

}

__DATA__
5.5.25.50 01-Feb-05
TEST1         22-Jul-04
BSTOP         03-Sep-02
DB00004639 21-Jan-05
DB00004693 25-Jan-05
CDM_3.1.0 27-May-03

I hope this helps

Mothra




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

Date: Tue, 08 Feb 2005 15:57:42 +0100
From: phaylon <phaylon@dunkelheit.at>
Subject: Re: To compare dates in a script
Message-Id: <pan.2005.02.08.14.57.41.432853@dunkelheit.at>

clearguy02 wrote:

> I have a file that has two entrees (a name and a date) seperated by a tab.
> I need to get only all those names in the file if the date on the each
> line is greater than a certain date, 12-31-2004.

Just for curiousity: Only that date? I just ask because Dec 31 is the last
day in '04, so you could just check the last two chars and put all out
which are higher than 04, like this:

#!/usr/bin/perl
use warnings;
use strict;

while( <DATA> ) {
    chomp;
    if( /^.+\s+[0-9]{2}-[a-z]+-([0-9]{2})$/i ) {
        print "$_\n" if $1 > 4;
    }
}

__DATA__
5.5.25.50   01-Feb-05
TEST1       22-Jul-04
BSTOP       03-Sep-02
DB00004639  21-Jan-05
DB00004693  25-Jan-05
CDM_3.1.0   27-May-03
__END__

hth,
phay

-- 
http://www.dunkelheit.at/
Thru the darkness of futures past, the magician longs to see.
One chants out between two worlds: Fire, walk with me.
                                     -- Twin Peaks, »Bob«



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

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


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