Compare two array's

2004-01-07 Thread Jerry Preston
Hi!,

I know that this is a no brainer, but I cannot not get it!  I want to
compare two arrays and delete the same values in one array.

foreach $j ( @a1 ) {
  foreach $p ( @a2 ) {
$a2[ $p ] = undef  if $a1[ $j ] == $a2 $p ];
  }
}

What is wrong and is there a better, PERL way to do this?

Thanks,

Jerry


Re: What is the source of my input, file or STDIN?

2004-01-07 Thread John W. Krahn
[EMAIL PROTECTED] wrote:
 
 As I understand it,  operator will open all items in @ARGV allowing
 one to do a shell command line of
 
perl.script file1 file2 file3
 
 and inside perl.script you only need
 
 while () { ... syntax to read all the files on the command line.
 
  will also open STDIN if the perl script is invoked from a pipe, such
 as
 
 ls | perl.script
 
 So, 1. from within perl.script, how can one tell if the input stream is
 coming from
 STDIN or a file that was opened by ?
 
 2. If input stream is not coming from STDIN, but a file, how can one
 tell which file is the current file (assuming multiple files were
 specified on the command line)?

$ARGV will contain the name of the current file or '-' if reading from
STDIN.

$ perl -le'while () {eof  print $ARGV}' test.txt test1.txt
test.txt
test1.txt
$ perl -le'while () {eof  print $ARGV}'  test.txt
-
$ cat test.txt | perl -le'while () {eof  print $ARGV}'   
-



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Learning Objects, destroy methods

2004-01-07 Thread Gary Stainburn
On Tuesday 06 January 2004 6:09 pm, Randal L. Schwartz wrote:
  Gary == Gary Stainburn [EMAIL PROTECTED] writes:

 Gary My idea is to keep only the %_BLOCKS as a strong ref and weaken
 Gary all others.  That way, I can guarantee that when I delete that
 Gary ref the object will be destroyed.

 I do believe you want it the other way around.

Hi Randal,

I've read the column you mentioned in a previous post, and I see what you mean 
with the above statement.

However, I believe what I am right for the effects I want.

my %_BLOCKS is the equivelent of your %REGISTRY, and when a block gets created 
I add it to %_BLOCKS.  However, I want that block to remain after the block 
that created it has finished - hence keeping it as a strong ref. (think init 
function which reads track definition from file then exits)

I also want to be confident that when I want to delete the block the object is 
actually deleted, hence weakening ALL other references to it.

However, as I said in a response to Rob, provided I don't do sloppy coding the 
problem should never arise anyway.
-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Adding white spaces

2004-01-07 Thread John W. Krahn
Jakob Kofoed wrote:
 
 Hi All,

Hello,

 I have a file looking like (where \n is new line):
 
 blabla\n
 blablablablablabla\n
 blablablablablablablablablabla\n
 blabla\n
 
 but I need every line to have 80 characters - in this case filled with white
 space.
 
 I can figure out how to do it when I have the same character number in every
 line - but when the lines changes in length - I'm lost!!
 
 The output should look like:
 
 blabla
 \n
 blablablablablabla
 \n
 blablablablablablablablablabla
 \n
 blabla
 \n
 
 I would appreciate any suggestions or hints.

You can use the pack function for this:

while ( FILE ) {
chomp;
print pack( 'A80', $_ ), \n;
}



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Compare two array's

2004-01-07 Thread Jan Eden
Maybe the missing opening bracket on the third line?

$a2[$p] = undef  if $a1[$j] == $a2[$p];

Being a beginner myself, I cannot recommend a better way.

- Jan

Jerry Preston wrote:

Hi!,

I know that this is a no brainer, but I cannot not get it!  I want to
compare two arrays and delete the same values in one array.

foreach $j ( @a1 ) {
  foreach $p ( @a2 ) {
$a2[ $p ] = undef  if $a1[ $j ] == $a2 $p ];
  }
}

What is wrong and is there a better, PERL way to do this?
-- 
There are 10 kinds of people:  those who understand binary, and those who don't

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Compare two array's

2004-01-07 Thread John W. Krahn
Jerry Preston wrote:
 
 Hi!,

Hello,

 I know that this is a no brainer, but I cannot not get it!  I want to
 compare two arrays and delete the same values in one array.
 
 foreach $j ( @a1 ) {
   foreach $p ( @a2 ) {
 $a2[ $p ] = undef  if $a1[ $j ] == $a2 $p ];
   }
 }
 
 What is wrong and is there a better, PERL way to do this?

No, but there is a Perl way to do it:   :-)

@a2 = do {
my %seen;
@seen{ @a1 } = ( 1 ) x @a1;
grep !$seen{ $_ }, @a2;
};



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Using File::Find to generate playlists

2004-01-07 Thread Alan
Ok, please don't laugh.  This is my very first shot at Perl and if I 
learn something, I'll be putting it to use for more important tasks.

Thanks in advance for any comments.


#!/usr/bin/perl

# A dorkey little perl script using File::Find.  The idea is to recurse
# subdirectories and write an .ASX file (sequenced playlist of file 
# names) to each subdirectory for the files located there.

# Aside from the slight This doesn't work as expected problem ...
# the following I haven't yet figured out:
#
# 1. The 'outfile.asx' needs to take its name from the current directory
#name and not be arbitrarily set to some predefined name 
#(outfile.asx in this case). Maybe munge the fully qualified path 
#somehow, or go back to READDIR? g
#
# 2. How does one set the top directory for File::Find to the directory
#in which the script is run?

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

find ( {
   wanted = \wanted,
   preprocess = \preprocess,
}, @ARGV);

sub wanted {
   if (-f _) { # check for avi, mpg, mpeg, divx, etc.?
  open( OUTFILE, $File::Find::dir/outfile.asx )
 or die( Cannot open $File::Find::dir/ .outfile.asx: $! );
  print( OUTFILE Entry\n );
  print( OUTFILERef href = \$File::Find::name\\n );
  print( OUTFILE Entry \n\n );
  close( OUTFILE ) 
 or die( Cannot close $File::Find::dir/ . outfile.asx: $! );
   }
}

sub preprocess {
   print Processing directory $File::Find::dir ...\n;
   open( OUTFILE, $File::Find::dir/outfile.asx )
  or die( Cannot open $File::Find::dir/ . outfile.asx: $! );
   print( OUTFILE Asx Version = \3.0\\n );
   print( OUTFILE Title/Title\n );
   print( OUTFILE Abstract/Abstract\n );
   print( OUTFILE Copyright/Copyright\n );
   print( OUTFILE Author/Author\n\n );
   close( OUTFILE ) 
 or die( Cannot close $File::Find::dir/ . outfile.asx: $! );

   sort { uc $a cmp lc $b } @_;
}




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Perl equivalent of Ruby/DL?

2004-01-07 Thread Rob Dixon
David Garamond wrote:

 Ruby/DL is a Ruby module that enables one to load a .DLL/.so and start
 using exported functions available in the DLL. It's a nice alternative
 of using an external library without messing with XS or writing real C
 files. Ruby/DL has been included in the standard Ruby distribution since
 1.8.

   http://ttsky.net/ruby/ruby-dl.html

 I wonder if CPAN has something similar to this.

Hi Dave.

You could take a look at Win32::API.

HTH,

Rob



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Compare two array's

2004-01-07 Thread Rob Dixon
Jerry Preston wrote:

 I know that this is a no brainer, but I cannot not get it!  I want to
 compare two arrays and delete the same values in one array.

 foreach $j ( @a1 ) {
   foreach $p ( @a2 ) {
 $a2[ $p ] = undef  if $a1[ $j ] == $a2 $p ];
   }
 }

 What is wrong and is there a better, PERL way to do this?

The first thing that's wrong is you're not starting with

  use strict;
  use warnings;

Your code doesn't work because you're iterating over the
values in the arrays instead of the indices. This will
work as you intended

  foreach my $j (0 .. $#a1) {
foreach my $p (0 .. $#a2) {
  $a2[$p] = undef if $a1[$j] == $a2[$p];
}
  }

but you'll get warnings when undefined elements of
@a2 are being compared.

The Perl way to do it is to build a hash of the elements
of @a1 like this

  my %a1 = map(($_, 1), @a1);
  foreach (@a2) { $_ = undef if $a1{$_} };

HTH,

Rob



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




symbolic references and hashes

2004-01-07 Thread Gary Stainburn
Hi folks,

I've got the code:

package Trainset;

my %_BLOCKS=(); # blocks of track
my %_TRAINS=(); # trains
my %_BOXS=();   # signalboxes

sub blocks { # Return list of blocks
  sort keys %_BLOCKS;
}
sub trains { # Return list of trains
  sort keys %_TRAINS;
}
sub boxes { # Return list of signalboxes
  sort keys %_BOXS;
}

I wanted to eliminate the duplicated code so I wrote:

sub list {
  my $self=shift;
  my $key=uc(shift);
  print using '_$key' as hash name\n;
  return sort keys %${_$key};
}

which according to the section of symbolic references in perldoc perlrefs 
should work.  However, while Trainset-blocks returns the list, 
Trainset-list('blocks') doesn't.

Can anyone spot the problem or suggest an alternative please.

-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




putting $1 into a var

2004-01-07 Thread angie ahl
hi people

I'm trying to get the value of $1 into a var, the following don't work
and I can't figure out why

$_ = $html_body;
my ($resrow) = m#!-- VM: resrow --(.*?)!-- VM: /resrow --#;
#print $1;
print $resrow;

$resrow holds nothing, however if I print $1 I do have a match

$_ = $html_body;
m#!-- VM: resrow --(.*?)!-- VM: /resrow --#;
my $resrow = $1;
print $resrow;

doesn't work either.

How do I get $1 into a var for later use. It's driving me a little loopy
now.

I'm basically trying to extract the middle bit into a var of it's own. I
thought that would be easy 

Cheers

Angie



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: putting $1 into a var

