Perl regular expresions HELP!

2002-02-13 Thread Bruce Ambraal

Please explain to me what this code does, here I'm tying to rename files
in current directory to 1.fil, 2.fil, ...

foreach my $f ( @files ){
if( $f =~ /private/ ){ next; }
chomp $f;
$fil{$f} = 0;
# if we match the extension...
if( $f =~ /\.$extension$/ ){
}
# if this isn't a directory name...
if( $f !~ /\\$/ ){ delete( $fil{$f} ); }
}

The complete program is:

#!/usr/local/bin/perl -w
# first example...

use strict;

# declarations...
my @files = `ls -F`;
my %fil;
foreach my $f ( @files ){
if( $f =~ /private/ ){ next; }
chomp $f;
$fil{$f} = 0;
# if we match the extension...
if( $f =~ /\.$extension$/ ){
}
# if this isn't a directory name...
if( $f !~ /\\$/ ){ delete( $fil{$f} ); }
}

Would some luv some assistance.

The struggling part is after having read current dir file into an array, I now want to 
rename these files into current dir to 
1.fill, 2.fill, ...

PLEASE HELP!!!

THANK!
Bruce






--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: finding .jpg or any .extention file

2002-02-13 Thread Bruce Ambraal

John
This is greater than great...
Thinks are getting to hot for me.
Thank again, I'll chat to you tomorrow, have to go...

In mean time  you may think about the this one, and don't tell me you got this one too.

Goes like this:
1)Open a file, create if necessary,
2)Prints you name into the file every time someone presses "enter",
3)Print a newline
4)Seek to the beginning of the file without closing the file
5)Print the file to STDOUT.

cheers for now and thank alot
Bruce


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: finding .jpg or any .extention file

2002-02-13 Thread Bruce Ambraal

Hey!!!

This man is really hot, he must be the man of the hour with more power.
thanks 
 and just for this last one modfication to the obove:

"Now I need to read in the extension from the command line"

John how long are you into perl?

Cheers
Bruce



>>> John Edwards <[EMAIL PROTECTED]> 02/13/02 05:32PM >>>
OK. Using the code from before

#!/usr/local/bin/perl -w
# first example...

use strict;

# declarations...
my @files = `ls -F`;
my %fil;

my $extension = "jpg";

foreach ( @files ){ # Use the special $_ var to store each iteration
next if /private/i; # Stop this iteration if the value of $_
contains private, case insensitive
chomp; # Chomp defaults to $_ if not specified.
# This line isn't needed $fil{$f} = 0; #
# if we match the extension...
if(/\.$extension$/){
$fil{$_} = $_;
}
# if this IS a directory - Surely you only want your list of files
to consist of file, not dirs?? - remove the entry from the %fil hash
# if(-d $_) delete( $fil{$_} ); As we no longer create the hash pair
unless the file matches the extension this isn't needed either
}

foreach my $key (sort keys %fil) {
print "$key\n";
}

Although, unless you do something more with the hash, you may be better off
storing the values in an array like this

#!/usr/local/bin/perl -w
# first example...

use strict;

# declarations...
my @files = `ls -F`;
my @jpegs;

my $extension = "jpg";

foreach ( @files ){
next if /private/i;
chomp;

if(/\.$extension$/){
push(@jpegs, $_);
}
}

foreach (@jpegs) {
    print "$_\n";
}

HTH

John

-Original Message-
From: Bruce Ambraal [mailto:[EMAIL PROTECTED]] 
Sent: 13 February 2002 15:30
To: [EMAIL PROTECTED] 
Subject: RE: finding .jpg or any .extention file


Hi Jonh

I want to recursively find files in a directory that end in .jpg.
Would you assist with this one?

Cheers
Bruce



--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Help can't figure this one out

2002-02-13 Thread Bruce Ambraal

I have written following coding to produce a triangle pattern(see below);
I now want to  produce following paterns I can't figer this out

(a)(b) (c) (d) diamond 
   
   ** * * * *   * * * * *  *
 * *   * * * ** * * ** * *
   * * *   * * ** * *   * * * *
 * * * *   * ** *  * * * * *
   * * * * *  * ** * * *
* * *
  *
__ 
#!/usr/local/bin/perl -w
my $num_rows;
my $i;
my $r;

$num_rows = ;

for ($r = 1; $r <= $num_rows; $r++)
{
# indent by printing num_rows - r spaces
for ($i = 1; $i <= $num_rows - $r; $i++) {print ("  \n");}
# print r asterisks
   for ($i=1; $i<= $r; $i++) { print (" *");}
# drop cursor to a new line
  print "\n";
 }
