Re: function alias

2019-09-04 Thread Paul Johnson
3)' 67 $ > for example, says() is alias to > print(). This is not possible. Though it is with some core functions. See https://perldoc.perl.org/CORE.html for details. -- Paul Johnson - p...@pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail:

Re: Syntax "||" before sub

2018-11-22 Thread Paul Johnson
shift; > >$name ||= 'Anonymous Person'; > > Which is usually written as: > >sub hello { >my $name = shift || 'Anonymous Person'; Or, nowadays, and if your perl version(s) support it, as: sub hello ($name = "Anonymous Person") { -- Paul Johnso

Re: return the list content

2018-06-14 Thread Paul Johnson
On Mon, Aug 18, 2014 at 06:07:59AM -0700, John SJ Anderson wrote: On Mon, Aug 18, 2014 at 1:38 AM, Paul Johnson wrote: > On Mon, Aug 18, 2014 at 04:17:53PM +0800, Ken Peng wrote: >> which one is the better way to return the list content? And if the >> method is an instance metho

Re: `$#array` vs `scalar @array`

2018-01-29 Thread Paul Johnson
13:39 Peng Yu <pengyu...@gmail.com> wrote: > > > Hi, > > > > For the following two expressions, are they of the same speed or one > > of them is faster? > > > > `$#array` vs `scalar @array` -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To

Re: OOP: a class using a class that is descended from it?

2017-08-05 Thread Paul Johnson
On Fri, Aug 04, 2017 at 05:45:08PM +0200, hw wrote: > Paul Johnson wrote: > > On Thu, Aug 03, 2017 at 08:44:45PM +0200, hw wrote: > > > > > > Hi, > > > > > > suppose I have a class FOO and a class BAR. The parent of BAR is FOO. > > > &g

Re: OOP: a class using a class that is descended from it?

2017-08-04 Thread Paul Johnson
ally called traits in other languages. You can use roles within Moose or Moo, or by using other CPAN modules. You can read more about roles/traits at https://en.wikipedia.org/wiki/Trait_(computer_programming) -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beg

Re: perl -e 'my $i = 0; $i = defined($i) ? (!!$i) : 0; print "i: $i\n";'

2017-08-03 Thread Paul Johnson
ing experience. The trick is to work with the language. Then programming becomes productive and enjoyable, the sun shines, ponies frolic through meadows, and unicorns graze contentedly beneath rainbows. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr

Re: Module to extract patterns

2017-06-13 Thread Paul Johnson
ule which will probably do what you want: PPI. See https://metacpan.org/pod/PPI -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: How to delete multiple indices from array

2017-04-12 Thread Paul Johnson
But they're all fast enough. Or none of them are. So choose the solution which is the clearest. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: [OT] app (ncurses?) mechanizer?

2017-03-27 Thread Paul Johnson
On Tue, Mar 28, 2017 at 12:20:29AM +0300, Shlomi Fish wrote: > Hi Paul! > > On Mon, 27 Mar 2017 22:21:06 +0200 > Paul Johnson <p...@pjcj.net> wrote: > > > On Mon, Mar 27, 2017 at 04:04:22PM +0200, Luca Ferrari wrote: > > > Hi all, > > > I've to run

Re: [OT] app (ncurses?) mechanizer?

2017-03-27 Thread Paul Johnson
the application with a file name, do a couple > of menu interactions and exit, then do it again for a hundred or so > files. > Is there any kind of "app-mechanize" similar to www::mechanize? Nothing to do with perl, but you could try xdotool http://www.semicomplete.com/proje

Re: deprecated idiom to simulate state variables

2017-01-10 Thread Paul Johnson
of years). As you note, the correct way to get this behaviour nowadays is to use the "state" keyword. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: XML::Simple Umlaute

2016-07-28 Thread Paul Johnson
t;utf8" and a lot of the problems go away. > Also, this answer on StackOverflow by tchrist (Tom Christiansen, who I > would say knows the most about the intersection of Perl and Unicode) > is a good resource: http://stackoverflow.com/a/6163129/78259 Quite. And utf8::all tries to

Re: Are there (non-obvious) differences in string quoting methods?

2016-04-06 Thread Paul Johnson
You'll notice that I disagree with Uri. You should follow the coding guidelines of any existing project you are working on, and make up your own mind about what to do when you get to decide the guidelines. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: returning arrays

2016-01-25 Thread Paul Johnson
On Mon, Jan 25, 2016 at 12:24:04AM +0100, lee wrote: > Paul Johnson <p...@pjcj.net> writes: > > > On Sun, Jan 24, 2016 at 05:44:14PM +0200, Shlomi Fish wrote: > >> Hi lee, > >> > >> On Sun, 24 Jan 2016 13:11:37 +0100 > >> lee <l...@yag

Re: returning arrays

2016-01-24 Thread Paul Johnson
On Sun, Jan 24, 2016 at 05:44:14PM +0200, Shlomi Fish wrote: > Hi lee, > > On Sun, 24 Jan 2016 13:11:37 +0100 > lee <l...@yagibdah.de> wrote: > > > Paul Johnson <p...@pjcj.net> writes: > > > > > > In scalar context the comma operator evaluates i

Re: uniq array creation

2015-11-29 Thread Paul Johnson
you're working far too hard! my @array = qw(11 2 3 4 55 4 3 2); my %seen; my @unique = grep !$seen{$_}++, @array; This method is mentioned in the Perl Cookbook that was linked to earlier in the thread. But I doubt that link should have been online, so get hold of a legal copy if this is usef

Re: To use signatures or not to use?

2015-07-22 Thread Paul Johnson
be completely backwards compatible. Or the feature may be completely scrapped. That's the risk you take with experimental features. But there is certainly a will to make this feature stick. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr

Re: Devel::Cover Use case

2015-07-22 Thread Paul Johnson
for that purpose. If you carry on down this path though, you will soon end up reinventing Perl's testing system. Give serious thought to whether moving to a standard test layout now wouldn't be a bad use of your time. Coverage without tests is hard though. -- Paul Johnson - p...@pjcj.net http

Re: Devel::Cover Use case

2015-07-22 Thread Paul Johnson
. And the way to do this is also in the synopsis that Shlomi pointed you to. Coverage without tests is hard though. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http

Re: How to check the index positions of an array element in perl in case of multiple occurance

2015-06-16 Thread Paul Johnson
1071 1161 1251 1341 1431 $ Thinking about it, there is (at least) one bug in there. But with the data provided it may not be important. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h

Re: Debug when script WILL NOT RUN

2015-02-01 Thread Paul Johnson
is an error, and the only one we can see in the code you have posted. $ perl -ce 'find ( sub {}, $tdir; )' syntax error at -e line 1, near $tdir; -e had compilation errors $ perl -ce 'find ( sub {}, $tdir )' -e syntax OK -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e

Re: ignoring bad Prompt argument Warning.

2014-12-29 Thread Paul Johnson
Prompt argument '//': missing opening delimiter of match operator at linux_diagnostics.pl line 189 Guessing: You are using Net::Telnet and your prompt should be // rather than '//' -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org

Re: Make scalar tainted

2014-12-06 Thread Paul Johnson
take the substr from the original string before splitting it, unless you wanted to taint $foo even if its source wasn't tainted. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org

Re: Problem with regex

2014-10-06 Thread Paul Johnson
Syndrome. Putting it together you get: my $start = qr!mailto:|ldap:///!; while ($str =~ /$start(.*?)(?=,$start|$)/sg) { print first = $1\n; } Or you could avoid the messing about with the while condition and use split: say for split $start, $str; -- Paul Johnson - p

Re: Difference between list and arrays.

2014-09-16 Thread Paul Johnson
) is: (1, 2, 3) - ((1, 2), 3) - (2, 3) - 3 And this is why $one_var gets the value 3 - not because there are three elements in a list on the RHS. This all becomes easier to understand if you don't use the values 1, 2 and 3 :) See also perldoc -q 'difference between a list and an array' -- Paul