2004-01-07 Thread Charles K. Clarkson
angie ahl [EMAIL PROTECTED] wrote:
: 
: I'm trying to get the value of $1 into a var, the following
: don't work and I can't figure out why
: 
: $_ = $html_body;
: my ($resrow) = m#!-- VM: resrow --(.*?)!-- VM: /resrow --#;
: #print $1;
: print $resrow;
: 
: $resrow holds nothing, however if I print $1 I do have a
: match
: 
: $_ = $html_body;
: m#!-- VM: resrow --(.*?)!-- VM: /resrow --#;
: my $resrow = $1;
: print $resrow;

Perhaps $html_body does not hold what you think it holds.
Commenting one line or the other seemed to work fine for me.

$_ = q|!-- VM: resrow --foo!-- VM: /resrow --|;

my ($resrow) = m#!-- VM: resrow --(.*?)!-- VM: /resrow --#;
print $1;
print $resrow;

__END__
Prints:
foofoo


HTH,

Charles K. Clarkson
-- 
Head Bottle Washer,
Clarkson Energy Homes, Inc.
Mobile Home Specialists
254 968-8328


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: putting $1 into a var

2004-01-07 Thread Rob Dixon
Angie Ahl wrote:

 I'm trying to get the value of $1 into a var, the following don't work
 and I can't figure out why

 $_ = $html_body;
 my ($resrow) = m#!-- VM: resrow --(.*?)!-- VM: /resrow --#;
m#!-- VM: resrow --(.*?)!-- VM: /resrow --#;
 #print $1;
 print $resrow;

 $resrow holds nothing, however if I print $1 I do have a match

 $_ = $html_body;
 m#!-- VM: resrow --(.*?)!-- VM: /resrow --#;
 my $resrow = $1;
 print $resrow;

 doesn't work either.

 How do I get $1 into a var for later use. It's driving me a little loopy
 now.

 I'm basically trying to extract the middle bit into a var of it's own. I
 thought that would be easy

Hi Angie.

It looks like your regex isn't matching. $1 will keep the value captured by
the last successful match.

Try this code. (The 'for ($html_body) { .. }' aliases $_ with $html_body
for the extent of the code block.)

  my $resrow;

  for ($html_body) {
if (m#!-- VM: resrow --(.*?)!-- VM: /resrow --#) {
  $resrow = $1;
}
else {
  die No match for HTML;
}
  }

  print $resrow, \n;

So I guess you need to fix your regex. Is it possible that the actual
text contains a newline? In which case you need to replace spaces with
'\s+'.

HTH,

Rob



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: symbolic references and hashes

2004-01-07 Thread Rob Dixon