# end for

-
unxsup:/home/bruce$ perl triangle.pl
5




 *



 * *


 * * *

 * * * *
 * * * * *

Cheer
Bruce


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Generating for loop paterns HELP!

2002-02-13 Thread Bruce Ambraal

Hi

 I have done (b) for coding see below, could someone assist with
(a)  (b) (d)

#!/usr/local/bin/perl -w
my $num_rows;
my $i;
my $r;


$num_rows = ;

for ($r = 1; $r <= $num_rows; $r++)
{
 for ($i=1; $i<= $r; $i++) {print ("  \n");}
 for ($i = $num_rows + 1 - $r;$i>=1; $i--){ print ("  * ");}
}# end for
print ("  \n");

solution:
-

5

  *   *   *   *   *

  *   *   *   *


  *   *   *



  *   *




  *


Thanks 
Bruce

--- Begin Message ---

I have written following coding to produce a triangle pattern(see below);
I now want to  produce following paterns I can't figer this out

(a)(b) (c) (d) diamond 
   
   ** * * * *   * * * * *  *
 * *   * * * ** * * ** * *
   * * *   * * ** * *   * * * *
 * * * *   * ** *  * * * * *
   * * * * *  * ** * * *
* * *
  *
__ 
#!/usr/local/bin/perl -w
my $num_rows;
my $i;
my $r;

$num_rows = ;

for ($r = 1; $r <= $num_rows; $r++)
{
# indent by printing num_rows - r spaces
for ($i = 1; $i <= $num_rows - $r; $i++) {print ("  \n");}
# print r asterisks
   for ($i=1; $i<= $r; $i++) { print (" *");}
# drop cursor to a new line
  print "\n";
 }
# end for

-
unxsup:/home/bruce$ perl triangle.pl
5




 *



 * *


 * * *

 * * * *
 * * * * *

Cheer
Bruce


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



--- End Message ---

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Generating for loop paterns HELP!

2002-02-14 Thread Bruce Ambraal

Hi

 I have done (b) for coding see below, could someone assist with
(a)  (b) (d)

#!/usr/local/bin/perl -w
my $num_rows;
my $i;
my $r;


$num_rows = ;

for ($r = 1; $r <= $num_rows; $r++)
{
 for ($i=1; $i<= $r; $i++) {print ("  \n");}
 for ($i = $num_rows + 1 - $r;$i>=1; $i--){ print ("  * ");}
}# end for
print ("  \n");

solution:
-

5

  *   *   *   *   *

  *   *   *   *


  *   *   *



  *   *




  *


Thanks 
Bruce

--- Begin Message ---

I have written following coding to produce a triangle pattern(see below);
I now want to  produce following paterns I can't figer this out

(a)(b) (c) (d) diamond 
   
   ** * * * *   * * * * *  *
 * *   * * * ** * * ** * *
   * * *   * * ** * *   * * * *
 * * * *   * ** *  * * * * *
   * * * * *  * ** * * *
* * *
  *
__ 
#!/usr/local/bin/perl -w
my $num_rows;
my $i;
my $r;

$num_rows = ;

for ($r = 1; $r <= $num_rows; $r++)
{
# indent by printing num_rows - r spaces
for ($i = 1; $i <= $num_rows - $r; $i++) {print ("  \n");}
# print r asterisks
   for ($i=1; $i<= $r; $i++) { print (" *");}
# drop cursor to a new line
  print "\n";
 }
# end for

-
unxsup:/home/bruce$ perl triangle.pl
5




 *



 * *


 * * *

 * * * *
 * * * * *

Cheer
Bruce


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



--- End Message ---

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Generating for loop paterns HELP!

2002-02-14 Thread Bruce Ambraal

Hi 
Everyone had to crawl before they could walk, 
JON, stop being polite  and help me
I need your assistance now...
Cheers
Bruce

>>> Jon Molin <[EMAIL PROTECTED]> 02/14/02 12:00PM >>>
This smells homework!

/jon


