RE: Missing something about arrays.

2002-12-04 Thread Beckett Richard-qswi266
Hmmm...Both replies haven't helped, I didn't understand Bruno's at all!
(sorry Bruno).

Maybe I should include a bit more of what I'm doing. My buttons are defined
thusly...

use Tk;
my $save = $frame - Button (
  -text = Save,
  -command = \ftp,
  )- pack ();

my $exit = $frame - Button (
  -text = Exit,
  -borderwidth = 5,
  -width = '10',
  -command = \ftp,
  )- pack ();

etc...

Then, I want a routine to disable all the buttons in one swell foop, sort of
like this...

our @buttons = (\$save, \$exit, etc, etc);
sub disable_buttons {
  foreach $buttons (@buttons) {
 $buttons - configure (-state = 'disable');
  }
}

The normal, and much more laborious way would be like this...

sub disable_buttons {
   $save - configure (-state = 'disable');
   $exit - configure (-state = 'disable');
   etc.
   etc.
}

Thanks.

R.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Making a line graph

2002-12-04 Thread Ian Robertson








Hi All,



I need to write a script to produce a line graph (quick and
dirty to prove a point)!



Can anybody recommend the best module to use?



Many thanks,



Ian.












RE: Making a line graph

2002-12-04 Thread Charbeneau, Chuck
 From: Ian Robertson [mailto:[EMAIL PROTECTED]] 
 Subject: Making a line graph


 I need to write a script to produce a line graph 
 (quick and dirty to prove a point)!
 
Can anybody recommend the best module to use?

The Chart module offers a quick interface.

C-.

CODE

use strict;
use Chart::Lines; 
my $outfile = 'PATH TO PNG\graphoutput.png';

my @LEGENDS = qw (SetOne SetTwo SetThree SetFour) ;
my @plotdata = (
[First, Second, Third, Fourth, Fifth, Sixth],
[12, 9, 2, 23, 9, -2],
[1, 3, 5, 7, 9, 11],
[3, 17, 7, 9, 11, 13],
[0, 12, 0, 12, 0, 12],
);
my $graph = Chart::Lines-new (640,480) or die $!;;
   $graph-set(
grid_lines = 'true',
title = 'Title of my Graph',
dclrs = [qw(
lred lorange lyellow lgreen lblue lpurple
dred  orange dyellow dgreen dblue dpurple
)],
   );
$graph-set ('legend_labels' = \@LEGENDS);
$graph-png($outfile, \@plotdata);

/CODE
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: Making a line graph

2002-12-04 Thread Ian Robertson

Chuck,

This is fantastic, thanks so much for your efforts! 

I really appreciate the help.

Ian.

-Original Message-
From: Charbeneau, Chuck [mailto:[EMAIL PROTECTED]] 
Sent: 04 December 2002 14:32
To: 'Ian Robertson'; [EMAIL PROTECTED]
Subject: RE: Making a line graph

 From: Ian Robertson [mailto:[EMAIL PROTECTED]] 
 Subject: Making a line graph


 I need to write a script to produce a line graph 
 (quick and dirty to prove a point)!
 
Can anybody recommend the best module to use?

The Chart module offers a quick interface.

C-.

CODE

use strict;
use Chart::Lines; 
my $outfile = 'PATH TO PNG\graphoutput.png';

my @LEGENDS = qw (SetOne SetTwo SetThree SetFour) ;
my @plotdata = (
[First, Second, Third, Fourth, Fifth,
Sixth],
[12, 9, 2, 23, 9, -2],
[1, 3, 5, 7, 9, 11],
[3, 17, 7, 9, 11, 13],
[0, 12, 0, 12, 0, 12],
);
my $graph = Chart::Lines-new (640,480) or die $!;;
   $graph-set(
grid_lines = 'true',
title = 'Title of my Graph',
dclrs = [qw(
lred lorange lyellow lgreen lblue lpurple
dred  orange dyellow dgreen dblue dpurple
)],
   );
$graph-set ('legend_labels' = \@LEGENDS);
$graph-png($outfile, \@plotdata);

/CODE

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Invoking Help