Gary Stainburn [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
 Hi folks,

 I've got the code:

 package Trainset;

 my %_BLOCKS=(); # blocks of track
 my %_TRAINS=(); # trains
 my %_BOXS=();   # signalboxes

 sub blocks { # Return list of blocks
   sort keys %_BLOCKS;
 }
 sub trains { # Return list of trains
   sort keys %_TRAINS;
 }
 sub boxes { # Return list of signalboxes
   sort keys %_BOXS;
 }

 I wanted to eliminate the duplicated code so I wrote:

 sub list {
   my $self=shift;
   my $key=uc(shift);
   print using '_$key' as hash name\n;
   return sort keys %${_$key};
 }

 which according to the section of symbolic references in perldoc perlrefs
 should work.  However, while Trainset-blocks returns the list,
 Trainset-list('blocks') doesn't.

 Can anyone spot the problem or suggest an alternative please.

You're trying to dereference $_BLOCKS as a hash reference. Use

  return sort keys %{_$key};

and it should work. But note that it won't return the keys from
the lexical ('my') hashes that you've used in your code: only
package ('our') variables are accessible by name.

Even so it's a horrible thing to be doing, if only because you
can't 'use strict'. This might be better

  sub list {
my $self = shift;
my %hash = (
  BLOCKS = \%_BLOCKS,
  TRAINS = \%_TRAINS,
  BOXS = \%_BOXS,
);
my $key = uc shift;

print using '_$key' as hash name\n;
return sort keys %{$hash{$key}};
  }

but I'd rather see this implemented as an object method with
the hashes stored as $object-{_BLOCKS} etc. As it stands your
Trainset class is working as an object, and you can never have
more than one trainset in your program.

HTH,

Rob



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Fixed Length Text Extract, Write to Excel

2004-01-07 Thread William Martell
Hello All,

I am trying to work with the code I have to extract fields from a text file report, 
and write the values into excel.

I am having trouble. 

When I get to push @order_detail, %item
I understand that this is pushing an associative array onto a list. (array
of hashes)

I am trying to write code that will open a new worksheet in excel and print
the values of %item onto a row.  When Perl encounters a certain key
(cust_number), I would like it to start a new row.

I have tried keys(), values(), pop() but I can't get it right.  I think some
of my trouble is b/c of the reference \%item.  When I remove the reference
backslash operator like this %item and type print. Perl returns with the
contents in scalar.

So.  My main question is how do I access the values and keys of %item in
@order_detail???
















[code]

#!/perl -w
use strict;
use Data::Dumper;
use Win32::OLE;


###
# CODE TO READ FROM FIXED LENGTH TEXT FILE

###


my $file = 'Artb30.da4';
open INFILE, $file or die Can't open $file: $!;

my @order_detail;
while ( INFILE ) {
last if /^GROUP TOTALS/;
s/\s+\Z//;  # remove all trailing whitespace
next unless /\d\.\d\d\Z/;   # only want lines with dollar amounts at end
my %item;
if ( length()  120 ) { # item 1 lines are shorter
@item{ qw/cust_number cust_name cycle customer_type acct_contact
phone credit_limit/ } =
map { s/^\s+//; $_ }
unpack 'A6 x2 A30 x2 A5 x2 A15 x2 A20 x2 A15 x2 A*', $_;
# unpack'A' removes trailing whitespace so we need the map{}
# to remove leading whitespace
}
elsif ( /^\d/ ) {   # item 2 lines start with a digit
@item{ qw/inv_no type inv_date current days_1_30 days_31_60
days_61_90 days_over_90 on_hold unap_cash total_ar/ } =
map { s/^\s+//; $_ }
unpack 'A6 x A3 x A8' . 'x3 A11' x 8, $_;
}
else {  # item 3 lines
@item{ qw/cust_totals_current cust_totals_days_1_30
cust_totals_days_31_60
cust_totals_days_61_90 cust_totals_days_over_90
cust_totals_on_hold
cust_totals_unap_cash cust_totals_total_ar/ } =
map { s/^\s+//; $_ }
unpack 'x19' . 'x3 A11' x 8, $_;
}

push @order_detail, \%item;

}

print Dumper [EMAIL PROTECTED];
[/code]

Thanks.

Will Martell
Dallas Texas
---




Re: case and functions

2004-01-07 Thread William.Ampeh




You can do something like this:

my $flip = something;

   SWITCH: {
  ( $flip =~ /^0$/ ||  $flip =~ /^1$/ ||  $flip =~ /^2$/ )  do {
 $local_pref = FL; last SWITCH; };

  ( $flip =~ /^3$/ ||  $flip =~ /^4$/ ||  $flip =~ /^5$/ )  do {
 $local_pref = FU; last SWITCH; };

  ( $flip =~ /^6$/ ||  $flip =~ /^7$/ )  do {
 $local_pref = FA; last SWITCH; };

  ( $flip =~ /^8$/ ||  $flip =~ /^9$/ )  do {
 $local_pref = FS; last SWITCH; };

   } # end switch


__

William Ampeh (x3939)
Federal Reserve Board


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Post Script - Hylafax - Text File - perl

2004-01-07 Thread Paul Kraus
I want to write a script that takes piped input and then fills out a
purchase order form that can then be sent to Hylafax as a postscript file.

Is there a way to write postscript with perl? I know very little about it.
Picture an empty purchase order form. I guess this would be saved as a
template somehow and perl would then parse the output of a text file to
determine what goes where on the form and what the fax number is.

 Paul Kraus
 ---
 PEL Supply Company
 Network Administrator
 ---
 800 321-1264 Toll Free
 216 267-5775 Voice
 216 267-6176 Fax
 www.pelsupply.com
 ---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response


Re: putting $1 into a var

2004-01-07 Thread R. Joseph Newton
angie ahl wrote:

 hi people

 I'm trying to get the value of $1 into a var, the following don't work
 and I can't figure out why

 $_ = $html_body;
 my ($resrow) = m#!-- VM: resrow --(.*?)!-- VM: /resrow --#;
 #print $1;
 print $resrow;

 $resrow holds nothing, however if I print $1 I do have a match

How do you know?  How are you testing to ensure that a match was found?



 $_ = $html_body;
 m#!-- VM: resrow --(.*?)!-- VM: /resrow --#;
 my $resrow = $1;
 print $resrow;

 doesn't work either.

 How do I get $1 into a var for later use. It's driving me a little loopy
 now.

Just the way you show in your second example.  If a match was found, the
captured text will appear in $resrow.

Better to find out:

if (m#!-- VM: resrow --(.*?)!-- VM: /resrow --#) {
   print $1\n;
} else {
   print Oops, back to the drawing board with this regex, huh?\n;
}

Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Perl equivalent of Ruby/DL?

2004-01-07 Thread Jenda Krynicky
From: David Garamond [EMAIL PROTECTED]
 Ruby/DL is a Ruby module that enables one to load a .DLL/.so and start
 using exported functions available in the DLL. It's a nice alternative
 of using an external library without messing with XS or writing real C
 files. Ruby/DL has been included in the standard Ruby distribution
 since 1.8.
 
   http://ttsky.net/ruby/ruby-dl.html
 
 I wonder if CPAN has something similar to this.

Either Win32::API or FFI.

See for example Win32::FileOp for examples of Win32::API's usage.

Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: Drawing an Arc at an angle.

2004-01-07 Thread Dan Muey
 On Tue, 6 Jan 2004 11:03:14 -0600, [EMAIL PROTECTED] (Dan Muey)
 wrote:
 
  Dan Muey wrote:
  
   I've made a funtion to calculate the Fresnal zone for wireless
   connections.
  
   What I'd like to do is generate an image based on that.
  Something like
   the example at: http://ydi.com/calculation/fresnel-zone.php
  
   However the two connected points are rarely going to be 
 at the same
   level so I'd need to draw the elipse At an angle instead of 
   horizontally.
  
   GD's elipse or arc function will probably do what I want
  but it seems
   all I can specify are the center point and width and height.
  
   Is there a way to also specify the x/y of each point on the
  left and
   right side of the elipse?
  
   Make sense?
  
  Yes, but you're out of luck I'm afraid Dan. The best I can
  suggest is that you use the 'filledPolygon' method and do the 
  maths yourself. (Sorry, that's 'math' over there isn't it.)
 
 
 Have you thought about trying to do this on a Tk canvas?
 The oval item lets you specify the diagonal corners of the
 oval's bounding box.
 Tk::canvas can export itself as postscript, so you
 could do your drawing, export it as ps, then convert it to
 whatever format you want.
 

Interesting I'm really workign on a dynamic system though, 
enter data into form and image is generated.
I wonder if those steps would be a bit rough that way.. I don't 
know, I'll look into it for sure.
Actually I guess I could do Tk::canvas save it to a temp .ps file and open 
the tmep file with GD or Imager or somethgin and conevrt it on the fly I 
guess it's not too impossible after all, I'll add this to my list of trick 
to try.

Thanks!

Dan

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: Using File::Find to generate playlists

2004-01-07 Thread Dan Muey
 Ok, please don't laugh.  This is my very first shot at Perl and if I 
 learn something, I'll be putting it to use for more important tasks.
 
 Thanks in advance for any comments.
 
 
 #!/usr/bin/perl
 
 # A dorkey little perl script using File::Find.  The idea is 
 to recurse # subdirectories and write an .ASX file (sequenced 
 playlist of file 
 # names) to each subdirectory for the files located there.
 
 # Aside from the slight This doesn't work as expected 
 problem ... # the following I haven't yet figured out: # # 1. 
 The 'outfile.asx' needs to take its name from the current directory
 #name and not be arbitrarily set to some predefined name 
 #(outfile.asx in this case). Maybe munge the fully qualified path 
 #somehow, or go back to READDIR? g
 #
 # 2. How does one set the top directory for File::Find to the 
 directory
 #in which the script is run?
 
 use strict;
 use warnings;
^^^
Excellent!! Bravo! :)
If I can I'll look at your questions in a bit.

 use File::Find;
 
 find ( {
wanted = \wanted,
preprocess = \preprocess,
 }, @ARGV);
 
 sub wanted {
if (-f _) { # check for avi, mpg, mpeg, divx, etc.?
   open( OUTFILE, $File::Find::dir/outfile.asx )
  or die( Cannot open $File::Find::dir/ .outfile.asx: $! );
   print( OUTFILE Entry\n );
   print( OUTFILERef href = \$File::Find::name\\n );
   print( OUTFILE Entry \n\n );
   close( OUTFILE ) 
  or die( Cannot close $File::Find::dir/ . 
 outfile.asx: $! );
}
 }
 
 sub preprocess {
print Processing directory $File::Find::dir ...\n;
open( OUTFILE, $File::Find::dir/outfile.asx )
   or die( Cannot open $File::Find::dir/ . outfile.asx: $! );
print( OUTFILE Asx Version = \3.0\\n );
print( OUTFILE Title/Title\n );
print( OUTFILE Abstract/Abstract\n );
print( OUTFILE Copyright/Copyright\n );
print( OUTFILE Author/Author\n\n );
close( OUTFILE ) 
  or die( Cannot close $File::Find::dir/ . 
 outfile.asx: $! );
 
sort { uc $a cmp lc $b } @_;
 }
 
 
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED] 
http://learn.perl.org/ http://learn.perl.org/first-response



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Array Manipulations

2004-01-07 Thread binhqnguyen
Hello Everyone,

I am a Perl newbie trying to learn as much Perl as I can.  I am trying to
combine specific array elements into one single array element so that I can
write
to an Excel cell, where all the data will fit.

For instance I have,

array[0] = F1: blue;
array[1] = F2: green;
array[2] = F3: red;
array[3] = F1: purple;
array[4] = F2: brown;
array[4] = F1: red;
array[5] = F2: pink;
array[6] = F3: blue;
array[7] = F4: white;

With the above information, I want to put all the F's in order before it
starts over at 1 again.  For instance, I want to store array[0], array[1],
and array[2] into a specific array element and then store array[3], array[4]
into another specific array element, then I start over again with array[5].
Each time I encounter an F1, I will store all the particular elements into
one single array element.  Is this possible?

Thanks for your time.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Perl equivalent of Ruby/DL?

2004-01-07 Thread David Garamond
Rob Dixon wrote:
Ruby/DL is a Ruby module that enables one to load a .DLL/.so and start
using exported functions available in the DLL. It's a nice alternative
of using an external library without messing with XS or writing real C
files. Ruby/DL has been included in the standard Ruby distribution since
1.8.
 http://ttsky.net/ruby/ruby-dl.html

I wonder if CPAN has something similar to this.
Hi Dave.

You could take a look at Win32::API.
I've found the module, it's called C::DynaLink by John Tobey. Nifty! I'm 
gonna give it a try.

Thanks,
--
dave
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



RE: Drawing an Arc at an angle.

2004-01-07 Thread Dan Muey

 On Wed, 7 Jan 2004 08:55:56 -0600, [EMAIL PROTECTED] (Dan Muey)
 wrote:
  
  Have you thought about trying to do this on a Tk canvas?
  The oval item lets you specify the diagonal corners of the oval's 
  bounding box. Tk::canvas can export itself as postscript, so you
  could do your drawing, export it as ps, then convert it to
  whatever format you want.
  
 
 Interesting I'm really workign on a dynamic system though, 
 enter data into form and image is generated.
 I wonder if those steps would be a bit rough that way.. I don't 
 know, I'll look into it for sure.
 Actually I guess I could do Tk::canvas save it to a temp .ps 
 file and open 
 the tmep file with GD or Imager or somethgin and conevrt it 
 on the fly I 
 guess it's not too impossible after all, I'll add this to my 
 list of trick 
 to try.
 
 Thanks!
 
 Oops, I just tried it. The plain Tk::Canvas dosn't support 
 rotation yet.
 And the Oval bounding box only does x-y alignment.
 
 The Tk::Zinc canvas does do rotation, but outputting postscript
 is still on the planned to do list. ;-(
 
 Zinc can make just about anything you want, with clipping, zooming,
 and rotations. But without the ps output, you would have to capture
 it manually. 
 
 Just for fun, I tried tuxpaint, and it does make ellipses which can be
 rotated with the mouse, but I don't think it has a programming
 interface.
 
 Maybe something in script-fu with Gimp?  There is an enormous number
 of scripts for script-fu.
 
 I did a groups.google.com search for rotate ellipse GD and 
 there seems
 to be alot of C code to do it with the real GD c libs. Maybe you could
 get one to compile and call it from your perl script, passing your
 parameters to it?
 
 Or maybe you could do it programmatically by learning to write
 postscript directly from perl?
 
 Zinc makes it real easy to do it, and as a matter of fact, someone
 on the Zinc maillist today, just asked the developer to get going
 on the postscript output. I've even made a lobe shape 
 programmatically
 with Zinc, and it's bezier curves.
 
 Good luckall my ideas are done. :-)
 

Thanks! Even more to add to my look into list!

 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Integrating perl scripts into KDE / Gnome

2004-01-07 Thread Dan Anderson
I was curious if anyone knows a good resource on integrating Perl
scripts into KDE (and I suppose gnome).  I want to start doing things
like adding my scripts to my taskbar, and was curious if that was
possible without compiling C extensions.

Thanks in advance,

Dan


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Fixed Length Text Extract, Write to Excel

2004-01-07 Thread R. Joseph Newton
William Martell wrote:

 Hello All,

 I am trying to work with the code I have to extract fields from a text file report, 
 and write the values into excel.

 I am having trouble.

 When I get to push @order_detail, %item
 I understand that this is pushing an associative array onto a list. (array
 of hashes)

That is the problem,  a list cannot contain a hash.  The keys and values of the hash 
simply become flattened into list
elements, and all the hashing magic is lost.

perldoc perlref

will explain how references can help resolve this problem..

Joseph



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Fixed Length Text Extract, Write to Excel

2004-01-07 Thread William Martell
Thanks for your reply Joseph,  I am reading perlref now.  If you can offer
some pointers on how to access the key value pairs of the reference object
%item.  I would appreciate it.


- Original Message -
From: R. Joseph Newton [EMAIL PROTECTED]
To: William Martell [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Wednesday, January 07, 2004 11:20 AM
Subject: Re: Fixed Length Text Extract, Write to Excel


 William Martell wrote:

  Hello All,
 
  I am trying to work with the code I have to extract fields from a text
file report, and write the values into excel.
 
  I am having trouble.
 
  When I get to push @order_detail, %item
  I understand that this is pushing an associative array onto a list.
(array
  of hashes)

 That is the problem,  a list cannot contain a hash.  The keys and values
of the hash simply become flattened into list
 elements, and all the hashing magic is lost.

 perldoc perlref

 will explain how references can help resolve this problem..

 Joseph



 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/ http://learn.perl.org/first-response



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: Fixed Length Text Extract, Write to Excel

2004-01-07 Thread NYIMI Jose (BMB)
while(my($key,$val)=each %item){
#do stuff
}

HTH,

José.

-Original Message-
From: William Martell [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, January 07, 2004 6:46 PM
To: R. Joseph Newton; [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: Fixed Length Text Extract, Write to Excel


Thanks for your reply Joseph,  I am reading perlref now.  If you can offer some 
pointers on how to access the key value pairs of the reference object %item.  I would 
appreciate it.


- Original Message -
From: R. Joseph Newton [EMAIL PROTECTED]
To: William Martell [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Wednesday, January 07, 2004 11:20 AM
Subject: Re: Fixed Length Text Extract, Write to Excel


 William Martell wrote:

  Hello All,
 
  I am trying to work with the code I have to extract fields from a 
  text
file report, and write the values into excel.
 
  I am having trouble.
 
  When I get to push @order_detail, %item
  I understand that this is pushing an associative array onto a list.
(array
  of hashes)

 That is the problem,  a list cannot contain a hash.  The keys and 
 values
of the hash simply become flattened into list
 elements, and all the hashing magic is lost.

 perldoc perlref

 will explain how references can help resolve this problem..

 Joseph



 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED] 
 http://learn.perl.org/ http://learn.perl.org/first-response



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ 
http://learn.perl.org/first-response




 DISCLAIMER 

This e-mail and any attachment thereto may contain information which is confidential 
and/or protected by intellectual property rights and are intended for the sole use of 
the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, total or 
partial reproduction, communication or distribution in any form) by other persons than 
the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by 
telephone or by e-mail and delete the material from any computer.

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at 
http://www.proximus.be or refer to any Proximus agent.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Fixed Length Text Extract, Write to Excel

2004-01-07 Thread Rob Dixon
William Martell wrote:

 I am trying to work with the code I have to extract fields from a text file
 report, and write the values into excel.

 I am having trouble.

 When I get to push @order_detail, %item

Looking at your code, you mean

  push @order_detail, \%item

 I understand that this is pushing an associative array onto a list. (array
 of hashes)

 I am trying to write code that will open a new worksheet in excel and print
 the values of %item onto a row.  When Perl encounters a certain key
 (cust_number), I would like it to start a new row.

 I have tried keys(), values(), pop() but I can't get it right.  I think some
 of my trouble is b/c of the reference \%item.  When I remove the reference
 backslash operator like this %item and type print. Perl returns with the
 contents in scalar.

 So.  My main question is how do I access the values and keys of %item in
 @order_detail???

Hi William.

You're building an array of hash references. To access a hash values
from a given array element, write

  my $cust_number = $order_detail[0]{cust_number}

To do the same for each detail record, do this

  foreach my $detail (@order_detail) {
my $cust_number = $detail-{cust_number};
  }

The value returned will be 'undef' if there is no such element for a given
order detail record.

I hope this helps.

Rob



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: What is the source of my input, file or STDIN?

2004-01-07 Thread drieux


On Jan 6, 2004, at 1:07 PM, david wrote:
[EMAIL PROTECTED] wrote:
Case 3. (this is the difficult case for me) the script is invoked
with no file and no pipe to it.  I would like the script to
end quietly, such as
test.input.source

Instead, it waits for input.

test.input.source
no command line args - switching to STDIN

and now it waits forever.
select / IO::Select is what you are looking for.
[..]

My compliments to David, as always.

The reason the code is 'waiting for ever' in
the case of having no STDIN is that it is in a
blocking IO Read on STDIN.
So since we have a better spec, I have updated the code
to show how the IO::Select could be used to gate
for the case that the code was called without
command line input, nor a current connection for STDIN.
http://www.wetware.com/drieux/pbl/perlTrick/CommandLine/ 
file_or_stdin.plx

Note all of the noisy 'print statements' are there
merely to show the transition of the logic of the code.
On Jan 6, 2004, at 12:53 PM, Steve Grazzini wrote:

On Jan 6, 2004, at 3:17 PM, [EMAIL PROTECTED] wrote:
Case 3. (this is the difficult case for me) the script is
invoked with no file and no pipe to it.  I would like the
script to end quietly
  die usage() if @ARGV == 0 and -t;
You might not want to test if there is a
controlling terminal - since that would prevent
the pipe fitting from working unless there was a
controlling terminal. A problem that will crop up
when JoeBob opts wants to use the pipe fitting in
their KSH script...
I didn't show you how to check for the pipe (-p) because
this should probably work, too:
  % your-script input.txt
We have So got to talk about your meds here...

8-)

To be honest, I had not thought about the idea of
'-p' even trying to test to see if it was a pipe
since it is-ish when one connects the pipe fittings
of the standard shell, or as you have done, the
express redirection of input...
[jeeves: 30:] wc -l funk*
  14 funk_env.plx
[jeeves: 31:] ./file*  funk*
no command line args - switching to STDIN
STDIN had 14 number of lines
we saw 14 number of lines
[jeeves: 32:]
The 'redirect in' of  simply is a way of changing
how STDIN is feed to the calling program by the shell.
It of course is dependent upon how the shell copes
with re-attaching STDIN|STDOUT combo's...
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Fixed Length Text Extract, Write to Excel

2004-01-07 Thread Wiggins d Anconia
Please bottom post...

 Thanks for your reply Joseph,  I am reading perlref now.  If you can offer
 some pointers on how to access the key value pairs of the reference object
 %item.  I would appreciate it.
 

May I also suggest the little easier reading of, 

perldoc perlreftut
perldoc perldsc
perldoc perllol

To go along with, and usually (at least the first) before perlref. It
can be quite thick to try and get through. The above are designed to be
less of a complete reference and more of a real world help tool

Good luck,

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Pipe and STDIN - Re: What is the source of my input, file or STDIN?

2004-01-07 Thread drieux
On Jan 6, 2004, at 12:17 PM, [EMAIL PROTECTED] wrote:
[..]
It just dawned on me that I may not be using the
correct terminology since pipe and STDIN probably
imply much more than I mean for them to convey.
[..]

This is a good angst point to raise.

Technically STDIN|STDOUT|STDERR denote
merely 'file descriptors' that will be
opened by the shell in compliance with
how the shell saw the voodoo passed to it.
Normally they will be implemented as a 'pipe'
unless we do something else with them, at
which they may be implemented as a 'closed fd'
8-)
One can implement Pipes that are not the
first three fd's in the _iobuf[] - and yes,
one can get into massed weirdness when screwing
around at that level. So the way to think about the
problem is that the first three fd's stdin|stdout|stderr
will be implemented at pipes, and as such are a proper
subset of the set of Pipes. We tend to speak in terms
of 'pipe fittings' because we think of them in terms of say
	ps -ef | grep foo | egrep -v grep | awk '{print $2}'

which we on the perl side of the line could have implemented
with say perl's popen() approach of say
open(PS, ps $ps_args |) or die unable to popen(ps $ps_args): $!;
while(PS)
{
# your proc grovelling here...
}
close(PS);
But for some reason, I'd hazzard to say that about 99%
of us fail to set a $SIG{'PIPE'} handler to deal with
the prospects of the pipe breaking because, well
most of the time we just do not care. Even MORE SO
when it is stdin|stdout|stderr ...
So the converse of your kvetch is of course,

Gosh, now that I feel at home writing pipe fittings,
when, where and how would I really want to be building
my own pipes and/or popen() types of tricks?
well for that there is perldoc perlipc
for everything else, there is ioctl()
8-)
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: What is the source of my input, file or STDIN?

2004-01-07 Thread Steve Grazzini
On Jan 7, 2004, at 1:10 PM, drieux wrote:
On Jan 6, 2004, at 12:53 PM, Steve Grazzini wrote:
  die usage() if @ARGV == 0 and -t;
You might not want to test if there is a
controlling terminal
I want to test whether STDIN (the default argument for -t)
is hooked up to the terminal (which is what -t tells you) so
that ARGV doesn't block waiting for user input.
But if you want to quibble, this still blocks:

  % perl -pe 'BEGIN{ die if @ARGV == 0 and -t }' /dev/tty

--
Steve
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: case and functions

2004-01-07 Thread drieux
On Jan 6, 2004, at 2:08 PM, [EMAIL PROTECTED] wrote:

Yo.
what Up.

I read in Learning Perl that there are no such constructs
like a case statement.  Is there something similar or did I misread 
this?
As folks have already pointed to both
the classic perlfaq, and implied that
one should consult
	perldoc Switch

which if you are not on perl5.8 can be
downloaded from the CPAN from
http://search.cpan.org/~dconway/Switch-2.09/Switch.pm

 Also what about functions and function calls,
do these exits or does the subroutines replace these?
[..]

This of course brings us to the more interesting
side of the swtich/case statement problem - namely
what are you trying to do with them, and have you
thought about the classic 'dispatching table' type
of solution - say something like
my %process = (
start = \do_start,
stop = \do_stop,
test = \do_test
);
if ( defined( $process{$ARGV[0]}))
{
$process{$ARGV[0]}(@ARGV);
} else {
print issued invalid command: $ARGV[0]\n;
}
sub do_start { ... }
sub do_stop  { ... }
sub do_test  { ... }
you will notice that this is similar to the classic
init script most folks have seen as say
#!/bin/sh

case $1 in
start) do_start ;;
stop)  do_stop ;;
test)  do_test ;;
*) echo i do not know how to to $1 ;;
esac
So it's sorta a case of what exactly were you trying
to do with the case like statement???
ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Integrating perl scripts into KDE / Gnome