Re: Difference between list and arrays.

2014-09-16 Thread Paul Johnson
On Tue, Sep 16, 2014 at 02:43:28PM -0500, Andy Bach wrote: On Tue, Sep 16, 2014 at 1:45 PM, Paul Johnson p...@pjcj.net wrote: The comma operator evaluates its LHS, throws it away, evaluates its RHS and returns that. The comma operator is left associative (see perlop). So the result

Re: returning arrays

2014-09-09 Thread Paul Johnson
assigned to $list. What is not happening at all is the creation of a list of numbers and a calculation of its length. See also perldoc -q 'difference between a list and an array' -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org

Re: return the list content

2014-08-18 Thread Paul Johnson
extra work and might cause someone to wonder why you haven't just returned a reference to the array. The second version is necessary when the array might persist between subroutine calls and you effectively need to return a copy. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net

Re: Please check my logic

2014-07-21 Thread Paul Johnson
lines which differ only in case. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Apologetic request for simple one-off script

2014-07-13 Thread Paul Johnson
perldoc perlrun if you want to see why that works. Take a look at the -a option. The -1 index into @F says use the last element of the array. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h

Re: Apologetic request for simple one-off script

2014-07-13 Thread Paul Johnson
On Sun, Jul 13, 2014 at 06:44:18PM -0400, ESChamp wrote: Paul Johnson has written on 7/13/2014 5:00 PM: perl -nale 'print $F[-1]' original_file.txt just_email.txt e:\Docs\perl -nale 'print $F[-1]' 4sam.txt just_email.txt Can't find string terminator ' anywhere before EOF at -e line 1