Bruce Ambraal wrote:
> 
> Hi
> 
>  I have done (b) for coding see below, could someone assist with
> (a)  (b) (d)
> 
> #!/usr/local/bin/perl -w
> my $num_rows;
> my $i;
> my $r;
> 
> $num_rows = ;
> 
> for ($r = 1; $r <= $num_rows; $r++)
> {
>  for ($i=1; $i<= $r; $i++) {print ("  \n");}
>  for ($i = $num_rows + 1 - $r;$i>=1; $i--){ print ("  * ");}
> }# end for
> print ("  \n");
> 
> solution:
> -
> 
> 5
> 
>   *   *   *   *   *
> 
>   *   *   *   *
> 
>   *   *   *
> 
>   *   *
> 
>   *
> 
> Thanks
> Bruce
> 
>   
> 
> Subject: Help can't figure this one out
> Date: Thu, 14 Feb 2002 08:24:11 +0200
> From: "Bruce Ambraal" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]>
> 
> I have written following coding to produce a triangle pattern(see below);
> I now want to  produce following paterns I can't figer this out
> 
> (a)(b) (c) (d) diamond
>** * * * *   * * * * *  *
>  * *   * * * ** * * ** * *
>* * *   * * ** * *   * * * *
>  * * * *   * ** *  * * * * *
>* * * * *  * ** * * *
> * * *
>   *
> __
> #!/usr/local/bin/perl -w
> my $num_rows;
> my $i;
> my $r;
> 
> $num_rows = ;
> 
> for ($r = 1; $r <= $num_rows; $r++)
> {
> # indent by printing num_rows - r spaces
> for ($i = 1; $i <= $num_rows - $r; $i++) {print ("  \n");}
> # print r asterisks
>for ($i=1; $i<= $r; $i++) { print (" *");}
> # drop cursor to a new line
>   print "\n";
>  }
> # end for
> 
> -
> unxsup:/home/bruce$ perl triangle.pl
> 5
> 
>  *
> 
>  * *
> 
>  * * *
> 
>  * * * *
>  * * * * *
> 
> Cheer
> Bruce
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED] 
> For additional commands, e-mail: [EMAIL PROTECTED] 
> 
>   
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED] 
> For additional commands, e-mail: [EMAIL PROTECTED]


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Printing data into a file every time some presses HELP!!

2002-02-18 Thread Bruce Ambraal

Hi 

Could someone help?

the following code is not working.

open(INPUT_FILE,"+>fixed.dat") || die "Could not open filename";
while () {
print INPUT_FILE "bruce\n";
}
close(INPUT_FILE);


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Fwd: Printing data into a file every time some pressesHELP!!

2002-02-18 Thread Bruce Ambraal

Hi 

Where's every one?

Or maybe our my server's down.

Help!

Cheers

--- Begin Message ---

Hi 

Could someone help?

the following code is not working.

open(INPUT_FILE,"+>fixed.dat") || die "Could not open filename";
while () {
print INPUT_FILE "bruce\n";
}
close(INPUT_FILE);


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



--- End Message ---

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


What is the value of @_4_[0], and $return_me? (see below)

2002-02-20 Thread Bruce Ambraal

Hi 

1. (see subject)
2. Explain  lines 3 , 4
3.Why does'nt this coding return anything2

sub routine {
my @arr = (0, 'a' 1, 'b');
@_ = @arr;
my $retun_me = shift;
return( $return_me )
};


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Fwd: What is the value of @_4_[0], and $return_me? (see below)

2002-02-20 Thread Bruce Ambraal

OOPs! 
I meant 
Fwd: What is the value of @_$_[0], and $return_me? (see below)

--- Begin Message ---

Hi 

1. (see subject)
2. Explain  lines 3 , 4
3.Why does'nt this coding return anything2

sub routine {
my @arr = (0, 'a' 1, 'b');
@_ = @arr;
my $retun_me = shift;
return( $return_me )
};


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



--- End Message ---

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Perl subroutines using array & hash????

2002-02-21 Thread Bruce Ambraal

Hi 

How do you do it
Give me two different methods in subroutines, that will:
match together all of its parameters into on large list.

Many thanks to the following people: Brett, Micheal F, Zentara, Stephen H, Edward) 
Appreciate all you asistance)

Cheers
Bruce


 


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Perl subroutines using array & hash????

2002-02-21 Thread Bruce Ambraal

JON MOLIN  many thanks to you too..., if that's what you want to hear.
Don't have time for these question need to get myself skilled in Perl soonest.
I surpose the name [EMAIL PROTECTED] is meant for people like me

SUSAN not to worry I am two weeks in the game too, worken on the 
above problem, let you know about my solution.

Cheers

Bruce

>>> Jon Molin <[EMAIL PROTECTED]> 02/21/02 01:44PM >>>