2004-01-07 Thread drieux
On Jan 7, 2004, at 9:00 AM, Dan Anderson wrote:

I was curious if anyone knows a good resource on integrating Perl
scripts into KDE (and I suppose gnome).  I want to start doing things
like adding my scripts to my taskbar, and was curious if that was
possible without compiling C extensions.
ok, I'm slow and it has been some time
since I did KDE/gnome - but if the code
is executable, then it is merely a matter
of Identifying the 'name' of the code just
as one would do with any other piece of code.
If you have command line code that needs to run
in a shell, and you were not planning on wrapping
it in say Perl/Tk or some other window GUI form
then how about the old dog trick of
##!/bin/sh
###
###if [ ${DISPLAY} =  ]
###then
### /usr/ucb/echo -n what display? 
### read DISPLAY
### export DISPLAY
###fi
###
###nohup xterm -geometry 80x60+0+0 -e goWork /dev/null 21 
###
###exit
###
vladimir: 58:]
this will invoke the 'goWork' code in an xterm...

HTH

ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



stop

2004-01-07 Thread David Kapp















I've requested 50 times to be taken off your mailing list, but you still send me this unwanted mail.
I will now report all mail sent to me by you as SPAM
Stop sending me spam.


















2003 www.hushport.com

RE:[OT] stop

