Re: add newline

2010-08-04 Thread Philip Potter
On 4 August 2010 01:59, Rob Dixon wrote: > > Speed of execution is the last goal of all. > > First of all make your program functional and intelligible. > > Only after that, if you have problems with resources (including time, disk > space, or processor) tune it to be more efficient. This, a thou

Re: has and non unique keys

2010-08-02 Thread Philip Potter
On 2 August 2010 12:11, Sharan Basappa wrote: > I am not trying to be critical of perl or anything (if that is what you felt). I didn't think you were; it didn't come across as criticism. > I am only trying to see if a certain feature exists or not. > The current problem I am working on has dupl

Re: Use of uninitialized value in print at...

2010-06-06 Thread Philip Potter
On 6 June 2010 14:37, Shawn H Corey wrote: > On 10-06-06 09:06 AM, Chas. Owens wrote: >> >> But that is not the problem; autovivification will create the references: >> >> perl -MData::Dumper -le '$c->[0]{a}; print Dumper $c' >> > > But that is the problem.  Autovivification should not happen for

Re: Need simple perl script

2010-06-06 Thread Philip Potter
On 5 June 2010 17:47, Mephistopheles wrote: > 1. Run sdiff on file1 and file2--supress identical lines > 2. OUtput column1 to outputfile1 and column2 to outputfile2 What have you tried so far? We can't correct your code if you don't give us any code to correct. -- To unsubscribe, e-mail: beginn

beginners@perl.org

2010-05-24 Thread Philip Potter
On 24 May 2010 11:49, Weizhong Dai wrote: > Hi guys, I met a problem. > When I tried this script below: > > // > sub print_instruction { >  my ($disk, $start, $end) = @_; >  print "Move disk #$disk from $start to $end.\n"; > } > >

Re: how to arrange a default action in a dispatch table

2010-05-08 Thread Philip Potter
On 8 May 2010 15:43, Harry Putnam wrote: > Philip Potter writes: > >> You are quite correct - there is no practical difference in this situation. >> >> [nitpick: actually, if $/ has been set to something other than "\n", >> $chosen may have a trailin

Re: how to arrange a default action in a dispatch table

2010-05-08 Thread Philip Potter
On 8 May 2010 14:47, Harry Putnam wrote: > Philip Potter writes: >> On 8 May 2010 13:35, Harry Putnam wrote: >>> I'm curious about one thing I see there: >>> >>>  `/\A\d+\z/ ' as opposed to `/^\d+$/' >>> >>> in this snippet

Re: how to arrange a default action in a dispatch table

2010-05-08 Thread Philip Potter
On 8 May 2010 13:35, Harry Putnam wrote: > I'm curious about one thing I see there: > >  `/\A\d+\z/ ' as opposed to `/^\d+$/' > > in this snippet: > >        if ( $chosen =~ /\A\d+\z/ && $chosen >= 1 && $chosen <= @h ) { >            print "Taking some action on $h[$chosen - 1]\n"; >            la

Re: how to arrange a default action in a dispatch table

2010-05-08 Thread Philip Potter
On 8 May 2010 13:09, Harry Putnam wrote: > "Uri Guttman" writes: > >> yes, i disable syntax coloring since it makes it HARDER for me to >> see > > [...] > > I'm terrible about leaving out one of "" '' () {} [] etc.. I always enter them in pairs. eg I first type if (condition) {} then put the c

Re: about dispatch tables

2010-05-05 Thread Philip Potter
On 5 May 2010 17:29, Harry Putnam wrote: > Anyway, I understood he was saying NOT global. > > What I asked is why that would matter.  That is, the values or > elements in @_ arrive inside the `sub dispt {...}', so should be > available to anything inside `sub dispt {...}'  right? > > And `%hash =

Re: about dispatch tables

2010-05-05 Thread Philip Potter
On 5 May 2010 15:26, Thomas Bätzler wrote: > Harry Putnam asked: > [...] >> which is also inside sub dispt {the sub function}.  Where does global >> come in? > > Hint: $code->(@_); Or indeed &$code; if you want to be cryptic :) Phil -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For

Re: about dispatch tables

2010-05-05 Thread Philip Potter
On 5 May 2010 14:36, Harry Putnam wrote: > "Uri Guttman" writes: > >>   HP> The output from the script below: >>   HP> Shows 6 elements arrive in dispt($g, @ar) as @_.  But when sub N(@_) >>   HP> is called, no variables arrive there. @_ is empty. When it seems like >>   HP> 5 elements should hav

Re: Still pondering working with hashs

2010-05-04 Thread Philip Potter
On 4 May 2010 15:19, Harry Putnam wrote: > Philip Potter writes: >> haven't explained *why* you are doing this comparison in this thread. >> [You might have done elsewhere, but I don't read every thread.] > Uri actually did (most of) it for me at one point in a