Re: List-AllUtils-0.07

2014-03-18 Thread Paul Johnson
://metacpan.org/pod/List::Util Depending on the distribution you are using you might have a tool to automate the process of recursively installing dependencies. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands

Re: Fail to match mixed quote pattern

2014-03-14 Thread Paul Johnson
--- leaving 'let us go' unmatched. I don't know how to describe this problem, Can anyone help me with this ? -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http

Re: Delete key-value pair in perl

2014-03-09 Thread Paul Johnson
, as Alex is doing here. This is good because, as we see here, it can reasonably be expected to work. perldoc -f each -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http

Re: match not matching

2014-03-01 Thread Paul Johnson
= Data::Dumper-Dump([$_, $project, $$_, $found]); $logger-trace(qq(dump=$dump)); } I can't explain why $found is not true on the 3rd pass. Does this have something to do with the way I'm dereferencing the blessed object? -- Paul Johnson - p...@pjcj.net http://www.pjcj.net

Re: file edit

2014-02-27 Thread Paul Johnson
try and understand it before trusting it. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Not mapping into a hash

2014-02-13 Thread Paul Johnson
= map {$_ = 1} @{$params-{direction}}; # -- HERE } else -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Test::More is_deeply failed data

2014-02-11 Thread Paul Johnson
the right thing to do to figure out why a test is failing? Perhaps you are looking for Test::Differences ? https://metacpan.org/pod/Test::Differences -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail

Re: package block

2014-02-09 Thread Paul Johnson
declaration line. What you have currently is an old-style package declaration and then an ordinary block, meaning that anything after the block is also in package Hello. Finally, 1 is a boring value to return. Be creative! See http://returnvalues.useperl.at/values.html -- Paul Johnson - p...@pjcj.net

Re: Using Files in Chronological Order

2014-01-27 Thread Paul Johnson
done, and a whole bunch of other considerations. In some cases shelling out to ls is exactly the correct thing to do, and when you have decided where your line lies based on your understanding of your requirements, don't let anyone without that understanding tell you otherwise. -- Paul Johnson

Re: regexp as hash value?

2014-01-25 Thread Paul Johnson
, this is possible. You need to use qr// to construct your RE: $ perl -E '$h = { a = qr/y/ }; say $_ =~ $h-{a} for qw(x y z)' 1 $ -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org

Re: regexp as hash value?

2014-01-25 Thread Paul Johnson
On Sat, Jan 25, 2014 at 06:41:00PM +0100, Luca Ferrari wrote: On Sat, Jan 25, 2014 at 4:12 PM, Paul Johnson p...@pjcj.net wrote: $ perl -E '$h = { a = qr/y/ }; say $_ =~ $h-{a} for qw(x y z)' Thanks, but then another doubt: having a look at http://perldoc.perl.org/perlop.html#Regexp-Quote

Re: Problem setting $= (Format Lines Per Page Special Variable)

2013-11-07 Thread Paul Johnson
on the FileHandle: REPORT-format_lines_per_page(10); -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: hello from a newbie

2013-10-26 Thread Paul Johnson
if the edition is old. The reason for that is that it isn't a book to use to learn Perl - the preface explicitly states that. It is a book from which to learn algorithms if you already know Perl. So if that's you, reading Mastering Algorithms with Perl will make you a better developer. -- Paul

Re: Problem rewinding the __DATA__ filehandle

2013-10-25 Thread Paul Johnson
Fcntl for details. And for your third approach, you need C $. = 0; -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: checking for file existence

2013-09-25 Thread Paul Johnson
, is seems not to work. It always returns The file $file_seqs does not exist!!!. Do you know where I am making a mistake? I don't know. How are you calling your program? Because it seems to work correctly for me. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail

Re: negate, !!$a, $a!!, flip-flop