is this homework? Your other posts looks very homeworkish...

/jon

Bruce Ambraal wrote:
> 
> Hi
> 
> How do you do it
> Give me two different methods in subroutines, that will:
> match together all of its parameters into on large list.
> 
> Many thanks to the following people: Brett, Micheal F, Zentara, Stephen H, Edward) 
>Appreciate all you asistance)
> 
> Cheers
> Bruce
> 
> 
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED] 
> For additional commands, e-mail: [EMAIL PROTECTED]


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Adding the input file digits together

2002-03-17 Thread Bruce Ambraal

Hi 
I am want to add digits in In_digits together.
Print total to screen.
Could someone help?

Thanx

Bruce


In_digits:
1,200
2,400

#!/usr/bin/perl -w
open(INPUT, "In_digits") || die;
open(OUTPUT, ">Out_digits") || die;
while () {
   if (/(\d{1})(\,)(\d{3})/) { 
print OUTPUT;
} else {
print "warning: line of unexpected format ($_)\n";
}
print
}
close(INPUT);
close(OUTPUT);




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Adding the input file digits together (Come on guys)

2002-03-17 Thread Bruce Ambraal

Hi 
I am want to add digits in In_digits together.
Print total to screen.
Could someone help?

Thanx

Bruce


In_digits:
1,200
2,400

#!/usr/bin/perl -w
open(INPUT, "In_digits") || die;
open(OUTPUT, ">Out_digits") || die;
while () {
   if (/(\d{1})(\,)(\d{3})/) { 
print OUTPUT;
} else {
print "warning: line of unexpected format ($_)\n";
}
print
}
close(INPUT);
close(OUTPUT);




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Seach around word text - display totals only!

2002-03-19 Thread Bruce Ambraal



An input data file looks like this: (see below) 

Description:  financial amount
Shoes: $110
Car:  $3,100
Rates:  $0,50

I want to add the total of amount.
Also want to add all the totals containing an "s" discription.

My problem is basically 
Searching arround the word text to display the total only.

Certainly I know how to go about adding  the totals.





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




How to handle a currency sign in a calulation

2002-03-21 Thread Bruce Ambraal

The following programs calculates sum totals of the values in file (Values.dat).

Values.dat:
---
$30,45
$0,50


How do I  handle the $ sign infront of the values.
I want the $ sign in the result when calulating sum of these values. 
In my program I left out the $ sign cause I dont know.


#!/usr/bin/perl -w
open(INPUT, "Values.dat") || die;
my $value;
while () {
   if (/\d*,\d{3}/) {s/,//; $value += $_; }
   else {print "warning: line of unexpected format ($_)\n";}
}
1 while( $value =~ s/(\d*,)(\d{3})(?=\.|,|\z)/$1,$2/ );
print $value;
close(INPUT);
---


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Printing frequency of word occurence in paragraph

2002-03-21 Thread Bruce Ambraal

In the program below I don't know when to stop the loop.
 (CTRL + d ) will just terminate the program, leaving the data via STDIN unattended, 
this is my problem.

Lets define what I want to do:
I want to print the frequency of every word at the beginning. and every word at the 
end of a line.

This could mean two things:
1) one line of text to be read in and on pressing  code below
will analyse the input.
2) a paragraph containing a number of lines get adressed.

I think my code adress 2) but problem with this is that I don't know when my coding 
should jump out of the loop?

Any ideas

> #!/usr/bin/perl
> while () {
>   if (/(\b[^\W_\d][\w-]+\b)/g) {
> $gotit{$1}++;
>   }
>   if (/(\b[^\W_\d][\w-]+\b\Z)/g) {
> $found{$1}++;
>   }
>
> }
> while (($wrd,$cnt)= each %gotit){
> print "$cnt $wrd\n";
> }#end of while
>
> foreach my $yes (keys (%found)){
> print "$found{$yes} $yes\n";
> }#end foreach



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Printing the number of times phone number appear in a textfile

2002-03-22 Thread Bruce Ambraal

Hi  all

In the program below I am attempting to count the number of times that a phone 
number(purely digits) occurs in a file of text. 
I am not succeeding cause i end up counting all the digits of phone numbers that 
occurs.

Could anyone help.

--
dat.txt
0216339509 is my phone number 0216339509 also belong to
my brother 0216339509 and 0216339509 from sister.
-

Program:

#!/usr/bin/perl -w
my $match_cntr = 0;
my $n = 0;

