Re: processing large datafiles

2009-02-17 Thread Jim Gibson
On 2/17/09 Tue Feb 17, 2009 9:06 AM, Pedro Soto pedrosoto2...@gmail.com scribbled: Dear all, I need to read a huge file and then write only the columns that match with ids from another file (with less ids) in a sorted fashion. I made a script thatdoes the work but it takes a lot of time. I

Re: What SSL version does LWP use?

2009-02-18 Thread Jim Gibson
On 2/18/09 Wed Feb 18, 2009 12:06 PM, David Shere dsh...@steelerubber.com scribbled: Either I'm blind or the LWP package documentation at http://search.cpan.org/~gaas/libwww-perl-5.825/lib/LWP.pm doesn't say what SSL standard it uses, or if it can use more than one. I recently received

Re: Invalid conversion in sprintf %\

2009-02-18 Thread Jim Gibson
On 2/18/09 Wed Feb 18, 2009 10:20 AM, Rob Canning r...@goto10.org scribbled: John W. Krahn said : Rob Canning wrote: hi i have a sprintf which uses a scalar as its format: my $Bformat = %1\$s16- %2\$s16 %3\$s16 %4\$s16 %5\$s16 %6\$s16- %7\$s16 %8\$s16 [...] any ideas what i am doing

Re: Invalid conversion in sprintf %\

2009-02-19 Thread Jim Gibson
program. I would suggest that Rob use single-quotes and avoid having to escape the dollar-signs. The q() and qq() forms are also useful at times. -- Jim Gibson -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: local and my in subroutines

2009-02-23 Thread Jim Gibson
On 2/23/09 Mon Feb 23, 2009 4:30 PM, Karyn Stump ka...@calarts.edu scribbled: I am trying to learn subroutines. I have seen refernces to using my and local for passing variables so I am playing with them to try to understand better how this all works. Neither 'local' nor 'my' is required

Re: replace text in file

2009-02-25 Thread Jim Gibson
On 2/25/09 Wed Feb 25, 2009 5:02 PM, lemba le...@sbcglobal.net scribbled: Hi All, I'm trying to replace some text in file. Below is my script. It basically makes a copy of line with changes. How can I replace pattern in the uxix sed way? I don't use sed, but you can use Perl one-liners

Re: regarding hash

2009-02-26 Thread Jim Gibson
On 2/26/09 Thu Feb 26, 2009 6:24 AM, Irfan Sayed irfan_sayed2...@yahoo.com scribbled: Hi All,   I have sorted one array in ascending order. Now i want to store that sorted output (key/value pair ) in new hash. How can i do that. By design, hashes do not have an order. Key/value pairs are

Re: connecting to multiple hosts using Net::SSH2

2009-02-26 Thread Jim Gibson
On 2/26/09 Thu Feb 26, 2009 8:26 AM, monnappa appaiah monnapp...@gmail.com scribbled: Hi all, I'm using windows machine and i'm using Net::SSH2 module to connect to remote machine How can i use the same piece of code to read a list of hosts from a text file and then connect to

Re: picking largest key by value..

2009-02-26 Thread Jim Gibson
On 2/26/09 Thu Feb 26, 2009 12:34 PM, Rick rich.j...@gmail.com scribbled: trying out getting lasrgest key(by value) but below is not working... help please. my %files=%{{one =1, thiry =30, four =4, never =997, forever =11, five =5}}; my $max; print join( ,keys %files),\n; =pod

Re: picking largest key by value..

2009-02-26 Thread Jim Gibson
On 2/26/09 Thu Feb 26, 2009 3:53 PM, John W. Krahn jwkr...@shaw.ca scribbled: Rick wrote: trying out getting lasrgest key(by value) but below is not working... help please. my %files=%{{one =1, thiry =30, four =4, never =997, forever =11, five =5}}; my $max; print join( ,keys

Re: picking largest key by value..

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

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 bill.harp...@ericsson.com 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

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 nore...@gunnar.cc 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 = STDIN );

Re: join and parenthesis. Is this a bug?

2009-03-03 Thread Jim Gibson
On 3/3/09 Tue Mar 3, 2009 3:05 AM, freefox robert.lo...@privat.utfors.se scribbled: Hi, As join is a build in I guess it should/could be called without parenthesis. However these two lines gives me two different answers. my @strings = ('foo', 'bar'); my $string1 = q{('} . join q{',

Re: Printing directory sizes

2009-03-04 Thread Jim Gibson
dividing the result by 1_000_000 (-s returns size in bytes, not bits). Or use 1_048_576 if you think megabytes should be a binary number. -- Jim Gibson -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Copy file recursively

2009-03-05 Thread Jim Gibson
On 3/5/09 Thu Mar 5, 2009 1:48 AM, Rock Lifestyle lifestyle.r...@yahoo.in scribbled: Hi ,   My directory structure is like   [snipped]   I want to copy some subdirectory and files under it to another directory it should exactly create similar directory structure Use the

Re: if (match) problem

2009-03-10 Thread Jim Gibson
On 3/10/09 Tue Mar 10, 2009 7:59 AM, Dermot paik...@googlemail.com scribbled: Hi, I am not getting the results that I expect from this test and I am not sure why. If I run the script below I get: 1..3 Line=???/FOO BAR, Name=Joe Smo M=??? ok 1 - handle_name ???/FOO BAR Line=change

Re: Regex problem

2009-03-10 Thread Jim Gibson
On 3/10/09 Tue Mar 10, 2009 8:19 AM, howa howac...@gmail.com scribbled: Hello, Consider the code: #=== use strict; my $a = 'a.jpg'; if ($a =~ /(html|jpg)/gi) { print 'ok'; } #=== Is the brucket () must be needed? Since I am not using

Re: Regex problem

2009-03-11 Thread Jim Gibson
On 3/10/09 Tue Mar 10, 2009 8:41 PM, howa howac...@gmail.com scribbled: Hi, On Mar 11, 1:16 am, nore...@gunnar.cc (Gunnar Hjalmarsson) wrote: I would do:      if ( $a =~ /\.(?:html|jpg)$/i ) Please readhttp://perldoc.perl.org/perlretut.htmland other appropriate docs. Read the

Re: OO constructors

2009-03-11 Thread Jim Gibson
On 3/11/09 Wed Mar 11, 2009 5:28 AM, Dermot paik...@googlemail.com scribbled: 2009/3/11 Dr.Ruud rvtol+use...@isolution.nl: Dermot wrote: I created  a small Class, initially with Moose. When I wanted an instance of the class I would call `my $instance = new MyClass`; I then removed

Re: Stupid newb question

2009-03-11 Thread Jim Gibson
On 3/11/09 Wed Mar 11, 2009 11:36 AM, neckha...@penntraffic.com neckha...@penntraffic.com scribbled: Hi guys, I am starting to learn Perl as the ksh scripting language (which I don't know either) looks less than powerful. I have used C many years ago, and write my stuff in REXX on a

Re: Network Printing using a Perl Script

2009-03-12 Thread Jim Gibson
On 3/12/09 Thu Mar 12, 2009 6:18 AM, Aglipay, Recelyn recelyn.agli...@ehmc.com scribbled: Hi Dave, I'm using a third party application to call the perl script. This application only allows for subroutines to be written since the app also uses some perl. So the code below is all I have.

Re: Error: Can't call method x without a package or object reference...

2009-03-16 Thread Jim Gibson
On 3/14/09 Sat Mar 14, 2009 5:28 AM, M. Coiffure coiff...@gmx.at scribbled: Hi all I'm getting this error on the following (test) script: Can't call method x without a package or object reference at test.pl line 12 ENT line 1 What I want to do is create a HashMap where the keys are

Re: Slice?

2009-03-16 Thread Jim Gibson
On 3/16/09 Mon Mar 16, 2009 3:05 PM, R. Hicks sigz...@gmail.com scribbled: $template-param( RESULTS = $self-dbh-selectall_arrayref(' SELECT age, day FROM table WHERE id = ?', { Slice = {} }, $self-session-param('cell')-{'sid'} ) ); I saw that code and while I do

Re: Writing a column after column

2009-03-17 Thread Jim Gibson
On 3/16/09 Mon Mar 16, 2009 10:20 AM, vd vvd2...@gmail.com scribbled: Hi all, I need to consolidate columns of data available across different directories into a single excel csv file. Usually we write to a file row after row but for the current task I have, it would be convenient to

Re: Matching Over Multiple Lines

2009-03-17 Thread Jim Gibson
On 3/17/09 Tue Mar 17, 2009 8:45 AM, Jeff Westman westf...@gmail.com scribbled: All, I know this has been asked many times, and I have read the documentation (perldoc -q matching over more than one line) and still can't make head or tails out of this. I have a problem where my pattern

Re: enumerating subarrays

2009-04-06 Thread Jim Gibson
On 4/4/09 Sat Apr 4, 2009 8:34 PM, Andrew Fithian afit...@gmail.com scribbled: What's a slick way to enumerate all subarrays of length n from a master array of length m? For example I've been enumerating all possible two card hands from a deck of 52 cards (n=2, m=52) using nested for loops:

Re: Random number generator

2009-04-09 Thread Jim Gibson
On 4/9/09 Thu Apr 9, 2009 2:34 PM, ANJAN PURKAYASTHA anjan.purkayas...@gmail.com scribbled: I need a Bernoulli random number generator which takes as inputs: a value for p(1) (probability of choosing a 1) and the number of trials and outputs a series of 0s and 1s according to the model

Re: Perl Script Error : Can't call method execute_flow without a package or object reference

2009-04-16 Thread Jim Gibson
On 4/15/09 Wed Apr 15, 2009 9:18 PM, Fatema M fsm1...@gmail.com scribbled: Hi, I am facing an error while executing the Perl script, its compilation fails with the following error Can't call method execute_flow without a package or object reference at addr Code Snippet: use

Re: Compiler options perl

2009-04-17 Thread Jim Gibson
On 4/16/09 Thu Apr 16, 2009 1:39 PM, edw...@yandex.ru edw...@yandex.ru scribbled: Hello, I would like to know, how to force perl unfold foreach expression during the compilation, i.e. I want next code: foreach (1..100) { block } to be compiled like this: block[$_ =

Re: help needed to get over endless loop

2009-04-17 Thread Jim Gibson
On 4/17/09 Fri Apr 17, 2009 10:02 AM, Brian brian5432...@yahoo.co.uk scribbled: Hi I had this semi-working, changed something and can't remember where I went right, so would appreciate some help getting back on top. I know 1..10 and 2..10 probably won't work in the following example, I

Re: Perl Script Error : Can't call method execute_flow without a package or object reference

2009-04-17 Thread Jim Gibson
On 4/16/09 Thu Apr 16, 2009 2:25 PM, Chas. Owens chas.ow...@gmail.com scribbled: 2009/4/16 Jim Gibson jimsgib...@gmail.com: snip This calls the new method in package vpu and assigns the return value, which should be a blessed scalar of some type, usually a reference to a hash, but it could

Re: help needed to get over endless loop

2009-04-17 Thread Jim Gibson
On 4/17/09 Fri Apr 17, 2009 1:50 PM, Brian brian5432...@yahoo.co.uk scribbled: Brian wrote: oops, should read.. $Year_out = $Year_in; while ($Year_out 100) {$Year_out -= 100;} if (($Year_out 00) ($Year_out = 25)) {$string = $string1;} if

Re: String manipulation question

2009-04-21 Thread Jim Gibson
On 4/21/09 Tue Apr 21, 2009 8:58 AM, Grant emailgr...@gmail.com scribbled: I'd like to take a string and manipulate it in a few ways. If the string is 34 characters or less, I'd like to append a colon character and save it to $var1. The length function will tell you how many characters

Re: String manipulation question

2009-04-21 Thread Jim Gibson
On 4/21/09 Tue Apr 21, 2009 10:46 AM, Grant emailgr...@gmail.com scribbled: Thanks guys. With some help I've come up with this: $string = 'abc def ghi jkl mno pqr stu vwx yz'; if(length($string) = 34) {$var1 = $string.:;} '=' is assignment, '==' is test for numerical equality. Change the

Re: String manipulation question

2009-04-21 Thread Jim Gibson
On 4/21/09 Tue Apr 21, 2009 11:16 AM, Grant emailgr...@gmail.com scribbled:   $string =~ s/\s//g; The above line deletes all of the spaces in $string. Is that what you want to do? All fixed up except for this. How can I remove only the spaces at the end of $var1 and $var2 if they

Re: String manipulation question

2009-04-21 Thread Jim Gibson
On 4/21/09 Tue Apr 21, 2009 11:42 AM, Grant emailgr...@gmail.com scribbled: I'm trying to pull 35 or fewer characters to the nearest space basically. This is what I have now: if(length($string) = 34) {$var1 = $string.:;} if(length($string) 34) { ($var1, $var2) = ($string =~

Re: String manipulation question

2009-04-21 Thread Jim Gibson
On 4/21/09 Tue Apr 21, 2009 11:54 AM, Grant emailgr...@gmail.com scribbled: if you have in $string = q[1234 12345 12 5346 12367 123 123678123]; Then $var1 will be '1234 12345 12 5346 12367 123 12367', but I thought you wanted '1234 12345 12 5346 12367 123'? Which one is the right one for

Re: libwww-perl library

2009-04-21 Thread Jim Gibson
On 4/21/09 Tue Apr 21, 2009 3:27 PM, hOURS h_o...@yahoo.com scribbled: Hi all, The get function in the libwww-perl library would be really useful to me, but I'm having problems making it work.  When I use it in a cgi script (it's ultimate destination) it fails.  My browser displays a

Re: How does printf able to receive a pointer when passing it a string constant?

2009-05-13 Thread Jim Gibson
On 5/13/09 Wed May 13, 2009 4:48 AM, Michael Alipio daem0n...@yahoo.com scribbled: I have a c code that looks like this: #includestdio.h main (){ char girl[] = anna; char boy[] = jude; stringcopy(boy, girl); /* copy boy to girl */ printf(%s, girl); } void stringcopy(char *b,

Re: Help with LWP

2009-05-13 Thread Jim Gibson
On 5/13/09 Wed May 13, 2009 2:17 PM, ANJAN PURKAYASTHA anjan.purkayas...@gmail.com scribbled: Hi, Here is a beginner's LWP code that is not working. The script is supposed to query the NCBI website with a user defined term: tuberculosis. The term is entered into a search box. The user

Re: Push to AoA

2009-05-13 Thread Jim Gibson
On 5/13/09 Wed May 13, 2009 4:48 PM, Steve Bertrand st...@ibctech.ca scribbled: Hi all, I'm trying to push a scalar onto an array. The array I'm trying to push() to is the first element of another array. I can't figure out what I'm missing. It would be appreciated if someone could point

Re: Write Excel and Open file from CGI

2009-05-14 Thread Jim Gibson
On 5/13/09 Wed May 13, 2009 11:03 AM, Vaishak vaishak...@gmail.com scribbled: Hello List, I have a DOS batch file which has perl script that runs at the end. The perl script fetches information from different files and database and generates an excel file. Is there a way I can

Re: How to append to existing excel sheet?

2009-05-27 Thread Jim Gibson
On 5/27/09 Wed May 27, 2009 2:14 AM, Kelvin Philip kelvinphi...@gmail.com scribbled: Hi, Is there any method to append a row to an existing Excel file? Can I do it using the Spreadsheet::WriteExcel module? The Spreadsheet::WriteExcel (SS:WE) module will not add data to an existing

Re: skipping a repeated header

2009-05-27 Thread Jim Gibson
On 5/27/09 Wed May 27, 2009 9:15 AM, Kirk Wythers kwyth...@umn.edu scribbled: Thanks David. I didn't include my attempts because the postgresql stuff took up so many lines. I have snippet out the data read part (including your suggestion) and pated below. As you can see I also, sent a

Re: Parsing TXT document and output to XML

2009-05-28 Thread Jim Gibson
On 5/27/09 Wed May 27, 2009 3:27 PM, Stephen Reese rsre...@gmail.com scribbled: List, I've been working on a method to parse a PDF or TXT document and output the results to XML over at Experts Exchange. http://www.experts-exchange.com/Programming/Languages/Scripting/Perl/Q_2443963 0.html

Re: calc function's executed time

2009-06-01 Thread Jim Gibson
On 6/1/09 Mon Jun 1, 2009 1:58 AM, practicalp...@gmail.com practicalp...@gmail.com scribbled: Hello, What's the standard way to calculate a subroute's executed time in Perl? Thanks in advance. One popular way is to use the Benchmark.pm module. See 'perldoc Benchmark' or

Re: Perl CGI: accessing a element value from the current form

2009-06-01 Thread Jim Gibson
On 6/1/09 Mon Jun 1, 2009 1:40 PM, Ravi Malghan rmalg...@yahoo.com scribbled: Hi: I have web page built using perl cgi. Generated page has the following element div id=userName style=display: none; name=userName admin /div Within the perl script is there a way to access the value of

Re: Efficiently going through results

2009-06-09 Thread Jim Gibson
On 6/9/09 Tue Jun 9, 2009 1:24 AM, Dave Tang d.t...@imb.uq.edu.au scribbled: Hello, I have a problem, which I have put into an analogy. Suppose a parent has 11 children. These children like chocolate. If 9 or more of the 11 children from the same parent like a particular chocolate, the

Re: 2 minutes and 8 second (how do i convert it to 02:08)??

2009-06-11 Thread Jim Gibson
On 6/11/09 Thu Jun 11, 2009 1:51 AM, Michael Alipio daem0n...@yahoo.com scribbled: Hi, I have a program that computes the number of elapsed minutes and seconds. if the outputs are: 2 minutes, and 8 seconds. How do I print those two values to look like Elapsed time: 02:08 This

Re: Please, I need help!!!

2009-06-12 Thread Jim Gibson
On 6/11/09 Thu Jun 11, 2009 11:00 AM, Phillip fibbe...@gmx.net scribbled: Hallo @ all, i am new in this domain(perlscript) and i have a question.i have a array,i sort it,i get the last element of the array but i want to get the next element after this one.how can i do this? There is a

Re: Alpaca Chap7 Question

2009-06-15 Thread Jim Gibson
On 6/15/09 Mon Jun 15, 2009 12:26 PM, Thomas H. George li...@tomgeorge.info scribbled: I do not fully understand the solution to the problem, p77-78 237. First, the declaration of the array my @files in the subroutine gather_mtime_between will be read every time find($gather,

Re: Exception error in perl code

2009-06-17 Thread Jim Gibson
On 6/16/09 Tue Jun 16, 2009 9:14 PM, Rajini Naidu rajinid...@gmail.com scribbled: Hi, I have the following code in my program. use strict; use warnings; use diagnostics; use Time::Local; my @match_list; my $days1 = ; my $days2 = ; my $day = ; if ($failtag eq CompileErr)

Re: recurive chown with perl chown

2009-06-19 Thread Jim Gibson
On 6/19/09 Fri Jun 19, 2009 8:44 AM, Harry Putnam rea...@newsguy.com scribbled: Chas. Owens chas.ow...@gmail.com writes: On Fri, Jun 19, 2009 at 09:35, Harry Putnamrea...@newsguy.com wrote: How to manage a recursive chown using perl function chown? Do I have to employ something like

Re: friend class in perl

2009-06-24 Thread Jim Gibson
On 6/24/09 Wed Jun 24, 2009 10:45 AM, Roman Makurin dro...@gmail.com scribbled: Hi I need create a friend class. Is there any special that I need to know ? For now, I get object and work with it like with ordinary reference with direct access to internal fields. All Perl classes are

Re: sorting anonymous arrays inside arrays

2009-07-02 Thread Jim Gibson
On 7/2/09 Thu Jul 2, 2009 12:12 PM, daem0n...@yahoo.com daem0n...@yahoo.com scribbled: Hi, If I have a loop that for each run creates while (FILE){   my $value =~ /^\d/;   $myhash{$mykey}-{'subkey'} = $value; } Normally, if I only want to sort $myhash through it's values, I

Re: Hello there

2009-07-06 Thread Jim Gibson
On 7/6/09 Mon Jul 6, 2009 3:19 PM, Emanuele Osimo e.os...@gmail.com scribbled: Hello there, I'm a biologist and I'm trying to start using bioperl for bioinformatic purposese but I've never programmed. Could you suggest me something to read to start from 0 level? See the FAQ 2 for Perl. Try

Re: Need some module help

2009-07-09 Thread Jim Gibson
of code which load the module in my caller are these: use lib 'Mod'; use Mod::myMod; The line of code where I get the error is this: my $obj = myMod-new(); Try this line instead: my $obj = Mod::myMod-new(); -- Jim Gibson j...@gibson.org -- To unsubscribe, e-mail: beginners-unsubscr

Re: Best way to mix two lists

2009-07-10 Thread Jim Gibson
On 7/10/09 Fri Jul 10, 2009 11:32 AM, Matteo Riva mura...@gmail.com scribbled: Hello everybody, I have two lists and I want to merge them like this: element 1 of list A, element 1 of list B, A2, B2, A3, B3, etc. I need this to create a sequence of key/value for an anonymous hash.

Re: Index a list

2009-07-10 Thread Jim Gibson
On 7/10/09 Fri Jul 10, 2009 12:37 PM, Steve steve.h...@digitalcertainty.co.uk scribbled: Hi list memebers. I'm new here and I'm interested in learning about Perl. I've managed to get some programs together but have a lot to learn. May I put a question to the experts? Suppose I have a

Re: html template loops not showing data

2009-07-10 Thread Jim Gibson
On 7/10/09 Fri Jul 10, 2009 2:25 PM, Shawn H. Corey shawnhco...@gmail.com scribbled: On Fri, 2009-07-10 at 15:19 -0600, Scott wrote: Hello, Here is my code on the perl side: my @wall_data = (); while(my $wallref = $wallpostquery-fetchrow_hashref()) { my %walldata;

Re: Finding out matching and not matching entries between two files !

2009-07-16 Thread Jim Gibson
the fact and read a line from the file with the lessor of the two line, alphabetically speaking, then compare again. -- Jim Gibson j...@gibson.org -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: misunderstanding

2009-07-18 Thread Jim Gibson
number of digits using printf and the format descriptor %.mf, where m is the number of digits you want. If you actually need more than 64 bits (and you probably don't), then use Math::BigFloat and suffer the performance penalty. -- Jim Gibson -- To unsubscribe, e-mail: beginners-unsubscr

Re: 'Join' query

2009-08-07 Thread Jim Gibson
On 8/7/09 Fri Aug 7, 2009 8:03 AM, jet speed speedj...@googlemail.com scribbled: Hi, I would like to join the $abc with ':' the final desired output 1:2:3:4:5 #!/usr/bin/perl use strict; use warnings; my $abc = 1 2 3 4 5; my $out = join ':', $abc; print $out; executing the

Re: Printing a hash of hashes of arrays

2009-08-27 Thread Jim Gibson
On 8/27/09 Thu Aug 27, 2009 10:42 AM, Ian pcs...@gmail.com scribbled: Pure beginners question. I'm creating a hash of arrays like this : $ihash{$3}{$1} = [...@itab]; For now I was able to get the data using Dumper but I need to create a pretty report. How do I loop over this

Re: Time issues

2009-08-31 Thread Jim Gibson
Excel on Windows? I would guess that the latter is slower than the former, but I never compared the two methods. -- Jim Gibson jimsgib...@gmail.com -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: search replace saved to a variable

2009-09-02 Thread Jim Gibson
At 7:22 PM -0700 9/2/09, Noah Garrett Wallach wrote: Hi there, what is the way to collapse this search/replace to one line? my $filename_cmd = $cmd[-1]; my $filename_cmd =~ s/\s/\./; (my $filename_cmd = $cmd[-1]) =~ s/\s/\./; -- Jim Gibson jimsgib...@gmail.com

Re: hash of hashes question

2009-09-04 Thread Jim Gibson
'}{$2} = 1; The rest looks OK, and compiles. -- Jim Gibson j...@gibson.org -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: hash of hashes values and keys

2009-09-04 Thread Jim Gibson
-of-hashes will have and always use the appropriate amount of dereferencing. Use the Data::Dumper module to print a multi-level data structure and reveal its structure and contents: use Data::Dumper; print Dumper(\%policy); -- Jim Gibson jimsgib...@gmail.com -- To unsubscribe, e

Re: perldoc modules

2009-09-04 Thread Jim Gibson
$/ }, @INC; print join \n, @files; -- Jim Gibson j...@gibson.org -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: push and split

2009-09-17 Thread Jim Gibson
); } This will not overwrite any data. You will probably have many one-element arrays, however. -- Jim Gibson -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: dealing with ~

2009-09-24 Thread Jim Gibson
On 9/24/09 Thu Sep 24, 2009 5:23 PM, Noah noah-l...@enabled.com scribbled: Hi there, How do I use the glob command to handle ~? I am getting file not found for something like ~/cvs/blah.pl so this command dies with file not found: open BBOUTPUT, $output_file or die $!;

Re: hash question

2009-09-25 Thread Jim Gibson
to work, I suggest that you may have a precedence problem in your call to the each routine. Try this line instead: while( my($key,$value) = each(%policy_Hash) ) { Note the parentheses around $key,$value. See 'perldoc -f each' for an example. -- Jim Gibson -- To unsubscribe, e-mail

Re: hash question

2009-09-25 Thread Jim Gibson
) { for my $key2 ( sort keys %{policy_Hash{$key1}} ) { print $key1 = $key2 = $policy_Hash{$key1}-{$key2}\n; } } This will only work if all values of the first-level hash are references to a hash. Data::Dumper can handle the case where this is not true. -- Jim Gibson

Re: how to do a `cp` on millions of files

2009-09-28 Thread Jim Gibson
At 10:50 PM -0400 9/28/09, Steve Bertrand wrote: xufengnju wrote: Hi all, I have a storage server that holds one million of images with well structured directory structure such as /data/user1/2008/09/12/image1.jpg /data/user1/2008/09/12/image2.jpg ... /data/user2/2009/01/01/image1.jpg

Re: How to fill an array from multiple row in a db

2009-09-30 Thread Jim Gibson
On 9/30/09 Wed Sep 30, 2009 11:33 AM, Bruce Ferrell bferr...@baywinds.org scribbled: Shawn H Corey wrote: Bruce Ferrell wrote: I have a database (mysql if it matters) and I can select columns and rows from it no problem. what I can't quite seem to see how to do is to take the columns

Re: Fw: yet another question

2009-10-06 Thread Jim Gibson
other array. You can read about @ARGV and many other special Perl variables in the 'perlvar' section of the built-in Perl documentation, available from a shell with perldoc perlvar -- Jim Gibson j...@gibson.org -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional

Re: Need explanation about this code.

2009-10-08 Thread Jim Gibson
On 10/8/09 Thu Oct 8, 2009 9:00 AM, Raheel Hassan raheel.has...@gmail.com scribbled: Hello, I have problems in understanding $...@$ use ? 1- my $ref = $$temp_sth - fetchall_arrayref({}); for(my $i=0; $i = $...@$ref}; $i++) { For any array @a, the largest index is given by $#a.

Re: for output from other unix commands

2009-10-08 Thread Jim Gibson
On 10/8/09 Thu Oct 8, 2009 3:56 PM, Harry Putnam rea...@newsguy.com scribbled: Shlomi Fish shlo...@iglu.org.il writes: Hi Harry! [...] I want to catch those long lines and format them like one might format a news/mail message... wrapped at column 72 or so but also indented

Re: Building a record on the fly via hash of hashes

2009-10-08 Thread Jim Gibson
a push equivalent for hash of hashes? No. Unless each record has a unique key, you are better off using an array of hashes, rather than a hash of hashes. Of course, you could use the line number as a unique key, but an array would be more efficient. -- Jim Gibson j...@gibson.org

Re: for output from other unix commands

2009-10-09 Thread Jim Gibson
On 10/9/09 Fri Oct 9, 2009 7:43 AM, Harry Putnam rea...@newsguy.com scribbled: I'm thinking of splitting on something like ' +' (spcspc+) since no regular output will have 2 spc or more between connected words I mean words that belong in a group. I would use the construct /\s{2,}/ for

Re: Can't use string (1) as a HASH ref while strict refs in use at ./policy.sanitizer line 255.

2009-10-09 Thread Jim Gibson
On 10/9/09 Fri Oct 9, 2009 2:12 PM, Noah noah-l...@enabled.com scribbled: Hi there, I am trying to figure out why the following lines are giving me an error: --- snip --- $found{filter}{$filter}{family}{$family} = 1; print keys %{

Re: Larry's filename fixer

2009-10-14 Thread Jim Gibson
, then standard input will be read to supply a list of file names. Therefore, you can pipe the results of some command that generates file names, such as ls or find, to rename: ls *.dat | rename s/dat$/data/ -- Jim Gibson -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org

Re: weird post problem

2009-10-18 Thread Jim Gibson
At 5:45 AM +0200 10/18/09, adlai burman wrote: Hello and help, please. This is actually a CGI/Perl issue I am having but Perl seems to be the closest forum here. I am having a very simple (hence very frustrating) problem with a CGI/ Perl script. For some reason if I pass things from a checkbox

Re: Don't understand the errors

2009-10-18 Thread Jim Gibson
lines except for the last twelve, and write the lines to the new file. No modules required, and no file copying either. Since bash history files are that big, you could also read the file into an array, get the number of elements in the array, and write out the array accordingly. -- Jim

Re: perl like tail -f

2009-10-19 Thread Jim Gibson
On 10/19/09 Mon Oct 19, 2009 11:38 AM, Harry Putnam rea...@newsguy.com scribbled: I'm not sure what it is about the tail -f command that allows it to keep reading over restarts of system logger (on Opensolaris)... but how can I emulate whatever it is.. in perl? There is an FAQ:

Re: How to set a proxy server.

2009-10-20 Thread Jim Gibson
At 9:35 AM +0800 10/21/09, Majian wrote: Dear list: I have a question on learning Perl . Please give me a help . The problem is : How can I split a string into chunks of size n bytes?Like this : #!/usr/bin/perl my $string = 1234567890abcdefghijABCDEFGHIJK; my $n = 2;# $n is group

Re: lettinf an external basgh command timeout inside eval

2009-10-21 Thread Jim Gibson
At 3:59 PM -0700 10/20/09, cerr wrote: Hi, I wanna execute an external bash command but timeout if it's taking longer than XX seconds. I've tried it like this: eval { local $SIG{ALRM} = sub {die alarm\n}; alarm $timeout; $test = `$sshpassPATH . -p .$clientpw. ssh

Re: newbie question : about the perl sprintf

2009-10-21 Thread Jim Gibson
At 8:52 PM +0800 10/21/09, Majian wrote: Hi, all ; I want to print this sentence The number in scientific notation is 1.255000e+02. So I write a perl script like this : #!/usr/bin/perl sprintf The number in scientific notation is %e,

Re: File Help

2009-10-21 Thread Jim Gibson
to the files in the temporary folder. Make sure your browser will download that type of file. Try just typing in a URL in your browser that points to your temporary folder. If you are lucky, you will get an index of the files in that directory and be able to download any of them. -- Jim Gibson

Re: Printing the contents of an array

2009-10-23 Thread Jim Gibson
At 11:21 AM +0530 10/23/09, pradeepkumar.sura...@wipro.com wrote: Hi, The contents in my array looks like this... change_id=B77_ip_sync_idl state=released customer_rel=B77 change_name=ip_vke_sync short_description=This feature introduces the Sync idl. planned_baseline=B77_135.00

Re: printf and zero padding

2009-10-24 Thread Jim Gibson
At 4:02 PM -0500 10/24/09, Harry Putnam wrote: With this little script, how would I manage to get the shorter timestamps zero padded using printf? I now how to get padded numbers but not when I'm pushing off the right margin too. cat script.pl #!/usr/local/bin/perl use strict; use

Re: More on perl like tail

2009-10-24 Thread Jim Gibson
At 3:57 PM -0500 10/24/09, Harry Putnam wrote: Sorry about being tricky with what was an older thread. But I suspect that thread died... and no one noticed there was an unaswered question still there. Or no one knew the answer. Shawn C originally suggested I use File::Tail. There was a

Re: printf with currency symbols

2009-10-26 Thread Jim Gibson
On 10/26/09 Mon Oct 26, 2009 8:57 AM, Bryan R Harris bryan_r_har...@raytheon.com scribbled: Is there a good way to do printf's with currency symbols? I've tried this: printf Total: \$%10.2f\n, $total; But it puts the dollar sign way out front (ugly). I want it to look like:

Re: AW: compact my wordlist generator

2009-10-26 Thread Jim Gibson
On 10/26/09 Mon Oct 26, 2009 8:45 AM, Michael Alipio daem0n...@yahoo.com scribbled: Thanks for the advice. Forgive me if I sounded like someone who's frustrated, couldn't do his homework asking somebody else for help. When I was learning C programming, I read that learning those difficult

Re: Not following the match problem in this simplified example

2009-10-28 Thread Jim Gibson
On 10/28/09 Wed Oct 28, 2009 9:37 AM, Harry Putnam rea...@newsguy.com scribbled: What follows is snippet out of a more complex script and reworked to simplify but still not seeing what causes the problem. I'm not sure if I've just stared at it too long or what. When I run it I get this

Re: Not following the match problem in this simplified example

2009-10-28 Thread Jim Gibson
On 10/28/09 Wed Oct 28, 2009 10:43 AM, Harry Putnam rea...@newsguy.com scribbled: Jim Gibson jimsgib...@gmail.com writes: We need to know what you are trying to accomplish here. Its over 300 lines of code at this writing. Well we definitely do not want to see all 300 lines. However

Re: About internal working of File::Find

2009-10-28 Thread Jim Gibson
On 10/28/09 Wed Oct 28, 2009 12:55 PM, Harry Putnam rea...@newsguy.com scribbled: Looking over the perldoc File::Find output (perl 5.8.4) I see at finddepth it says: [...] in part finddepth() works just like find() except that is invokes the wanted function for a

Re: A question on filehandles

2009-10-28 Thread Jim Gibson
On 10/28/09 Wed Oct 28, 2009 3:00 PM, ANJAN PURKAYASTHA anjan.purkayas...@gmail.com scribbled: Trying to learn how to run Gnuplot via a Perl script I came across the following helpful example: #!/usr/bin/perl # Generate postscript and png plot with GNUplot from Perl # Author: Ioan Vancea

Re: About internal working of File::Find

2009-10-28 Thread Jim Gibson
On 10/28/09 Wed Oct 28, 2009 3:18 PM, Harry Putnam rea...@newsguy.com scribbled: Jim Gibson jimsgib...@gmail.com writes: If you want to process files in a certain order, then save the files in an array. When find is finished, sort that array and process the files in any order. For example

  1   2   3   4   5   6   7   8   >