2013-09-10 Thread Paul Johnson
0 [ If it's not obvious, my tongue was in my cheek for half of this post. ] -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: how to retrieve the keys from hash in the sequence in which data is inserted

2013-04-23 Thread Paul Johnson
. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Any alternative for substr() function

2013-04-12 Thread Paul Johnson
of lines. If I use perl in-built function substr() to data extraction, it has huge impact on performance. Compared to what? Is there any alternative for this? Perhaps unpack() or regular expressions, but I doubt either would be much faster, if at all. -- Paul Johnson - p...@pjcj.net http

Re: obfuscating code

2013-02-13 Thread Paul Johnson
for this list. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Regex issue

2013-01-03 Thread Paul Johnson
-- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: substitution: interpolate capture buffer into variable?

2012-12-26 Thread Paul Johnson
=~ s/\$rx/$r/; Three points: - make sure you trust your input - be sure to check $@ - there's no need to check if the pattern matches first, just attempt the substitution -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org

Re: grouping in regex

2012-12-25 Thread Paul Johnson
On Mon, Dec 24, 2012 at 08:01:11PM +, Rob Dixon wrote: On 24/12/2012 13:08, Paul Johnson wrote: On Sun, Dec 23, 2012 at 06:57:38PM +0530, punit jain wrote: I am seeing which lines have both POP and Webmail as below :- if( $line =~ /AccessModes\s*=\s*.*(WebMail)*.*(POP).*(WebMail

Re: grouping in regex

2012-12-24 Thread Paul Johnson
substrings appear in the same same string is to program the way you define the problem: if (/WebMail/ /POP/) { ... } -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http

Re: Regex help

2012-12-22 Thread Paul Johnson
/' in out See perldoc perlrun for the switches and Range Operators from perdoc perlop for .. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Is this code which is using Switch.pm safe?

2012-11-22 Thread Paul Johnson
if you update your perl version I would stay away from given/when for now. And you should update your perl version. It's unsuported, buggy and I'm sure it has security problems which have been fixed in the last eight years. (That's always a good case to make to management folk.) -- Paul Johnson - p

Re: Fwd: Is this code which is using Switch.pm safe?

2012-11-22 Thread Paul Johnson
product though. On Thu, Nov 22, 2012 at 3:32 PM, Paul Johnson p...@pjcj.net wrote: On Thu, Nov 22, 2012 at 11:37:15AM +0530, Chankey Pathak wrote: In our company we were using this code (given at the end) for about 10 years and it worked fine. Some days ago we faced some issues

Re: Regex one-liner to find several multi-line blocks of text in a single file

2012-11-01 Thread Paul Johnson
to search from START to the next END and then start the search pattern over again with the next START-END match. How might I go about achieving this? perl -ne 'print if /# START block #/ .. /# END block #/' file.txt -- Paul Johnson - p...@pjcj.net http://www.pjcj.net

Re: changing $/ for recognising empty line

2012-10-29 Thread Paul Johnson
On Mon, Oct 29, 2012 at 12:48:33PM +0100, Hermann Norpois wrote: But still: What is wrong with $/=^\s+$ ? From perldoc perlvar: Remember: the value of $/ is a string, not a regex. awk has to be better for something. :-) -- Paul Johnson - p...@pjcj.net http://www.pjcj.net

Re: Concatenation in Perl

2012-07-22 Thread Paul Johnson
On Sun, Jul 22, 2012 at 11:09:10PM +0200, Jenda Krynicky wrote: From: Paul Johnson p...@pjcj.net You need a mixture of the two approaches: map to prepend not in: and join to join them. my $query = join and , map not in:$_, @folders; @folders = ('one', 'two'); my $query

Re: Concatenation in Perl

2012-07-19 Thread Paul Johnson
and in beginning. Any idea how to do this ? You need a mixture of the two approaches: map to prepend not in: and join to join them. my $query = join and , map not in:$_, @folders; -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr

Re: Regex character classes: n OR m

2012-07-06 Thread Paul Johnson
as for example, you could do this: /^(?:a{3}|a{5})$/ -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: How to create a user manual window

2012-06-12 Thread Paul Johnson
On Tue, Jun 12, 2012 at 07:11:57PM +0300, Shlomi Fish wrote: OK. For Windows there is now http://dwimperl.com/ which is open-source and is considered better than Activestate Perl. [citation needed] -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners

Re: subroutine returning data

2012-06-04 Thread Paul Johnson
%{$href-{$_[0]}}) { return 1 if $_ eq 'ND'; #need to test all values are eq to 'ND' } return ''; } I would imagine it to be much easier to look at it from the other way. Return 0 any time you find a value that does not equal NO. Then return 1 at the end. -- Paul Johnson - p

Re: Using perlbrew to change Perl version for scripts

2012-06-03 Thread Paul Johnson
). If not, what are you asking? Are you actually looking for this? $ perlbrew exec perl my_snazzy_program.pl -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http

Re: shift vs @_

2012-05-21 Thread Paul Johnson
but too slowly and profiling has determined that this is the bottleneck. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Perl preprocessor

2012-05-04 Thread Paul Johnson
that. But take a look at https://metacpan.org/module/Mason Good luck, -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: how to get two matches out

2012-05-03 Thread Paul Johnson
... it says @words, not @word.) This has now been fixed by http://perl5.git.perl.org/perl.git/commitdiff/5a0c7e9d45ff6da450098635b233527990112d8a?hp=68cd360812f9eaa2d34c45c501e2fef87c44ccde and will be in the upcoming 5.16.0 release. Thanks for mentioning it. -- Paul Johnson - p...@pjcj.net http

Re: Updating Perlbrew

2012-05-03 Thread Paul Johnson
or perlbrew help you'll see the main commands. The one you want is perlbrew self-upgrade. Just run that and it'll do the rest. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http

Re: and subroutine

2012-04-16 Thread Paul Johnson
On Mon, Apr 16, 2012 at 06:53:53AM -0700, Paul.G wrote: Hi All Have a question, is it good coding practice to use a when calling a subroutine, or it is not required, or it doesn't matter? It's good practice not to use it unless you understand exactly why you would need to use it. -- Paul

Re: Using the ternary operator to concat a string not working like I think?

2012-04-04 Thread Paul Johnson
and third arguments are lvalues, which can be useful sometimes. Most of this, including the specific problem you are seeing, is documented in perlop under the heading Conditional Operator. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr

Re: Perl script not executing from cron job

2012-03-27 Thread Paul Johnson
chaning the time the cronjob runs every time you need to run a test, which is a real pain and seems like the sort of thing for which there really should be a better solution. With luck, someone will reply and say what that solution is. Good luck, -- Paul Johnson - p...@pjcj.net http

Re: Why do I get a warning?

2012-03-26 Thread Paul Johnson
as there are to add them. Indeed, it could be argued that adding them goes against the perlstyle advice: Omit redundant punctuation as long as clarity doesn't suffer. So, to a certain extent, you'll need to devise your own style. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net

Re: Why do I get a warning?

2012-03-22 Thread Paul Johnson
unsupported you should really upgrade if you can. With the imminent release of 5.16, 5.12 will shortly become unsupported. It looks like you are tyring to open two different filehandles. You need to delcare HDL. open my $HDL, '', fileio2.txt; should fix it. No, it won't. -- Paul Johnson - p

Re: strict subs in use at -e line 1.

2012-03-06 Thread Paul Johnson
, The immediate problem you are seeing is that you should be using the number zero (0) rather than the uppercase letter O (O). If you are not using a font which allows you to easily distinguish between then two, may I suggest inconsolata as a good choice for programming? -- Paul Johnson - p...@pjcj.net

Re: Access class symtab by dereferencing an object

2012-03-03 Thread Paul Johnson
this that someone could point out? no strict refs; foreach my $entry ( keys %{ ref($dog) . :: }) But why? If you really need class introspection then OK, but for general programming you should follow the API as documented. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail

Re: Access class symtab by dereferencing an object

2012-03-03 Thread Paul Johnson
need to be modified, I'm going to scoop up the code globs, modify them, then reinstall them back into the class. Perhaps you might like to look at Moose, and in particular the method modifiers? -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr

Re: Can recursion eliminate nested foreach() loops?

2012-02-27 Thread Paul Johnson
, but there are quite a few of them in a short piece of code. Is there a way to simplify this within Perl? I suppose the question of whether or not this is simplified comes down to definitions. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners

Re: how to understand shift?

2012-02-07 Thread Paul Johnson
are false. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Merging Files

2012-01-31 Thread Paul Johnson
for merge. This is zsh. I presume it could be converted into bash fairly easily. Run it from new_dir. for f (../dir*/*) { cat $f | $f(:t) } :t is essentially basename. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional

Re: issue with perl map function

2011-12-02 Thread Paul Johnson
] } @sympd_list -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: round to the nearest 10 or 100

2011-11-08 Thread Paul Johnson
something like $r = int($n / 100 + .5) * 100; -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: CPAN question

2011-11-01 Thread Paul Johnson
on your path so that a plain perl or cpan will pick up the /usr/local/bin versions. Just be careful that you don't inadvertently call some other program in /usr/local/bin now having different behaviour to what would otherwise have been called. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net

Re: Help pulling data from website

2011-10-26 Thread Paul Johnson
, that screen scraping is evil (and do you have permission?) and what if the site changes its format, and that no, you really, really (no, really) shouldn't parse HTML with a regular expression. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org

Re: sub local variable changes global variable.

2011-10-15 Thread Paul Johnson
][ 1 ] = 7; return 3; } my @a; $a[ 0 ][ 1 ] = ; print Before: . $a[ 0 ][ 1 ] . \n; try( @a ); print After: . $a[ 0 ][ 1 ] . \n; exit; = What happens: Before: After: 7 = What I would expect: Before: After: 0 = -- Paul Johnson

Re: how to sort two array in perl

2011-10-14 Thread Paul Johnson
; use warnings; my @a = (1, 7, 54, 2); my @b = (2, 89, 78, 33); my $l = [ sort { $a-[0] = $b-[0] || $a-[1] = $b-[1] } map [ $a[$_], $b[$_] ], 0 .. $#a ]; @a = map $_-[0], @$l; @b = map $_-[1], @$l; -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail

Re: Why perlcritic complains?

2011-09-30 Thread Paul Johnson
://rt.cpan.org/Public/Dist/Display.html?Name=Perl-Critic -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Why perlcritic complains?

2011-09-30 Thread Paul Johnson
to keep using this policy then I suppose you should either adhere to it, or tweak the configuration until you are happy with it. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http

Re: @INC

2011-09-23 Thread Paul Johnson
IIRC. Run perl -V to see what it is set to. mike@/deb40a:~/perl perl -v This is perl, v5.8.8 built for i486-linux-gnu-thread-multi Do you have $PERL5LIB or $PERLLIB set? Or something strange like PERL5OPT=-M-lib=/usr/share/perl/5.8.8? -- Paul Johnson - p...@pjcj.net http://www.pjcj.net

Re: /usr/lib/perl5/auto/Cwd/Cwd.so: undefined symbol: Perl_Gthr_key_ptr

2011-09-21 Thread Paul Johnson
a correct version of the package. Or you could try compiling everything up yourself. Or just the source for that package. Or you could log a bug somewhere. I depends on how much it's worth to you and how much time and effort you have to invest. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net

Re: /usr/lib/perl5/auto/Cwd/Cwd.so: undefined symbol: Perl_Gthr_key_ptr

2011-09-21 Thread Paul Johnson
just be rebuilt with all the same properties and mismatches. You'll probably need to do something like that. Or tell it to use your system tools somehow. Or get your system tools out of the way somehow. You *may* be able to get away with explicitly setting @INC, perhaps in $PERL5OPT. -- Paul

Re: Strawberry Perl Installing CPAN modules

2011-09-21 Thread Paul Johnson
? -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Maintain Packages

2011-09-20 Thread Paul Johnson
that you could manage that. Or if you have some modules that you like or are familiar with, you could ask the author directly. Finding something from RT and sending in a patch for it would be a very good introduction. Thanks for being willing to give back. Good luck! -- Paul Johnson - p

Re: Files and Arrays - Search for values and write to the right

2011-09-16 Thread Paul Johnson
on the intent of the code rather than the syntax. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Help, About Global variable.

2011-09-14 Thread Paul Johnson
, or $customer and $context depending on the size of their scope. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: hi

2011-09-14 Thread Paul Johnson
-4,3-5 1-6,2-5,3-4 Can anyone help me in this Unlikely, unless you are a bit more specific about what you are trying to do. And even then, it's hard to help you to improve your code if you don't show it. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail

Re: how good is Net::OpenSSH::Parallel in your experience

2011-09-10 Thread Paul Johnson
better strategy, but ultimately you'll need to try it for yourself and see if it does what you want. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: perl help

2011-09-09 Thread Paul Johnson
On Fri, Sep 09, 2011 at 12:11:04PM +0300, Shlomi Fish wrote: next if (!length($dist) or !length($cell) or !length($sect)); There's a better way using List::MoreUtils : For some definition of better. See also De Morgan. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net

Re: Basic Script Needed

2011-08-31 Thread Paul Johnson
or for a school assignment. Perhaps you are looking for mailshar, which is part of GNU sharutils? -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

  1   2   3   4   5   6   7   8   9   >