2004-01-07 Thread Tim Johnson

Wow.  50 times.  That's some stamina.  I imagine that's almost as
annoying as getting a humongous Christmas picture background HTML mail
in your Perl mailing list... 






From: David Kapp [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, January 07, 2004 11:31 AM
To: [EMAIL PROTECTED]
Subject: stop

I've requested 50 times to be taken off your mailing list, but you still
send me this unwanted mail.
I will now report all mail sent to me by you as SPAM
Stop sending me spam.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




[ADMIN] Re: stop

2004-01-07 Thread Casey West
It was Wednesday, January 07, 2004 when David Kapp took the soap box, saying:
: I've requested 50 times to be taken off your mailing list, but you still
: send me this unwanted mail.
: I will now report all mail sent to me by you as SPAM
: Stop sending me spam.

You can send a message to [EMAIL PROTECTED] and respond
to the confirmation request you get as a result.  Emailing this list
directly will not help you.  If that still doesn't work for you, email
[EMAIL PROTECTED] with the exact email address you would like
removed and the perl.org admins will take care of it.

As an aside, this mailing list could never be SPAM to you because you
confirmed your subscription to it and thus every message is
solicited.  Even so, I'm sorry they bother you.

  Casey West

-- 
Shooting yourself in the foot with APL
You hear a gunshot and there's a hole in your foot, but you don't
remember enough linear algebra to understand what has happened.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: [OT] stop

2004-01-07 Thread Ned Cunningham
Yeah or taking the time to blame the users of the list.

Happy New Year!!!

Ned Cunningham
POS Systems Development
Monro Muffler Brake
200 Holleder Parkway
Rochester, NY 14615
(585) 647-6400 ext. 310
[EMAIL PROTECTED]

-Original Message-
From:   Tim Johnson [mailto:[EMAIL PROTECTED]
Sent:   Wednesday, January 07, 2004 2:36 PM
To: David Kapp; [EMAIL PROTECTED]
Subject:RE:[OT] stop


Wow.  50 times.  That's some stamina.  I imagine that's almost as
annoying as getting a humongous Christmas picture background HTML mail
in your Perl mailing list... 






From: David Kapp [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, January 07, 2004 11:31 AM
To: [EMAIL PROTECTED]
Subject: stop

I've requested 50 times to be taken off your mailing list, but you 
still
send me this unwanted mail.
I will now report all mail sent to me by you as 
SPAM
Stop sending me spam.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: stop

2004-01-07 Thread Dan Muey
 I've requested 50 times to be taken off your mailing list, 
 but you still send me this unwanted mail.

You've sent 50 emails to [EMAIL PROTECTED]

I get no spam from this list ever, maybe it's coming 
from someone who harvested your email address from a web site or something?

 I will now report all mail sent to me by you as SPAM

What are the headers and ip addresses, I doubt it's coming from the 
real beginners list or else I'd have gotton spam also since I've 
subscribed for a while now.

 Stop sending me spam.

I never have and the list hasn't either. It's got to be a harvesting 
bot, virus, etc... Maybe your IncrediMail or Kazaa or somethgin has spyware in it?

HTH

DMuey

 2003 www.hushport.com

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: putting $1 into a var

2004-01-07 Thread Dan Muey

 Thanks to everyone who helped me with this one, I had a 
 deadline to meet that is now met. 
 
 It was a missing ~ and me failing to use s on the end of my pattern
 
 may be of use to other users but for some reason my Linux 
 server needs s///s; to match over newlines and my OSX set up 
 doesn't, that didn't help ;)

OSX! Yummy! It probably has something to do with the Unix/Mac/Winders 
newline character issue.  They all use different characters for that 
so it can cause issues.


Dmuey

 
 Angie
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED] 
http://learn.perl.org/ http://learn.perl.org/first-response



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




-t and STDIN was Re: What is the source of my input, file or STDIN?

2004-01-07 Thread drieux
On Jan 7, 2004, at 10:37 AM, Steve Grazzini wrote:
[..]
I want to test whether STDIN (the default argument for -t)
is hooked up to the terminal (which is what -t tells you) so
that ARGV doesn't block waiting for user input.
[..]

I have absolutely no problem with the idea that
one wants to use '-t' to establish that there is
a controlling terminal, AKA a ttyline - but the
problem is the false assumption that this is in
some way associated with STDIN.
IF i am going to guard my code with '-t' to
establish if there is any STDIN then as soon
as the code is used inside of a forked and exec'd
event where the child process is no longer attached
to the TTYLINE then
	foo | bar

will break because bar, failing to find it's controlling
terminal will not see the information coming at it from
foo through the STDIN pipe. So if one wanted to check
that there were bits in STDIN, then one should do that
with the IO::Select approach - since that will tell one
if there are bits on STDIN, even if the process itself
is being run without a controlling terminal.
To help illustrate the point:

http://www.wetware.com/drieux/pbl/perlTrick/CommandLine/ 
got_ttyline.plx

now granted, I have only tested this on darwin|freebsd|solaris|linux
and only with perl 5.6 and 5.8 but they all come back with:
vladimir: 67:] perl got_ttyline.plx
This Will Gin Up:
Mother Got Back:hello, I am /tmp/drieux/CallMe.txt
Mother Got Back:what tty line?
Mother Got Back:STDIN says : /tmp/drieux/SomeCmd.txt:About to shout out
Mother Got Back:STDIN says : sending var1
Mother Got Back:STDIN says : sending thing2
Mother Got Back:STDIN says : sending thing3
vladimir: 68:]
So it is possible that there are implementations of this
which will not work in the way that I expect it - but
as a general rule of thumb if one wants to know that
one has a controlling terminal - -t then one should
test for it. But simply because there is no controlling
terminal does NOT mean that there is nothing on STDIN.
So that we are clear on this, it is not merely an issue
in Perl, this is even MORE depressing when it is coded
in a 'realCoderLanguage[dm]' and worse YET when the dilbert
made TOTALLY irrational presumptions that if there was no
controlling terminal that this of course meant that the build
was suppose to use some WingNarkFrimFrimFrim library that of
course leads to totally wacky problems when the build by hand
at a terminal works find, and all of the code builds correctly
but Blows Big Ones when done in an automated environment


ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: stop

2004-01-07 Thread jeff



you could always change your email 
address! Just a thought.

  - Original Message - 
  From: 
  David Kapp 
  
  To: [EMAIL PROTECTED] 
  Sent: Wednesday, January 07, 2004 
  14:31
  Subject: stop
  
  

  

  
  

  


  

  I've requested 50 times to be taken off your mailing list, 
  but you still send me this unwanted mail.
  I will now report all mail sent to me by you as 
  SPAM
  Stop sending me spam.

  

  
  

  


  
  
  
  

  


  
2003 www.hushport.com
2004.jpgnew_year_01a.jpg

Re: stop

2004-01-07 Thread Dan Anderson
Uhhh...at the bottom of every list message is:

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response

withold sarcastic comment about thinking before you post /

-Dan


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: symbolic references and hashes

2004-01-07 Thread Gary Stainburn
Hi Rob,

On Wednesday 07 January 2004 1:48 pm, Rob Dixon wrote:
 Gary Stainburn [EMAIL PROTECTED] wrote in message
[snip]
 You're trying to dereference $_BLOCKS as a hash reference. Use

   return sort keys %{_$key};

 and it should work. But note that it won't return the keys from
 the lexical ('my') hashes that you've used in your code: only
 package ('our') variables are accessible by name.

I would have thought that because the 'list' method is in the Trainset class 
that it would work, as at that point it's in scope, then simply passing back 
an array of sorted keys.  I certainly don't want to extend the scope of the 
variables.


 Even so it's a horrible thing to be doing, if only because you
 can't 'use strict'. This might be better

   sub list {
 my $self = shift;
 my %hash = (
   BLOCKS = \%_BLOCKS,
   TRAINS = \%_TRAINS,
   BOXS = \%_BOXS,
 );
 my $key = uc shift;

 print using '_$key' as hash name\n;
 return sort keys %{$hash{$key}};
   }


I had thought about this, and like that fact that I can make the list method 
more intelligent, using %hash for access rights etc., but initially I wanted 
to keep it simple.

 but I'd rather see this implemented as an object method with
 the hashes stored as $object-{_BLOCKS} etc. As it stands your
 Trainset class is working as an object, and you can never have
 more than one trainset in your program.


I've also thought of this, although like CGI.pm it's not likely that one 
program will have multiple trainsets, my main reason is again for simplicity.

I'm thinking of when I've got multiple blocks and want to start linking them.  
addlink is a method for a block object, but will need access to the %_BLOCKS 
which would be an attribute of the root trainset object.

At the moment it's a global class variable which would be easily accessible, 
but how could I do:

my $set=Trainset-new('NYMR'); # create holder
my $platform1=$set-block('Platform 1','Block'); # create both platforms
my $platform2=$set-block('Platform 2','Block');
my $points=$set-block('Shunt','Points'); # create the points
$platform1-addlink('Shunt',0); # link to shunt position 0;
$platform2-addlink('Shunt',1); # link to shunt position 1;