Re: Still pondering working with hashs

2010-05-04 Thread Philip Potter
On 4 May 2010 13:45, Bob McConnell wrote: > From: Uri Guttman > >>> "HP" == Harry Putnam writes: >> >>   HP> "Uri Guttman" writes: >>   >> nope. been doing this for 35 years and it is solid advice. you > can't do >>   >> a proper program unless you have a proper goal which is what the >>   >

Re: Still pondering working with hashs

2010-05-04 Thread Philip Potter
On 3 May 2010 22:06, Harry Putnam wrote: > Philip Potter writes: > > [...] > > Both you and Uri are right to a degree.  I have to respect Uris' > experience, but in fact I have presented goals at every step in this > thread.  Uri just doesn't want to recognize them

Re: Still pondering working with hashs

2010-05-03 Thread Philip Potter
On 3 May 2010 20:56, Uri Guttman wrote: >> "HP" == Harry Putnam writes: >  HP> "Uri Guttman" writes: >  >> this is what has been bothering me here. you haven't yet spit out a >  >> proper problem specification. as i kept saying comparing dir trees is >  >> tricky and you kept showing incompl

Re: testing if divisible by?

2010-05-03 Thread Philip Potter
2010/5/3 Jay Savage : > On Sat, May 1, 2010 at 7:45 AM, Philip Potter > wrote: >> On 1 May 2010 12:15, Paul wrote: >>> Hello all.  How can I test to see if a number is divisible by say, 40? >> >> Use the modulo operator %. Given integers $x and $y, the expr

Re: testing if divisible by?

2010-05-01 Thread Philip Potter
On 1 May 2010 12:15, Paul wrote: > Hello all.  How can I test to see if a number is divisible by say, 40? > Thanks. Use the modulo operator %. Given integers $x and $y, the expression $x % $y gives the remainder when $x is divided by $y. As a result, if (and only if) $x is exactly divisible by $y

Re: Redirecting the Output and Error of Perl script

2010-05-01 Thread Philip Potter
On 30 April 2010 18:45, Parag Kalra wrote: > Hey All, > > I am trying to execute a Perl via shell script. I want to redirect output of > Perl script to one file and error occured (if any) to other file. > > This is the snippet from my shell script: > > perl output_error.pl 1>> Report.log 2>>Error.

Re: ExtUtils::MakeMaker, execute Perl code during "make test"

2010-04-16 Thread Philip Potter
On 16 April 2010 14:38, Steve Bertrand wrote: > On 2010.04.16 09:15, Philip Potter wrote: >> What are you *actually* >> trying to do? What are you testing and why does this test require you >> to print output to the user under "make test"? > > This parti

Re: ExtUtils::MakeMaker, execute Perl code during "make test"

2010-04-16 Thread Philip Potter
On 16 April 2010 13:20, Steve Bertrand wrote: > I use prove often, usually when I want to quickly and non-verbosely (-Q) > work with a single test file that I'm currently adding new tests to, or > to ensure existing tests still pass if making changes to a function. > > What I want to be able to do

Re: how to create a hash on the fly

2010-04-16 Thread Philip Potter
On 16 April 2010 03:17, Steve Bertrand wrote: > On 2010.04.15 03:37, raphael() wrote: >> But as a beginning Perl programmer I find references extremely complicated. >> Although I have to learn them sometime. > > Although I Am Not A Programmer, if you do actually desire spending time > on writing P

Re: ExtUtils::MakeMaker, execute Perl code during "make test"

2010-04-16 Thread Philip Potter
On 16 April 2010 02:05, Steve Bertrand wrote: > On 2010.04.15 18:50, Steve Bertrand wrote: >> Hi all, >> >> In one of my projects, I've written a test file t/22-upgrade.t. > > [..snip..] > >> However, when I run "make test", the Perl code for print does not execute. > > Replying my own post, this

Re: free memory

2010-04-13 Thread Philip Potter
On 13 April 2010 16:25, Patrick Dupre wrote: > Hello, > > I have the a hash of hash of ... of array > (see below hwo I can list it) whose i wish to free the memory at one > point. Right now the desallocation is not clean, ie that evert time that > I reallocate the hash, the programme requires more

Re: the range of an array

2010-04-13 Thread Philip Potter
2010/4/13 WashingtonGeorge : > Sorry,my expressions had something wrong a moment ago.i wanted to say in > case i must to use a number bigger than 2**31-1,what should i do? Please quote the message you are replying to. If you have a dataset with more than 2**31-1 elements, you probably shouldn't b

