RE: Use of uninitialized value

2005-09-13 Thread DBSMITH
   
 Charles K.   
 Clarkson 
 [EMAIL PROTECTED]  To 
 .net beginners@perl.org
cc 
 09/13/2005 01:19  
 PMSubject 
   RE: Use of uninitialized value  
   
   
   
   
   
   







[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote:

: do you want me to seed the entire program. it is over 700
: lines? it on lines 246 for eaxmple.  And anywhere I assign a
: variable to a q-param construct such as $which_import and
: $which_radio_button.

You could send us a working example which produces the same
error. Snip out the irrelevant parts of your script. There is a
chance that you will find the error as you write the example code.
That's happened to me more than once. :)


HTH,

Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328

*

I'd rather send the whole thing b/c I also would like a critique as well.
Here she is!

thank you

derek


(See attached file: ASM_monitor.pl)


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


RE: Use of uninitialized value

2005-09-13 Thread Charles K. Clarkson
[EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] wrote:

: I'd rather send the whole thing b/c I also would like a critique
: as well. Here she is!

First glaring item: you cannot nest subroutines. To perl, the
following are equivalent.


===
print blah;
if ( $which_radio_button eq 'All-Clients' ) {
viewall();

sub viewall {
# do something;
}

} elsif ( $which_radio_button eq 'Backup-Tapes' ) {
viewbkups();
sub viewbkups {
# do something else;
}
}


===

print blah;
if ( $which_radio_button eq 'All-Clients' ) {
viewall();

} elsif ( $which_radio_button eq 'Backup-Tapes' ) {
viewbkups();
}

sub viewall {
# do something;
}

sub viewbkups {
# do something else;
}

===

So there's no advantage to placing the subs in line and taking
them out makes your code more readable.


HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
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: Use of uninitialized value

2005-09-13 Thread Charles K. Clarkson

Which line is giving you the error? Line 246 is blank.


Charles K. Clarkson
-- 
Mobile Homes Specialist
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: Help with sprintf

2005-09-13 Thread John W. Krahn
Kevin Old wrote:
 Hello everyone,

Hello,

 I'm having trouble with sprintf.  I know it's some silly mistake I'm
 making, but can't seem to figure it out.
 
 Here's what I have:
 
 my @time = localtime();
 $time[4]++;
 $time[5] += 1900;
 my $lastmonday = sprintf(%02d, $time[5]) . sprintf(%02d, $time[4]) . '01';
 
 My result is: 20050901, but what I'm trying to get is 050901.
 
 Any ideas what I'm doing wrong?

You have to make the year a two digit number in order to display it correctly.

my @time = localtime;
$time[4]++;
$time[5] %= 100;
my $lastmonday = sprintf '%02d%02d01', @time[5,4];



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




Infinite loop problem

2005-09-13 Thread Vineet Pande

Dear Perl Guru:

I want to write a script which takes input a text file with sequence of 
alphabets (amino acids) like GAGAGAGAGGA etc. and converts them to a 
three letter corresponding code [G= GLY, A= ALA]. The output should be then 
written to another file. I wrote the following script, but it seems it goes 
in an infinite loop and only prints GLY GLY GLYinfinitely for an input 
of GAAAGAGAAGA etc. Any suggestions? Thanks in advance

-Vineet


#!/usr/bin/perl
use warnings;

my $fasta_file = fasta.txt; #this contains single letter code#
chomp $fasta_file;
my $charmm_file = charmm.txt; #this is expected to have three letter 
converted#

unless (open (IN, $fasta_file) )
{
print Cannot open file \fasta_file\\n\n;
exit;
}

open OUT, $charmm_file or die;
@protein = IN;
close IN;
$protein = join( '', @protein);
$protein =~ s/\s//g;

for ( $position=0; $position  length $protein; ++$protein )

{
$aa = substr($protein, $position, 1);


   if ($aa eq 'G') {
   $praa = GLY ;
   print OUT $praa;
   }
elsif ($aa eq 'A') {
   $prab = ALA ;
   print OUT $prab;
   }
else {
exit;
 }
  }

  close OUT;

**

_
FREE pop-up blocking with the new MSN Toolbar - get it now! 
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/



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




Re: Infinite loop problem

2005-09-13 Thread Xavier Noria

On Sep 13, 2005, at 13:00, Vineet Pande wrote:


for ( $position=0; $position  length $protein; ++$protein )


Look at the right, you are incrementing $protein instead of $position.

-- fxn

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




Re: Infinite loop problem

2005-09-13 Thread Chris Devers
On Tue, 13 Sep 2005, Xavier Noria wrote:

 On Sep 13, 2005, at 13:00, Vineet Pande wrote:
 
  for ( $position=0; $position  length $protein; ++$protein )
 
 Look at the right, you are incrementing $protein instead of $position.
 
And that's (part of) why the usual Perl idiom is to skip C style loops 
like this one in favor of the simpler, clearer

  foreach $position ( @protein )

which, in general, is a more direct approach to this kind of task.


-- 
Chris Devers

‡G“•Ãxb˜,¤;³
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response


[Fwd: Re: Infinite loop problem]

2005-09-13 Thread Suvajit Sengupta

Hi Vineet,

 Since Perl provides strong feature of pattern matching of Regular 
Expn you should use that.
Just read in the pattern GAGAGAGAGGA from the file and store it in a 
scalar variable.

You can refer to the following perl code snippet for getting  yout job done.
#! /usr/bin/perl
my $x = 'GAGAGAGAAAGG';
$x =~ s/G/GLY/g;  # Search for pattern G globally and replace it with 'GLY'
$x =~ s/A/ALA/g;  # Search for pattern A gloablly and replace it with 'ALA'
print $x;  # Print replaced string

1. Read in the string from your file .
2. Search and replace the string as required
3. Write the string in another file
The code wont take more than 10-12 lines. And the beauty is you dont have to 
iterate over your string.

Regards,
Suvajit


Vineet Pande wrote:


Dear Perl Guru:

I want to write a script which takes input a text file with sequence 
of alphabets (amino acids) like GAGAGAGAGGA etc. and converts them 
to a three letter corresponding code [G= GLY, A= ALA]. The output 
should be then written to another file. I wrote the following script, 
but it seems it goes in an infinite loop and only prints GLY GLY 
GLYinfinitely for an input of GAAAGAGAAGA etc. Any suggestions? 
Thanks in advance

-Vineet


#!/usr/bin/perl
use warnings;

my $fasta_file = fasta.txt; #this contains single letter code#
chomp $fasta_file;
my $charmm_file = charmm.txt; #this is expected to have three letter 
converted#

unless (open (IN, $fasta_file) )
{
print Cannot open file \fasta_file\\n\n;
exit;
}

open OUT, $charmm_file or die;
@protein = IN;
close IN;
$protein = join( '', @protein);
$protein =~ s/\s//g;

for ( $position=0; $position  length $protein; ++$protein )

{
$aa = substr($protein, $position, 1);


   if ($aa eq 'G') {
   $praa = GLY ;
   print OUT $praa;
   }
elsif ($aa eq 'A') {
   $prab = ALA ;
   print OUT $prab;
   }
else {
exit;
 }
  }

  close OUT;

**

_
FREE pop-up blocking with the new MSN Toolbar - get it now! 
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/






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




Re: Infinite loop problem

2005-09-13 Thread John Doe
Vineet Pande am Dienstag, 13. September 2005 13.00:
 Dear Perl Guru:

 I want to write a script which takes input a text file with sequence of
 alphabets (amino acids) like GAGAGAGAGGA etc. and converts them to a
 three letter corresponding code [G= GLY, A= ALA]. The output should be then
 written to another file. I wrote the following script, but it seems it goes
 in an infinite loop and only prints GLY GLY GLYinfinitely for an input
 of GAAAGAGAAGA etc. Any suggestions? Thanks in advance
 -Vineet

 
 #!/usr/bin/perl
 use warnings;

 my $fasta_file = fasta.txt; #this contains single letter code#
 chomp $fasta_file;
 my $charmm_file = charmm.txt; #this is expected to have three letter
 converted#
 unless (open (IN, $fasta_file) )
 {
 print Cannot open file \fasta_file\\n\n;
 exit;
 }

 open OUT, $charmm_file or die;
 @protein = IN;
 close IN;
 $protein = join( '', @protein);
 $protein =~ s/\s//g;

 for ( $position=0; $position  length $protein; ++$protein )

 {
 $aa = substr($protein, $position, 1);


 if ($aa eq 'G') {
 $praa = GLY ;
 print OUT $praa;
 }
  elsif ($aa eq 'A') {
 $prab = ALA ;
 print OUT $prab;
 }
  else {
  exit;
   }
}

close OUT;


Here another way (you have to integrate it), avoiding multiple print 
statements and a bit shorter:

[tested]

use strict;
use warnings;

# provide translation map:
my %map=(A='ALA ', G='GLY ');

# ...get input into $in...

my $txt='GAGAGAGAGGA'; # just an example

# not the fastest way, but adapts to the contents of %map:
$txt=~s/(.)/$map{$1}/gs;

print $txt;


# output:
GLY ALA GLY ALA GLY ALA GLY ALA GLY ALA ALA ALA ALA GLY ALA



joe

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




local variabless vs my

2005-09-13 Thread Christopher Spears
I've been reading the following docs on Perl
subroutines:

http://perldoc.perl.org/perlsub.html#Persistent-Private-Variables

I just read the section on local variables and am
completely confused.  What is a local variable?  How
is local $x different from my $x?

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




Re: local variabless vs my

2005-09-13 Thread Peter Scott
On Tue, 13 Sep 2005 06:09:22 -0700, Christopher Spears wrote:
 I've been reading the following docs on Perl
 subroutines:
 
 http://perldoc.perl.org/perlsub.html#Persistent-Private-Variables
 
 I just read the section on local variables and am
 completely confused.  What is a local variable?  How
 is local $x different from my $x?

Try this instead:

http://perl.plover.com/FAQs/Namespaces.html

-- 
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/


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




Algorithm Help Needed

2005-09-13 Thread Bob Showalter
Guys,

I need help with an algorithm. I'm writing a program that sends a repeated
pattern of requests to a service. Each request has a weight that controls
the relative frequency with which I need to send that particular request. So
given:

   foo = 1
   bar = 3

I would send four requests, one of which is a 'foo', and the other three are
'bar'. So my requests would look like:

   foo, bar, bar, bar, foo, bar, bar, bar, ...

If I have a case like:

   foo = 1
   bar = 1
   qux = 6

I can easily send one foo, followed by a bar, followed by 6 qux:

   foo
   bar
   qux qux qux qux qux qux

However, what I need to do is to distribute the requests so that the
intervals between instances of a given request are distributed as equally as
possible. For example:

   foo 
   qux qux qux
   bar 
   qux qux qux

Now I have only intervals of 0 or 1 between successive qux, instead of an
interval of 2 as in the previous case.

As an extreme example, if I had a dozen requests with a weight of 1 and a
final request with a weight of 12, I would starve the highly-weighted
request until the first 12 had been sent.

How can I generalize this for any given set of requests and weights? Is
anyone aware of any general literature on this kind of problem? (Sounds like
a scheduling algorithm maybe?)

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: Algorithm Help Needed

2005-09-13 Thread Jeff 'japhy' Pinyan

On Sep 13, Bob Showalter said:


I need help with an algorithm. I'm writing a program that sends a repeated
pattern of requests to a service. Each request has a weight that controls
the relative frequency with which I need to send that particular request.

  foo = 1
  bar = 1
  qux = 6


  foo
  qux qux qux
  bar
  qux qux qux

Now I have only intervals of 0 or 1 between successive qux, instead of an
interval of 2 as in the previous case.

As an extreme example, if I had a dozen requests with a weight of 1 and a
final request with a weight of 12, I would starve the highly-weighted
request until the first 12 had been sent.


The extreme cases are the easy ones, though.  What I'd like to see are 
cases like:


  foo = 1
  bar = 2
  qux = 3
  baz = 4
  zip = 5

Once I know what the algorithm's outcome should be for something like 
that, I think I can develop it.


--
Jeff japhy Pinyan%  How can we ever be the sold short or
RPI Acacia Brother #734%  the cheated, we who for every service
http://www.perlmonks.org/  %  have long ago been overpaid?
http://princeton.pm.org/   %-- Meister Eckhart

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




Comparing file contents (code included)

2005-09-13 Thread Robert
When Perl is doing this comparison is it doing it line by line (like an
actual DIFF) or is it putting the lines into an array and the checking
that array against the second file?

use strict;
use warnings;

open VASH, vash.txt or die Can't open the file: $!\n;
open MONH, monh.txt or die Can't open the file: $!\n;
open MANI, mani.txt or die Can't open the file: $!\n;

my %dict;

$dict{$_} = 1 while VASH;

# This will insert in the text files the lines that are in
# the Vashon but not in the Monhegan
while (MONH) {
open VASH2MONH, VASH2MONH.TXT;
print VASH2MONH if !$dict{$_};
close VASH2MONH;
}
print Mohegan comparison is done.\n;

# This will insert in the text files the lines that are in
# the Vashon but not in the Manitou
while (MANI) {
open VASH2MANI, VASH2MANI.TXT;
print VASH2MANI if !$dict{$_};
close VASH2MANI;
}
print Manitou comparison is done.\n;

close MANI;
close MONH;
close VASH;

print Comparison is completed.\n;

It works. I am just wondering in what fashion it IS working.

Robert



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




RE: Use of uninitialized value

2005-09-13 Thread DBSMITH
do you want me to seed the entire program. it is over 700 lines?
it on lines 246 for eaxmple.  And anywhere I assign a variable to a
q-param construct such as $which_import and $which_radio_button.

thank you so much!


Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams




   
 Jeff 'japhy'  
 Pinyan
 [EMAIL PROTECTED]  To 
 rg   [EMAIL PROTECTED]  
cc 
 09/12/2005 02:47  Charles K. Clarkson   
 PM[EMAIL PROTECTED], 
   beginners@perl.org  
   Subject 
   RE: Use of uninitialized value  
   
   
   
   
   
   




On Sep 12, [EMAIL PROTECTED] said:

 I have tried this and I am still getting a similiar error.
 Here is my perl-cgi code:

WHICH line is the uninitialized value warning coming from?

 my $which_import = $q-param('action') || '';

 foreach my $scalar (@imports)
 {
  if ($which_import eq 'Import H9940')
  {
 while (SAM)
 {
  if (/(?ig)$scalar/)

You can't put 'g' inside the (?...) construct of a regex.  That should be
written as

   /(?i)$scalar/g

or just

   /$scalar/ig

But I'm not even sure the /g is necessary...

--
Jeff japhy Pinyan%  How can we ever be the sold short or
RPI Acacia Brother #734%  the cheated, we who for every service
http://www.perlmonks.org/  %  have long ago been overpaid?
http://princeton.pm.org/   %-- Meister Eckhart



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




Re: Comparing file contents (code included)

2005-09-13 Thread Robert
I did see my %dict error but my question is still the same.

Robert



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




Re: Comparing file contents (code included)

2005-09-13 Thread Wiggins d'Anconia
Robert wrote:
 When Perl is doing this comparison is it doing it line by line (like an
 actual DIFF) or is it putting the lines into an array and the checking
 that array against the second file?


Well yes and no, to both. It is storing the lines temporarily, but it is
storing them to a hash, not an array. Then it is checking them line by
line. Depending on the purposes there are several large differences
between the code and a DIFF. For one, order is not maintained in a
hash so it is really checking just to see if the line did exist in the
first file, rather than that they are in the same order, which matters
to a diff. Secondly it is checking to see if that line is in fact Perly
true, so if a line consisted of just a 0 it would be false and return a
false negative. Thirdly, because a hash can only store a key a single
time then duplicated lines would be unconditionally kept, and no
indication provided, even if for example the second file contained 43
copies of the same line and the first file only contained 1.

There are other issues, for instance the first three opens check for
success but the others don't.  Additionally there is absolutely no
reason to open/close the file within the loops, this really kills
efficiency.

If you are really looking for a diff creator there are several good ones
on CPAN.

http://danconia.org

 use strict;
 use warnings;
 
 open VASH, vash.txt or die Can't open the file: $!\n;
 open MONH, monh.txt or die Can't open the file: $!\n;
 open MANI, mani.txt or die Can't open the file: $!\n;
 
 my %dict;
 
 $dict{$_} = 1 while VASH;
 
 # This will insert in the text files the lines that are in
 # the Vashon but not in the Monhegan
 while (MONH) {
 open VASH2MONH, VASH2MONH.TXT;
 print VASH2MONH if !$dict{$_};
 close VASH2MONH;
 }
 print Mohegan comparison is done.\n;
 
 # This will insert in the text files the lines that are in
 # the Vashon but not in the Manitou
 while (MANI) {
 open VASH2MANI, VASH2MANI.TXT;
 print VASH2MANI if !$dict{$_};
 close VASH2MANI;
 }
 print Manitou comparison is done.\n;
 
 close MANI;
 close MONH;
 close VASH;
 
 print Comparison is completed.\n;
 
 It works. I am just wondering in what fashion it IS working.
 
 Robert
 
 
 

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




Re: Algorithm Help Needed

2005-09-13 Thread Eric Walker
On Tuesday 13 September 2005 09:55 am, Jeff 'japhy' Pinyan wrote:
 On Sep 13, Bob Showalter said:
  I need help with an algorithm. I'm writing a program that sends a
  repeated pattern of requests to a service. Each request has a weight
  that controls the relative frequency with which I need to send that
  particular request.
 
foo = 1
bar = 1
qux = 6
 
 
foo
qux qux qux
bar
qux qux qux
 
  Now I have only intervals of 0 or 1 between successive qux, instead of
  an interval of 2 as in the previous case.
 
  As an extreme example, if I had a dozen requests with a weight of 1 and a
  final request with a weight of 12, I would starve the highly-weighted
  request until the first 12 had been sent.

 The extreme cases are the easy ones, though.  What I'd like to see are
 cases like:

foo = 1
bar = 2
qux = 3
baz = 4
zip = 5

 Once I know what the algorithm's outcome should be for something like
 that, I think I can develop it.

 --
 Jeff japhy Pinyan%  How can we ever be the sold short or
 RPI Acacia Brother #734%  the cheated, we who for every service
 http://www.perlmonks.org/  %  have long ago been overpaid?
 http://princeton.pm.org/   %-- Meister Eckhart

yes, how would you want to split zip which is odd..  Also, with your extreme 
case you said you would do all the singles first and do the 12 weighted one 
last. that goes against your primary objective which is to distribute the 
service request evenly . In that case I would expect the one with weight of 
12 to be distributed among the single weighted request..
if foon=1 and bar = 12 then
foon
bar
foon
bar
etc... 



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




Re: Comparing file contents (code included)

2005-09-13 Thread Robert
Wiggins d'Anconia [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Robert wrote:
  When Perl is doing this comparison is it doing it line by line (like an
  actual DIFF) or is it putting the lines into an array and the checking
  that array against the second file?
 

 Well yes and no, to both. It is storing the lines temporarily, but it is
 storing them to a hash, not an array. Then it is checking them line by
 line. Depending on the purposes there are several large differences
 between the code and a DIFF. For one, order is not maintained in a
 hash so it is really checking just to see if the line did exist in the
 first file, rather than that they are in the same order, which matters
 to a diff. Secondly it is checking to see if that line is in fact Perly
 true, so if a line consisted of just a 0 it would be false and return a
 false negative. Thirdly, because a hash can only store a key a single
 time then duplicated lines would be unconditionally kept, and no
 indication provided, even if for example the second file contained 43
 copies of the same line and the first file only contained 1.

 There are other issues, for instance the first three opens check for
 success but the others don't.  Additionally there is absolutely no
 reason to open/close the file within the loops, this really kills
 efficiency.

 If you are really looking for a diff creator there are several good ones
 on CPAN.

 http://danconia.org


Thanks. I am looking to see what is IN one file but NOT in the other (not a
DIFF). I will check but I believe that the lines themselves are unique.

I will remove the open and close from the loop and I fixed the checking for
open success.

Thanks!

Robert



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




Re: Comparing file contents (code included)

2005-09-13 Thread John W. Krahn
Wiggins d'Anconia wrote:
 Robert wrote:
When Perl is doing this comparison is it doing it line by line (like an
actual DIFF) or is it putting the lines into an array and the checking
that array against the second file?
 
 Well yes and no, to both. It is storing the lines temporarily, but it is
 storing them to a hash, not an array. Then it is checking them line by
 line. Depending on the purposes there are several large differences
 between the code and a DIFF. For one, order is not maintained in a
 hash so it is really checking just to see if the line did exist in the
 first file, rather than that they are in the same order, which matters
 to a diff. Secondly it is checking to see if that line is in fact Perly
 true, so if a line consisted of just a 0 it would be false and return a
 false negative.

No, the line contents are stored in the hash key but the check is done on the
hash value which is always one.


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: Use of uninitialized value

2005-09-13 Thread Charles K. Clarkson
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote:

: do you want me to seed the entire program. it is over 700
: lines? it on lines 246 for eaxmple.  And anywhere I assign a
: variable to a q-param construct such as $which_import and
: $which_radio_button.

You could send us a working example which produces the same
error. Snip out the irrelevant parts of your script. There is a
chance that you will find the error as you write the example code.
That's happened to me more than once. :)


HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
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: Comparing file contents (code included)

2005-09-13 Thread Wiggins d'Anconia
John W. Krahn wrote:
 Wiggins d'Anconia wrote:
 
Robert wrote:

When Perl is doing this comparison is it doing it line by line (like an
actual DIFF) or is it putting the lines into an array and the checking
that array against the second file?

Well yes and no, to both. It is storing the lines temporarily, but it is
storing them to a hash, not an array. Then it is checking them line by
line. Depending on the purposes there are several large differences
between the code and a DIFF. For one, order is not maintained in a
hash so it is really checking just to see if the line did exist in the
first file, rather than that they are in the same order, which matters
to a diff. Secondly it is checking to see if that line is in fact Perly
true, so if a line consisted of just a 0 it would be false and return a
false negative.
 
 
 No, the line contents are stored in the hash key but the check is done on the
 hash value which is always one.
 
 
 John

Ah, good point. Attention to detail

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: Algorithm Help Needed

2005-09-13 Thread Jay Savage
On 9/13/05, Eric Walker [EMAIL PROTECTED] wrote:
 On Tuesday 13 September 2005 09:55 am, Jeff 'japhy' Pinyan wrote:
  On Sep 13, Bob Showalter said:
   I need help with an algorithm. I'm writing a program that sends a
   repeated pattern of requests to a service. Each request has a weight
   that controls the relative frequency with which I need to send that
   particular request.
  
 foo = 1
 bar = 1
 qux = 6
  
  
 foo
 qux qux qux
 bar
 qux qux qux
  
   Now I have only intervals of 0 or 1 between successive qux, instead of
   an interval of 2 as in the previous case.
  
   As an extreme example, if I had a dozen requests with a weight of 1 and a
   final request with a weight of 12, I would starve the highly-weighted
   request until the first 12 had been sent.
 
  The extreme cases are the easy ones, though.  What I'd like to see are
  cases like:
 
 foo = 1
 bar = 2
 qux = 3
 baz = 4
 zip = 5
 
  Once I know what the algorithm's outcome should be for something like
  that, I think I can develop it.
 
  --
  Jeff japhy Pinyan%  How can we ever be the sold short or
  RPI Acacia Brother #734%  the cheated, we who for every service
  http://www.perlmonks.org/  %  have long ago been overpaid?
  http://princeton.pm.org/   %-- Meister Eckhart
 
 yes, how would you want to split zip which is odd..  Also, with your extreme
 case you said you would do all the singles first and do the 12 weighted one
 last. that goes against your primary objective which is to distribute the
 service request evenly . In that case I would expect the one with weight of
 12 to be distributed among the single weighted request..
 if foon=1 and bar = 12 then
 foon
 bar
 foon
 bar
 etc...

This sort of thing is unfortunately application specific, and depends
a lot on what your goal is. If you do a web search for wieghted round
robin or load balancing, you'll get a lot of food for thought. If you
really need to do careful scheduling--say for load balancing--you'll
need to take into account not just requests but open connections, and
the (unfortunately C, I think) code in the wikipedia weighted round
robin entry is reasonable.

On the other hand, if all you just need to ensure an *average*
response time over a significant number of iterations, and your goal
is statistical distribution not real-world load managment, randomizing
will serve you just as well and be much easier to implement:

#!/usr/bin/perl

use warnings;
use strict;
use List::Util qw(shuffle);

my %weights = ( 'foo' = 12,
'bar' = 7,
'baz' = 2,
'quux' = 6,
'zip' = 1);

my @a;

while (1) {
while (my($k, $v) = each %weights) {
push(@a, $k) for 1..$v;
}

foreach (shuffle(@a)) {
# do something
}
}

HTH,

-- jay
--
This email and attachment(s): [  ] blogable; [ x ] ask first; [  ]
private and confidential

daggerquill [at] gmail [dot] com
http://www.tuaw.com  http://www.dpguru.com  http://www.engatiki.org

values of β will give rise to dom!


RE: Use of uninitialized value

2005-09-13 Thread DBSMITH
   
 Charles K.   
 Clarkson 
 [EMAIL PROTECTED]  To 
 .net beginners@perl.org
cc 
 09/13/2005 01:19  
 PMSubject 
   RE: Use of uninitialized value  
   
   
   
   
   
   







[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote:

: do you want me to seed the entire program. it is over 700
: lines? it on lines 246 for eaxmple.  And anywhere I assign a
: variable to a q-param construct such as $which_import and
: $which_radio_button.

You could send us a working example which produces the same
error. Snip out the irrelevant parts of your script. There is a
chance that you will find the error as you write the example code.
That's happened to me more than once. :)


HTH,

Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328

*

I'd rather send the whole thing b/c I also would like a critique as well.
Here she is!

thank you

derek


(See attached file: ASM_monitor.pl)


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


Re: Comparing file contents (code included)

2005-09-13 Thread Robert
Is there a way (since I have the file open) that I can prepend a value (I
need a number to be inserted) onto the line?

Robert



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




Problem with backtick command to compile a perl program

2005-09-13 Thread Tony Frasketi
I can't seem to get any results back from compiling a perl progam from 
another perl program via the backtick method. My understanding that the 
output of the backtick command returns the results of the command 
executed into an array. And in the past I've used the backtick method 
successfully for getting output of the ls command.


Following is an extract from my program 
 ===

 my($filename) = /home/blahblah/cgi-bin/ifgen/ifgen.cgi
 my($command) = /usr/bin/perl -c $filename;
 print command[$command]br;
 my(@results) = `$command`;
 my $len = @results;
 print len[$len]br;
 print results of compile: [EMAIL PROTECTED]br;
 ===

And this is the output I get ...

command[/usr/bin/perl -c /home/blahblah/cgi-bin/ifgen/ifgen.cgi]
len[0]
results of compileresults[]
-
Any help would be greatly appreciated
TIA
Tony Frasketi
P.S. And I will try to break my habit of TOP POSTING  :-)


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




RE: Algorithm Help Needed

2005-09-13 Thread Bob Showalter
Jeff 'japhy' Pinyan wrote:
 The extreme cases are the easy ones, though.  What I'd like to see are
 cases like:
 
foo = 1
bar = 2
qux = 3
baz = 4
zip = 5
 
 Once I know what the algorithm's outcome should be for something like
 that, I think I can develop it.

Here's what I've come up with so far, which is extremely simple and seems to
work reasonably well:

1. Compute total weight as sum of individual weights
2. For each item in the list compute an interval as (total weight) /
(individual weight)
3. Write an entry for weight times, adding interval each time

So, for the example above, total weight is 15.

Start with foo: interval = 15 / 1 = 15. We need 1 foo, so:

   foo 15

bar: interval = 15 / 2 = 7.5. We need 2 bar's, so:

   bar 7.5
   bar 15

qux: interval = 15 / 3 = 5. Need 3 qux, so:

   qux 5
   qux 10
   qux 15

Final list is:

   foo 15
   bar 7.5
   bar 15
   qux 5
   qux 10
   qux 15
   baz 3.75
   baz 7.5
   baz 11.25
   baz 15
   zip 3
   zip 6
   zip 9
   zip 12
   zip 15

Now sort the list by column 2, then by column 1:

   zip 3
   baz 3.75
   qux 5
   zip 6
   bar 7.5
   baz 7.5
   zip 9
   qux 10
   baz 11.25
   zip 12
   bar 15
   baz 15
   foo 15
   qux 15
   zip 15

Column 1 becomes the round-robin sequence, with the right number of each
request, and farily evenly distributed.

The sequence starts and ends with a zip, so I have between 0 and 4 non-zip
entries between pairs of zip's. 6 of every 15 requests should be a zip, so
there should be an average of 1.5 non-zip's between zip's. Maybe I should
could tweak my algorithm to better smooth the distribution of zip's.

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




RE: Use of uninitialized value

2005-09-13 Thread Jeff 'japhy' Pinyan

On Sep 13, [EMAIL PROTECTED] said:


do you want me to seed the entire program. it is over 700 lines?
it on lines 246 for eaxmple.  And anywhere I assign a variable to a
q-param construct such as $which_import and $which_radio_button.


What I meant was, given the code you've SHOWN us, tell us WHICH of those 
lines produced the warning message.


--
Jeff japhy Pinyan%  How can we ever be the sold short or
RPI Acacia Brother #734%  the cheated, we who for every service
http://www.perlmonks.org/  %  have long ago been overpaid?
http://princeton.pm.org/   %-- Meister Eckhart

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




Re: Problem with backtick command to compile a perl program

2005-09-13 Thread Jeff 'japhy' Pinyan

On Sep 13, Tony Frasketi said:


my($filename) = /home/blahblah/cgi-bin/ifgen/ifgen.cgi
my($command) = /usr/bin/perl -c $filename;
print command[$command]br;
my(@results) = `$command`;


'perl -c' sends its output to STDERR, not STDOUT.  To catch that, I would 
suggest using the IPC::Open3 module, which comes with Perl.


--
Jeff japhy Pinyan%  How can we ever be the sold short or
RPI Acacia Brother #734%  the cheated, we who for every service
http://www.perlmonks.org/  %  have long ago been overpaid?
http://princeton.pm.org/   %-- Meister Eckhart

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




Re: Algorithm Help Needed

2005-09-13 Thread John W. Krahn
Jay Savage wrote:
 
 This sort of thing is unfortunately application specific, and depends
 a lot on what your goal is. If you do a web search for wieghted round
 robin or load balancing, you'll get a lot of food for thought. If you
 really need to do careful scheduling--say for load balancing--you'll
 need to take into account not just requests but open connections, and
 the (unfortunately C, I think) code in the wikipedia weighted round
 robin entry is reasonable.
 
 On the other hand, if all you just need to ensure an *average*
 response time over a significant number of iterations, and your goal
 is statistical distribution not real-world load managment, randomizing
 will serve you just as well and be much easier to implement:
 
 #!/usr/bin/perl
 
 use warnings;
 use strict;
 use List::Util qw(shuffle);
 
 my %weights = ( 'foo' = 12,
 'bar' = 7,
 'baz' = 2,
 'quux' = 6,
 'zip' = 1);
 
 my @a;
 
 while (1) {
 while (my($k, $v) = each %weights) {
 push(@a, $k) for 1..$v;

Or without the for modifier:

  push @a, ( $k ) x $v;


 }
 
 foreach (shuffle(@a)) {
 # do something
 }
 }


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: Problem with backtick command to compile a perl program

2005-09-13 Thread Tony Frasketi



Jeff 'japhy' Pinyan wrote:


On Sep 13, Tony Frasketi said:


my($filename) = /home/blahblah/cgi-bin/ifgen/ifgen.cgi
my($command) = /usr/bin/perl -c $filename;
print command[$command]br;
my(@results) = `$command`;



'perl -c' sends its output to STDERR, not STDOUT.  To catch that, I 
would suggest using the IPC::Open3 module, which comes with Perl.



Thanks for quick response, Jeff. I'll investigate IPC::Open3 module.
In the meantime, I've found the following also works to redirect STDERR 
to STDOUT..


my($command) = /usr/bin/perl -c $filename 21;

Thanks again!
Tony Frasketi


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




Re: Comparing file contents (code included)

2005-09-13 Thread Chris Charley


- Original Message - 
From: Robert [EMAIL PROTECTED]

Newsgroups: perl.beginners
To: beginners@perl.org
Sent: Tuesday, September 13, 2005 1:39 PM
Subject: Re: Comparing file contents (code included)



Is there a way (since I have the file open) that I can prepend a value (I
need a number to be inserted) onto the line?

Robert


Not sure what 'kind' of number you want. Perl provides the line of the read 
file in the variable, $. and I'm guessing you want to prepend 'some' number 
to your files being read. (VASH, MONH, MANI).


It all depends on what kind of number you want.

If you want to prepend to one of the read files, you could open them for 
inplace editing.

http://perldoc.perl.org/perlfaq5.html#How-can-I-use-Perl's-'-i'-option-from-within-a-program%3f

Chris 




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




Re: Comparing file contents (code included)

2005-09-13 Thread Robert

Chris Charley wrote:


- Original Message - From: Robert [EMAIL PROTECTED]
Newsgroups: perl.beginners
To: beginners@perl.org
Sent: Tuesday, September 13, 2005 1:39 PM
Subject: Re: Comparing file contents (code included)



Is there a way (since I have the file open) that I can prepend a value (I
need a number to be inserted) onto the line?

Robert



Not sure what 'kind' of number you want. Perl provides the line of the 
read file in the variable, $. and I'm guessing you want to prepend 
'some' number to your files being read. (VASH, MONH, MANI).


It all depends on what kind of number you want.

If you want to prepend to one of the read files, you could open them for 
inplace editing.
http://perldoc.perl.org/perlfaq5.html#How-can-I-use-Perl's-'-i'-option-from-within-a-program%3f 



Chris

I am sorry I wasn't more specific. I meant that for each line that is 
going to be written to the file that before that line is written to 
prepend it with a number, I mean all lines.


12345 this is the line
12345 this is the next line
12345 this is the next next line

I guess can I re-write the line before it gets written to the file?

Robert

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




how do i test for reference equality?

2005-09-13 Thread Denis
I am working with the perl Template-Toolkit with DateTime objects.
When I try to use the DateTime object:
[% dt.year %]
in the TT template the script dies:

undef error - Cannot compare a datetime to a regular scalar at 
/usr/local/lib/perl5/site_perl/5.8.7/i686-linux/DateTime.pm line 1397

I have traced the problem to the _dotop subroutine in Stash.pm of Template 
Toolkit.
The code in the subroutine tries to test for reference equality with the eq 
operator:
$foo eq $baz
DateTime object reference happens to be on the left side of the eq operator 
which is overloaded in  DateTime in such a way that it dies when an object 
of uncomparable type is encountered.

I've managed to hack the source to be like
$foo eq $baz
This performs a string comparison of references represnetation and is 
obviously inefficient.

Are there any ways to test whether the two references point to the same 
thing?




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




Can I alter the system wide @INC array?

2005-09-13 Thread Andre

Hello,

I have trouble to use the perldoc program.
I want to read the documentation for WidgetDemo which is installed
in /usr/lib/perl5/vendor_perl/5.8.5/i686-linux/Tk/WidgetDemo.pod.

When I give the command perldoc WidgetDemo then I get the
error 'No documentation found for WidgetDemo.'

The tail of output from perl -V is:
...
Characteristics of this binary (from libperl):
 Compile-time options: USE_LARGE_FILES
 Built under linux
 Compiled at Jul 20 2005 16:09:39
 @INC:
   /etc/perl
   /usr/lib/perl5/site_perl/5.8.6/i686-linux
   /usr/lib/perl5/site_perl/5.8.6
   /usr/lib/perl5/site_perl/5.8.5
   /usr/lib/perl5/site_perl
   /usr/lib/perl5/vendor_perl/5.8.6/i686-linux
   /usr/lib/perl5/vendor_pCharacteristics of this binary (from libperl):
 Compile-time options: USE_LARGE_FILES
 Built under linux
 Compiled at Jul 20 2005 16:09:39
 @INC:
   /etc/perl
   /usr/lib/perl5/site_perl/5.8.6/i686-linux
   /usr/lib/perl5/site_perl/5.8.6
   /usr/lib/perl5/site_perl/5.8.5
   /usr/lib/perl5/site_perl
   /usr/lib/perl5/vendor_perl/5.8.6/i686-linux
   /usr/lib/perl5/vendor_perl/5.8.6
   /usr/lib/perl5/vendor_perl/5.8.5
   /usr/lib/perl5/vendor_perl/5.8.5/i686-linux
   /usr/lib/perl5/vendor_perl
   /usr/lib/perl5/5.8.6/i686-linux
   /usr/lib/perl5/5.8.6
   /usr/local/lib/site_perl
   /usr/lib/perl5/site_perl/5.8.5
   .
erl/5.8.6
   /usr/lib/perl5/vendor_perl/5.8.5
   /usr/lib/perl5/vendor_perl/5.8.5/i686-linux
   /usr/lib/perl5/vendor_perl
   /usr/lib/perl5/5.8.6/i686-linux
   /usr/lib/perl5/5.8.6
   /usr/local/lib/site_perl
   /usr/lib/perl5/site_perl/5.8.5
   .
Characteristics of this binary (from libperl):
 Compile-time options: USE_LARGE_FILES
 Built under linux
 Compiled at Jul 20 2005 16:09:39
 @INC:
   /etc/perl
   /usr/lib/perl5/site_perl/5.8.6/i686-linux
   /usr/lib/perl5/site_perl/5.8.6
   /usr/lib/perl5/site_perl/5.8.5
   /usr/lib/perl5/site_perl
   /usr/lib/perl5/vendor_perl/5.8.6/i686-linux
   /usr/lib/perl5/vendor_perl/5.8.6
   /usr/lib/perl5/vendor_pCharacteristics of this binary (from libperl):
 Compile-time options: USE_LARGE_FILES
 Built under linux
 Compiled at Jul 20 2005 16:09:39
 @INC:
   /etc/perl
   /usr/lib/perl5/site_perl/5.8.6/i686-linux
   /usr/lib/perl5/site_perl/5.8.6
   /usr/lib/perl5/site_perl/5.8.5
   /usr/lib/perl5/site_perl
   /usr/lib/perl5/vendor_perl/5.8.6/i686-linux
   /usr/lib/perl5/vendor_perl/5.8.6
   /usr/lib/perl5/vendor_perl/5.8.5
   /usr/lib/perl5/vendor_perl/5.8.5/i686-linux
   /usr/lib/perl5/vendor_perl
   /usr/lib/perl5/5.8.6/i686-linux
   /usr/lib/perl5/5.8.6
   /usr/local/lib/site_perl
   /usr/lib/perl5/site_perl/5.8.5
   .
Characteristics of this binary (from libperl):
 Compile-time options: USE_LARGE_FILES
 Built under linux
 Compiled at Jul 20 2005 16:09:39
 @INC:
   /etc/perl
   /usr/lib/perl5/site_perl/5.8.6/i686-linux
   /usr/lib/perl5/site_perl/5.8.6
   /usr/lib/perl5/site_perl/5.8.5
   /usr/lib/perl5/site_perl
   /usr/lib/perl5/vendor_perl/5.8.6/i686-linux
   /usr/lib/perl5/vendor_perl/5.8.6
   /usr/lib/perl5/vendor_perl/5.8.5
   /usr/lib/perl5/vendor_perl/5.8.5/i686-linux
   /usr/lib/perl5/vendor_perl
   /usr/lib/perl5/5.8.6/i686-linux
   /usr/lib/perl5/5.8.6
   /usr/local/lib/site_perl
   /usr/lib/perl5/site_perl/5.8.5
   .
erl/5.8.5
   /usr/lib/perl5/vendor_perl/5.8.5/i686-linux
   /usr/lib/perl5/vendor_perl
   /usr/lib/perl5/5.8.6/i686-linux
   /usr/lib/perl5/5.8.6
   /usr/local/lib/site_perl
   /usr/lib/perl5/site_perl/5.8.5
   .

Now, can I permanently edit the value of the @INC?
I am using a Gentoo system.

Can anybody help?

Thanks.
Andre


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




Re: Comparing file contents (code included)

2005-09-13 Thread John Doe
Robert am Mittwoch, 14. September 2005 00.38:
 Chris Charley wrote:
  - Original Message - From: Robert [EMAIL PROTECTED]
  Newsgroups: perl.beginners
  To: beginners@perl.org
  Sent: Tuesday, September 13, 2005 1:39 PM
  Subject: Re: Comparing file contents (code included)
 
  Is there a way (since I have the file open) that I can prepend a value
  (I need a number to be inserted) onto the line?
 
  Robert
 
  Not sure what 'kind' of number you want. Perl provides the line of the
  read file in the variable, $. and I'm guessing you want to prepend
  'some' number to your files being read. (VASH, MONH, MANI).
 
  It all depends on what kind of number you want.
 
  If you want to prepend to one of the read files, you could open them for
  inplace editing.
  http://perldoc.perl.org/perlfaq5.html#How-can-I-use-Perl's-'-i'-option-fr
 om-within-a-program%3f
 
 
  Chris

 I am sorry I wasn't more specific. I meant that for each line that is
 going to be written to the file that before that line is written to
 prepend it with a number, I mean all lines.

 12345 this is the line
 12345 this is the next line
 12345 this is the next next line

 I guess can I re-write the line before it gets written to the file?

Of course, f.e. by replacing the line

   print VASH2MANI if !$dict{$_};

with 

   print VASH2MANI $some_value, $_ if !$dict{$_};

(where $some_value is what you want to prepend to the line(s))

joe

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




Re: Can I alter the system wide @INC array?

2005-09-13 Thread John Doe
Andre am Dienstag, 13. September 2005 22.08:
 Hello,

 I have trouble to use the perldoc program.
 I want to read the documentation for WidgetDemo which is installed
 in /usr/lib/perl5/vendor_perl/5.8.5/i686-linux/Tk/WidgetDemo.pod.

This means that the packages full name is Tk::WidgetDemo - translated to 
Tk/WidgetDemo.pm in the file system - ...

 When I give the command perldoc WidgetDemo then I get the
 error 'No documentation found for WidgetDemo.'

...so you find the documentation by 

perldoc Tk::WidgetDemo

 The tail of output from perl -V is:
[...]
   @INC:
 /etc/perl
 /usr/lib/perl5/site_perl/5.8.6/i686-linux

Within this include path is Tk/WidgetDemo.pm

[...]


joe

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




Re: how do i test for reference equality?

2005-09-13 Thread Adriano Ferreira
 Are there any ways to test whether the two references point to the same
 thing?

From perldoc perlref:

Using a reference as a number produces an integer
representing its storage location in memory. The only useful thing to be
done with this is to compare two references numerically to see whether
they refer to the same location.

if ($ref1 == $ref2) {  # cheap numeric compare of references
print refs 1 and 2 refer to the same thing\n;
}

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




Re: Comparing file contents (code included)

2005-09-13 Thread Robert

John Doe wrote:

Robert am Mittwoch, 14. September 2005 00.38:


Chris Charley wrote:


- Original Message - From: Robert [EMAIL PROTECTED]
Newsgroups: perl.beginners
To: beginners@perl.org
Sent: Tuesday, September 13, 2005 1:39 PM
Subject: Re: Comparing file contents (code included)



Is there a way (since I have the file open) that I can prepend a value
(I need a number to be inserted) onto the line?

Robert


Not sure what 'kind' of number you want. Perl provides the line of the
read file in the variable, $. and I'm guessing you want to prepend
'some' number to your files being read. (VASH, MONH, MANI).

It all depends on what kind of number you want.

If you want to prepend to one of the read files, you could open them for
inplace editing.
http://perldoc.perl.org/perlfaq5.html#How-can-I-use-Perl's-'-i'-option-fr
om-within-a-program%3f


Chris


I am sorry I wasn't more specific. I meant that for each line that is
going to be written to the file that before that line is written to
prepend it with a number, I mean all lines.

12345 this is the line
12345 this is the next line
12345 this is the next next line

I guess can I re-write the line before it gets written to the file?



Of course, f.e. by replacing the line

   print VASH2MANI if !$dict{$_};

with 


   print VASH2MANI $some_value, $_ if !$dict{$_};

(where $some_value is what you want to prepend to the line(s))

joe

Thanks, I will try that tomorrow.

Robert

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