addlink needs to access $set-{_BLOCKS} to convert 'Shunt' to point to the 
$points object (asuming that I didn't already have $points defined).

The only alternative I can see is to have a method of $set that returns an 
objectref from it's name, which increases the amount of code to run.
 HTH,

 Rob

-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: stop

2004-01-07 Thread u235sentinel
After being part of this list for a month, I don't recall seeing more than just this 
email requesting removal from the list.  

Oh well.  An amusing message.  I see them all the time in the Linux mail lists I 
participate in. Pity people can't follow directions :-)

 Uhhh...at the bottom of every list message is:
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/ http://learn.perl.org/first-response
 
 withold sarcastic comment about thinking before you post /
 
 -Dan
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/ http://learn.perl.org/first-response
 
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: stop

2004-01-07 Thread Morbus Iff
For the sake of:

 * giving the guy a break.
 * expecting some intellect.
 * realizing he's probably
   not reading your responses.
Notice he didn't say whether he requested to the list, or to the
proper email unsubscribe address: just that he had requested multiple
times to be removed. The flip side of the coin is that there may
very well be a problem with the unsubscription scripts.
Yes, this is a far-flung possibility, but besides courtesy in
the face of idiocy, one of the things ANY beginner to ANY thing
should know is to think things through from ALL angles: just
because the answer seems obvious, doesn't mean it is.


--
Morbus Iff ( i put the demon back in codemonkey )
Culture: http://www.disobey.com/ and http://www.gamegrene.com/
Spidering Hacks: http://amazon.com/exec/obidos/ASIN/0596005776/disobeycom
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



PERL debuggers

2004-01-07 Thread William.Ampeh




Are there any free PERL debuggers?

I once came across pvdb (a vi-aware front-end for the PERL debugger
developed by Tom Christainsen), but I never got it to work.


__

William Ampeh (x3939)
Federal Reserve Board


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: stop

2004-01-07 Thread Charles K. Clarkson
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
: 
: Oh well.  An amusing message.  I see them all the time in
: the Linux mail lists I participate in. Pity people can't
: follow directions :-)

Be careful what you wish for.

If everyone could follow directions we would be one
step closer to everyone being able to *write* directions.
Then I would have to become one of those really exceptional
programmers instead of just the average one I am today. :)


Charles K. Clarkson
-- 
Head Bottle Washer,
Clarkson Energy Homes, Inc.
Mobile Home Specialists
254 968-8328





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: PERL debuggers

2004-01-07 Thread Dan Muey
 Are there any free PERL debuggers?

Have you tried use strict and use warnigns in your scripts?
Also perl -c script.pl is helpfule and then the perl debugger itself:
perl -d

I'm sure their's thrid party stuff but I never use any, 
the above does plenty for my needs.

HTH

Dmuey

 
 I once came across pvdb (a vi-aware front-end for the PERL 
 debugger developed by Tom Christainsen), but I never got it to work.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: PERL debuggers

2004-01-07 Thread Wiggins d Anconia
 
 Are there any free PERL debuggers?
 
 I once came across pvdb (a vi-aware front-end for the PERL debugger
 developed by Tom Christainsen), but I never got it to work.
 

perldoc perldebtut
perldoc perldebug

Have you had a look at those?

http://danconia.org

p.s. perldoc -q 'Perl'

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Question about CPAN's Text::Diff

2004-01-07 Thread stuart_clemons




Hi all:

This newbie would like to compare two files, let's say File1 and File2.   I
want to put the difference from File2 only,  into a new file, File3.

For example:

File1.txt
oranges
apples
bananas

File2.txt
apples
kiwi
bananas

The result I want for File3 is the new entry in File2, which is kiwi.  (I
don't care that oranges was in File1 and not File2.)

Can the Text:Diff module (or some other means) do this ?  (I looked at the
Text::Diff doc and it wasn't obvious to me.  I hope to play with this later
this evening or tomorrow.)

Thanks in advance for your help (and for your past help as well !)

- Stuart


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: stop

2004-01-07 Thread Dan Muey
Please tell me this thread will stay in the archives! It's hilarious!

I feel kinda bad for Mr. Kapp though, but if you're rude for no good 
reason what can you expect.

 - Original Message - 
 From: [EMAIL PROTECTED] 
 To: [EMAIL PROTECTED] 
 Sent: Wednesday, January 07, 2004 14:31
 Subject: stop

 I've requested 50 times to be taken off your mailing list, but you still send me 
 this unwanted mail.
 I will now report all mail sent to me by you as SPAM
 Stop sending me spam.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: PERL debuggers

2004-01-07 Thread Jenda Krynicky
From:   [EMAIL PROTECTED]
 Are there any free PERL debuggers?

http://world.std.com/~aep/ptkdb/

Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: -t and STDIN was Re: What is the source of my input, file or STDIN?

2004-01-07 Thread Steve Grazzini
On Jan 7, 2004, at 2:57 PM, drieux wrote:
But simply because there is no controlling
terminal does NOT mean that there is nothing on STDIN.
Were you reading that code backwards?

  die usage() if @ARGV == 0 and -t;

  # if ((THERE ARE NO FILENAMES IN ARGV) 
  # (STDIN IS HOOKED UP TO A TERMINAL))
  # {
  # COMPLAIN;
  # }
We only complain if STDIN *is* a tty.

I have absolutely no problem with the idea that
one wants to use '-t' to establish that there is
a controlling terminal, AKA a ttyline - but the
problem is the false assumption that this is in
some way associated with STDIN.
% perldoc -f -X
... If the argument is omitted, tests $_, except for
-t, which tests STDIN.
--
Steve
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



utc to local time

2004-01-07 Thread Paul Kraus
How can I convert a utc time stamp to a perl standard time stamp for my
timezone?

 Paul Kraus
 ---
 PEL Supply Company
 Network Administrator
 ---
 800 321-1264 Toll Free
 216 267-5775 Voice
 216 267-6176 Fax
 www.pelsupply.com
 ---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response


RE: Question about CPAN's Text::Diff

2004-01-07 Thread Paul Kraus
Why not just use the diff command?
Man diff

 Paul Kraus
 ---
 PEL Supply Company
 Network Administrator

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, January 07, 2004 3:22 PM
 To: [EMAIL PROTECTED]
 Subject: Question about CPAN's Text::Diff
 
 
 
 
 
 Hi all:
 
 This newbie would like to compare two files, let's say File1 and File2.
 I
 want to put the difference from File2 only,  into a new file, File3.
 
 For example:
 
 File1.txt
 oranges
 apples
 bananas
 
 File2.txt
 apples
 kiwi
 bananas
 
 The result I want for File3 is the new entry in File2, which is kiwi.  (I
 don't care that oranges was in File1 and not File2.)
 
 Can the Text:Diff module (or some other means) do this ?  (I looked at the
 Text::Diff doc and it wasn't obvious to me.  I hope to play with this
 later
 this evening or tomorrow.)
 
 Thanks in advance for your help (and for your past help as well !)
 
 - Stuart
 
 
 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/ http://learn.perl.org/first-response



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: stop

2004-01-07 Thread Casey West
It was Wednesday, January 07, 2004 when Dan Muey took the soap box, saying:
: Please tell me this thread will stay in the archives! It's hilarious!
: 
: I feel kinda bad for Mr. Kapp though, but if you're rude for no good 
: reason what can you expect.

Well, around these parts we don't *expect* rudeness in return.  I
believe that rudeness must conform to the all things in moderation
rule whenever it cannot be helped, which /should/ never happen.  :-)

For the record the archives don't lie, the thread will be there.
That's precisely why rudeness must be kept in check.

I think now is a good time to stop this thread.  Everything that
should have been said has been, as well as some things that shouldn't
have.  :-)

  Casey West

-- 
Shooting yourself in the foot with Pascal 
The compiler won't let you shoot yourself in the foot. 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: PERL debuggers

2004-01-07 Thread Esposito, Anthony
There is Open Perl IDE.  Check out http://open-perl-ide.sourceforge.net.
Unfortunately, it is for Windows only.

HTH  :-)

Tony Esposito
Oracle Developer, Enterprise Business Intelligence
XO Communications
Plano, TX  75074
Work Phone: 972-516-5344
Work Cell: 972-670-6144
Email: [EMAIL PROTECTED]


-Original Message-
From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, January 07, 2004 2:29 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: PERL debuggers

 
 Are there any free PERL debuggers?
 
 I once came across pvdb (a vi-aware front-end for the PERL debugger
 developed by Tom Christainsen), but I never got it to work.
 

perldoc perldebtut
perldoc perldebug

Have you had a look at those?

http://danconia.org

p.s. perldoc -q 'Perl'

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: PERL debuggers

2004-01-07 Thread Dan Anderson
I've created a module that I am planning on eventually releasing to CPAN
which provides a good framework for debugging.  Basically you can have
your code report 4 types of warnings: 

INFO
WARNING
ERROR
FATAL_ERROR

You can also assign a class to each and turn on or off all of one type
or all of one subclass of one type.  Everything either records to a log
file or prints to STDERR, and I am going to (eventually) add the
capability to e-mail the log of errors to an admin.  (So if you create a
program and your users do something unexpected you can have them send
you a readout of exactly what happened).  And I've got a bunch of other
ideas (i.e. HTML output) that I may implement when I finally manage to
getting around to see if I can put it on CPAN.

It's written in pure perl and GPLed.  e-mail me if you'd like me to send
you over a copy.  It's still being developed though.

-Dan


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: PERL debuggers

2004-01-07 Thread Dan Anderson
I'd like to add that it's not a debugger like the one someone else
posted for stepping through your code and setting breakpoints.  It's
designed to allow you to create a log with the state of your script and
what has been done, so that way you can have somebody who is not a
programmer and who is using your script send you the log (because, of
course, most of those type of people can't debug with you over the
phone).  :-D

-Dan


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: PERL debuggers