open(FILE," ;
for($n=0;$n<=$#file_array;$n++) {
while($file_array[$n]=~/(\d)/gxom){
print $1;
$match_cntr++;
}
}#end of for loop
print "NUMBERS COUNTED = ",$match_cntr,"\n";
close(FILE);


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Script extracting the output from a search engine - Help!

2002-03-23 Thread Bruce Ambraal

In the script below I am trying to to extract the results from performing a search on  
the word "help" at   http://srch.overture.com 

Running the  script produce lots of errors.
What am I doing wrong, is my rules correct.

Help




#!/usr/bin/perl - strict

open(A_file,"");
my@ary = ;
while($n < $#ary){
chomp($ary[$n];
while($ary[$n] =~ s#.*(href = http.*)\s.*#\1#n){
$ary[$n] = ~s/<.*>//g;
$ary[$n] =~ s/>.*//g;
print $ary[$n],"\n";
}
$n++;
}


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




A script to understand the output from a search engine HELP!!

2002-03-23 Thread Bruce Ambraal

Hi all,

Part I
If you get the script below to work then it needs to be modified:

I have pulled the seach.html file as follows:
I went to link http://srch.overture.com) then search for word "help",
then I save the result as file named search.html 
Then I wrote the script below to extract and find the URLs in this 
saved web page (which is not working very well).

Part II
I now want to pipe the saved file to the script from STDIN.
the URLs found should be printed to the command line, each on different line.
The  script should be   general enough so that it can be tested with a different 
query, eg. "help them".


This is where I am at:
A script that does not really work

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

open(A_file,";
my $n = 0;
while($n <= $#ary){

chomp($ary[$n]);

while($ary[$n] =~ s#.*(href = http.*)\s.*#$1#){

$ary[$n] =~ s/<.*>//g;

$ary[$n] =~ s/>.*//g;

print $ary[$n],"\n";
}
$n++;
}
close(A_file);



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




The LinkExtor.pm module

2002-03-24 Thread Bruce Ambraal

Hi friends

I call you all friend because I am very impress with the way in which you are guiding 
me.

Indeed I want to locate the LinkExtor.pm module.

Cheers
Bruce




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




The LinkExtor.pm module (Wow! its very quiet in here) Anybodyout there!!!

2002-03-24 Thread Bruce Ambraal

Hi friends

I call you all friend because I am very impress with the way in which you are guiding 
me.

Indeed I want to locate the LinkExtor.pm module.

Cheers
Bruce




--
To unsubscribe, e-mail: [EMAIL PROTECTED] 
For additional commands, e-mail: [EMAIL PROTECTED] 



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Table for message board server to save/delete/update messages

2002-03-27 Thread Bruce Ambraal

Hi all 

Am I on the write track, else assist.


boris this is where I'm at currently:


Could you assist

#!/usr/local/bin/perl

use DBI;
my $dbname = 'Bruce';
my $dbhostname = 'localhost';
my $user   = 'root';
my $password   = '' ;

CREATE TABLE employee_Info ( 
primary_key INT AUTO_INCREMENT NOT NULL, 
nameCHAR(20), 
surname CHAR(20),
employee_no CHAR(10),
shoe_colour CHAR (10),
PRIMARY KEY (primary_key)
);

my $db = dbi->connect ("dbi:mysql:dbname ; host = $dbhostname;$user;$passwd");

$db->do ("SAVE INTO Employee_Info (primarykey, name, surname, shoecolour, employee_no) 
value(1,'Ambraal','Bruce','White', '9536826')");

$db-> do(" SAVE INTO Employee_Info (primarykey, name, shoecolour, employee _no) 
value(2, 'September', 'John', 'Pink','9536456')");
$db->do("DELETE FROM Employee_Info (

$db->do("UPDATE FROM Employee_Info (

$db->disconnect();
;


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Creating table for message board server tosave/delete/update messages

2002-03-27 Thread Bruce Ambraal

Hi All

I need some one to comment on the program below 
With the code below I am trying to  design a table that allows a simple message board 
server to:
1) Save a message,
2) delete a message,
3) update a message
The password + username must be saved in the same table entry, and compare it when 
receiving an update or delete.

---
#!/usr/local/bin/perl

use DBI;
my $dbname = 'Bruce';
my $dbhostname = 'localhost';
my $user   = 'root';
my $password   = '' ;

CREATE TABLE employee_Info ( 
primary_key INT AUTO_INCREMENT NOT NULL, 
nameCHAR(20), 
surname CHAR(20),
employee_no CHAR(10),
shoe_colour CHAR (10),
PRIMARY KEY (primary_key)
);

my $db = dbi->connect ("dbi:mysql:dbname ; host = $dbhostname;$user;$passwd");

$db->do ("SAVE INTO Employee_Info (primarykey, name, surname, shoecolour, employee_no) 
value(1,'Ambraal','Bruce','White', '9536826')");

$db-> do(" SAVE INTO Employee_Info (primarykey, name, shoecolour, employee _no) 
value(2, 'September', 'John', 'Pink','9536456')");
$db->do("DELETE FROM Employee_Info (

$db->do("UPDATE FROM Employee_Info (

$db->disconnect();
;






--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Read in from STDIN

2002-04-04 Thread Bruce Ambraal

Please help with following:

Using a while loop I want to do the following:
Read info in from STDIN
Read in any number of name/value pairs,
Read in names in pairs of two, and compute their sum.
Choose the maximum of all those pairs and print it.
At the same time choose the minimum and print it.


My code does not do what I want it to do:
---
#!/usr/bin/perl -w

my @NumberArray;
my $ArrayIndex =-1;
my $NumberFromConsole;

while ($ArrayIndex < 3)
{
$NumberFromConsole = ;
chomp($NumberFromConsole);
$ArrayIndex = $ArrayIndex + 1;
$NumberArray[$ArrayIndex] = $NumberFromConsole;
}

my $FirstNumber = $NumberArray[0] + $NumberArray[1];
my $SecondNumber = $NumberArray[2] + $NumberArray[3];

print "The Number array is @NumberArray\nThe first two are $FirstNumber\nThe
second two are $SecondNumber\n";

if ($FirstNumber > $SecondNumber)
{
print "The first number was bigger, ";
print $FirstNumber;
}

elsif ($SecondNumber > $FirstNumber)
{
print "The second number was bigger, ";
print $SecondNumber;
}

else
{
print "The numbers are equal.";
}



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Opens / create file if necessary

2002-04-04 Thread Bruce Ambraal

Could you help I am not doing what I'm surpose to

With the code below I'm trying to do the following:
-Open a file, creating it  if necessary
-Print a name in file every time someone presses "enter"
-Print  a new line 
-Seek to the begining of file without closing file
-and print the file to STDOUT

--
#!/usr/bin/perl -w

open(INFILE,"+>>inline") || die "Could not open filename";
open(OUTFILE,"+>>outline") || die "Could not open filename";
 my $inline = ; chop($inline);

  print OUTFILE "$inline\n";
close(INFILE);
close(OUTFILE);



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Split input on whitespaces - Another approach

2002-04-04 Thread Bruce Ambraal

Hi all

My code below  does the following :
- Reads from STDIN
- Splits the input on whitespace
- And prints the frequency of terms, with each term printed next to its frequency on 
STDOUT.

I need another approach (code) to do the same things


#!/usr/bin/perl -w

my %freq;
while( my $line =  ){
foreach my $w ( split( /\s+/, $line ) ){
if( exists $freq{$w} ){ 
$freq{$w}++; 
}else{
$freq{$w} = 1;
}
}
}

foreach my $k ( keys( %freq ) ){
print "$k $freq{$k}\n";
} 




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




find files with .jpg extensions in directories

2002-04-04 Thread Bruce Ambraal

Hi John 

Seems you're the only one around here.
also the prev solution(RE: Opens / create file if necessary)
just worked  fine.

Help I'm struggling to have these two pieces of codes do
what I want it to do

With code (1)
I'm trying to recursively decends into directories to find
all the files that end in .jpg.

With code (2)
I'm trying to read in the extentionfrom the command line. 
 
---code(1) -
 #!/usr/local/bin/perl -w
# first example...

use strict;

# declarations...
my @files = `ls -F`;
my @jpegs;

my $extension = "jpg";

foreach ( @files ){
next if /private/i;
chomp;

if(/\.$extension$/){
push(@jpegs, $_);
}
}

foreach (@jpegs) {
print "$_\n";
}
-
 -code(2)

#!/usr/local/bin/perl -w
# first example...

use strict;

# declarations...
my @files = `ls -F`;
my @jpegs;

print "Enter a file extension (e.g jpg): ";
chomp(my $extension = );
print "\n";

until ($extension =~ /^[A-Za-z]{3}$/) {
print "Please enter a three letter extension. E.g jpg
txt doc: ";
chomp($extension = );
print "\n";
}

print "Searching for *.$extension";

foreach ( @files ){
next if /private/i;
chomp;

if(/\.$extension$/){
push(@jpegs, $_);
}
}

foreach (@jpegs) {
print "$_\n";
}






--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Fwd: Split input on whitespace

2002-04-04 Thread Bruce Ambraal

Could you help me...

With the code below (see attached) I tried to do following:
Read from STDIN, 
splits the input in whitespace, 
and prints the frequency of terms, with each term printed next to its frequency on 
STDOUT. 

--- Begin Message ---

Why does my code not write  the splitted words to STDOUT? 

#!/usr/bin/perl -w
open (OUTPUT, ">ex92.out")||die;
my %freq;
while (my $line  = ) {
foreach my $w ( split( /\s+/, $line ) ){
if( exists $freq{$w} ){ 
$freq{$w}++; 
}else{
$freq{$w} = 1;
}
}
print "\n";
exit if $line eq "q\n";
}
foreach my $k ( keys( %freq ) ){
print OUTPUT  "$k $freq{$k}\n";
} 

close (OUTPUT);


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



--- End Message ---

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: Split input on whitespace

2002-04-04 Thread Bruce Ambraal

This is not working I tried it 
my output file is still empty.

>>> "Timothy Johnson" <[EMAIL PROTECTED]> 04/05/02 12:58AM >>>

Add a line like this:

print "$k $freq{$k}\n";

After this line:

print OUTPUT  "$k $freq{$k}\n";

BTW: Seriously, you don't need the if() statement by the increment.

-Original Message-
From: Bruce Ambraal [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, April 04, 2002 3:00 PM
To: [EMAIL PROTECTED] 
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] 
Subject: Fwd: Split input on whitespace


Could you help me...

With the code below (see attached) I tried to do following:
Read from STDIN, 
splits the input in whitespace, 
and prints the frequency of terms, with each term printed next to its
frequency on STDOUT. 



This email may contain confidential and privileged 
material for the sole use of the intended recipient. 
If you are not the intended recipient, please contact 
the sender and delete all copies.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Spit the input in whitespace

2002-04-04 Thread Bruce Ambraal


One last request please run the code below and see whether it does 
the following

With the code below (see attached) I tried to do following:
Read from STDIN, 
splits the input in whitespace, 
and prints the frequency of terms, with each term printed next to its
frequency on STDOUT. 

According to me it does not print any info to STDOUT.
This is my problem
---
#!/usr/bin/perl -w
open (OUTPUT, ">file.out")||die;
my %freq;
while (my $line  = ) {
foreach my $w ( split( /\s+/, $line ) ){
if( exists $freq{$w} ){ 
$freq{$w}++; 
}else{
$freq{$w} = 1;
}
}
}
foreach my $k ( keys( %freq ) ){
   print OUTPUT  "$k $freq{$k}\n";
print STDOUT  "$k $freq{$k}\n";

} 

close (OUTPUT);





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Split input on whitespaces - Another approach - Co m e o n g u y s

2002-04-04 Thread Bruce Ambraal

Hi all

My code below  does the following :
- Reads from STDIN
- Splits the input on whitespace
- And prints the frequency of terms, with each term printed next to its frequency on 
STDOUT.

I need another approach (code) to do the same things


#!/usr/bin/perl -w

my %freq;
while( my $line =  ){
foreach my $w ( split( /\s+/, $line ) ){
if( exists $freq{$w} ){ 
$freq{$w}++; 
}else{
$freq{$w} = 1;
}
}
}

foreach my $k ( keys( %freq ) ){
print "$k $freq{$k}\n";
} 




--
To unsubscribe, e-mail: [EMAIL PROTECTED] 
For additional commands, e-mail: [EMAIL PROTECTED] 



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Read from STDIN

2002-04-04 Thread Bruce Ambraal

Anyone's free to assist

 Part 1 is already done just need assistance for part (2-4)
See below provided test data aswell

1)Read in any number of name/value pairs,
 2)Read in names in pairs of two, and compute their sum.
 3)Choose the maximum of all those pairs and print it.
 4)At the same time choose the minimum and print it.


In the code below  part 1) is done


1) testing input data: boris 1
 bruce 2
 john 3
output data : key = boris value = 1
 key = bruce value =2
 key = john value = 3
---
2) testing input data: boris 1
 bruce 2
output data:   sum = 3
---
3) output data :max_of_pairs = bruce 2
--
4) output data :min_of_pairs = boris value
--
use strict;
my %nvp;#hash containing nae value pairs
my $name;   # key of the hash
my $value;  # value associated with the key
$| = 1;
print"Enter Name Value\n";
while () {
chomp;
last unless $_; # end loop if STDIN had only a new line
if (/([A-Za-z]+)\s(\d+)/) { # here names have only letters and name vale
pairs are space delimited
$name = $1; # captured alphabetic char fm above
$value = $2;# captured digits fm above
$nvp{$name} = $value;   # $name and $value could be eliminated by using $1
$2 here...
} else {# reject if not valid
print "I don't see this a a valid name/value pair\n";
}
}
print"Sorted:\n\n";
foreach my $key (sort keys %nvp) {
print"key = $key value = $nvp{$key}\n";
}
print"Unsorted:\n\n";
foreach my $key (keys %nvp) {
print"key = $key value = $nvp{$key}\n";
}
--



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Read from STDIN