Re: the range of an array

2010-04-13 Thread Philip Potter
2010/4/13 Xubo : > > thank you for responding to me,but supposing i want to use an array which > should includes plenty of elements,what should i do? Do you really need an array with > 2,000,000,000 elements? If you use such large arrays, you're probably not using Perl in the best way that you can

Re: the range of an array

2010-04-13 Thread Philip Potter
2010/4/13 Xubo : > > Hi,all: > the "learning perl" say an array can have any number of elements,but when i > run such codes: > #!perl > @abc=1..9; > print @abc; > it shows "range iterator outside integer range at 123 line 2." > Regards, > George (You should ask you

Re: Subroutine doesn't write to file

2010-04-12 Thread Philip Potter
On 12 April 2010 16:39, Uri Guttman wrote: >>>>>> "PP" == Philip Potter writes: > >  PP> On 12 April 2010 11:34, Shlomi Fish wrote: >  >> Hi Uri and Philip (and Abimael), >  >> On Monday 12 Apr 2010 10:32:36 Uri Guttman wrote: >  >

Re: Subroutine doesn't write to file

2010-04-12 Thread Philip Potter
On 12 April 2010 11:34, Shlomi Fish wrote: > Hi Uri and Philip (and Abimael), > On Monday 12 Apr 2010 10:32:36 Uri Guttman wrote: >>   PP> Where did I say PBP was always right? I just didn't want to let your >>   PP> style argument be the only one in this thread, since there are >> clearly PP> peo

Re: Subroutine doesn't write to file

2010-04-12 Thread Philip Potter
On 12 April 2010 07:55, Uri Guttman wrote: >>>>>> "PP" == Philip Potter writes: > >  PP> On 12 April 2010 04:31, Uri Guttman wrote: >  >>>>>>> "AM" == Abimael Martinez writes: >  >> >  >>  AM>   prin

Re: Subroutine doesn't write to file

2010-04-11 Thread Philip Potter
On 12 April 2010 04:31, Uri Guttman wrote: >> "AM" == Abimael Martinez writes: > >  AM>   print {$tmp} "$div_start"; > > no need for the {} around a single scalar handle. But it *does* comply with Perl Best Practices #136. * It makes the filehandle obviously different from the other argumen

Re: Looping in Test::Harness

2010-04-09 Thread Philip Potter
On 9 April 2010 18:04, Bob McConnell wrote: > After a great deal of reading and speculation, it looks like YAML is the > way to go. I will have to move the loop inside each test script, and > iterate thorough the records read. The biggest problem is that the plan > is no longer fixed, so I do lose

Re: Decimal representation of binary file (unpack)

2010-04-08 Thread Philip Potter
On 8 April 2010 06:30, Raymond Wan wrote: > > Hi all, > > I would like to read in a binary file and extract the 4-byte ints from it. >  Under Linux, something like "od -t uI".  I got it working as follows: > > > my $buffer = ; > my @buffer = split //, $buffer; > for (my $i = 0; $i < length ($buffe

Re: about beginner perl site and developing skill