2004-01-07 Thread Wiggins d Anconia


 I've created a module that I am planning on eventually releasing to CPAN
 which provides a good framework for debugging.  Basically you can have
 your code report 4 types of warnings: 
 
 INFO
 WARNING
 ERROR
 FATAL_ERROR
 
 You can also assign a class to each and turn on or off all of one type
 or all of one subclass of one type.  Everything either records to a log
 file or prints to STDERR, and I am going to (eventually) add the
 capability to e-mail the log of errors to an admin.  (So if you create a
 program and your users do something unexpected you can have them send
 you a readout of exactly what happened).  And I've got a bunch of other
 ideas (i.e. HTML output) that I may implement when I finally manage to
 getting around to see if I can put it on CPAN.
 
 It's written in pure perl and GPLed.  e-mail me if you'd like me to send
 you over a copy.  It's still being developed though.
 
 -Dan
 

From your description this sounds very similar to Log4perl (a Log4j Perl
implementation) have you checked it out to see what may already be
available, if for no other reason than to borrow from? 

Certainly not trying to discredit your efforts, just spreading the
log4perl wealth, I have found it incredibly robust while at the same
time being complex enough to handle some intricate tasks.

http://log4perl.sf.net

For more information, be sure to check out the retire your debugger
article

Good luck,

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: PERL debuggers

2004-01-07 Thread William.Ampeh




No, I love perldebug, I was just wondering if I there were any other neat
tools unknown to me.

__

William Ampeh (x3939)
Federal Reserve Board


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Question about CPAN's Text::Diff

2004-01-07 Thread Rob Dixon
Stuart Clemons wrote:

 This newbie would like to compare two files, let's say File1 and File2.   I
 want to put the difference from File2 only,  into a new file, File3.

 For example:

 File1.txt
 oranges
 apples
 bananas

 File2.txt
 apples
 kiwi
 bananas

 The result I want for File3 is the new entry in File2, which is kiwi.  (I
 don't care that oranges was in File1 and not File2.)

 Can the Text:Diff module (or some other means) do this ?  (I looked at the
 Text::Diff doc and it wasn't obvious to me.  I hope to play with this later
 this evening or tomorrow.)

Hi Stuart.

Yes, Text::Diff will do that for you, but you will have to write your own
formatting class to generate it as it's not one of the standard output
formats.

You have to be clear that this is the correct solution for you though, as
Text::Diff insists that the entirety of the two files to be compared are
first read into arrays. It may be just as simple to do that anyway and
write something yourself to compare the two, especially if the ordering of
the records and multiple identical records aren't signnificant.

HTH,

Rob



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




One line variable declaration with multiple conditions

2004-01-07 Thread Dan Muey
Howdy list.
I'm trying to one lineify this:

my $guts = $firstchoice || ''; 
if(!$guts  $use_second_choice_if_first_is_empty) { 
$guts = $secondchoice;
}

Basically 
my $guts = $firstchoice || $secondchoic || ''; 
Would be perfect except I only want to let it use $seconchoice if 
$use_second_choice_if_first_is_empty has a true value.
This does not work like I want but illustrates the goal if you read it our loud.
my $guts = $firstchoice || $secondchoic if $use_second_choice_if_first_is_empty || '';

Is that possible to do with one line?

TIA

Dan

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: One line variable declaration with multiple conditions

2004-01-07 Thread Bob Showalter
Dan Muey wrote:
 Howdy list.
 I'm trying to one lineify this:
 
 my $guts = $firstchoice || '';
 if(!$guts  $use_second_choice_if_first_is_empty) {  $guts =
 $secondchoice; }
 
 Basically
 my $guts = $firstchoice || $secondchoic || '';
 Would be perfect except I only want to let it use
 $seconchoice if $use_second_choice_if_first_is_empty has a true value.
 This does not work like I want but illustrates the goal if
 you read it our loud.
 my $guts = $firstchoice || $secondchoic if
 $use_second_choice_if_first_is_empty || '';
 
 Is that possible to do with one line?

  $first || ($use_second  $second) || '';

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: One line variable declaration with multiple conditions

2004-01-07 Thread Wiggins d Anconia


 Howdy list.
 I'm trying to one lineify this:
 
 my $guts = $firstchoice || ''; 
 if(!$guts  $use_second_choice_if_first_is_empty) { 
   $guts = $secondchoice;
 }
 
 Basically 
 my $guts = $firstchoice || $secondchoic || ''; 
 Would be perfect except I only want to let it use $seconchoice if
$use_second_choice_if_first_is_empty has a true value.
 This does not work like I want but illustrates the goal if you read it
our loud.
 my $guts = $firstchoice || $secondchoic if
$use_second_choice_if_first_is_empty || '';
 
 Is that possible to do with one line?
 
 TIA
 
 Dan

Seems like the ternary operator should set you up... perldoc perlop look
for Conditional Operator...

my $guts = (($firstchoice ne '') ? $firstchoice : (($firstchoice eq '')
? $secondchoice : ''));

Though there may be a better way using some combination of ||= or am I
misunderstanding you completely?

http://danconia.org


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




coping txt files over a peer to peer.

2004-01-07 Thread Tino Arellano
Hello folks,

How do I send the file name used by the client so that the server uses the same file 
name 
When it is writing it own file. 


thank you.

here's the client: 

use IO::Socket;

my $server = IO::Socket::INET-ne­w(
   PeerAddr = 'localhost',
   PeerPort = 5050,
   Proto= 'tcp'
) or die Can't create client socket: $!;


open FILE, original_file_name;
while (FILE) {
  print $server $_;
  }
close FILE;


Here's the server:

use IO::Socket;

my $server = IO::Socket::INET-ne­w(
   Listen = 5,
   LocalAddr = 'localhost',
   LocalPort = 5050,
   Proto = 'tcp'
) or die Can't create server socket: $!;

my $client = $server-accept;


open FILE, copy_file_name or die Can't open: $!;
 while ($client) {
   print FILE $_;
   }
close FILE;


--






-- 
__
Check out the latest SMS services @ http://www.linuxmail.org 
This allows you to send and receive SMS through your mailbox.


Powered by Outblaze

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: One line variable declaration with multiple conditions

2004-01-07 Thread drieux
On Jan 7, 2004, at 2:20 PM, Dan Muey wrote:

Is that possible to do with one line?
technically no, because you needed
my ($firstchoice, $use_second_choice_if_first_is_empty);
my $secondchoice = 's2';
then you can do

my $guts = ($use_second_choice_if_first_is_empty)? $secondchoice : 
$firstchoice || '';

ciao
drieux
---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: setPalette doesnt work in win32

2004-01-07 Thread James Osborn
I dug through the archive and found a similar problem posted regarding 
setPalette under Solaris.  So I tried the suggested workaround in that post:

1. Issue the setPalette call right after creating the main window.
2. Use the 'interactive' priority option.
So for example:

   $mainwidget = Tk::MainWindow-new ();
   $mainwidget-setPalette(qw/background snow3 priority interactive/);
This works under all Windows OS's I have access to.  As I previously 
reported, using setPalette later in the program and/or apparently 
without the interactive priority option set, causes it to not work under 
W2K (and I gather Solaris), but does work under XP, go figure.

-- James

James Osborn wrote:
An obscure and probably (?) highly specific problem.  When I install the 
Apache/Perl (binaries for both Perl-5.6/Apache-1.0/mod_perl-1 and 
Perl-5.8/Apache-2/mod_perl-2) from the ports page 
(http://www.cpan.org/ports/index.html#win32), using setPalette in my pTk 
programs works fine under XP Pro, but installing the same port under W2K 
Pro causes setPalette to do nothing.  Furthermore, the default color 
scheme varies from W2K machine to W2K machine (e.g. seafoam on one and 
black on another).  This behavior is clearly demonstrated by the widgets 
demo too, not just my programs.

Anybody know what I am talking about or how to fix it?

-- James



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



RE: One line variable declaration with multiple conditions

2004-01-07 Thread Dan Muey
 
 On Jan 7, 2004, at 2:20 PM, Dan Muey wrote:
 
 
  Is that possible to do with one line?
 
 technically no, because you needed
 my ($firstchoice, $use_second_choice_if_first_is_empty);
 my $secondchoice = 's2';

Sorry, I figured we could assume they were 
declared earlier so as not to muck up the screen and it 
wouldn't really change the question or answer.

 
 then you can do
 
 my $guts = ($use_second_choice_if_first_is_empty)? $secondchoice : 
 $firstchoice || '';
 

Nice.

 
 ciao
 drieux
 
 ---
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED] 
http://learn.perl.org/ http://learn.perl.org/first-response



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: One line variable declaration with multiple conditions

2004-01-07 Thread Dan Muey
  Howdy list.
  I'm trying to one lineify this:
  
  my $guts = $firstchoice || '';
  if(!$guts  $use_second_choice_if_first_is_empty) { 
  $guts = $secondchoice;
  }
  
  Basically
  my $guts = $firstchoice || $secondchoic || ''; 
  Would be perfect except I only want to let it use $seconchoice if
 $use_second_choice_if_first_is_empty has a true value.
  This does not work like I want but illustrates the goal if 
 you read it
 our loud.
  my $guts = $firstchoice || $secondchoic if
 $use_second_choice_if_first_is_empty || '';
  
  Is that possible to do with one line?
  
  TIA
  
  Dan
 
 Seems like the ternary operator should set you up... perldoc 
 perlop look for Conditional Operator...
 
 my $guts = (($firstchoice ne '') ? $firstchoice : 
 (($firstchoice eq '') ? $secondchoice : ''));

Thanks! I'll try each of these suggestions and maybe Benchmark them for grins.

 
 Though there may be a better way using some combination of 
 ||= or am I misunderstanding you completely?
 
http://danconia.org


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: One line variable declaration with multiple conditions

2004-01-07 Thread Dan Muey
 Dan Muey wrote:
  Howdy list.
  I'm trying to one lineify this:
  
  my $guts = $firstchoice || '';
  if(!$guts  $use_second_choice_if_first_is_empty) {$guts =
  $secondchoice; }
  
  Basically
  my $guts = $firstchoice || $secondchoic || '';
  Would be perfect except I only want to let it use $seconchoice if 
  $use_second_choice_if_first_is_empty has a true value. This 
 does not 
  work like I want but illustrates the goal if you read it our loud.
  my $guts = $firstchoice || $secondchoic if
  $use_second_choice_if_first_is_empty || '';
  
  Is that possible to do with one line?
 
   $first || ($use_second  $second) || '';
 

Short and sweet! Thanks Bob!

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: One line variable declaration with multiple conditions

2004-01-07 Thread Dan Muey
  Howdy list.
  I'm trying to one lineify this:
  
  my $guts = $firstchoice || '';
  if(!$guts  $use_second_choice_if_first_is_empty) { 
  $guts = $secondchoice;
  }
  
  Basically
  my $guts = $firstchoice || $secondchoic || ''; 
  Would be perfect except I only want to let it use $seconchoice if
 $use_second_choice_if_first_is_empty has a true value.
  This does not work like I want but illustrates the goal if 
 you read it
 our loud.
  my $guts = $firstchoice || $secondchoic if
 $use_second_choice_if_first_is_empty || '';
  
  Is that possible to do with one line?
  
  TIA
  
  Dan
 
 Seems like the ternary operator should set you up... perldoc 
 perlop look for Conditional Operator...
 
 my $guts = (($firstchoice ne '') ? $firstchoice : 
 (($firstchoice eq '') ? $secondchoice : ''));

Except I only want to assign $secondchoice to it if  
$use_second_choice_if_first_is_empty is true.

BTW - I'm not really using these variable names, only using them here ot help clarify 
my goal.
Bob's woprks perfect and I havn';t tied Driex's as I have to leave right now. 
I'm going to benchmark them and see if there is any performance gain in either, though 
I doubt it.

Thanks
 
 Though there may be a better way using some combination of 
 ||= or am I misunderstanding you completely?
 
http://danconia.org


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: coping txt files over a peer to peer.

2004-01-07 Thread Dan Muey
 Hello folks,

Howdy, 
Funny I was just thinking about Sockets today.
I don't use them nitty gritty like this but I would assume you need to do multiple 
send/receive/accept in a little session via your own prtocol.

Something like:

Client hello
Server howdy
Client NAME fred.txt
Server NAMEIS fred.xt Thanks - SENDFILE
Client FILE 
Server Thanks Writing file...FILEOK
Client bye I am done
Server bye hava good one

I'm interested in seeing how to do this, sorry it probably wasn't much help.


 
 How do I send the file name used by the client so that the 
 server uses the same file name 
 When it is writing it own file. 
 
 
 thank you.
 
 here's the client: 
 
 use IO::Socket;
 
 my $server = IO::Socket::INET-ne­w(
PeerAddr = 'localhost',
PeerPort = 5050,
Proto= 'tcp'
 ) or die Can't create client socket: $!;
 
 
 open FILE, original_file_name;
 while (FILE) {
   print $server $_;
   }
 close FILE;
 
 
 Here's the server:
 
 use IO::Socket;
 
 my $server = IO::Socket::INET-ne­w(
Listen = 5,
LocalAddr = 'localhost',
LocalPort = 5050,
Proto = 'tcp'
 ) or die Can't create server socket: $!;
 
 my $client = $server-accept;
 
 
 open FILE, copy_file_name or die Can't open: $!;
  while ($client) {
print FILE $_;
}
 close FILE;
 
 
 --
 
 
 
 
 
 
 -- 
 __
 Check out the latest SMS services @ http://www.linuxmail.org 
 This allows you to send and receive SMS through your mailbox.
 
 
 Powered by Outblaze
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED] 
http://learn.perl.org/ http://learn.perl.org/first-response



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: coping txt files over a peer to peer.

