An array like line that I do not understand

2006-06-16 Thread Alan_C
Hi,

I've a flat file database of sorts.  Each of the flat file has a keyword line 
as one of the first nine lines.  A keyword line begins with: #:

Here's a keyword line:

#: building a linux kernel from source

The enclosed Perl code uses a hash to store the name(s) of the particular flat 
file(s) that my search criteria was found in (this part works fine).

The problem is that, out of all the Perl code, there's only a line or two 
therein that I do not understand of which I think this doesn't use a hash and 
it stores the found keyword lines.

The actual problem is that it stores and then prints a particular keyword line 
more than once.

Here's the video screen output where you can see that I had to enter a 4 just 
in order to get what is listed (lists keyword lines) as the 6th or 7th line 
representing a flat file to choose from.

Also note that the next line after 7 lists the names of the flat files in 
which the search criteria is found and that there are 4 of these files listed 
(due to the hash I mentioned that prevents file name duplicates).

[EMAIL PROTECTED]:~$ grepf7tst build kernel

Perl db (default if none/nothing specified/entered)
1 nx db
2 sl db

enter (nothing) OR a 1 OR a 2: 2


db_choice is: sl

1 'build'  slack build slackbuild sbuild pkg

2 'build'  slack build slackbuild sbuild pkg

3 'build'  slack build slackbuild sbuild pkg

4 'kernel'  slackware 2.6 kernel howto

5 'kernel'  kernel compile install 2.6

6 'build'  building a linux kernel from source

7 'kernel'  building a linux kernel from source

/home/al/doc/db/sl/xsl0001 /home/al/doc/db/sl/xsl0002 
/home/al/doc/db/sl/xsl0008 /home/al/doc/db/sl/xsl0009

enter a digit: 4
/home/al/doc/db/sl/xsl0009
#: building a linux kernel from source

how I build my 2.6 kernels.
[ snip ]
# end of the video screen output

--

I need to eliminate those duplicated keyword lines in the numbered list.  In 
this particular search/case it's 2 and 3 and 7  (note that I chose 4 in order 
to get printed out #6 or #7).
-

In the code where I suspect the problem lies, am I on target as to where the 
problem is?  And, how to not have duplicated keyword lines?

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

my @search4 = @ARGV;# keywords

print STUF;

Perl db (default if none/nothing specified/entered)
1 nx db
2 sl db
STUF
print \nenter (nothing) OR a 1 OR a 2: ;
chomp(my $db_choice = STDIN);
print \n;

