Use join on multi-dimensional array

2009-02-27 Thread Bill Harpley
Suppose I have a multidimensional array of the form: @array[names][values] For example, I have a list of database field names and the value associated with each one. If this was a single dimensional array called @list, I could create an output line in CSV format by using the 'join' command like

Exception Handling in perl

2009-02-27 Thread Sarsamkar, Paryushan
Hi All, Can we handle exceptions in PERL programs? For example - Here if it fails to copy then can I handle the exception and perform the next steps in my script? I tried removing "die" but then it does not complain and I wont be able to come to know if that is copied or not. (Is there anyt

DBI fetchall_arrayref

2009-02-27 Thread David Shere
The following sub uses "fetchall_arrayref" in the DBI module to put the results of an SQL command into an array, where each element of the array is a hash of that records name/value pairs. The documentation says to pass it a reference to a hash. My interpretation of that requirement is below. Di

Re: Exception Handling in perl

2009-02-27 Thread David Shere
On Fri, 2009-02-27 at 08:41 -0500, Sarsamkar, Paryushan wrote: > copy ("C:\\build.xml","D:\\build.xml") or die "Cannot copy : $!"; simplest (?) solution: copy ("C:\\build.xml","D:\\build.xml") or print "Cannot copy : $!"; You can also have it do more than one thing: copy ("C:\\build.xml","D:\\bui

Re: Exception Handling in perl

2009-02-27 Thread David Shere
On Fri, 2009-02-27 at 08:49 -0500, David Shere wrote: > You can also have it do more than one thing: > copy ("C:\\build.xml","D:\\build.xml") or ( print "Cannot copy : $!" and > somethingElse() ); Or you can have more fun: unless (copy ("C:\\build.xml","D:\\build.xml")) { print "Cannot copy : $

RE: Exception Handling in perl

2009-02-27 Thread Sarsamkar, Paryushan
Thanks... My bad... I did not realize to use print instead of just "die"ing :) Thanks, Paryushan -Original Message- From: David Shere [mailto:dsh...@steelerubber.com] Sent: Friday, February 27, 2009 7:31 PM To: Sarsamkar, Paryushan Cc: beginners@perl.org Subject: Re: Exception Handling

Acepting default value for user input

2009-02-27 Thread Sarsamkar, Paryushan
Hi All, I would like to accept some user inputs (using ), but it might be easier for a user if I can provide the default value, so that they just have to press ENTER. How can I do that? I've played around with but I cannot make it work exactly as I'd like. E.g. Do you want to do th

Re: Use join on multi-dimensional array

2009-02-27 Thread Gunnar Hjalmarsson
Bill Harpley wrote: Suppose I have a multidimensional array of the form: @array[names][values] For example, I have a list of database field names and the value associated with each one. Is this what you mean: my @record = ( [ col1 => 'val1' ], [ col2 => 'val2' ], );

Re: Acepting default value for user input

2009-02-27 Thread Gunnar Hjalmarsson
Sarsamkar, Paryushan wrote: I would like to accept some user inputs (using ), but it might be easier for a user if I can provide the default value, so that they just have to press ENTER. How can I do that? I've played around with but I cannot make it work exactly as I'd like. E.g. Do you want

Re: Acepting default value for user input

2009-02-27 Thread Chas. Owens
On Fri, Feb 27, 2009 at 10:03, Sarsamkar, Paryushan wrote: snip > I would like to accept some user inputs (using ), but it might be > easier for a user if I can provide the default value, so that they just > have to press ENTER. snip > Do you want to do the normal thing? [yes] : > > Do you want to

Re: Re: Acepting default value for user input

2009-02-27 Thread juliaaaa . 1
Hi people!! I´m using Perl for the first time in my Mac OS X... How can I check installed modules ??? I am running a Mac OS X Leopard 10.5.6 with Perl version v5.8.8 built for darwin-thread-multi-2level... Thanks

Re: Acepting default value for user input

2009-02-27 Thread Chas. Owens
On Fri, Feb 27, 2009 at 11:07, Gunnar Hjalmarsson wrote: > Sarsamkar, Paryushan wrote: >> >> I would like to accept some user inputs (using ), but it might be >> easier for a user if I can provide the default value, so that they just >> have to press ENTER. >> >> How can I do that? I've played aro

Re: Re: Acepting default value for user input

2009-02-27 Thread Chas. Owens
On Fri, Feb 27, 2009 at 11:16, wrote: > Hi people!! > > I´m using Perl for the first time in my Mac OS X... > > > How can I check installed modules ??? > > > I am running a Mac OS X Leopard 10.5.6 with Perl version v5.8.8 built for > darwin-thread-multi-2level... > > > Thanks > Please do not

Re: picking largest key by value..

2009-02-27 Thread Rick
Jim Gibson wrote: On 2/26/09 Thu Feb 26, 2009 3:53 PM, "John W. Krahn" scribbled: I get "Use of uninitialized value in numeric gt (>) at ..." for that, since @max is undefined the first time through the loop. Here is a version using each that doesn't produce that error. It uses the fact th

Re: DBI fetchall_arrayref

2009-02-27 Thread Chas. Owens
On Fri, Feb 27, 2009 at 08:43, David Shere wrote: > The following sub uses "fetchall_arrayref" in the DBI module to put the > results of an SQL command into an array, where each element of the array > is a hash of that records name/value pairs.  The documentation says to > pass it a reference to a

Installing Perl DBD, DBI::mysql Modules

2009-02-27 Thread juliaaaa . 1
Hi there, I would like to know how can I install Perl DBD, DBI::mysql Modules I have an Intel Mac OS X (10.5.6) Leopard with Perl v5.8.8 built for darwin-thread-multi-2level

Re: Exception Handling in perl

2009-02-27 Thread Jenda Krynicky
Subject:Re: Exception Handling in perl From: David Shere To: "Sarsamkar, Paryushan" Copies to: beginners@perl.org Date sent: Fri, 27 Feb 2009 09:00:41 -0500 > On Fri, 2009-02-27 at 08:49 -0500, David Shere wrote: > >

Re: Use join on multi-dimensional array

2009-02-27 Thread Jenda Krynicky
From: "Bill Harpley" > Suppose I have a multidimensional array of the form: > > @array[names][values] > > For example, I have a list of database field names and the value > associated with each one. > > If this was a single dimensional array called @list, I could create an > output line in CSV

Re: Installing Perl DBD, DBI::mysql Modules

2009-02-27 Thread Francisco Valladolid
hi, You maybe need investigate the correct way to do it in Mac OS X 9 maybe macports, I dont' have idea. In BSD (pkgsrc or ports ) are the best way to do it task. Try with $ perl -MCPAN -e shell Regards On Fri, Feb 27, 2009 at 11:15 AM, wrote: > Hi there, I would like to know how can I inst

Re: picking largest key by value..

2009-02-27 Thread Jim Gibson
On 2/27/09 Fri Feb 27, 2009 8:33 AM, "Rick" scribbled: > Jim Gibson wrote: >> On 2/26/09 Thu Feb 26, 2009 3:53 PM, "John W. Krahn" >> scribbled: >> >> I get "Use of uninitialized value in numeric gt (>) at ..." for that, since >> @max is undefined the first time through the loop. Here is

Re: Use join on multi-dimensional array

2009-02-27 Thread Jim Gibson
On 2/27/09 Fri Feb 27, 2009 5:21 AM, "Bill Harpley" scribbled: > Suppose I have a multidimensional array of the form: > > @array[names][values] There is no such construct in Perl. An array is a one-dimensional list of scalar values, indexed by integers. You can emulate multi-dimensional array

Re: Use join on multi-dimensional array

2009-02-27 Thread John W. Krahn
Jenda Krynicky wrote: From: "Bill Harpley" Suppose I have a multidimensional array of the form: @array[names][values] For example, I have a list of database field names and the value associated with each one. If this was a single dimensional array called @list, I could create an output line

Re: DBI fetchall_arrayref

2009-02-27 Thread John W. Krahn
Chas. Owens wrote: On Fri, Feb 27, 2009 at 08:43, David Shere wrote: The following sub uses "fetchall_arrayref" in the DBI module to put the results of an SQL command into an array, where each element of the array is a hash of that records name/value pairs. The documentation says to pass it a

Re: Acepting default value for user input

2009-02-27 Thread Gunnar Hjalmarsson
Chas. Owens wrote: On Fri, Feb 27, 2009 at 11:07, Gunnar Hjalmarsson wrote: Sarsamkar, Paryushan wrote: I would like to accept some user inputs (using ), but it might be easier for a user if I can provide the default value, so that they just have to press ENTER. How can I do that? I've played

Re: Acepting default value for user input

2009-02-27 Thread Jim Gibson
On 2/27/09 Fri Feb 27, 2009 2:05 PM, "Gunnar Hjalmarsson" scribbled: > Which takes us to the obvious step of validating the user input. > > my $normal; > while (1) { > print 'Do you want to do the normal thing? [yes] : '; > chomp( $normal = ); > $normal =

Re: Acepting default value for user input

2009-02-27 Thread Rob Dixon
Gunnar Hjalmarsson wrote: > Chas. Owens wrote: >> On Fri, Feb 27, 2009 at 11:07, Gunnar Hjalmarsson wrote: >>> Sarsamkar, Paryushan wrote: I would like to accept some user inputs (using ), but it might be easier for a user if I can provide the default value, so that they just have t

Re: regarding regular expression

2009-02-27 Thread itshardtogetone
- Original Message - From: "John W. Krahn" To: "Perl Beginners" Sent: Thursday, February 26, 2009 10:54 PM Subject: Re: regarding regular expression Irfan Sayed wrote: Hi All, Hello, I have a string like this "pqp-un_1.0G_2009-02-23_17-38-09_5678903.txt " now what i need is only

Re: picking largest key by value..

2009-02-27 Thread Rick
Jim Gibson wrote: NO it is not. The way to diagnosis this type of problem is to look at the contents of your variables, either by stepping through your program with a debugger or by adding print statements to your program. If you do that, you will find that the @next array is not assigned the key

Re: picking largest key by value..

2009-02-27 Thread Rick
Jim Gibson wrote: On 2/27/09 Fri Feb 27, 2009 8:33 AM, "Rick" scribbled: Jim Gibson wrote: On 2/26/09 Thu Feb 26, 2009 3:53 PM, "John W. Krahn" scribbled: I get "Use of uninitialized value in numeric gt (>) at ..." for that, since @max is undefined the first time through the