2004-01-07 Thread Bakken, Luke
 Howdy, 
 Funny I was just thinking about Sockets today.
 I don't use them nitty gritty like this but I would assume 
 you need to do multiple send/receive/accept in a little 
 session via your own prtocol.
 
 Something like:
 
 Client hello
 Server howdy
 Client NAME fred.txt
 Server NAMEIS fred.xt Thanks - SENDFILE
 Client FILE 
 Server Thanks Writing file...FILEOK
 Client bye I am done
 Server bye hava good one
 
 I'm interested in seeing how to do this, sorry it probably 
 wasn't much help.
 
 
  
  How do I send the file name used by the client so that the 
  server uses the same file name 
  When it is writing it own file. 
  

This is a clever idea - you could also send the file name in a fixed
number of bytes at the beginning of the send, and read() that on the
recieving end first.

Luke

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: coping txt files over a peer to peer.

2004-01-07 Thread david
Tino Arellano wrote:

 Hello folks,
 
 How do I send the file name used by the client so that the server uses the
 same file name When it is writing it own file.

this can't be done without the client and server agree on how to retrive the 
file name. one reasonable approach is let the client send the filename 
first before any newline and then file content, the server will handle the 
task of separating the filename and file content. here is one simple 
implementation:

#!/usr/bin/perl -w
use strict;

use IO::Socket::INET;

#--
#-- server.pl
#--
my $server = IO::Socket::INET-new(Listen= 5,
   LocalAddr = 'localhost',
   LocalPort = 5050,
   Proto = 'tcp') || die $!;

#-- have we receive the filename from the client yet?
my $file = undef;

while(my $client = $server-accept){

#-- 
#-- in your code, you have while($client){...}
#-- which is very dangeous because  will hang if
#-- client and server use a different newline encoding
#-- so please avoid using $client in your networking code
#--
#-- 1024 is also a hack which assume your filename will not
#-- be longer than 1K.
#--
while(sysread($client,$_,1024)){

#--
#-- look for a filename before the first newline
#--
if(/(.+?)\n(.*)/  !$file){

#--
#-- for demo, i will create a filename (sent in by client)
#-- appending with .by_server. this helps you
#-- to run this demo code without worrying overwriting
#-- the original file in the same machine
#--
$file = $1 . '.by_server';
open(FILE,$file) || last;
print FILE $2;
}else{
print FILE if($file);
}
}

close(FILE) if($file);
close($client);
}

__END__

#!/usr/bin/perl -w
use strict;

use IO::Socket::INET;

#--
#-- client.pl
#--
my $server = IO::Socket::INET-new(PeerAddr = 'localhost',
   PeerPort = 5050,
   Proto= 'tcp') || die $!;

my $file = 'tmp.txt';

#--
#-- send the file name to server.pl
#--
print $server $file\n;

#--
#-- and then the content
#--
open(FILE,$file) || die $!;
print $server $_ while(FILE);
close(FILE);

close($server);

__END__

[panda]$ perl server.pl 
[1] 14329
[panda]$ perl client.pl
[panda]$ ls
tmp.txt  tmp.txt.by_server

notice the 'tmp.txt.by_server' file created by the server. other than the 
name, the file is identical to tmp.txt.

david
-- 
sub'_{print@_ ;* \ = * __ ,\  \}
sub'__{print@_ ;* \ = * ___ ,\  \}
sub'___{print@_ ;* \ = *  ,\  \}
sub'{print@_,\n}{_+Just}(another)-(Perl)-(Hacker)

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: utc to local time

2004-01-07 Thread Owen
On Wed, 7 Jan 2004 15:43:05 -0500
Paul Kraus [EMAIL PROTECTED] wrote:

 How can I convert a utc time stamp to a perl standard time stamp for my
 timezone?


Can you show what *your* UTC timestamp looks like

Can you give an example of a perl standard time stamp format



-- 
Owen


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: stop

2004-01-07 Thread R. Joseph Newton
Casey West wrote:

 It was Wednesday, January 07, 2004 when Dan Muey took the soap box, saying:
 : Please tell me this thread will stay in the archives! It's hilarious!
 :
 : I feel kinda bad for Mr. Kapp though, but if you're rude for no good
 : reason what can you expect.

 Well, around these parts we don't *expect* rudeness in return.  I
 believe that rudeness must conform to the all things in moderation
 rule whenever it cannot be helped, which /should/ never happen.  :-)

 For the record the archives don't lie, the thread will be there.
 That's precisely why rudeness must be kept in check.

 I think now is a good time to stop this thread.  Everything that
 should have been said has been, as well as some things that shouldn't
 have.  :-)

   Casey West

Hi Casey,

I think there is one point that I have not seen presented here.  Unfortunately,
many *real* spammers abuse the courtesy [or legal requirement?] of unsubscribe
information, and actually use it as a probe to detect live addresses.  At least
many people believe that this is so.  Some people may fear that they would only
get enmeshed more deeply by using the unsubscribe link.

Thanks for re-asserting the standards of kindness for the list.

Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: One line variable declaration with multiple conditions

2004-01-07 Thread R. Joseph Newton
Dan Muey wrote:

 Howdy list.
 I'm trying to one lineify this:

 my $guts = $firstchoice || '';
 if(!$guts  $use_second_choice_if_first_is_empty) {
 $guts = $secondchoice;
 }

 Basically
 my $guts = $firstchoice || $secondchoic || '';
 Would be perfect except I only want to let it use $seconchoice if 
 $use_second_choice_if_first_is_empty has a true value.
 This does not work like I want but illustrates the goal if you read it our loud.
 my $guts = $firstchoice || $secondchoic if $use_second_choice_if_first_is_empty || 
 '';

 Is that possible to do with one line?

 TIA

 Dan

I don't know Dan, it looks like you already said it clearly in the first cnstruct 
above.  I would not discard that clarity
without good reason.  Isn't it more important to say what you mean than to tuck it all 
up tightly?

Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: One line variable declaration with multiple conditions

2004-01-07 Thread R. Joseph Newton
Dan Muey wrote:

 BTW - I'm not really using these variable names, only using them here ot help 
 clarify my goal.

Why not?  They looked very good to me, at least in the context of the question at 
hand.  One of the
best aspects of Perl, IMHO, is that it allows you to just say what you mean.  I think 
people take far
too little advantage of this boon.


 Bob's woprks perfect

I agree.  It is quite elegant, with no loss of clarity.

Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response