Re: pushing web form params into mysql table

2007-06-28 Thread Sean Davis
Shad Keene wrote: Sean, Thanks...I got it to work. It turned out that I didn't have default values for the other columns so it wouldn't enter one column into the database w/o default values for the others. Until I put the die-error message after the execute, I didn't know why it wasn't

problem printing contents of file in directory

2007-06-28 Thread alok nath
Hi, Can anybody tell me why its not printing the contents of each inside a particular folder ? I lost all my hairs scratching my head. Thanks Alok. my $tstToRunDir = C:\\perlScripts ; my $fileInTstToRunDir ; opendir TST2RUN, $tstToRunDir || die Failed to open $tstToRunDir $!\n ; open

Re: problem printing contents of file in directory

2007-06-28 Thread John W. Krahn
alok nath wrote: Hi, Hello, Can anybody tell me why its not printing the contents of each inside a particular folder ? Yes I can, and so can Perl's documentation: perldoc -f readdir my $tstToRunDir = C:\\perlScripts ; my $fileInTstToRunDir ; opendir TST2RUN, $tstToRunDir || die Failed

Re: String Manipulation

2007-06-28 Thread Dharshana Eswaran
Thank you. But i am unable to understand the working of the code which you have written. Can you please explain it? Thanks and Regards, Dharshana On 6/28/07, Chas Owens [EMAIL PROTECTED] wrote: On 6/27/07, Dharshana Eswaran [EMAIL PROTECTED] wrote: On 6/28/07, Tom Phoenix [EMAIL PROTECTED]

Re: using a homemade perl module

2007-06-28 Thread Mathew Snyder
Brad Baxter wrote: On Jun 14, 10:22 pm, [EMAIL PROTECTED] (Mathew Snyder) wrote: I fixed all of the bugs save one. I can't access any of my subroutines without explicitly using it with dates_emails::subroutine. I was under the impression that if I was exporting them all from the module,

printing content of found file

2007-06-28 Thread Amichai Teumim
I'm trying to do the following: I want to search for a specific file/s in my current dir and when it finds it, print its contents. So I did the following: #!/usr/bin/perl opendir(CURRENT,.); @list = readdir(CURRENT); closedir(CURRENT); foreach $item (@list){ if($item =~ /notes/){

shuffling cards

2007-06-28 Thread Amichai Teumim
I want to shuffle a deck of cards and then print out the top five cards. #!/usr/bin/perl @startingdeck = (A H,2 H,3 H,4 H,5 H,6 H,7 H,8 H, 9 H,10 H,J H,Q H,K H, A D,2 D,3 D,4 D,5 D,6 D,7 D,8 D, 9 D,10 D,J D,Q D,K D, A C,2 C,3 C,4

Re: printing content of found file

2007-06-28 Thread Jeff Pang
Amichai Teumim 写道: I'm trying to do the following: I want to search for a specific file/s in my current dir and when it finds it, print its contents. So I did the following: #!/usr/bin/perl please add 'use strict' and 'use warnings' at the the begin of a script. opendir(CURRENT,.);

Re: printing content of found file

2007-06-28 Thread John W. Krahn
Amichai Teumim wrote: I'm trying to do the following: I want to search for a specific file/s in my current dir and when it finds it, print its contents. So I did the following: #!/usr/bin/perl The next two lines in your program should be: use warnings; use strict; opendir(CURRENT,.);

Re: shuffling cards

2007-06-28 Thread Jeff Pang
Amichai Teumim 写道: I want to shuffle a deck of cards and then print out the top five cards. But what's top five cards since I saw all the cards are unique. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: shuffling cards

2007-06-28 Thread John W. Krahn
Amichai Teumim wrote: I want to shuffle a deck of cards and then print out the top five cards. I want to learn this, so please provide me with hints and tips as opposed to plain solutions if possible please. perldoc -q shuffle John -- Perl isn't a toolbox, but a small machine shop where you