2002-04-04 Thread Bruce Ambraal

Thanx boris problem completely solved.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Split input on whitespace

2002-04-04 Thread Bruce Ambraal

Why does my code not write  the splitted words to STDOUT? 

#!/usr/bin/perl -w
open (OUTPUT, ">ex92.out")||die;
my %freq;
while (my $line  = ) {
foreach my $w ( split( /\s+/, $line ) ){
if( exists $freq{$w} ){ 
$freq{$w}++; 
}else{
$freq{$w} = 1;
}
}
print "\n";
exit if $line eq "q\n";
}
foreach my $k ( keys( %freq ) ){
print OUTPUT  "$k $freq{$k}\n";
} 

close (OUTPUT);


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Thanks alot Boris

2002-04-26 Thread Bruce Ambraal

Hi 
Boris I see you are still around.
Well I just want to take the oportunity in thanking you for all the help that you have 
given me I really appreciate it.
Go well.

Psst! Boris is the man of the hour with more power.
Cheers
Bruce  




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




HELP! : To write a script that reads numbers from STDIN andprint on STDOUT.

2002-02-07 Thread Bruce Ambraal

Hi ALL

Could  any one write some coding for the following problem.

In perl against Linx could someone help.
---
I want to write a script that reads in four numbers from STDIN and add the first two 
together, and than adds the second 2 together.
The input format is a number on a line.(press enter after every number)
I also want to ompare the resulting two numbers with > or < and print the largest on 
STDOUT.


