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
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
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
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]
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,
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/){
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
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,.);
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,.);
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/
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
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;
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);
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);
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);
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,
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
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
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.
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
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
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
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,
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
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?
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
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,
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
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:
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
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
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
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/
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] =
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.
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: //,
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 =
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
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
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 =
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
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
-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,
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
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
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
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
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?
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?
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
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
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 ;
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
53 matches
Mail list logo