RE: shuffling cards

2007-06-28 Thread Thomas Bätzler
Amichai Teumim [EMAIL PROTECTED] asked: I want to shuffle a deck of cards and then print out the top five cards. Read the Perl faq entry on shuffling arrays (i.e. perldoc -q shuffle). If you're using a fairly recent version of Perl, this'll get you started. #!/usr/bin/perl -w use strict;

Re: printing content of found file

2007-06-28 Thread Prabu Ayyappan
Hi, Hope you can find your solution from the following two approaches Approach I #!/usr/bin/perl while (*) { if ($_ =~ /note/){ open(FH, $_); @fcontent = FH; print @fcontent; close(FH); } } APPROACH II opendir(CURRENT,.); @list = readdir(CURRENT);

Re: printing content of found file

2007-06-28 Thread Prabu Ayyappan
Hi, Hope you can find your solution from the following two approaches Approach I #!/usr/bin/perl while (*) { if ($_ =~ /note/){ open(FH, $_); @fcontent = FH; print @fcontent; close(FH); } } APPROACH II opendir(CURRENT,.); @list = readdir(CURRENT);

Re: printing content of found file

2007-06-28 Thread Prabu Ayyappan
Hi, Hope you can find your solution from the following two approaches Approach I #!/usr/bin/perl while (*) { if ($_ =~ /note/){ open(FH, $_); @fcontent = FH; print @fcontent; close(FH); } } APPROACH II opendir(CURRENT,.); @list = readdir(CURRENT);

shuffling cards

2007-06-28 Thread Amichai Teumim
Thanks for all the answers. I know there are other better ways of doing this shuffle. I must however, use pop shift ans push. #!/usr/bin/perl @startingdeck = (A H,2 H,3 H,4 H,5 H,6 H,7 H,8 H, 9 H,10 H,J H,Q H,K H, A D,2 D,3 D,4 D,5 D,6 D,7 D,8 D,

More loops

2007-06-28 Thread Amichai Teumim
I need to use two loops and an if statement to sort the contents of this array so that the number go from lowest to highest. #!/usr/bin/perl @array = (5,3,2,1,4); ## include your code here ## foreach $elem (@array){ print $elem; } Looking further into this it was revealed to me that I

Re: shuffling cards

2007-06-28 Thread Martin Barth
Hi, If you don't use rand() you will allways get the same result after shuffeling. Is that OK for you? ( you're cheating in card games, right? *eg* ) On Thu, 28 Jun 2007 12:37:29 +0300 Amichai Teumim [EMAIL PROTECTED] wrote: Thanks for all the answers. I know there are other better ways of

parsing a line

2007-06-28 Thread alok nath
Hi, I am parsing a file which has lines like this. Test Description = Test 1 ID = ID A1 DirAbsolute = C:/perl/ Got stuck up while trying to extract values of fields called Description, ID ? Pls help. Thanks Alok.

don't understand working script

2007-06-28 Thread Amichai Teumim
I have this script, If you run it you can see how it nicely idents the directories. I don't understand everything in this script. Please see my comments. #!/usr/bin/perl $startdir = /lib; $level = 0;#WHAT DOES THIS DO? list_dirs($startdir,$level); #WHAT DOES THIS DO? sub list_dirs(){ my

Re: String Manipulation

2007-06-28 Thread Chas Owens
On 6/28/07, Dharshana Eswaran [EMAIL PROTECTED] wrote: Thank you. But i am unable to understand the working of the code which you have written. Can you please explain it? Thanks and Regards, Dharshana What, specifically, do you not understand? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For

Re: don't understand working script

2007-06-28 Thread Chas Owens
On 6/28/07, Amichai Teumim [EMAIL PROTECTED] wrote: I have this script, If you run it you can see how it nicely idents the directories. I don't understand everything in this script. Please see my comments. #!/usr/bin/perl $startdir = /lib; $level = 0;#WHAT DOES THIS DO? It assigns 0 to

Re: using a homemade perl module

2007-06-28 Thread Mumia W.
On 06/28/2007 03:00 AM, Mathew Snyder wrote: our @ISA = qw(Exporter); our @EXPORT = qw(startDate endDate searchStart searchEnd); our $VERSION = '1'; Those lines need to be within a BEGIN block. See perlmod: http://perldoc.perl.org/perlmod.html -- To unsubscribe,

Re: More loops

2007-06-28 Thread Jenda Krynicky
From: Amichai Teumim [EMAIL PROTECTED] I need to use two loops and an if statement to sort the contents of this array so that the number go from lowest to highest. @sorted = sort {$a = $b} @unsorted; You can use the builtin function sort(). All you have to do is to tell it how do you want

Re: shuffling cards

2007-06-28 Thread Martin Barth
I dont understand why you dont like your solution? whats wrong at 3 H 4 H 5 H 6 H 7 H? On Thu, 28 Jun 2007 12:59:21 +0300 Amichai Teumim [EMAIL PROTECTED] wrote: Yeah I don't mind cheating in this one ;) I just need the top five cards printed, even if the same each time. Any ideas?

Re: using a homemade perl module

2007-06-28 Thread Paul Johnson
On Thu, Jun 28, 2007 at 06:58:36AM -0500, Mumia W. wrote: On 06/28/2007 03:00 AM, Mathew Snyder wrote: our @ISA = qw(Exporter); our @EXPORT = qw(startDate endDate searchStart searchEnd); our $VERSION = '1'; Those lines need to be within a BEGIN block. See

Re: More loops

2007-06-28 Thread Chas Owens
On 6/28/07, Jenda Krynicky [EMAIL PROTECTED] wrote: From: Amichai Teumim [EMAIL PROTECTED] snip foreach $elem (@array){ print $elem\n; } This can be simplified to print join(\n, @array), \n; snip or (since this is Perl and TIMTOWTDI) print map { $_\n } @array; -- To unsubscribe,

Re: shuffling cards

2007-06-28 Thread Chas Owens
On 6/28/07, Martin Barth [EMAIL PROTECTED] wrote: snip #!/usr/bin/perl You are missing two lines here. use strict; use warnings; If you don't put those two lines you will be surprised by what Perl does with your code. @startingdeck = (A H,2 H,3 H,4 H,5 H,6 H,7 H,8 H, 9

Re: parsing a line

2007-06-28 Thread Chas Owens
On 6/28/07, alok nath [EMAIL PROTECTED] wrote: Hi, I am parsing a file which has lines like this. Test Description = Test 1 ID = ID A1 DirAbsolute = C:/perl/ Got stuck up while trying to extract values of fields called Description, ID ? What have you tried? -- To unsubscribe, e-mail:

Re: More loops

2007-06-28 Thread Jenda Krynicky
From: Chas Owens [EMAIL PROTECTED] On 6/28/07, Jenda Krynicky [EMAIL PROTECTED] wrote: From: Amichai Teumim [EMAIL PROTECTED] snip foreach $elem (@array){ print $elem\n; } This can be simplified to print join(\n, @array), \n; snip or (since this is Perl

Re: parsing a line

2007-06-28 Thread alok nath
Hi, So I tried something like this .It works ! if( $_ =~ m/ID\s=\s(.*?)\sDirAbsolute/){ print Test ID is $1 \n ; }else{ print FAILED to locate Test ID \n ; } May be its crude way. Thanks Alok. - Original Message From: Chas Owens [EMAIL PROTECTED] To: alok nath

Re: More loops

2007-06-28 Thread Chas Owens
On 6/28/07, Jenda Krynicky [EMAIL PROTECTED] wrote: From: Chas Owens [EMAIL PROTECTED] On 6/28/07, Jenda Krynicky [EMAIL PROTECTED] wrote: From: Amichai Teumim [EMAIL PROTECTED] snip foreach $elem (@array){ print $elem\n; } This can be simplified to print

Re: parsing a line

2007-06-28 Thread Chas Owens
On 6/28/07, alok nath [EMAIL PROTECTED] wrote: snip if( $_ =~ m/ID\s=\s(.*?)\sDirAbsolute/){ snip It does look fragile. A lot depends on how likely the real input matches the example you gave. That regex will break if the input is Test Description = Test 1 ID = ID A1 DirAbsolute = C:/perl/

missing curly - brain fried

2007-06-28 Thread Amichai Teumim
Where is the open curly missing here? #!/usr/bin/perl @array = (5,3,2,1,4); for ($i=0; $i$n-1; $i++) { ( for ($j=0; $j$n-1-$i; $j++) if ($array[$j+1] $array[$j]) { /* compare the two neighbors */ $tmp = $array[$j]; /* swap $array[j] and $array[j+1] */ $array[$j] =

Re: String Manipulation

2007-06-28 Thread Jay Savage
On 6/27/07, Dharshana Eswaran [EMAIL PROTECTED] wrote: On 6/28/07, Tom Phoenix [EMAIL PROTECTED] wrote: On 6/27/07, Dharshana Eswaran [EMAIL PROTECTED] wrote: I am unable to get a generalised way in which it can extract them as few structures have comments, few does not hav comments etc.

Re: missing curly - brain fried

2007-06-28 Thread Martin Barth
Hi Amichai, first of all never write own code without these two lines: use strict; use warnings; this should allways help a lot. Remember the e-mail from Chas Owens regarding the shuffling cards. making comments in perl goes this way: # hello, i am a comment. you made C-style comments: //,

Re: missing curly - brain fried

2007-06-28 Thread jbuburuz
Where is the open curly missing here? #!/usr/bin/perl @array = (5,3,2,1,4); for ($i=0; $i$n-1; $i++) { I think its missing on the line bellow. I count three brackets bellow. ( for ($j=0; $j$n-1-$i; $j++) if ($array[$j+1] $array[$j]) { /* compare the two neighbors */ $tmp =

Re: printing content of found file

2007-06-28 Thread John W. Krahn
Amichai Teumim wrote: Thank you John Why do I need use warnings; use strict; It works without them: with them i get: Global symbol @list requires explicit package name at ./obj14-2.pl line 7. Global symbol $item requires explicit package name at ./obj14-2.pl line 10. Global symbol @list

Re: missing curly - brain fried

2007-06-28 Thread Tom Phoenix
On 6/28/07, Amichai Teumim [EMAIL PROTECTED] wrote: Where is the open curly missing here? Here it is: @array = sort { $a = $b } @array; But if you really want to do it the hard, slow way Well, then you should be programming this as a shell script. But let's at least translate your

Re: don't understand working script

2007-06-28 Thread John W. Krahn
Amichai Teumim wrote: I have this script, If you run it you can see how it nicely idents the directories. I don't understand everything in this script. [ SNIPPED an example of *BAD* code ] Your example would be better written as: #!/usr/bin/perl use warnings; use strict; my $startdir =

SOLVED - Re: Tie::Handle::CSV

2007-06-28 Thread Gary Stainburn
Hi folks The problem was that the files I'm reading are generated on M$ servers in DOS format. This meant that at the end of the file is a line containing the DOS EOF char ^Z. Using grep to remove this before reading the file has fixed the problem. The error's gone and my program continues

Need idea for doing automatic iteration, please.

2007-06-28 Thread Patrik Hasibuan
Dear my friends... I want my code does an action if it find a directory or file, namely: storing the url/path of a file or a directory onto mysql database. I am meaning, my code should look up every file/directory name resides under the $rootdir iteratively for doing storing onto mysql on each

RE: Need idea for doing automatic iteration, please.

2007-06-28 Thread Wagner, David --- Senior Programmer Analyst --- WGO
-Original Message- From: Patrik Hasibuan [mailto:[EMAIL PROTECTED] Sent: Thursday, June 28, 2007 12:55 To: Milis CPAN-Perl-Beginners Subject: Need idea for doing automatic iteration, please. Dear my friends... I want my code does an action if it find a directory or file,

RE: Build module on one box and move to another box?

2007-06-28 Thread RICHARD FERNANDEZ
Can this be done? Can I compile a module on one box and somehow install the code on another? Might this be as simple as copying over the contents of the directories in @INC? As it turns out, this was fairly easy to do. I followed the advice from Chas Owens who suggested that I build them

Re: using a homemade perl module

2007-06-28 Thread Mumia W.
On 06/28/2007 07:46 AM, Paul Johnson wrote: On Thu, Jun 28, 2007 at 06:58:36AM -0500, Mumia W. wrote: On 06/28/2007 03:00 AM, Mathew Snyder wrote: our @ISA = qw(Exporter); our @EXPORT = qw(startDate endDate searchStart searchEnd); our $VERSION = '1'; Those lines need

Formats for invoices.

2007-06-28 Thread Francisco Valladolid
Hi Folks I'm doing a single perl script to get data from a database (SQLlite), and want put some data in a format The output format is record in a simple temporary .txt file and send to lpr. the format is for a invoice displaying most important data. I have the next questions. 1.- How can

Re: Formats for invoices.

2007-06-28 Thread Tom Phoenix
On 6/28/07, Francisco Valladolid [EMAIL PROTECTED] wrote: 1.- How can put lines containing products descriptions ? 2.- Ho can justify or align a variable into format ? Have you seen the perlform manpage? http://perldoc.perl.org/perlform.html Hope this helps! --Tom Phoenix Stonehenge

Re: Formats for invoices.

2007-06-28 Thread Chas Owens
On 6/28/07, Tom Phoenix [EMAIL PROTECTED] wrote: On 6/28/07, Francisco Valladolid [EMAIL PROTECTED] wrote: 1.- How can put lines containing products descriptions ? 2.- Ho can justify or align a variable into format ? Have you seen the perlform manpage?

Re: Formats for invoices.

2007-06-28 Thread Daniel Kasak
On Thu, 2007-06-28 at 17:24 -0700, Tom Phoenix wrote: On 6/28/07, Francisco Valladolid [EMAIL PROTECTED] wrote: 1.- How can put lines containing products descriptions ? 2.- Ho can justify or align a variable into format ? Have you seen the perlform manpage?

Re: using a homemade perl module

2007-06-28 Thread Mathew Snyder
Paul Johnson wrote: On Thu, Jun 28, 2007 at 06:58:36AM -0500, Mumia W. wrote: On 06/28/2007 03:00 AM, Mathew Snyder wrote: our @ISA = qw(Exporter); our @EXPORT = qw(startDate endDate searchStart searchEnd); our $VERSION = '1'; Those lines need to be within a BEGIN

Re: using a homemade perl module

2007-06-28 Thread Mathew Snyder
Paul Johnson wrote: On Thu, Jun 28, 2007 at 06:58:36AM -0500, Mumia W. wrote: On 06/28/2007 03:00 AM, Mathew Snyder wrote: our @ISA = qw(Exporter); our @EXPORT = qw(startDate endDate searchStart searchEnd); our $VERSION = '1'; Those lines need to be within a BEGIN

processing XL using Win32::OLE

2007-06-28 Thread alok nath
Hi, Can anybody tell how to open an already existing xL file and then probabaly do some processing using Win32::OLE I found quite a few examples but none of them open an existing excel file. Or is there some better module for XL processing ? Here is my code .. use strict ; use warnings ;

Re: processing XL using Win32::OLE

2007-06-28 Thread Prabu Ayyappan
Hi Alok, Hope the examples in the below links help your needs. For opening and reading an XL(Excel) use strict; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; $Win32::OLE::Warn = 3;# die on errors... # get already active Excel