unless ($db_choice) {
$db_choice = 'pl';
}
   SWITCH: for ($db_choice) {
   /1/do { $db_choice = 'nx'; last; };
   /2/do { $db_choice = 'sl'; last; };
   /pl/   do {last; };
   die unknown value for form variable db_choice: `$db_choice';
   }

print \ndb_choice is: $db_choice\n;

@ARGV = glob /home/al/doc/db/$db_choice/x*;
my @lines;
while (  ) {
if ( s/^#:// ) {
push @lines, [ $ARGV, split ];
}

# quit looking when we reach the ninth line
close ARGV if $. == 9;
}
# map {print @$_} @lines; # works
# foreach (@lines) { # works
# print @$_, \n;
# }

print \n;
my $found_tally = 0;
my %data;
for my $keyline ( @lines ) {
my $filename = shift @$keyline;
for my $search ( @search4 ) {
for ( @$keyline ) {
if ( /$search/ ) {
# How to not have duplicated keyword lines?
# the next line I don't understand.  How to get it hash like?
push @{ $data{ $filename } }, $_; # I think this line cause
#print ++$found_tally .   . $search,@$keyline, \n; # 
prints keyline 4 ea found
print ++$found_tally, '$search'  @$keyline\n\n;
}
}
}
}

my @foundin = sort keys %data;
#print @foundin, \n; # does not print
print @foundin\n\n; # why are  needed?

# print wherefound '@foundin'\n\n;

print enter a digit: ;
my $d = STDIN - 1;

print $foundin[$d]\n;
open my $fh, $foundin[ $d ] or die Cannot open '$foundin[$d]' $!;
print while $fh;
# --- end 

Soon I'll also be looking for a way to add another choice to the initial menu 
so as to be able to glob both the nx and the sl folders in one go (I guess 
glob each then join or push or otherwise somehow combine then search).

-- 
Alan.

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




Re: Windows find what apps are opened

2006-06-16 Thread Dr.Ruud
Gallagher, Tim (NE) schreef:

Please don't top-post.

 What I am looking for is to see what apps are opened not processes.

So you need to find out how the Task Manager decides which processes are
applications or part of applications. That seems to be a question for a
windows newsgroup.

-- 
Affijn, Ruud

Gewoon is een tijger.



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




Re: scoping problem with hash

2006-06-16 Thread Paul Johnson
On Tue, Jun 13, 2006 at 12:06:02PM -0700, Lawrence Statton wrote:

 Charles Clarkson wrote:
  @{ %$hash_ref }{ keys %kv_pairs } = values %kv_pairs;
 
 You can excise a little of the snyactic sugar there
 
 @$hash_ref{keys %kv_pairs} = values %kv_pairs;

%hash = (%hash, %kv_pairs);

hmmm, tradeoffs ...

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

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




Re: scoping problem with hash

2006-06-16 Thread Beginner
On 16 Jun 2006 at 12:15, Paul Johnson wrote:

 On Tue, Jun 13, 2006 at 12:06:02PM -0700, Lawrence Statton wrote:
 
  Charles Clarkson wrote:
   @{ %$hash_ref }{ keys %kv_pairs } = values %kv_pairs;
  
  You can excise a little of the snyactic sugar there
  
  @$hash_ref{keys %kv_pairs} = values %kv_pairs;
 
 %hash = (%hash, %kv_pairs);
 
 hmmm, tradeoffs ...
 

Would anyone care to explain what any of these varations do? Are they all 
slices?

And while your at it you could also explain how to sort the reference by the 
hashkey when  
$hashkey looks like 'Mon-05'.  

$hashref{$hashkey}{name} = $name;  

I only ask because everyone seems eager to demonstate the perl prowess.  

Dp.



Dermot Paikkos

[EMAIL PROTECTED]
Network Administrator @ Science Photo Library
Phone: 0207 432 1100 
Fax: 0207 286 8668


PERL CGI drop down list

2006-06-16 Thread Mark Martin

Hi,
does anybody have the correct syntax for using a drop down list.
I'm using the object oriented type syntax for CGI. For example my text 
boxes are printed thus :


$cgi = new CGI;
print $cgi-input({-type=text,-name=textbox01,-class=textbox})

drop down list innormal html would be  :

select name=selectName size=1
option value=oneFirst
option value=twoSecond
option value=threeThird
/select

cant figure out for cgi . . . .??

Cheers,
Mark


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




About Encryption/ Decription

2006-06-16 Thread kilaru rajeev

Hi,

Please tell me how can we encrypt or decript file. Please give me the
information regarding this.

Regards,
Rajeev


RE: About Encryption/ Decription

2006-06-16 Thread Jeff Peng
Have you tried to search on CPAN? There are lots of modules for your 
requests there.




From: kilaru rajeev [EMAIL PROTECTED]
To: beginners@perl.org
Subject: About Encryption/ Decription
Date: Fri, 16 Jun 2006 16:29:09 +0530

Hi,

Please tell me how can we encrypt or decript file. Please give me the
information regarding this.

Regards,
Rajeev




--
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 CGI drop down list

2006-06-16 Thread Prabu Ayyappan

On 6/16/06, Mark Martin [EMAIL PROTECTED] wrote:


Hi,
does anybody have the correct syntax for using a drop down list.
I'm using the object oriented type syntax for CGI. For example my text
boxes are printed thus :

$cgi = new CGI;
print $cgi-input({-type=text,-name=textbox01,-class=textbox})

drop down list innormal html would be  :

select name=selectName size=1
option value=oneFirst
option value=twoSecond
option value=threeThird
/select

cant figure out for cgi . . . .??

Cheers,
Mark


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




See a small program for dropdown (popup_menu)

#!/usr/bin/perl

use CGI;
$p = new CGI;
print $p-header;
print $p-start_html();
print
$p-popup_menu(-name='dropdown',-values=['one','two','three','four']);
print $p-end_html;


--
Prabu M A


Re: scoping problem with hash

2006-06-16 Thread John W. Krahn
Beginner wrote:
 On 16 Jun 2006 at 12:15, Paul Johnson wrote:
 
On Tue, Jun 13, 2006 at 12:06:02PM -0700, Lawrence Statton wrote:

Charles Clarkson wrote:
@{ %$hash_ref }{ keys %kv_pairs } = values %kv_pairs;
You can excise a little of the snyactic sugar there

@$hash_ref{keys %kv_pairs} = values %kv_pairs;
%hash = (%hash, %kv_pairs);

hmmm, tradeoffs ...
 
 Would anyone care to explain what any of these varations do? Are they all 
 slices?

@{ %$hash_ref }{ keys %kv_pairs } = values %kv_pairs;

Which should really be:

@{ $hash_ref }{ keys %kv_pairs } = values %kv_pairs;

But the '%' is allowed for backward compatibility, and:

@$hash_ref{ keys %kv_pairs } = values %kv_pairs;

Do exactly the same thing - they add the keys and values of %kv_pairs to
$hash_ref (using a hash slice.)


%hash = ( %hash, %kv_pairs );

Creates a list of all the keys and values of %hash and %kv_pairs and assigns
that list to %hash overwriting its previous contents.



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: PERL CGI drop down list

2006-06-16 Thread Mr. Shawn H. Corey
On Fri, 2006-16-06 at 11:43 +, Mark Martin wrote:
 Hi,
 does anybody have the correct syntax for using a drop down list.
 I'm using the object oriented type syntax for CGI. For example my text 
 boxes are printed thus :
 
 $cgi = new CGI;
 print $cgi-input({-type=text,-name=textbox01,-class=textbox})
 
 drop down list innormal html would be  :
 
 select name=selectName size=1
   option value=oneFirst
   option value=twoSecond
   option value=threeThird
   /select
 
 cant figure out for cgi . . . .??


Search `perldoc CGI` for:

  CREATING A POPUP MENU

  CREATING AN OPTION GROUP

  CREATING A SCROLLING LIST


-- 
__END__

Just my 0.0002 million dollars worth,
   --- Shawn

For the things we have to learn before we can do them, we learn by doing them.
  Aristotle

* Perl tutorials at http://perlmonks.org/?node=Tutorials
* A searchable perldoc is at http://perldoc.perl.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 CGI drop down list

2006-06-16 Thread Chandru

Prabu Ayyappan wrote:

On 6/16/06, Mark Martin [EMAIL PROTECTED] wrote:


Hi,
does anybody have the correct syntax for using a drop down list.
I'm using the object oriented type syntax for CGI. For example my text
boxes are printed thus :

$cgi = new CGI;
print $cgi-input({-type=text,-name=textbox01,-class=textbox})

drop down list innormal html would be  :

select name=selectName size=1
option value=oneFirst
option value=twoSecond
option value=threeThird
/select

cant figure out for cgi . . . .??

Cheers,
Mark


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




See a small program for dropdown (popup_menu)

#!/usr/bin/perl

use CGI;
$p = new CGI;
print $p-header;
print $p-start_html();
print
$p-popup_menu(-name='dropdown',-values=['one','two','three','four']);
print $p-end_html;



Seems good :)

-Chandru



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




Re: About Encryption/ Decription

2006-06-16 Thread Prabu

kilaru rajeev wrote:

Hi,

Please tell me how can we encrypt or decript file. Please give me the
information regarding this.

Regards,
Rajeev


Try out with the modules available in

http://search.cpan.org/~aar/Module-Crypt-0.04/Crypt.pm 
http://search.cpan.org/%7Eaar/Module-Crypt-0.04/Crypt.pm


*Module::Crypt*

--
Prabu

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




Re: About Encryption/ Decription

2006-06-16 Thread Prabu

kilaru rajeev wrote:

Hi,

Please tell me how can we encrypt or decript file. Please give me the
information regarding this.

Regards,
Rajeev


Try out with the modules available in

http://search.cpan.org/~aar/Module-Crypt-0.04/Crypt.pm

Module::Crypt

--
Prabu

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




Re: defaults

2006-06-16 Thread Dr.Ruud
(Randal L. Schwartz) schreef:

 And I came up with this:

 $variable ||= 0; # all false values become 0
 $variable = 1; # all true values become 1

How about this:

  ($variable ||= 0) = 1 ;

or

  ($variable = 1) ||= 0 ;

depending on whether you expect $variable to be false or true.

-- 
Affijn, Ruud

Gewoon is een tijger.



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




Re: scoping problem with hash

2006-06-16 Thread Mr. Shawn H. Corey
On Fri, 2006-16-06 at 12:15 +0200, Paul Johnson wrote:
 On Tue, Jun 13, 2006 at 12:06:02PM -0700, Lawrence Statton wrote:
 
  Charles Clarkson wrote:
   @{ %$hash_ref }{ keys %kv_pairs } = values %kv_pairs;
  
  You can excise a little of the snyactic sugar there
  
  @$hash_ref{keys %kv_pairs} = values %kv_pairs;
 
 %hash = (%hash, %kv_pairs);
 
 hmmm, tradeoffs ...

When I wrote the original subroutine, I wanted to avoid things like
this. After all, push can be replaced in a similar manner:

  push @list, $item;
  @list = (@list, $item);

However, you have inspired a new version:
# --
# hset %hash, ( $key = $value, ... );
#   Augment the hash with the key-value pairs.
#   WARNING: This subroutine overwrites the value of any key that
already
#   exists.
sub hset (\%%) {
  my $hash_ref = shift;

  die odd number of items in hash\n if @_ % 2;

  while( @_ ){
my $key = shift @_;
$hash_ref-{$key} = shift @_;
  }
}


-- 
__END__

Just my 0.0002 million dollars worth,
   --- Shawn

For the things we have to learn before we can do them, we learn by doing them.
  Aristotle

* Perl tutorials at http://perlmonks.org/?node=Tutorials
* A searchable perldoc is at http://perldoc.perl.org/



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




AW: DESTROY executed twice

2006-06-16 Thread Glaessl, Danilo
 Thank you, that's it! Removing the exit call from DESTROY solves the problem.

-Ursprüngliche Nachricht-
Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Tom Phoenix
Gesendet: Mittwoch, 14. Juni 2006 18:15
An: Glaessl, Danilo
Cc: beginners@perl.org
Betreff: Re: DESTROY executed twice

On 6/13/06, Glaessl, Danilo [EMAIL PROTECTED] wrote:

 sub DESTROY {

 exit($exit_code);
 }

I don't think that exit() will do what you might expect, when called from 
DESTROY. At that point, the DESTROY hasn't finished, so your object is still 
alive, and thus it will need to be sent DESTROY I don't know that this is 
why you're seeing it called twice, but my tests seem to bear that out:

  my $obj = bless {}, 'Tryout';
  my $count = 0;

  sub Tryout::DESTROY {
print This is destruction , ++$count, \n;
exit($count);
  }

There may be other problems in your code as well, but this one jumps out at me. 
Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

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




Re: About Encryption/ Decription

2006-06-16 Thread Anthony Ettinger

interesting, has anybody had any success with this on nix and win32 platforms?

On 6/16/06, Prabu [EMAIL PROTECTED] wrote:

kilaru rajeev wrote:
 Hi,

 Please tell me how can we encrypt or decript file. Please give me the
 information regarding this.

 Regards,
 Rajeev

Try out with the modules available in

http://search.cpan.org/~aar/Module-Crypt-0.04/Crypt.pm

Module::Crypt

--
Prabu

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






--
Anthony Ettinger
Signature: http://chovy.dyndns.org/hcard.html

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




Re: An array like line that I do not understand

2006-06-16 Thread Dave Gray

On 6/16/06, Alan_C [EMAIL PROTECTED] wrote:
[snip]

1 'build'  slack build slackbuild sbuild pkg

2 'build'  slack build slackbuild sbuild pkg

3 'build'  slack build slackbuild sbuild pkg

4 'kernel'  slackware 2.6 kernel howto

5 'kernel'  kernel compile install 2.6

6 'build'  building a linux kernel from source

7 'kernel'  building a linux kernel from source

[snip]

for my $keyline ( @lines ) {
my $filename = shift @$keyline;
for my $search ( @search4 ) {
for ( @$keyline ) {
if ( /$search/ ) {
# How to not have duplicated keyword lines?
# the next line I don't understand.  How to get it hash like?
push @{ $data{ $filename } }, $_; # I think this line cause
#print ++$found_tally .   . $search,@$keyline, \n; #
prints keyline 4 ea found
print ++$found_tally, '$search'  @$keyline\n\n;

last;

}
}
}
}


Notice that the first three matches are the same, and the word build
occurs 3 times in that one @$keyline array. Sounds like you want to
stop looping over [EMAIL PROTECTED] after your first match.

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: An array like line that I do not understand

2006-06-16 Thread Mr. Shawn H. Corey
On Thu, 2006-15-06 at 23:31 -0700, Alan_C wrote:
 1 'build'  slack build slackbuild sbuild pkg
 
 2 'build'  slack build slackbuild sbuild pkg
 
 3 'build'  slack build slackbuild sbuild pkg
 
 4 'kernel'  slackware 2.6 kernel howto
 
 5 'kernel'  kernel compile install 2.6
 
 6 'build'  building a linux kernel from source
 
 7 'kernel'  building a linux kernel from source

See `perldoc -q duplicate`


-- 
__END__

Just my 0.0002 million dollars worth,
   --- Shawn

For the things we have to learn before we can do them, we learn by doing them.
  Aristotle

* Perl tutorials at http://perlmonks.org/?node=Tutorials
* A searchable perldoc is at http://perldoc.perl.org/



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




Term::Readline

2006-06-16 Thread Jorge Almeida

Anyone knows some tutorial about using Term::Readline::Gnu?
Or some article, somewhere?

--
Jorge Almeida

--
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 CGI drop down list

2006-06-16 Thread Prabu

Mark Martin wrote:

Thanks Prabu ,
Works great. I'm not having any luck finding good documentation on 
this so I'll throw 2 more questions at you if that's okay:


Is there a method for setting the selected  value as with the html 
below? Also, is it possible to display meaningful text instead of the 
value as with the html below?


select name='dropdown' size=1
option value=oneOn
option value=two selectedOff
/select

Cheers,
Mark




Hello Mark,

Hope this helps you,

#!/usr/bin/perl
use CGI;
$p = new CGI;
print $p-header;
print $p-start_html();
%attributes = ('on'={'name'='one'},'off'={'name'='two'});
print $p-popup_menu(-name='dropdown', -size='1',
 -values=['on','off'],
 
-default='off',-attributes=\%attributes);

print $p-end_html;



---
Prabu.M.A



At 16:59 16/06/2006 +0530, Prabu Ayyappan wrote:

On 6/16/06, Mark Martin [EMAIL PROTECTED] wrote:


Hi,
does anybody have the correct syntax for using a drop down list.
I'm using the object oriented type syntax for CGI. For example my text
boxes are printed thus :

$cgi = new CGI;
print $cgi-input({-type=text,-name=textbox01,-class=textbox})

drop down list innormal html would be  :

select name=selectName size=1
option value=oneFirst
option value=twoSecond
option value=threeThird
/select

cant figure out for cgi . . . .??

Cheers,
Mark


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



See a small program for dropdown (popup_menu)

#!/usr/bin/perl

use CGI;
$p = new CGI;
print $p-header;
print $p-start_html();
print
$p-popup_menu(-name='dropdown',-values=['one','two','three','four']);
print $p-end_html;


--
Prabu M A





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




Re: An array like line that I do not understand

2006-06-16 Thread Alan_C
On Friday 16 June 2006 09:02, you wrote:
 On 6/16/06, Alan_C [EMAIL PROTECTED] wrote:
 [snip]

  1 'build'  slack build slackbuild sbuild pkg
 
  2 'build'  slack build slackbuild sbuild pkg
 
  3 'build'  slack build slackbuild sbuild pkg
 
  4 'kernel'  slackware 2.6 kernel howto
 
  5 'kernel'  kernel compile install 2.6
 
  6 'build'  building a linux kernel from source
 
  7 'kernel'  building a linux kernel from source

 [snip]

  for my $keyline ( @lines ) {
      my $filename = shift @$keyline;
      for my $search ( @search4 ) {
          for ( @$keyline ) {
              if ( /$search/ ) {
  # How to not have duplicated keyword lines?
  # the next line I don't understand.  How to get it hash like?
                  push @{ $data{ $filename } }, $_; # I think this line
  cause #                print ++$found_tally .   . $search,@$keyline,
  \n; # prints keyline 4 ea found
                  print ++$found_tally, '$search' [EMAIL PROTECTED];

 last;

                  }
              }
          }
      }

 Notice that the first three matches are the same, and the word build
 occurs 3 times in that one @$keyline array. Sounds like you want to
 stop looping over [EMAIL PROTECTED] after your first match.

That definitely helps.

Except for when there are two different search words found in the *same* 
keyline (it doesn't iterate or go far enough back up the nested levels so as 
to get the next keyline until it exhausts all search word searches on a 
particular keyline)

[EMAIL PROTECTED]:~$ !498
grepf7tst build kernel

[ snip ]
db_choice is: sl

1 'build'  slack build slackbuild sbuild pkg

2 'kernel'  slackware 2.6 kernel howto

3 'kernel'  kernel compile install 2.6

4 'build'  building a linux kernel from source

5 'kernel'  building a linux kernel from source
---

(there's still only 4 files that the criteria is found in)

1 through 4 calls and then prints a particular file.  But 5 calls nothing 
except a bunch of uninitialized value errors.

4 and 5 I'd want concatenated into one #4 line, like so:

4 'build' 'kernel' building a linux kernel from source

 # the next line I don't understand.  How to get it hash like?
                 push @{ $data{ $filename } }, $_; # I think this line cause

And *now* I see that that line *is* a hash, push filename onto %data hash

And I *now* see that my problem is the print line:

print ++$found_tally, '$search' [EMAIL PROTECTED];

But since it prints 3 separate parameters, I'm confused if it can somehow into 
hash rather than print it at that point.

An alternative way to do it could be to check if a particular keyword line has 
been visited more than once, and if so, concatenate the multiple search words 
together as per my above example (and do not increment ++$found_tally).

I suppose I need some hints and/or additional assistance, otherwise I might 
create an increment operator that I can then check to see if I've already 
visited a particular keyword line and if so, concatenate the search words.  
But I haven't a clue how I'd concatenate the search words before the printing 
out of that keyline.

Thanks.

-- 
Alan.

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




RE: Exec a script on one server that will exec other scripts on a different serv

2006-06-16 Thread Alan Reinhold
It would seem to be that the best solution here would be to have a server 
script that creates a tcp/ip socket and sites on a read on the socket, in 
which then the client connects to the server, sends a msg, and based on that 
msg, the server would execute the desired action.  This would be a tpical 
server-client network communication procedure.  The server script would sit 
in a state in which it is waiting for the other side of the socket to be 
connect by the client, accept a msg, and then disconnect the client, and 
what for another connection.


Alan



From: William Paulsen (W) [EMAIL PROTECTED]
To: Jerry DuVal [EMAIL PROTECTED], beginners@perl.org
Subject: RE: Exec a script on one server that will exec other scripts on a 
different server..

Date: Thu, 8 Jun 2006 15:31:12 +0200


Adding it would be an advantage, however right now I just need setup a
client side script that'll tell the server side to exec/run one of
three scripts on the other server.

tks
William
Gugulethu

-Original Message-
From: Jerry DuVal [mailto:[EMAIL PROTECTED]
Sent: 08 June 2006 03:09 PM
To: William Paulsen (W); beginners@perl.org
Subject: RE: Exec a script on one server that will exec other scripts
on a different server..



-Original Message-
From: William Paulsen (W) [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 08, 2006 8:54 AM
To: beginners@perl.org
Subject: Exec a script on one server that will exec other scripts on
a
different server..


Hi,

I'm trying to write a perl script that will run on one server but can
instruct either socker server deamon on another server to exec any
one
of three applications on a different box.  The reason for this is the
password changes every month and the scripts that I'm currently using
fails because of that.  Is this possible in perl?


Can you add public/private keys pairs then a password is not needed?


~~
This e-mail and its contents are subject to the Telkom SA Limited
e-mail legal notice available at
http://www.telkom.co.za/TelkomEMailLegalNotice.PDF
~~

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





_
Don’t just search. Find. Check out the new MSN Search! 
http://search.msn.click-url.com/go/onm00200636ave/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: Term::Readline

2006-06-16 Thread Prabu

Jorge Almeida wrote:

Anyone knows some tutorial about using Term::Readline::Gnu?
Or some article, somewhere?


Hello,

There are some programs under directories eg/ and t/ in 
Term::Readline::Gnu module which includes many examples which this 
modules support.

Also read the description about the function in

http://search.cpan.org/dist/Term-ReadLine-Gnu/Gnu.pm

hope will help u to get some idea.

--
Prabu

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




Re: An array like line that I do not understand

2006-06-16 Thread Alan_C
On Friday 16 June 2006 09:02, you wrote:
 On 6/16/06, Alan_C [EMAIL PROTECTED] wrote:
 [snip]

  1 'build'  slack build slackbuild sbuild pkg
 
  2 'build'  slack build slackbuild sbuild pkg
 
  3 'build'  slack build slackbuild sbuild pkg
 
  4 'kernel'  slackware 2.6 kernel howto
 
  5 'kernel'  kernel compile install 2.6
 
  6 'build'  building a linux kernel from source
 
  7 'kernel'  building a linux kernel from source

 [snip]

  for my $keyline ( @lines ) {
  my $filename = shift @$keyline;
  for my $search ( @search4 ) {
  for ( @$keyline ) {
  if ( /$search/ ) {
  # How to not have duplicated keyword lines?
  # the next line I don't understand.  How to get it hash like?
  push @{ $data{ $filename } }, $_; # I think this line
  cause #print ++$found_tally .   . $search,@$keyline,
  \n; # prints keyline 4 ea found
  print ++$found_tally, '$search'  @$keyline\n\n;

 last;

  }
  }
  }
  }

[ . . ]

[EMAIL PROTECTED]:~$ grepf7tst build kernel
[ snip ]
1 'build'  slack build slackbuild sbuild pkg
2 'kernel'  slackware 2.6 kernel howto
3 'kernel'  kernel compile install 2.6
4 'build'  building a linux kernel from source
4 'kernel'  building a linux kernel from source

That's acceptable (4 files, 4 digits)

I changed $found_tally to $file_tally since this is what I use to represent 
(as a digit) which file I will then choose to be printed.

I added $i to track when the same keyline is visited more than once.

Upon succesive visits to the same keyline, $file_tally does not get 
incremented.

IOW there is only to be just one increment of $file_tally for each keyline.

It works.  I suspect there likely is a more elegant way in which to achieve 
this.  But then again I also have yet more learning curve to go through too.

Thanks!!

my $file_tally = 0;
my $i;
my %data;
for my $keyline ( @lines ) {
my $filename = shift @$keyline;
$i = 0; # now its a fresh keyline
for my $search ( @search4 ) {
for ( @$keyline ) {
if ( /$search/ ) {
push @{ $data{ $filename } }, $_;
++$i; # tracks multiple visits to one keyline
#print ++$file_tally .   . $search,@$keyline, \n;
# dont inc file_tally upon any successive visit to the same keyline
$file_tally-- if $i  1;
print ++$file_tally, '$search'  @$keyline\n;
last;
}
}
}
}
# end of code snippet

-- 
Alan.

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