2002-12-04 Thread Terry Franklin

Hi all, can someone point me in the correct direction for invoking help
files from within a Perl TK application running on Microsoft Windows 98 on
up to 2000?

People are asking for online help files in my perl apps like they have in
their other applications, and I cannot find what I need to do.

Thx
Terry
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Puzzle of the Week

2002-12-04 Thread Erich C. Beyrent
Hey everyone,

I have a string of data that I am parsing that looks like this:

# Replace all of the apostrophed days of week
if ($text =~ s/(Sunday's)|(Sunday's Games)/)
{
$day = Sunday;
$text =~ s/(Sunday's)|(Sunday's Games)//;
}
elsif ($text =~ s/(Monday's)|(Monday's Games)/)
{
$day = Monday;
$text =~ s/(Monday's)|(Monday's Games)//;
}
elsif ($text =~ s/(Tuesday's)|(Tuesday's Games)/)
{
$day = Tuesday;
$text =~ s/(Tuesday's)|(Tuesday's Games)//;
}
elsif ($text =~ s/(Wednesday's)|(Wednesday's Games)/)
{
$day = Wednesday;
$text =~ s/(Wednesday's)|(Wednesday's Games)//;
}
elsif ($text =~ s/(Thursday's)|(Thursday's Games)/)
{
$day = Thursday;
$text =~ s/(Thursday's)|(Thursday's Games)//;
}
elsif ($text =~ s/(Friday's)|(Friday's Games)/)
{
$day = Friday;
$text =~ s/(Friday's)|(Friday's Games)//;
}
elsif ($text =~ s/(Saturday's)|(Saturday's Games)/)
{
$day = Saturday;
$text =~ s/(Saturday's)|(Saturday's Games)//;
}

Surely there is a more efficient and cleaner way to code this.  Any and all
assistance is GREATLY appreciated.

Thanks!

-Erich-

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: Puzzle of the Week

2002-12-04 Thread Erich C. Beyrent
 Hey everyone,

 I have a string of data that I am parsing that looks like this:

 # Replace all of the apostrophed days of week
 if ($text =~ s/(Sunday's)|(Sunday's Games)/)
 {
 $day = Sunday;
 $text =~ s/(Sunday's)|(Sunday's Games)//;
 }
 elsif ($text =~ s/(Monday's)|(Monday's Games)/)
 {
 $day = Monday;
 $text =~ s/(Monday's)|(Monday's Games)//;
 }
 elsif ($text =~ s/(Tuesday's)|(Tuesday's Games)/)
 {
 $day = Tuesday;
 $text =~ s/(Tuesday's)|(Tuesday's Games)//;
 }
 elsif ($text =~ s/(Wednesday's)|(Wednesday's Games)/)
 {
 $day = Wednesday;
 $text =~ s/(Wednesday's)|(Wednesday's Games)//;
 }
 elsif ($text =~ s/(Thursday's)|(Thursday's Games)/)
 {
 $day = Thursday;
 $text =~ s/(Thursday's)|(Thursday's Games)//;
 }
 elsif ($text =~ s/(Friday's)|(Friday's Games)/)
 {
 $day = Friday;
 $text =~ s/(Friday's)|(Friday's Games)//;
 }
 elsif ($text =~ s/(Saturday's)|(Saturday's Games)/)
 {
 $day = Saturday;
 $text =~ s/(Saturday's)|(Saturday's Games)//;
 }

 Surely there is a more efficient and cleaner way to code this.  Any and
all
 assistance is GREATLY appreciated.

 Thanks!

 -Erich-


Ooops.  BAD BAD BAD.  Please ignore the obvious error of the s/ in the if ..
elsif statements...

-Erich-

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: Question on sub/method call and context

2002-12-04 Thread Thomas R Wyant_III

Burak Gürsoy [EMAIL PROTECTED] wrote:

 umm... did you read my message?

 wantarray is 'exactly' what you want

Second the motion. In fact, Last night I spent a little time writing a
rebuttal, but then I tried it, and you're exactly right. I figured this
would be the last word, but should have known better.

In support of the correct position:

C:\perldoc -f wantarray
wantarray
Returns true if the context of the currently executing
subroutine is looking for a list value. Returns false if the
context is looking for a scalar. Returns the undefined value if
the context is looking for no value (void context).

return unless defined wantarray;# don't bother doing more
my @a = complex_calculation();
return wantarray ? @a : @a;

This function should have been named wantlist() instead.


C:\

Tom Wyant



This communication is for use by the intended recipient and contains
information that may be privileged, confidential or copyrighted under
applicable law.  If you are not the intended recipient, you are hereby
formally notified that any use, copying or distribution of this e-mail,
in whole or in part, is strictly prohibited.  Please notify the sender
by return e-mail and delete this e-mail from your system.  Unless
explicitly and conspicuously designated as E-Contract Intended,
this e-mail does not constitute a contract offer, a contract amendment,
or an acceptance of a contract offer.  This e-mail does not constitute
a consent to the use of sender's contact information for direct marketing
purposes or for transfers of data to third parties.

 Francais Deutsch Italiano  Espanol  Portugues  Japanese  Chinese  Korean

http://www.DuPont.com/corp/email_disclaimer.html


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



perl-win32-users - Best way to return a path to a file ?

2002-12-04 Thread Neil



Hi,

I have just started to code up a subroutine to 
return the path only from a complete path to a file. This must the the 3rd time 
in two months as I have mislaid the routine on my HD and searching for it would 
probably take longer than the coding.

When writing this routine, I always seem to take 
the long way roundand this got my curiosity going and wondering what other 
solutions people have come up with that are more elegant and obvious than my 
own.

I find many times that looking at someone elses 
code can provide an "aha" moment that last far beyong the snippet 
involved.

If anyone cares to share their code for this - that 
would be cool. If not - thats cool too. I am gonna head back to the editor and 
throw it together - again ;-) and I'll post it later so we can flame it in a 
public display of humiliation ;-)

Neil


Re: Puzzle of the Week

2002-12-04 Thread Thomas R Wyant_III


The code:

while () {
$day = '';
print Before: $_;
s/(Monday|Tuesday|Wednesday|Thursday|Friday|
  Saturday|Sunday)'s(\s+Games)?//x and $day = $1;
print After: $_;
print Day = '$day'\n;
}

The test:

C:\perl trw.tmp
Yesterday's Games were boring
Before: Yesterday's Games were boring
After: Yesterday's Games were boring
Day = ''
Before Sunday's Games we partied
Before: Before Sunday's Games we partied
After: Before  we partied
Day = 'Sunday'
After sunday's games we had hangover
Before: After sunday's games we had hangover
After: After sunday's games we had hangover
Day = ''
Monday we had to be at work
Before: Monday we had to be at work
After: Monday we had to be at work
Day = ''
Monday's work was no fun
Before: Monday's work was no fun
After:  work was no fun
Day = 'Monday'

Yesterday's Games were boring was unaffected.
Before Sunday's Games we partied had Sunday's Games stripped, and $day set to 
Sunday.
After sunday's games we had hangovers was unaffected, because the match was 
case-sensitive.
Monday we had to be at work was unaffected, because Monday had no apostrophe
Monday's work was no fun had Monday's stripped, and $day set to Monday.

Tom Wyant




This communication is for use by the intended recipient and contains 
information that may be privileged, confidential or copyrighted under
applicable law.  If you are not the intended recipient, you are hereby
formally notified that any use, copying or distribution of this e-mail,
in whole or in part, is strictly prohibited.  Please notify the sender
by return e-mail and delete this e-mail from your system.  Unless
explicitly and conspicuously designated as E-Contract Intended,
this e-mail does not constitute a contract offer, a contract amendment,
or an acceptance of a contract offer.  This e-mail does not constitute
a consent to the use of sender's contact information for direct marketing
purposes or for transfers of data to third parties.

 Francais Deutsch Italiano  Espanol  Portugues  Japanese  Chinese  Korean

http://www.DuPont.com/corp/email_disclaimer.html


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: Puzzle of the Week

2002-12-04 Thread Scot Robnett
I'm sure there are more elegant ways to do this, and I'm sure they'll be
coming through the list shortly, but here's an option:


my @days =('Sunday','Monday','Tuesday',
'Wednesday','Thursday','Friday','Saturday');
foreach my $text(@days) {
 $text =~ s/day/day\'s Games/;
}


-
Scot Robnett
inSite Internet Solutions
[EMAIL PROTECTED]


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of
Erich C. Beyrent
Sent: Wednesday, December 04, 2002 10:34 AM
To: [EMAIL PROTECTED]
Subject: Puzzle of the Week


Hey everyone,

I have a string of data that I am parsing that looks like this:

# Replace all of the apostrophed days of week
if ($text =~ s/(Sunday's)|(Sunday's Games)/)
{
$day = Sunday;
$text =~ s/(Sunday's)|(Sunday's Games)//;
}
elsif ($text =~ s/(Monday's)|(Monday's Games)/)
{
$day = Monday;
$text =~ s/(Monday's)|(Monday's Games)//;
}
elsif ($text =~ s/(Tuesday's)|(Tuesday's Games)/)
{
$day = Tuesday;
$text =~ s/(Tuesday's)|(Tuesday's Games)//;
}
elsif ($text =~ s/(Wednesday's)|(Wednesday's Games)/)
{
$day = Wednesday;
$text =~ s/(Wednesday's)|(Wednesday's Games)//;
}
elsif ($text =~ s/(Thursday's)|(Thursday's Games)/)
{
$day = Thursday;
$text =~ s/(Thursday's)|(Thursday's Games)//;
}
elsif ($text =~ s/(Friday's)|(Friday's Games)/)
{
$day = Friday;
$text =~ s/(Friday's)|(Friday's Games)//;
}
elsif ($text =~ s/(Saturday's)|(Saturday's Games)/)
{
$day = Saturday;
$text =~ s/(Saturday's)|(Saturday's Games)//;
}

Surely there is a more efficient and cleaner way to code this.  Any and all
assistance is GREATLY appreciated.

Thanks!

-Erich-

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: Changing tk icon in focus

2002-12-04 Thread C. Church
- Original Message -
From: Matthew Greenberg [EMAIL PROTECTED]

 I was wondering if it is possible to change the tk icon in focus to a
 user defined image. If so, how?

I'm not sure what you mean by 'tk icon', but if you want to change the
properties of a widget when it comes into focus, perldoc Tk::bind

e.g.:

$imgWig-bind('FocusIn' = sub { $imgWig-configure(...); });

!c

C. Church
http://www.digitalKOMA.com/church/
http://www.DroneColony.com/



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: perl-win32-users - Best way to return a path to a file ?

2002-12-04 Thread Dirk Bremer \(NISC\)



Neil,

This is a little sub that I rolled up to provide the path, 
filename, and extension:

sub Fparse($){ local $_ = 
shift; my ($Delim, $Fp, $Fn, $Fe, $Pos1, 
$Pos2);

 # Check whether the filename contains 
forward or backward slashes. $Delim = (index($_,'/')  
-1) ? '/' : '\\';

 # Find the last slash in the 
filename. $Pos1 = rindex($_,$Delim);

 # Extract the path if 
present. if ($Pos1) {$Pos1++; $Fp = substr($_,0,$Pos1)} 
else {$Fp = undef; $Pos1 = 0}

 # Find the last period in the 
filename. $Pos2 = rindex($_,'.');

 # Extract the name and 
extension. if ($Pos2) {$Fn = substr($_,$Pos1,$Pos2 - 
$Pos1); $Pos2++; $Fe = substr($_,$Pos2)} else {$Fn = 
substr($_,$Pos1); $Fe = undef}

 
return(($Fp,$Fn,$Fe));}
=item Fparse($filename)

=item

=over 4

This routine accepts a string as an argument that will contain 
afilename and will parse the filename into the path, name, and 
fileextension. The parsed elements will be returned as an lvalue. An 
undefwill be returned for elements that do not exist in the passed filename, 
i.e.path and/or file extension.
You could select just the path like this, assuming $file 
contains the fully qualified filename:

($path, undef, undef) = Fparse($file);
Dirk Bremer - Systems Programmer II - ESS/AMS - NISC St. 
Peters636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]www.nisc.cc

  - Original Message - 
  From: 
  Neil 
  
  To: [EMAIL PROTECTED] 
  
  Sent: Wednesday, December 04, 2002 
  10:48
  Subject: perl-win32-users - Best way to 
  return a path to a file ?
  
  Hi,
  
  I have just started to code up a subroutine to 
  return the path only from a complete path to a file. This must the the 3rd 
  time in two months as I have mislaid the routine on my HD and searching for it 
  would probably take longer than the coding.
  
  When writing this routine, I always seem to take 
  the long way roundand this got my curiosity going and wondering what 
  other solutions people have come up with that are more elegant and obvious 
  than my own.
  
  I find many times that looking at someone elses 
  code can provide an "aha" moment that last far beyong the snippet 
  involved.
  
  If anyone cares to share their code for this - 
  that would be cool. If not - thats cool too. I am gonna head back to the 
  editor and throw it together - again ;-) and I'll post it later so we can 
  flame it in a public display of humiliation ;-)
  
  Neil


RE: perl-win32-users - Best way to return a path to a file ?

2002-12-04 Thread Edwards, Mark \(CXO\)
Title: Message



Try 
File::Basename and you won't have to reinvent the wheel.

  
  -Original Message-From: Neil 
  [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 04, 2002 
  9:48 AMTo: 
  [EMAIL PROTECTED]Subject: perl-win32-users 
  - Best way to return a path to a file ?Importance: 
  Low
  Hi,
  
  I have just started to code up a subroutine to 
  return the path only from a complete path to a file. This must the the 3rd 
  time in two months as I have mislaid the routine on my HD and searching for it 
  would probably take longer than the coding.
  
  When writing this routine, I always seem to take 
  the long way roundand this got my curiosity going and wondering what 
  other solutions people have come up with that are more elegant and obvious 
  than my own.
  
  I find many times that looking at someone elses 
  code can provide an "aha" moment that last far beyong the snippet 
  involved.
  
  If anyone cares to share their code for this - 
  that would be cool. If not - thats cool too. I am gonna head back to the 
  editor and throw it together - again ;-) and I'll post it later so we can 
  flame it in a public display of humiliation ;-)
  
  Neil


Re: perl-win32-users - Best way to return a path to a file ?

2002-12-04 Thread michael higgins
Edwards, Mark (CXO) wrote:

Try File::Basename and you won't have to reinvent the wheel.

-Original Message-
From: Neil [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, December 04, 2002 9:48 AM
To: [EMAIL PROTECTED]
Subject: perl-win32-users - Best way to return a path to a file ?
Importance: Low

Hi,
 
I have just started to code up a subroutine to return the path only
from a complete path to a file. This must the the 3rd time in two
months as I have mislaid the routine on my HD and searching for it
would probably take longer than the coding.
 
When writing this routine, I always seem to take the long way
round and this got my curiosity going and wondering what other
solutions people have come up with that are more elegant and obvious
than my own.
 
I find many times that looking at someone elses code can provide an
aha moment that last far beyong the snippet involved.
 
If anyone cares to share their code for this - that would be cool.
If not - thats cool too. I am gonna head back to the editor and
throw it together - again ;-) and I'll post it later so we can flame
it in a public display of humiliation ;-)
 
Neil


if you have 'use Win32;' at the head of your script:

from 'perldoc win32'

   Win32::GetFullPathName(FILENAME)
   [CORE] GetFullPathName combines the FILENAME with the current drive
   and directory name and returns a fully qualified (aka, absolute)
   path name. In list context it returns two elements: (PATH, FILE)
   where PATH is the complete pathname component (including trailing
   backslash) and FILE is just the filename part. Note that no attempt
   is made to convert 8.3 components in the supplied FILENAME to
   longnames or vice-versa. Compare with Win32::GetShortPathName and
   Win32::GetLongPathName.

   This function has been added for Perl 5.6.




--
Michael Higgins
Development Associate
Joseph Slifka Center
  for Jewish Life at Yale
[EMAIL PROTECTED]

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs