Re: Writing a column after column

2009-03-17 Thread Jim Gibson
On 3/16/09 Mon Mar 16, 2009 10:20 AM, "vd" 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 write the fil

Re: Matching Over Multiple Lines

2009-03-17 Thread Jim Gibson
On 3/17/09 Tue Mar 17, 2009 8:45 AM, "Jeff Westman" 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 can be

Re: enumerating subarrays

2009-04-06 Thread Jim Gibson
On 4/4/09 Sat Apr 4, 2009 8:34 PM, "Andrew Fithian" 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: > for ( $i =

Re: Random number generator

2009-04-09 Thread Jim Gibson
On 4/9/09 Thu Apr 9, 2009 2:34 PM, "ANJAN PURKAYASTHA" 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 B(p(1)). > Any thoughts on

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" 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 " > > Code Snippet: > > use netElemen

Re: Compiler options perl

2009-04-17 Thread Jim Gibson
On 4/16/09 Thu Apr 16, 2009 1:39 PM, "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[$_ = 1

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" 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 > have just changed

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" scribbled: > 2009/4/16 Jim Gibson : > 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 c

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" 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 (($Year_out > 25) &

Re: String manipulation question

2009-04-21 Thread Jim Gibson
On 4/21/09 Tue Apr 21, 2009 8:58 AM, "Grant" 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 are in a string.

Re: String manipulation question

2009-04-21 Thread Jim Gibson
On 4/21/09 Tue Apr 21, 2009 10:46 AM, "Grant" 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 above line t

Re: String manipulation question

2009-04-21 Thread Jim Gibson
On 4/21/09 Tue Apr 21, 2009 11:16 AM, "Grant" 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 exist? Anc

Re: String manipulation question

2009-04-21 Thread Jim Gibson
On 4/21/09 Tue Apr 21, 2009 11:42 AM, "Grant" 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 =~ /(.{35})(.{26})/);

Re: String manipulation question

2009-04-21 Thread Jim Gibson
On 4/21/09 Tue Apr 21, 2009 11:54 AM, "Grant" 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 what you are

Re: libwww-perl library

2009-04-21 Thread Jim Gibson
On 4/21/09 Tue Apr 21, 2009 3:27 PM, "hOURS" 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 generic erro

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" scribbled: > I have a c code that looks like this: > > #include > > main (){ > char girl[] = "anna"; > char boy[] = "jude"; > stringcopy(boy, girl); /* copy boy to girl */ > printf("%s", girl); > > } > > void stringcopy(char *b, char *g)

Re: Help with LWP

2009-05-13 Thread Jim Gibson
On 5/13/09 Wed May 13, 2009 2:17 PM, "ANJAN PURKAYASTHA" 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 chooses a database from a

Re: Push to AoA

2009-05-13 Thread Jim Gibson
On 5/13/09 Wed May 13, 2009 4:48 PM, "Steve Bertrand" 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 me in the >

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" 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 open the ex

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" 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 spreadsheet. If you are

Re: skipping a repeated header

2009-05-27 Thread Jim Gibson
On 5/27/09 Wed May 27, 2009 9:15 AM, "Kirk Wythers" 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 number of variab

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" 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 > > You

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" 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" scribbled: > > Hi: I have web page built using perl cgi. Generated page has the following > element > > admin > > Within the perl script is there a way to access the value of the element > userName and assign it to a variable? > Something a

Re: Efficiently going through results

2009-06-09 Thread Jim Gibson
On 6/9/09 Tue Jun 9, 2009 1:24 AM, "Dave Tang" 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 parent will

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" 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 is h

Re: Please, I need help!!!

2009-06-12 Thread Jim Gibson
On 6/11/09 Thu Jun 11, 2009 11:00 AM, "Phillip" 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 language cal

Re: Alpaca Chap7 Question

2009-06-15 Thread Jim Gibson
On 6/15/09 Mon Jun 15, 2009 12:26 PM, "Thomas H. George" 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, > $starting_directories) c

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" 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 "Compi

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" scribbled: > "Chas. Owens" writes: > >> On Fri, Jun 19, 2009 at 09:35, Harry Putnam wrote: >>> How to manage a recursive chown using perl function chown? >>> >>> Do I have to employ something like File::Find to recursively chown a >>> direc

Re: friend class in perl

2009-06-24 Thread Jim Gibson
On 6/24/09 Wed Jun 24, 2009 10:45 AM, "Roman Makurin" 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 friends, if

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" scribbled: > > Hi, > > If I have a loop that for each run creates > > while (){ >   my $value =~ /^\d/; >   $myhash{$mykey}->{'subkey'} = $value; > } > > > Normally, if I only want to sort $myhash through it's values, I would do > s

Re: Hello there

2009-07-06 Thread Jim Gibson
On 7/6/09 Mon Jul 6, 2009 3:19 PM, "Emanuele Osimo" 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 this at a c

Re: Need some module help

2009-07-09 Thread Jim Gibson
should do to "load" the module, and can't make it work properly. The lines 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:

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" 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. > > I'm using

Re: Index a list

2009-07-10 Thread Jim Gibson
On 7/10/09 Fri Jul 10, 2009 12:37 PM, "Steve" 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 text file that has a whopp

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" 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; >> >> $walldata{WALL_SU

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

2009-07-16 Thread Jim Gibson
tch, record 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
appropriate 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 unsub

Re: 'Join' query

2009-08-07 Thread Jim Gibson
On 8/7/09 Fri Aug 7, 2009 8:03 AM, "jet speed" 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 above,

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" 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 hash/has

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 -- To

Re: hash of hashes question

2009-09-04 Thread Jim Gibson
{'group_name'}{$1} = 1; $policy{'policy_statement'}{$key}{'policy_type'}{$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
74. You must be consistent and decide how many levels your hash-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

Re: perldoc modules

2009-09-04 Thread Jim Gibson
my @files; find sub { push @files, $File::Find::name if -f _ && /\.pm$/ }, @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
p ) = split; push( @{$hosts{$host}}, $ip ); } 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" 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 $!; Converting th

Re: hash question

2009-09-25 Thread Jim Gibson
print "$key => $value \n"; > } > } #end while > close(INFILE); There are many improvements you can make to this program, including better indentation and eliminating all but one call to split. However, since your immediate

Re: hash question

2009-09-25 Thread Jim Gibson
while > close(INFILE); This is how to print a two-level hash-of-hashes: while ( my ($key,$value)= each %policy_Hash ) { while ( my($key2,$value2) = each %{$value} ) { print "$key => $key2 => $value2 \n"; } } Here is a way that sorts the keys: for my $key1 ( sort keys %policy_Hash ) { 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 -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

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" 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 I can

Re: Fw: yet another question

2009-10-06 Thread Jim Gibson
and can be accessed in your program like any 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

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" 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. $ref is a ref

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" scribbled: > Shlomi Fish 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 >>> whatever spcs looks good

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

2009-10-08 Thread Jim Gibson
e contents are lost. Because the hash reference now points to the newer data. How do I overcome this? More importantly do we have 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

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" scribbled: > I'm thinking of splitting on something like ' +' (+) 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 "two or more spaces"

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" 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 %{ $found{filter}{$filter}{family} }; >

Re: Larry's filename fixer

2009-10-14 Thread Jim Gibson
files names to be processed by the for loop. If there are no arguments left in @ARGV after the RE has been removed, 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:

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 t

Re: Don't understand the errors

2009-10-18 Thread Jim Gibson
into an array, get the number of elements in the array, and write out the array accordingly. -- 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: perl like tail -f

2009-10-19 Thread Jim Gibson
On 10/19/09 Mon Oct 19, 2009 11:38 AM, "Harry Putnam" 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: perldoc -q tai

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 siz

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 ro

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", 1.

Re: File Help

2009-10-21 Thread Jim Gibson
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-22 Thread Jim Gibson
At 11:21 AM +0530 10/23/09, 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" change_id="B77_ip_sync_idl" stat

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 warnin

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 s

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" 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: > > Total:$

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" 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 > algorithms s

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" 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 error: >

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" scribbled: > Jim Gibson 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, so

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" 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 directory 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" 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 > # Usage: Give "da

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" scribbled: > Jim Gibson 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. F

Re: Emulating Sort through Perl

2009-10-30 Thread Jim Gibson
On 10/30/09 Fri Oct 30, 2009 12:37 PM, "Parag Kalra" scribbled: > Hello Folks, > > This is my first post here. > > I am trying to emulate Linux 'sort' command through Perl. I got following > code through Internet to sort the text file: > > # cat sort.pl > my $column_number = 2; # Sorting by

Re: Emulating Sort through Perl

2009-10-30 Thread Jim Gibson
On 10/30/09 Fri Oct 30, 2009 1:50 PM, "Parag Kalra" scribbled: > Folks, > > Thanks a bunch for your replies... > > Honestly speaking I couldn't understand the code completely as its not mine > and being a beginer my head is spinning between these references and > complexly & strangely used so

Re: Optimizing File handling operations

2009-11-05 Thread Jim Gibson
1 && defined $line2 ); # compare lines } One potential problem is if the files do not have the same number of lines. You can check for $line1 or $line2 containing anything after the loop has terminated. -- Jim Gibson j...@gibson.org -- To unsubscribe, e-mail: beginners-unsu

Re: splitting and replacing characters

2009-11-09 Thread Jim Gibson
On 11/9/09 Mon Nov 9, 2009 5:03 AM, "rithu" scribbled: > Hi, > > Please help me to split a string as follows.. > > my $line = "abcdefghijkl" > > the expected output should be like: > > ab > ef > ij > > > The logic is like alternate 2 characters should be removed split would not be th

Re: splice without the remove

2009-11-09 Thread Jim Gibson
On 11/9/09 Mon Nov 9, 2009 10:46 AM, "Dermot" scribbled: > Hi, > > I just spent 20mins scratching my head because I didn't read the docs > very closely concerning splice. I had assumed it left the array > intact, its doesn't. I was hoping for a function more akin to substr > where the return w

Re: verilog-perl-3.221 usage troubles

2009-11-10 Thread Jim Gibson
On 11/9/09 Mon Nov 9, 2009 7:48 PM, "cute" scribbled: > I try the latest version 3.221 and found some difference between > manual. > The Verilog::Netlist::Net object seem not recognize its member > function "->data_type" > > is there any advise? Yes. Post a short program that illustrates the

Re: On map

2009-11-10 Thread Jim Gibson
On 11/10/09 Tue Nov 10, 2009 1:22 PM, "Bryan R Harris" scribbled: > > > I have a curiosity maybe someone here can help with. > > This code: > >@a=(1,2); >map { $_ = 3 } @a; >print join(",", @a), "\n"; > > ... prints "3,3". That map is changing the @a array as it goes through i

Re: redirecting to a file in perl

2009-11-14 Thread Jim Gibson
-eng-fra $english); The standard output of the dict program will be captured and assigned to the $translation variable. -- 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: join lines

2009-11-16 Thread Jim Gibson
On 11/16/09 Mon Nov 16, 2009 1:23 PM, "Jackie Jackie" scribbled: > What this means > > if( ! length() ) It means evaluate the expression '! length()' in a scalar context, interpret the value as a logical expression, and branch accordingly. ! is the not operator. length() is the length ope

Re: How to redirect a message simultaneously to a file-handler and standard O/P

2009-11-17 Thread Jim Gibson
On 11/17/09 Tue Nov 17, 2009 9:24 AM, "Parag Kalra" scribbled: > Hi All, > > I know this may be a very basic question but I don't know how to accomplish > it. :( > > I want to know how to redirect a message simultaneously to a file-handler > and standard O/P. > > So basically I want a short