2010-04-06 Thread Philip Potter
On 6 April 2010 17:21, Rob Coops wrote: > On Tue, Apr 6, 2010 at 5:56 PM, Harry Putnam wrote: >> This doesn't actually have to be a paying job... I'm retired and do >> have an income.  But it would need to be a situation where I was >> expected to produce something on a continuing basis.  (Of cou

Re: Looping in Test::Harness

2010-04-06 Thread Philip Potter
On 6 April 2010 16:52, Bob McConnell wrote: > I have a test harness set up with a series of Selenium test scripts. > Each script tests a specific scenario on my web site. But I have some > scenarios that I want to test multiple times with different data entered > each time. Currently I am using en

Re: AW: about the various styles of `open'

2010-04-06 Thread Philip Potter
On 6 April 2010 16:48, Harry Putnam wrote: > Thanks for the effort, but I'm still a bit confused. Just need to > think it over some more maybe.  Is it fair to say that the `magic' > open is far and away the most common working case? And that the 3 arg > open is for unusual circumstances? No, gene

Re: free memory

2010-04-01 Thread Philip Potter
On 1 April 2010 16:13, Patrick Dupre wrote: > Hello, > > I cannot subscribe to perl-xs so, I am still posting here. I don't understand the problem. Firstly, I just emailed perl-xs-subscr...@perl.org and got a response from the mailing list software. Secondly, how come you were posting on perl-x

Re: good books for novice perl beginners

2010-03-25 Thread Philip Potter
On 24 March 2010 18:16, NAKO wrote: > Hello All, > > Can you please recommend some good books for novice beginners? Thanks http://learn.perl.org/books.html is a good start. The rest of the http://learn.perl.org/ website is worth a look too, which is why it's linked in the footers of this mailing

Re: Getting garbage fast

2010-03-24 Thread Philip Potter
On 24 March 2010 00:56, Eric Veith1 wrote: > Sam wrote on 03/23/2010 11:18:11 PM: >> Could you use a file of random data? You can create one of those really >> easy: dd if=/dev/urandom of=ranfile bs= > > Theoretically, yes, of course I could just try to create an arbitrary > sized file from /

Re: quick question

2010-03-19 Thread Philip Potter
On 19 March 2010 11:45, wrote: > On 19/03/10 13:19 +0200, Chris Knipe wrote: >> >> my ($foo, $bar) = 1 >> >> I am getting more and more occurances where when I use the later as above, >> $bar would not have a defined value...  I'm not quite sure I understand >> why. > > Does; > my ($foo,$bar) = 1

Re: Any Good SCM tool to manage Perl Code locally

2010-03-16 Thread Philip Potter
On 16 March 2010 06:44, Parag Kalra wrote: > Yes  I have started using Git and I am very happy with it so far. > > Just couple of questions - How can I make my code readonly using Git such > that it can be edited only when it is checked out. I don't understand the question. If you have source fil

Re: Angle bracket operator with list

2010-03-12 Thread Philip Potter
On 12 March 2010 09:17, Uri Guttman wrote: >>>>>> "PP" == Philip Potter writes: > >  PP> I found this code example on Stack Overflow to prettyprint a hash: >  PP> (link: >  PP> > http://stackoverflow.com/questions/2431032/how-to-print-a-

Angle bracket operator with list

2010-03-12 Thread Philip Potter
I found this code example on Stack Overflow to prettyprint a hash: (link: http://stackoverflow.com/questions/2431032/how-to-print-a-key-value-using-the-perl-hases/2431139#2431139 ) use strict; use warnings; my %hash = (2009 => 9, 2010 => 10); print join (" => ", each %hash), "\n" while ; My q

Re: Mass value assigment

2010-03-09 Thread Philip Potter
On 9 March 2010 11:49, Shlomi Fish wrote: > Otherwise you can assign several variables the same initial value using the x > operator: > > my ($x, $y, $z) = (("test") x 3); > > Note that both pairs of parentheses on the right are required. Are the outer pair really required? I would have thought t

Re: Perl Hiding Username/Password

2010-02-11 Thread Philip Potter
On 10 February 2010 23:04, newbie01 perl wrote: > > Hi all, > > Can anyone please advise how I can change the following codes to work where > the and are not exposed? > Script is ran via crontab and can also be run manually, at the moment am > reading these values from some sort of delimited fil

Re: Clone an object

2009-12-28 Thread Philip Potter
2009/12/28 Philip Potter : > If you want to clone an object from a library > provided by someone else, you have to read its documentation and find > a clone object. This should be a clone method, of course. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional co

Re: Clone an object

2009-12-28 Thread Philip Potter
2009/12/28 Christoph Friedrich : > I have searched the internet but didn't found a good answer. > How do I clone a Perl Object? > > For example like this: > > $a = My::Object->new(); > $b = $a->clone(); > > Where $b is an exact copy of $a but in its own memory. You call the function that the objec

Re: regex question

2009-12-22 Thread Philip Potter
2009/12/22 Parag Kalra : > You can try following: > > $_ =~ s/^\.(\s)+//g; This isn't quite right. There are two ways in which you might use this substitution: either $_ will contain a single line, or it will contain multiple lines. The single line case might look something like this: while (<>)

Re: Git Talk by Randal

2009-12-19 Thread Philip Potter
2009/12/19 Erez Schatz : > One problem I have with Merlyn, is when he starts talking about > something, you're willing to throw everything away and go where he > points. He's such a passionate, compelling speaker. > My other problem is that he's mostly right. Who are you talking about? Is Merlyn s

Re: Git Talk by Randal

2009-12-19 Thread Philip Potter
2009/12/19 Parag Kalra : > Hello All, > > I know most of the big guns on this mailing list may already know this but > still felt like sharing this with you all specially for the beginers like > me. :) > >  A nice, very informative and well presented talk on Git given by our own > old gold Randal :

Re: capture error - the better way?

2009-12-18 Thread Philip Potter
2009/12/18 Peter Scott : > On Wed, 16 Dec 2009 10:09:38 +0000, Philip Potter wrote: >> Yes, it can't fold the constant. That's no excuse for changing the >> behaviour of the program. What it should do is what I wrote in my >> previous email -- replace it with code

Re: being smart about script structure

2009-12-16 Thread Philip Potter
2009/12/16 Bryan R Harris : > What's the difference between pointers and references?  Where can I read > about that difference? The key difference in my mind is this: Perl references are defined in terms of perl datatypes. C pointers are defined (more or less) in terms of memory locations. If you

Re: parsing template

2009-12-16 Thread Philip Potter
2009/12/16 Avani : > Hi all, > > I am very new to perl. I have to parse template in perl. > > do anybody have any reference code to do it? > > currently I am using regular expression. Right now, i m only able to > replace variables. HOw to do it for "for loop" and "if conditions" ? You may have to

Re: capture error - the better way?

2009-12-16 Thread Philip Potter
2009/12/16 Shlomi Fish : > On Tuesday 15 Dec 2009 17:14:25 Philip Potter wrote: >> If evaluating a constant expression results in a runtime exception, >> that runtime exception must happen at runtime, and not at compile >> time. In general, it is the duty of an optimizer never

Re: Comparing aggregates for equality when order doesn't matter

2009-12-15 Thread Philip Potter
2009/12/15 Shawn H Corey : > Philip Potter wrote: >> 1. Is there a "set" type which holds aggregate data and doesn't care >> about order, which I could use to compare these results for equality? > > You can use a hash as a set or a bag. Yeah I thought about

Comparing aggregates for equality when order doesn't matter

2009-12-15 Thread Philip Potter
Hi all, I have a method which returns two arrayrefs: one is an array of hashes, and the other an array of arrays. I'm writing a test harness for this method, so I put together some testcases and expected results. I don't care what order the arrays are in; I only care that the arrayrefs returned by

Re: capture error - the better way?

2009-12-15 Thread Philip Potter
2009/12/15 Shlomi Fish : > On Tuesday 15 Dec 2009 15:53:28 Philip Potter wrote: >> How can "Illegal division by zero" be a compile-time error? It seems >> clear to me that it's a run-time error, which the optimizer has >> (wrongly) decided to raise at compile-

Re: capture error - the better way?

2009-12-15 Thread Philip Potter
2009/12/15 Shlomi Fish : > On Tuesday 15 Dec 2009 14:25:28 Xiao Lan (小兰) wrote: >> On Tue, Dec 15, 2009 at 7:50 PM, Xiao Lan (小兰) > wrote: >> > I did have tried that, but this will get a runtime error. >> >> Sorry this is exactly a compile-time error. >> >> # cat except.pl >> >> eval { $x=12/0 };

Re: capture error - the better way?

2009-12-15 Thread Philip Potter
2009/12/15 Xiao Lan (小兰) : > On Tue, Dec 15, 2009 at 6:34 PM, Shlomi Fish wrote: >> You can use block eval {} instead of string eval "": > I did have tried that, but this will get a runtime error. > > # perl -e ' > eval { $x = 12/0 }; > if ($@) { print "0 div error" }' > > Illegal division by zero

Re: Windoze Woez

2009-12-12 Thread Philip Potter
2009/12/12 Shawn H Corey : > Alan Haggai Alavi wrote: >> Hi, >> >> Windows requires you to use double quotes in place of single quotes. Saving >> to >> a file and executing it is the only way that is cross-platform, I suppose. > > Doesn't Windows respond to here redirects? > > perl <> print "Hello

Re: Windoze Woez

2009-12-12 Thread Philip Potter
2009/12/12 Parag Kalra : > How is it going to new line without a new line character - '\n'. If I am not > wrong - 'q/ /' signifies quoted context thus - a replacement for double > quotes but still you should need a new line character to go to next line. q// is single quotes, qq// is double quotes.

Re: Windoze Woez

2009-12-12 Thread Philip Potter
2009/12/12 Parag Kalra : > Hello All, > > This works on Linux - > perl -e 'foreach (Sugar,Sex,Simplicity,Sleep,Success,Smoking) { print "I am > only addicted to - 'Shekels' \n" if ($_ =~ /^s.*/i) }' > > This works on Windoze - perl -e "foreach (Sugar,Sex,Simplicity,Sleep,Success,Smoking) { print '

Re: being smart about script structure

2009-12-12 Thread Philip Potter
2009/12/11 Bryan R Harris : >>> Seems like a waste to do step 2 in a subroutine since we only do it once, >>> but it does fill the main body of the script with code-noise that makes it >>> harder to debug overall logic problems...  Not much logic here, but >>> certainly in more complex scripts. >>

Re: being smart about script structure

2009-12-11 Thread Philip Potter
2009/12/11 Bryan R Harris : > I'm not even sure how to ask this question, but here goes: > > I struggle knowing how to structure my code, what things belong as their own > subroutines and what things can stay in the main script.  How do the smart > guys make these decisions? > > For example, let's

Re: assign operator

2009-12-11 Thread Philip Potter
2009/12/11 Steve Bertrand : > Rafa? Pocztarski wrote: >> There is no := operator in Perl 5. In Perl 6 := is a run-time binding >> operator: >> >> $x = 1; >> $y := $x; >> $y = 2; >> >> Now both $x ==2 and $y == 2 >> In Perl 5 you use typeglob assignment to achieve the same thing: >> >> $x = 1; >> *

Re: Problem with break

2009-12-10 Thread Philip Potter
2009/12/9 Anush : > Hi all, i have a problem with the break statement, in my program the > break is not working, that is the control would not breaks from the > loop. Please help me. Can you give an example of your problem? What is your code? What did it do? What did you expect it to do? Perhaps

Re: matching an element from one array to another

2009-12-10 Thread Philip Potter
2009/12/10 John W. Krahn : > Noah wrote: >> >> Hi there, > > Hello, > >> I am hoping to figure out the best Way to write something.  I have two >> arrays @previous_hostnames and @hostnames. >> >> I want to figure out if there is at least one matching element in >> @previous_hostnames that is found

Re: Email does not send attachment ...

2009-12-09 Thread Philip Potter
2009/12/9 Sneed, Sean P : > Try the paths like this C:\\my_file.log Is there a reason that you suggested this? Perl under Windows, just like C and C++ under Windows, accepts / as a directory separator just fine. And if you stick to using / as your directory separator, porting to unix-based systems

Re: passing Hash to subroutine help please

2009-12-09 Thread Philip Potter
2009/12/9 John W. Krahn : > Jeff Pang wrote: >> >> Noah: >>> >>> sub exiting { >>>    my ($hostname, %login) = @_; >> >> Passing arguments like this has no such problem. >> But you'd better pass the hash as a reference to the subroutine. >> >> exitint($hostname, \%login); >> >> sub exiting { >>    

Re: Can I design a website using Perl

2009-12-06 Thread Philip Potter
2009/12/6 Parag Kalra : >> Question to the OP: Why have you decided to try things out in Perl? If >> it is because you've heard something like "Perl is better than PHP" >> then stop and try to find out *why* and *in what situations* is Perl >> better than PHP. In the situation of a simple webpage w

Re: Can I design a website using Perl

2009-12-06 Thread Philip Potter
2009/12/6 Erez Schatz : > This being said, anything you can do in PHP is available in Perl, PHP > being the "less talented brother" of Perl and all. For instance, for > embedding code tags in your HTML page, look no further than some > awsome and powerful Perl modules such as Template::Toolkit > (w

Re: I want to know the reason

2009-12-05 Thread Philip Potter
2009/12/5 Parag Kalra : > But this code is not working: > > #!/usr/bin/perl >> my @column_names=(A..ZZ); >> for(my $i=0; $i<26; $i=$i+1) { >>     my $tmp_file = "$column_names[$i]".".out"; >>     open $column_names[$i], ">column_names/$tmp_file" or die "Could not >> create the file - $tmp_file \n";

Re: Need to process a XML file through Perl.

2009-12-02 Thread Philip Potter
2009/12/2 Parag Kalra : > Currently I am planning to process the above requirement using simple Perl > regex. But I feel it can be made simpler using any of the available modules. > > So I have following questions: > 1.       Which are the best available XML modules for Perl? > 2.       Out of the

Re: CGI programming

2009-11-30 Thread Philip Potter
2009/11/30 Anant Gupta : > I am not allowed to write to /var/www/cgi-bin/ > > I am not the root user of my machine > Is their any way i can try out my perl cgi programs on this machine( Red Hat > Linux) Ask the root user of your machine. As an example of how these things work, at my university I c

Re: Assignment Operator

2009-11-26 Thread Philip Potter
2009/11/26 Marco Pacini : > Hi All, > > I'm studying Perl since one week on "Learning Perl" written by L. Wall and in > the paragraph "Assignment Operators" i don't understand why this: > >        ($temp = $global) += $constant; > > is equivalent of: > >        $tmp = $global + $constant; > > Inst

Re: Code issue with perl5.10

2009-11-25 Thread Philip Potter
2009/11/25 Steve Bertrand : > Steve Bertrand wrote: >> Hi all, >> >> I just upgraded from perl 5.8 to perl 5.10.1. Everything went well, >> except for a single module that I need. >> >> The offending code is this: >> >> ${$self->{__pb_template_list}}[...@{$self->{__PB__TEMPLATE_LIST}}}]->param( >>

Re: Documentation practices

2009-11-24 Thread Philip Potter
2009/11/24 Steve Bertrand : > 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 overwhelmingly cumbersome, as I have to read th

Re: Regex to get last 3 digits of a number.

2009-11-24 Thread Philip Potter
2009/11/23 Alan Haggai Alavi : > my $number = '0111'; > my ($index) = ( $number =~ /\d+(\d{3})/ ); > > $index would contain the last three digits: '111'. \d+ should be \d* above, otherwise you fail to match on 3 digit numbers: p...@tui:~/tmp$ perl -E ' my $number = q{111}; my ($index)

Re: how to write a debug-print sub with one argument?

2009-11-23 Thread Philip Potter
2009/11/23 Mark_Galeck : > Hello,  I want to write a simple debug-print subroutine, which you > could call like this: > > $foobar = "foobar"; > dbgPrint foobar; One problem with your interface is it breaks under "use strict;". You should always use strict and use warnings in any program not part o

Re: 答复: the question of one program

2009-11-20 Thread Philip Potter
2009/11/20 gaochong : > Thanks . > But the code is from cpan.org ,and is crappy ,where I will go ? CPAN has no quality control. There is no guarantee that anything you get from CPAN will not be, as you say, "crappy". As a result, be selective with what you download from CPAN. Ask questions, go by

Re: redirecting to a file in perl

2009-11-13 Thread Philip Potter
2009/11/13 Dermot : > 2009/11/13 Subhashini : >> i did try it but didn't work.. > > Did try what? Can you please show us what you've tried. Post the > updated version. And can you please reply to the mailing list. There > will be others how might find the answer to their problem by searching > the

Re: Explicit return and anonymous hashes

2009-11-12 Thread Philip Potter
2009/11/12 Peter Scott : > On Thu, 12 Nov 2009 09:55:39 +0000, Philip Potter wrote: >> 2009/11/11 Shawn H Corey : >>> no warnings 'once'; >>> my @aoh = pairwise { +{ %{$a}, %{$b} } } @aoh_a, @aoh_b; >> >> Thanks for your response. What are the

Re: Explicit return and anonymous hashes

2009-11-12 Thread Philip Potter
2009/11/11 Shawn H Corey : > Philip Potter wrote: >> my @aoh = pairwise { { %{$a}, %{$b} } } @aoh_a, @aoh_b; > > no warnings 'once'; > my @aoh = pairwise { +{ %{$a}, %{$b} } } @aoh_a, @aoh_b; Thanks for your response. What are the grammar rules here? Why must I use

Explicit return and anonymous hashes

2009-11-11 Thread Philip Potter
I am playing with List::MoreUtils::pairwise and noticed some funny behaviour. I'm trying to merge two lists of hashes into one list of hashes: p...@tui:~/tmp$ cat bar.pl use strict; use warnings; use List::MoreUtils qw(pairwise); use Data::Dumper; my @aoh_a = ( { foo => 1, bar => 2 }, {foo => 3,

Re: hash keys and readable code

2009-11-11 Thread Philip Potter
2009/11/11 Uri Guttman : >>>>>> "PP" == Philip Potter writes: > >  PP>     my %readfsgs_flags; >  PP>     my @flags_to_copy = qw(limit); # can scale up by adding more hash > keys here >  PP>     @readfsgs_fla...@flags_to_copy} = @{$flag.

hash keys and readable code

2009-11-11 Thread Philip Potter
Hi all, I have a subroutine which uses a hashref to accept optional parameters: sub do_test { my ($testfilename, $flags) = @_; ## etc... } Here $flags is given an hashref containing optional arguments such as { thorough => 1, limit => 3, retries => 2}. One (but not all) of the flags is,

Re: the classic "which is the fastest way to sort" question

2009-11-09 Thread Philip Potter
2009/11/9 Michael Alipio : > Hi, >> >>  Do you need the fastest possible sort? > > I'm not even sure if I really need to worry about all these > sorting techniques. My program just reads a text file > (wordlist). It might be megabyte-sized or probably few > gigabytes (i might also add size checking

Re: the classic "which is the fastest way to sort" question

2009-11-09 Thread Philip Potter
2009/11/9 Michael Alipio : > Hi, > > i'm planning to sort an input file (which was File::Slurp'ed, most likely > megabyte-sized file) in various ways. I did some readings and learned several > methods > that people have come up with in recent years. So to summarize, the default > sort is fast (u

Re: Is Larry Wall member of this mailing list

2009-11-04 Thread Philip Potter
2009/11/4 Parag Kalra : > Are you this Larry Wall - http://en.wikipedia.org/wiki/Larry_Wall Yes I am and so's my wife. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: print flips to scientific notation when integer exceeds 15 decimal digits

2009-11-04 Thread Philip Potter
2009/11/4 David Lee : > Many thanks for the reply. > > Following the initial surprise, my main concern was that attempts to unearth > a description or explanation (i.e. documentation) for the observed behaviour > was so tricky.  For instance, there was nothing obvious in the relevant > parts of "Pr

Re: print flips to scientific notation when integer exceeds 15 decimal digits

2009-11-03 Thread Philip Potter
2009/11/3 David Lee : > Although I've used perl for many years, I've just been surprised (in the > unpleasant sense) by a recent event.  Given a variable, say "$int", which is > a growing integer, I would expect "print $int" to print it as a simple > integer; indeed it usually does so.  But when it

Re: Increment Operator (++) question in Perl

2009-11-03 Thread Philip Potter
2009/11/3 Majian : > Hi ,all: > >  When I test the increment operator in Perl and  find   a question : > > The question is : > #!/usr/bin/perl > use warnings; > > my $i = 1; > print  ++$i  + ++$i, "\n"; > > The above code prints  out  the answer 6 . > But in the other language  the anser is 5 , > >

Re: How do I pick one random element from an array?

2009-11-03 Thread Philip Potter
2009/11/3 John W. Krahn : > Majian wrote: >> my @array = ('uriel', 'daniel', 'joel', 'samuel'); >> >> Now what I want is create a process so every time I print the array it >> prints  one element from the array . >> >> I wrote it like this : >> >> #!/usr/bin/perl -w >> >> use strict; > > use List::

Re: foreach loop

2009-11-02 Thread Philip Potter
2009/11/2 Thomas Bätzler : > while( my $line = <$file> ){ > > } Won't this loop terminate early if there is a blank line or a line containing only '0'? If I do a readline loop I always do: while (defined ($line = <$file>)) Is there something magical happening here I don't know about? I know abou

Re: Emulating Sort through Perl

2009-10-30 Thread Philip Potter
2009/10/30 Jim Gibson : > Approach 1. is called a "stable sort". As you can see, Perl's sort gives you > a stable sort, as the last two lines are in the order they appear in the > original file. The Unix sort is not stable, so the lines with equal keys get > reversed in the output. Whether or not y

Re: compact my wordlist generator

2009-10-26 Thread Philip Potter
2009/10/26 Michael Alipio : > Then as suggested (see far below), a recursive function will do what I want.. > After some googling I found this: > > > permutate(0,2); > > sub permutate($$){ > >  my ($cur,$max) = @_; > >  if ($cur>=$max){ >     print "$result\n"; >     return; >  } > >  for(@word){

Re: newbie question : about the perl sprintf

2009-10-25 Thread Philip Potter
2009/10/25 Majian : > I found these : > perl -e'print 01.234 + 01.234', "\n"' print (01).(234+01).234, "\n"; this evaluates to '1'.'235'.'234' > perl -e'print 01.234 + 011.234' "\n"' I didn't get 1235234, I got 1243234. print (01).(234+011).(234),"\n" evaluates to print '1'.(234+9).'234',"\n";

Re: compact my wordlist generator

2009-10-25 Thread Philip Potter
2009/10/25 Michael Alipio : >  I'm trying to write a word list generator which can >  generate all possible combinations of n characters, within n >  set of characters. Have you looked into the magical autoincrement operator? http://perldoc.perl.org/perlop.html#Auto-increment-and-Auto-decrement

Re: Convert Site Name to Dotted IP Address

2009-10-22 Thread Philip Potter
2009/10/22 Anant Gupta : > Thank you. > I just used "use strict" and "use warnings" and it worked. > Even now I cant figure out what difference can this make :) > > Thank you for tour time If it helps, I have no idea either :) Philip -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For

Re: Convert Site Name to Dotted IP Address

2009-10-22 Thread Philip Potter
er chance of helping you. Unfortunately, there are still no guarantees :( Philip > Thanks > > On Thu, Oct 22, 2009 at 4:33 PM, Philip Potter > wrote: >> >> 2009/10/22 Anant Gupta : >> > I wrote >> > >> > #!usr/bin/perl >> > use Socke

  1   2   >