I have a second part to the previous problem.

I now want to modify the script to read a name, and then the number
(again each on its own line)
To read four name/number pairs
To read two names from STDIN and add the associated numbers together.
Repeat this step.
Then to compare the resulting two numbers with
< or > and print the largest on STDOUT.

Thanks in advance

Bruce


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: To write a script that reads numbers from STDIN and printonSTDOUT.

2002-02-11 Thread Bruce Ambraal

Hi 
Stephen  thanks a million, I cross referenced the program and clearly it make in deed 
sense.

I have done the second part myself.
ANYONE  please assist and check whether the following code will work.

The  problem gets defined as follows.
To write a script to read a name, and then the number
(again each on its own line)
To read four name/number pairs
To read two names from STDIN and add the associated numbers together.
Repeat this step.
Then to compare the resulting two numbers with
< or > and print the largest on STDOUT.

Solution:
---
#!/usr/bin/perl

my @DaysArray;
my $ArrayIndex =-1;
my $DaysFromConsole;

while ($ArrayIndex < 7)
{
$daysFromConsole = ;
chomp($DaysFromConsole);
$ArrayIndex = $ArrayIndex + 1;
$DaysArray[$ArrayIndex] = $DaysFromConsole;
}

#Example 
#@DaysArray =("Sunday",1,"Monday",2,"Tuesday",3,"Wednesday",4);
my %Hashdays = @DaysArray;
my $Firstdays = $Hashdays{"Sunday"} + $Hashdays{"Monday"}; 
my $Seconddays = $Hashdays{"Tuesday"} + $Hashdays{"Wednesday"}; 
$, = " => "; 
print "The Days is  Hash is %Hashdays\nThe first two are 
$Firstdays\nThe second two are $Seconddays\n";

if ($Firstdays > $Seconddays)
{
print "The first number was bigger, ";
print $Firstdays;
}

elsif ($Seconddays > $Firstdays)
{
print "The second number was bigger, ";
print $Seconddays;
}

else
{
print "The numbers are equal.";
}




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]