Re: ìö‘` : the question of one program

2009-11-19 Thread Jim Gibson
At 11:48 AM +0800 11/20/09, gaochong wrote: Thanks . But the code is from cpan.org ,and is crappy ,where I will go ? You figure out what is wrong with it and improve it. You have already been given some hints from people on this list. Here are some more: 1. Don't call subroutines with the '&

Re: Documentation practices

2009-11-24 Thread Jim Gibson
On 11/24/09 Tue Nov 24, 2009 11:09 AM, "Steve Bertrand" scribbled: > I've noticed that the POD for several modules do not include method > usage for the functions/methods that are designed as 'internal-only'. > > I've reached a stage where not having POD for ALL of my methods is > becoming ove

Re: a match question

2009-11-24 Thread Jim Gibson
On 11/24/09 Tue Nov 24, 2009 4:42 PM, "Orchid Fairy (兰花仙子)" scribbled: > On Wed, Nov 25, 2009 at 8:38 AM, Shawn H Corey wrote: > >> >> It seems to be picking up an extra empty string after a non-zero length >> match. >> > > Thanks John and Shawn. > Yup what let me be confused is that, wh

Re: How to toggle a variable with each iteration?

2009-11-25 Thread Jim Gibson
On 11/25/09 Wed Nov 25, 2009 2:14 AM, "kusuma ramaswamy" scribbled: > Hello, I am new to perl. I would like to know how to toggle a variable with > each iteration in a loop ?? while( ... ) { $variable = ! $variable; } Does that do what you want? -- To unsubscribe, e-mail: beginners-u

Re: speed test

2009-12-01 Thread Jim Gibson
At 9:58 AM +0800 12/2/09, =?GB2312?B?T3JjaGlkIEZhaXJ5ICjAvLuoz8nX0yk=?= wrote: Hello, Maybe it's not so suitable to ask this here. But is there a good way (code sample?) to implement a speed test between Perl and C? For a project which handles lots of data we want to know how slower perl is than

Re: How much time my Perl script is taking

2009-12-05 Thread Jim Gibson
, formatting and get the time of execution. But is there a simpler way than this? Check out the Benchmark.pm module, which should be included as part of your Perl distribution. The documentation for the module has many suitable examples for timing part or all of your program. -- Jim Gibson j

Re: passing Hash to subroutine help please

2009-12-08 Thread Jim Gibson
On 12/8/09 Tue Dec 8, 2009 5:41 PM, "Noah" scribbled: > > Hi there List people, > > I am hoping to send a hash and a scalar to a subroutine but the variable > is not completely being sent. Below is the error message below is > showing something is not getting passed that well to the subrouti

Re: passing command-line arg containing '@'

2009-12-09 Thread Jim Gibson
On 12/9/09 Wed Dec 9, 2009 6:01 PM, "Tony Esposito" scribbled: > I need to pass an command-line arg that is a string which contains the '@'. > Is there any way to do this and also 'tell' Perl not to interpret this as > other than a '@' character? The '@' character is only special in Perl sourc

Re: pid file issues...? HUH???

2009-12-10 Thread Jim Gibson
At 11:43 AM -0800 12/9/09, cerr wrote: Hi There, I use below code to make sure i have only one instance of my script running at a time. But weirdly enough i sometimes seem to have running two instances. This script is getting called on a regular basis by a cron job and may take a long time (30+m

Re: $Sql{mydata} fails?

2009-12-12 Thread Jim Gibson
On 12/12/09 Sat Dec 12, 2009 12:26 PM, "Grant" scribbled: > I have a perl script which creates a PDF file from data in a table. > This morning I was making some modifications to it, and it stopped > working with a "Couldn't get mydata handle" error. I restored the > original file, but it still

Re: Modifying files with PERL

2009-12-15 Thread Jim Gibson
On 12/15/09 Tue Dec 15, 2009 7:42 AM, "A4r0N" scribbled: > I need to add "new lines" of text with special characters, to specific > lines in the file. There are 3 modifications needed. Been testing 2 > here without success. > > #!/usr/bin/perl > > use FileHandle; > $file=FileHandle->new; > $F

Re: Perlcritic complains about assignment within conditional

2009-12-15 Thread Jim Gibson
On 12/15/09 Tue Dec 15, 2009 4:49 PM, "Shawn H Corey" scribbled: > Steve Bertrand wrote: >> my $month = $ARGV[0] if $ARGV[0]; > > $ cat myscript.pl > #!/usr/bin/perl > > use strict; > use warnings; > > my $month = $ARGV[0] if $ARGV[0]; > print "$month\n"; > $ ./myscript.pl > Use of uninitial

Re: being smart about script structure

2009-12-16 Thread Jim Gibson
On 12/16/09 Wed Dec 16, 2009 6:57 AM, "Bryan R Harris" scribbled: > > > [stuff cut out] > >>> For example, if I'm populating a complex variable @d with >>> lots of pointers, >>> hashes, arrays, etc. within, if I populate that within a >>> subroutine, how do >>> I get it back out conveniently

Re: Regexp to remove spaces

2009-12-21 Thread Jim Gibson
At 6:11 PM +0800 12/21/09, Albert Q wrote: 2009/12/20 Dr.Ruud > > For a multi-line buffer you can do it like this: perl -wle ' my $x = <<"EOT"; 123456 \t abc def \t\t\t\t\t\t\t\t *** *** *** \t EOT s/^\s+//mg, s/\s+$//mg, s/[^\S\n]+/ /g for $x; I kno

  1   2   3   4   5   6   7   8   >