Re: use string in "use"

2020-12-15 Thread Chas. Owens
The use function happens at compile time and must take a bareword, but it is functionally equivalent to BEGIN { require Module; Module->import( LIST ); } And the require function allows you to pass a string, but be aware there are lots of differences in behavior when passing a string vs a barewor

Re: perl-5.32.0 - Failed test ''S' is set in PERL_UNICODE, or in -C, honor it, utf8 should be on'

2020-09-29 Thread Chas. Owens
The correct answer (as I am sure you know) is not to be using EOL software. That said you may be jumping too far forward with your Perl release. It looks like OpenSSL only requires 5.10 (from 2007) and you are trying to install 5.32 (from June). Your current system is only running 5.8.8 (which w

Re: covert perl code to binary

2019-01-17 Thread Chas. Owens
The author of that module is Reini Urban. He has a long standing feud with the Perl 5 Porters (the team that writes Perl). On Fri, Jan 11, 2019 at 11:05 AM Mike Flannigan wrote: > > > Thanks. > > My Strawberry install finally failed with > Stopping: 'install' failed for 'B::C'. > > I am running v

Re: covert perl code to binary

2019-01-17 Thread Chas. Owens
The only way to truly hide code is to not give the code to the person you don't want to see it. Even languages like C have decompilers. If you truly need to prevent people from seeing code, then your only real option is to run a server and distribute a client that connects to the server. If all y

Re: What hash function to use

2018-08-23 Thread Chas. Owens
It looks like https://metacpan.org/pod/Crypt::Password might implement Modular Crypt Format. On Thu, Aug 23, 2018 at 11:38 AM Chas. Owens wrote: > That prefix appears to for the modular crypt format (see below) and lets > the shadow file use different hashing functions for different pas

Re: What hash function to use

2018-08-23 Thread Chas. Owens
That prefix appears to for the modular crypt format (see below) and lets the shadow file use different hashing functions for different passwords. It is not part of the Bcrypt spec, but you should be able to just add it on. Does the password hash correctly otherwise? https://passlib.readthedocs.io

Re: regex to get the rpm name version

2018-07-27 Thread Chas. Owens
, $version, $build) = $s =~ m{ ^ (.*) # name - (.*) # version - ([0-9]+) # build [.] [^.]+ # os [.] [^.]+ \z # architecture }x; print "n $name v $version b $build\n"; } On Fri, Jul 27, 2018 at 9:14 AM Chas. Owens wrote: > I don't think a regex is the simplest and most maint

Re: regex to get the rpm name version

2018-07-27 Thread Chas. Owens
I don't think a regex is the simplest and most maintainable way to get this information. I think it is probably better to take advantage of the structure of the string to discard and find information: #!/usr/bin/perl use strict; use warnings; for my $s (qw/binutils-2.23.52.0.1-12.el7.x86_64 com

Re: about system() call

2018-07-24 Thread Chas. Owens
The first spawns a shell and can handle things like globs. This is less efficient, more powerful, and more dangerous (susceptible to code injection attacks) The second does not spawn a shell and therefore cannot handle globs. It is also less susceptible to code injection attacks. system "ls *.p

Re: Unfamiliar syntax

2018-07-20 Thread Chas. Owens
All of this is supposition since I can't see anything you haven't shown us. It sounds like this code is part of a larger program that is going to call do "EPrints"; which will bring the source of EPrints into the larger program. The $c variable is probably setup there. What the code in EPrin

Re: Net::XMPP::Client

2018-06-15 Thread Chas. Owens
Look at the SetMessageCallBacks method in Net::XMPP::Protocol. It lets you set the function to run when a message of a specific type comes in. On Fri, Jun 15, 2018 at 5:34 AM hw wrote: > On 06/15/2018 02:21 PM, Chas. Owens wrote: > > In Net::XMPP::Client it says > > > &g

Re: Net::XMPP::Client

2018-06-15 Thread Chas. Owens
In Net::XMPP::Client it says For a full list of high level functions available please see Net::XMPP::Protocol. In that documentation it says $Con = new Net::XMPP::Client(); # From $status = $Con->Connect(hostname=>"jabber.org"); # Net::XMPP::Client $Con->Send("XML"); On Fri, Jun 15, 2018, 03

Re: Read a huge text file in perl

2018-05-24 Thread Chas. Owens
A lot depends on the contents of "some task;". If the task does not leave stuff in memory for each iteration, then it is just taking a long time. If it does leave stuff in memory, then you could easily run out of memory. Also, a lot depends on the OS. For instance, the defaults for filesystems

Re: ssh::command

2018-02-13 Thread Chas. Owens
On Tue, Feb 13, 2018 at 1:19 AM Lancelot Mak wrote: > #!/usr/bin/perl -W > > use SSH::Command; > > $cmdln = `grep $ARGV[0] list.txt`; > chomp($cmdln); > ($cmdhost,$user,$pass) = split(':',$cmdln); > $p = `echo $pass|base64 -d`; > chomp($p); > > $cmdlog = ssh_execute( > host => $cmdhost, > usernam

Re: ssh::command

2018-02-13 Thread Chas. Owens
Can you simplify your code to a short program that had the issue and post it? Often the act of shortening the program reveals the problem on its own. On Mon, Feb 12, 2018, 22:37 Lancelot Mak wrote: > Hi all, > I am using SSH::Command module to do ssh stuff but it does not return > full reply

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

2018-01-29 Thread Chas. Owens
Luckily in these cases, the faster answer is also the clearest answer in either case. On Mon, Jan 29, 2018 at 5:32 PM Paul Johnson wrote: > On Sun, Jan 28, 2018 at 10:57:25PM +0000, Chas. Owens wrote: > > $#array is the index of the last element of @array, so it will be one > l

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

2018-01-28 Thread Chas. Owens
$#array is the index of the last element of @array, so it will be one less than scalar @array which is the number of elements in @array (since Perl arrays start with index 0). Therefore, to get the number of elements, you would need to add one to $#array, which makes scalar @array faster. To get th

Re: What is the substitute for $#?

2018-01-26 Thread Chas. Owens
Before it was removed, the docs say it was: The output format for printed numbers. This variable is a half-hearted attempt to emulate awk's OFMT variable. There are times, however, when awk and Perl have differing notions of what counts as numeric. The initial value is "%.ng", where n is the value

Re: Problem with perlbrew and LiteSpeed

2017-12-05 Thread Chas. Owens
Test one: does the file actually exist. It is possible that the user is different, or something else in the park is wrong Test two: are the permissions on the file and the directories leading up to the file correct. If the process can't see the file, then there will be a problem. Test three: Is

Re: alternative to feature 'signatures'?

2017-11-19 Thread Chas. Owens
What no one has said so far is the importance of using Carp when throwing errors related to how the function was called. The Carp module provides versions of warn (carp) and die (croak) that give the line and file where the call to the function occurred rather than the line of the carp or croak:

Re: Distinguish module loading error: Compilation fail vs. not existing

2017-11-17 Thread Chas. Owens
$_ =~ /Compilation failed in require/) { > say "compilation failed"; > } > elsif ($_ =~ /Can't locate .* in \@INC/) { > say "module not found"; > } > }; > > > Am 17.11.2017 um 18:06 schrieb Chas. Owens: > > This is probably th

Re: Distinguish module loading error: Compilation fail vs. not existing

2017-11-17 Thread Chas. Owens
This is probably the best technique to use. I would note that your code is not handling exceptions in the safest way. You can increase the safety of your code by saying: eval { autoload($module); 1; #force true value on success } or do { if ($@ =~ /Compilation failed in require/) {

Re: Perl invocations

2017-10-29 Thread Chas. Owens
Shawn Corey misstated the issue, it isn't that -w can't be turned off, the problem is that it is turned on globally rather than lexically. That is, it forces warnings onto modules that may have been designed to not use warnings: $ cat T.pm package T; sub foo { my $x = shift; # und

Re: do something when using Gtk3

2017-09-05 Thread Chas. Owens
Here is how one of the example programs access the Glib timeout: https://github.com/dave-theunsub/gtk3-perl-demos/blob/master/search_entry.pl#L126 I would have pointed to docs, but they don't seem to be as easy to find as they used to be in the Gtk1/Gtk2 days. On Tue, Sep 5, 2017 at 1:58 AM hw

Re: reading from (TCP) sockets

2017-08-12 Thread Chas. Owens
Sockets cannot tell you how much data will come in any language. You HAVE to rely on Content-Length, that is what it is for. Why do you think "It doesn´t seem wise to rely [it]"? It is not possible for a loop to both be blocking (which means it is using no CPU until signaled there is data) and u

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

2017-08-04 Thread Chas. Owens
> > What happens when you bless something in a module? > In Perl 5 an object is a reference that has been blessed (with a package name). The namespace of that package is used to find the methods associated with the object. If no methods can be found, then the @ISA package variable is checked to

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

2017-08-04 Thread Chas. Owens
On Fri, Aug 4, 2017 at 11:52 AM hw wrote: > > Often you will see a module that contains one package statement which > leads to the confusion. > > Huh? How many package statements is a module supposed to contain? > And doesn´t a package statement turn a module into a package? > No, package statem

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

2017-08-04 Thread Chas. Owens
On Fri, Aug 4, 2017 at 9:25 AM hw wrote: snip > Now I´m confused as to what is a module and a package. Both are files. > No, packages are not files. A package is created by a package statement: package Foo; If you do not explicitly create a package with a package statement, then you are in t

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

2017-08-03 Thread Chas. Owens
On Thu, Aug 3, 2017 at 3:29 PM hw wrote: > David Mertens wrote: > It is nonsense to logically negate a string, and it is nonsense to convert > undefined values into 'false'. Negating strings is a well defined operation in Perl 5. The following values in Perl 5 are false: undef, 0, 0.0, "", "0"

Re: Trap undefined barewords in subroutines

2017-08-02 Thread Chas. Owens
I believe your best bet is to use string eval instead of do and injecting "no strict qw/vars/;" into the code (to prevent your use strict from requiring the variables be declared). I would spend a bit of time trying to understand where these files come from and fixing that though. There has to be

Re: debug perl package

2017-07-17 Thread Chas. Owens
Perl has a built in debugger. You can say perl -d abc.pl And it will stop at the first executable line (ignoring BEGIN blocks and use statements). You can then step through or over the code. See https://perldoc.perl.org/perldebug.html or perldoc perldebug for more information. On Mon, Jul 17,

Re: Filehandle within foreach loop

2017-07-12 Thread Chas. Owens
That code will read each line from each file. The problem is likely in the part that says: #[process the lines & hash construction.] What are you doing there? On Wed, Jul 12, 2017 at 3:23 PM perl kamal wrote: > Hello All, > > I would like to read multiple files and process them.But we could r

Re: IPC::Open3 and output

2017-07-10 Thread Chas. Owens
2>&1") > > while > $pid=open3(undef,undef,$file,$cmdprog, @args) > > does not until you iterate over the FH > > thanks > > > > > > On 10 July 2017 at 07:13, Chas. Owens wrote: > >> On Sun, Jul 9, 2017, 19:37 Mike Martin wrote: >> >&

Re: IPC::Open3 and output

2017-07-09 Thread Chas. Owens
On Sun, Jul 9, 2017, 19:37 Mike Martin wrote: > Hi > I am trying to use Open3 to capture stderr and avoiding the shell ie: > my $str="-v 35 -i /data/Downloads/testinput.mp4 -c:v libx264 -preset fast > -crf 28 -g 25 -c:a libmp3lame -b:a 128000 -threads 4 -af volume=2.5 -vf > scale='352:trunc(o

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

2017-07-06 Thread Chas. Owens
On Thu, Jul 6, 2017 at 9:33 AM hw wrote: > False and true are genuinely numeric. You can´t say for a string > whether it is true or false; it is a string. > This is not a true statement in Perl. All values in Perl can be true or false. And the prototypical true and false values, PL_sv_yes and

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

2017-07-06 Thread Chas. Owens
On Thu, Jul 6, 2017 at 9:38 AM hw wrote: > Chas. Owens wrote: > > > > > > On Sat, Jul 1, 2017, 12:44 Shlomi Fish shlo...@shlomifish.org>> wrote: > > > > Hi Shawn! > > > > On Sat, 1 Jul 2017 11:32:30 -0400 > > Shawn H Corey m

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

2017-07-01 Thread Chas. Owens
On Sat, Jul 1, 2017, 12:44 Shlomi Fish wrote: > Hi Shawn! > > On Sat, 1 Jul 2017 11:32:30 -0400 > Shawn H Corey wrote: > > > !!$i which is !(!(0)) which is !(1) which is 0 > > > > I suspect !1 returns an empty string in scalar context. > !1 returns PL_sv_no (an internal scalar variable). It is

Re: [solved] Re: Module to extract patterns

2017-06-13 Thread Chas. Owens
Regexp")) { print "\t", $token->content, "\n"; next; } next unless $token->content eq "=~"; my $next_token = $token->snext_sibling; next if $next_token->content =~ m{^(?:[ms].|/)}; print "\t", $next_token->content, " at line ",

Re: [solved] Re: Module to extract patterns

2017-06-13 Thread Chas. Owens
Two notes: Firstly, $document->find will return undef if no regexes are found, not an empty arrayref, so you should say my $regex = $document->find('PPI::Token::Regexp') || []; or for my $expr ( @[ $regex || [] ] ) { or even print qq(\n$file :\n); if (my $regex = $document->find('PPI::Token:

Re: Time::HiRes output

2017-05-24 Thread Chas. Owens
You can use printf or sprintf to control the format, but what you are doing is called profiling and it is better to use an actual profiler. Take a look at Devel::NYTProf http://search.cpan.org/~timb/Devel-NYTProf-6.04/lib/Devel/NYTProf.pm https://www.perl.org/about/whitepapers/perl-profiling.html

Re: Getting a specific page using WWW::Mechanize

2017-04-25 Thread Chas. Owens
Are you using JavaScript to redirect the user to the sorry page? If so then WWW::Mechanise won't redirect. It doesn't understand JavaScript. Happily, there are drop in replacements for it that do: http://search.cpan.org/~oalders/WWW-Mechanize-1.84/lib/WWW/Mechanize/FAQ.pod#Which_modules_work_lik

Re: are state objects ok?

2017-04-24 Thread Chas. Owens
State variables are just like my variables but with a different lifetime, so it is safe (assuming it would be safe to use my variables that life for the lifetime of the program). In this case, what happens if you lose database access and then reconnect? What happens if you have two database handles

Re: why moose

2017-04-24 Thread Chas. Owens
The main benefits I see are 1. You have to write less code 2. Roles provide the benefits of multiple inheritance without the insanity 3. Introspection of Moose classes is easier 4. Type safety (which is really just points 1 and 3 again) The biggest one is 1. Moose is basically a declarative langu

Re: Scalar References - oxymoron?

2017-04-04 Thread Chas. Owens
On Mon, Apr 3, 2017 at 6:55 PM SSC_perl wrote: > Reading http://perldoc.perl.org/perlreftut.html I see it’s > possible to create a scalar reference. What situation would require > someone to create a reference to a scalar? I thought refs were only useful > for passing complex data struc

Re: how to recursion

2017-03-29 Thread Chas. Owens
On Tue, Mar 28, 2017 at 9:27 PM PYH wrote: > Hi, > > what's the better way to write a recursion in perl's class? > > sub my_recursion { > my $self = shift; > > if (...) { > $self->my_recursion; > } > } > > this one? > Define better. In general that is the right

Re: Calling Perl from AppleScript [SOLVED]

2017-03-07 Thread Chas. Owens
It is entirely possible that Applescript is intentionally changing directory to a temporary directory before executing external programs as a security measure. On Tue, Mar 7, 2017, 00:41 debt wrote: > Please disregard my last email. Apparently you have to supply > full paths (as Thomas

Re: Uninitialized Value, but It Isn't, so Why?

2017-03-02 Thread Chas. Owens
On Thu, Mar 2, 2017, 19:32 Shawn H Corey wrote: > On Thu, 2 Mar 2017 16:35:17 -0600 > Andy Bach wrote: > > Hah! "undef" is an uninitialized value ! > > $ perl -we 'if (not $interdest5) {$interdest5 = "";} print > "|$interdest5|\n"' > || > $ perl -we 'if (! $interdest5) {$interdest5 = "";} print

Re: multiple named captures with a single regexp

2017-03-01 Thread Chas. Owens
\w+\s/ && $s =~ /(?:\s+(\w+))/g; or (if you don't like using && like that) my @args = $s =~ /^\w+\s/ ? $s =~ /(?:\s+(\w+))/g : (); On Wed, Mar 1, 2017 at 9:34 AM X Dungeness wrote: > On Wed, Mar 1, 2017 at 2:52 AM, Chas. Owens wrote: > > Sadly, Perl will onl

Re: multiple named captures with a single regexp

2017-03-01 Thread Chas. Owens
Sadly, Perl will only capture the last match of capture with a qualifier, so that just won't work. The split function really is the simplest and most elegant solution for this sort of problem (you have a string with a delimiter and you want the pieces). All of that said, if you are willing to mod

Re: interesting regex delimiters

2017-02-24 Thread Chas. Owens
Be careful, it isn't actually a regex; it is a string that will be compiled to a regex. You can see one difference here: #!/usr/bin/perl use v5.20; use warnings; say "string matches:"; for my $s ("foo", "AfooZ") { say "\t$s: ", $s =~ "\Afoo\Z" ? "true" : "false"; } say "regex matches:"; for my

Re: Extra text printed by Data::Dumper

2017-02-03 Thread Chas. Owens
You are splitting on /,/ but your name and value are separated by a space. This means $var_name is being set to "database $database" not "database" and $var_value is undef (the undefined value). This whole routine is suspect though. What if you want to pass an array or a hash? You can't pass the

Re: application starter kit

2017-01-23 Thread Chas. Owens
module. In particular, look at the EXE_FILES section of its Makefile.PL and the modules layout. http://cpansearch.perl.org/src/MIYAGAWA/App-cpanminus-1.7042/Makefile.PL On Mon, Jan 23, 2017, 04:44 Luca Ferrari wrote: > On Mon, Jan 23, 2017 at 10:39 AM, Chas. Owens > wrote: > > I t

Re: application starter kit

2017-01-23 Thread Chas. Owens
I think you are saying you want to be able to create one file you can give to someone else and have them run a Perl 5 program you have written without having to install all of the modules (and possibly even perl itself). If this is the case, then you are in luck. There are a couple of solutions t

Re: How to get a called perl script to write output to a file with DIFFERENT user:group than the calling app?

2017-01-15 Thread Chas. Owens
snip > So I guess the question is - > > - is there a way in perl to authorize the callED perl script to have > higher perms than the callING app's, so that it can write to the file I'm > targeting? > > Or do I have to to this OUTSIDE of the perl script? > The short answer is that this is OS depen

Re: script that passes args to subroutine works ok, after I unpack the args. But perlcritic says I'm not unpacking?

2017-01-15 Thread Chas. Owens
On Sun, Jan 15, 2017, 16:19 wrote: Hi, On Sun, Jan 15, 2017, at 01:01 PM, Shawn H Corey wrote: > > Is there a different, recommended way? > > Nothing's wrong. perlcritic does not this valid method, that's all. > > TIMTOWTDI (There Is More Than One Way To Do It.) Hm, ok. As long as it's not wro

Re: dereferencing an object

2016-11-08 Thread Chas. Owens
On Tue, Nov 8, 2016 at 5:38 AM wrote: > Hi, > > Yes, I was using a ref with my dumper. When i don't do that I don't get > $VAR1 = \{ . > I am still getting an error when I dereference. > > my $name = ${$hash_ref_decode}->{items}[0]{content}; snip This says dereference $hash_ref_decode as a

Re: api request

2016-10-12 Thread Chas. Owens
Looking at the documentation for curl, it says: -d/--data (HTTP) Sends the specified data in a POST request to the HTTP server, in the same way that a browser does when a user has filled in an HTML form and presses the submit button. This will cause curl to pass the data to the server using the c

Re: Counting elements returned from expression

2016-10-05 Thread Chas. Owens
is the same: only the last item in a sequence returns its value. On Wed, Oct 5, 2016 at 4:34 PM khalil zakaria Zemmoura < zemmoura.kha...@gmail.com> wrote: > I think I had a problem with my approach. I never thought about assignment > operator as returning something at all ! >

Re: Counting elements returned from expression

2016-10-04 Thread Chas. Owens
t it > self. When in scalar context, it's the number of elements of that list > (it is empty but stored the number of all the elements returned by > get_hats_clone() > > since we are using scalar context with $s = (), then we get the number > of all the elements. > >

Re: Re-exec in perl

2016-10-04 Thread Chas. Owens
000 > "Chas. Owens" wrote: > > > It looks like the problem exists at the C level as well. This code > > doesn't work past the first alarm: > > Doesn't it say the alarm has to be reset by the code in the > documentation? After all, you don't want

Re: Re-exec in perl

2016-10-04 Thread Chas. Owens
char*)argv[1]); } printf("run %d\n", n); n++; snprintf(s, 10, "%d", n); signal(SIGALRM, handle_alrm); alarm(1); sleep(3); if (alarm_called) { execv(prog, (char*[]) { prog, s, NULL }); } alarm(0); return 0; } On Tue, Oct 4, 2016 at 10:40 AM Chas. Owens wrote: > Firs

Re: Re-exec in perl

2016-10-04 Thread Chas. Owens
First, never use -w flag to enable warnings; use the warnings pragma instead. Second, you should not exec the script directly, you don't know if it is executable or not, and it could even wind up running under a different version of perl. Instead, you should exec same the interpreter that is runn

Re: Counting elements returned from expression

2016-10-04 Thread Chas. Owens
On Mon, Oct 3, 2016 at 10:45 PM Lawrence Statton wrote: snip > the =()= "operator" just does that without creating a temporary variable snip Almost, but not quite. You can see the difference when =()= is in list context: my @a = (my @temp) = get_clown_hat; my @b = () = get_clown_hat; @a will

Re: Counting elements returned from expression

2016-10-03 Thread Chas. Owens
So, list assignment is my ($foo, $bar, $baz) = ("a", "b", "c"); $foo will be "a", $bar will be "b", etc. There can be more items on the right hand side and they won't be copied. This operation has a return value. In list context it is the list of values that got assigned. In scalar context it is

Re: DBI and field type 'bit'

2016-10-01 Thread Chas. Owens
The URL for the bug report is https://rt.cpan.org/Ticket/Display.html?id=118207&results=52bad5c05e442e5750731e7011056012 On Sat, Oct 1, 2016 at 11:44 AM Chas. Owens wrote: > Poking around in the source, it does not appear to be well tested WRT bind > variables (see the test file below

Re: DBI and field type 'bit'

2016-10-01 Thread Chas. Owens
k (my $result = $sth->fetchall_arrayref); ok defined($result), "result returned defined"; is $result->[0][0], 1111, "should be "; is $result->[1][0], 1010, "should be 1010"; is $result->[2][0], 101, "should be 101"; ok ($sth->fini

Re: DBI and field type 'bit'

2016-10-01 Thread Chas. Owens
Whoops, meant to include links for the docs to those two functions: http://perldoc.perl.org/functions/pack.html http://perldoc.perl.org/functions/vec.html On Sat, Oct 1, 2016 at 11:31 AM Chas. Owens wrote: > DBD::mysql is treating 1 and 3 as their ASCII values on insert due to > quoting

Re: DBI and field type 'bit'

2016-10-01 Thread Chas. Owens
DBD::mysql is treating 1 and 3 as their ASCII values on insert due to quoting. You need to create values that are bit fields themselves. This being Perl, there are lots of ways of doing that: $dbh->do("create table bittest (lilbits bit(8))"); my $insert = $dbh->prepare("insert into bittest valu

Re: Data type of attributes

2016-09-29 Thread Chas. Owens
This is what the meta object is for: #!/usr/bin/perl { package Foo; use Moose; use warnings; has num => ( is => "rw", isa => "Int" ); has str => ( is => "rw", isa => "Str" ); } use strict; use feature "say"; use warnings; my $foo = Foo->new; for my $attr ("num"

Re: Remove Newlines from String

2016-09-09 Thread Chas. Owens
On Tue, Sep 6, 2016 at 3:24 PM Shawn H Corey wrote: > > #Change the value to the maximum you want > > my %HEXCODES = map{$_ => sprintf("%03X", $_)} (0..128); > > my %HexCodes = map { ord($_) => sprintf '%02X', $_ } ( 0 .. 128 ); > Just your friendly reminder that Unicode exists and unless y

Re: solved: Net::FTP ALLO --- and how to advise functions in perl

2016-08-20 Thread Chas. Owens
{CODE} *Fully::Qualified::sub_name = sub { #do stuff before $old->(@_); #do stuff after }; } On Sat, Aug 20, 2016, 05:44 hw wrote: > Chas. Owens schrieb: > > If you want to get rid of ALLO completely, it looks like you just need > to monkeypatch Net::FTP::_ALLO to r

Re: if element exists in an array

2016-08-19 Thread Chas. Owens
On Fri, Aug 19, 2016 at 2:22 PM Chas. Owens wrote: > Truth. If you are checking in lots of things exist a hashset might be a > better way to go: > > my %hashset = map { ($_ => undef) } (3,1,4,2,9,0); > > my $found = exists $hashset{4} || 0; > my $not_found = exists $

Re: if element exists in an array

2016-08-19 Thread Chas. Owens
enet.de, wrote: > > Thanks for all the replies. > Yes I found List::Util is a useful toolset. > > > On 2016/8/19 10:00, Chas. Owens wrote: > > The any function from List::Util will also do what you want. > > perldoc List::Util > > http://perldoc.perl.org/List/Util.h

Re: Net::FTP ALLO --- and how to advise functions in perl

2016-08-19 Thread Chas. Owens
2016 at 1:13 PM hw wrote: > Chas. Owens schrieb: > > Based on a cursory reading of the perldoc, it looks like the ALLO > command is only sent if you call the Net::FTP::alloc method. If you aren't > calling it, can you provide a toy test case for us where the code sends &g

Re: Net::FTP ALLO

2016-08-19 Thread Chas. Owens
Based on a cursory reading of the perldoc, it looks like the ALLO command is only sent if you call the Net::FTP::alloc method. If you aren't calling it, can you provide a toy test case for us where the code sends ALLO. I will try to debug why it is sending a command you aren't asking for. If you

Re: if element exists in an array

2016-08-18 Thread Chas. Owens
On Thu, Aug 18, 2016 at 9:39 PM wrote: > Hello, > > What's the better way to decide if an element exists in an array? > Something like what ruby does, > > irb(main):001:0> x=[3,1,4,2,9,0] > => [3, 1, 4, 2, 9, 0] > irb(main):002:0> x.include? 4 > => true > irb(main):003:0> x.include? 10 > => fals

Re: XML::Simple Umlaute

2016-08-09 Thread Chas. Owens
{df}"' On Tue, Aug 9, 2016 at 7:34 AM hw wrote: > Chas. Owens schrieb: > > > > On Thu, Jul 28, 2016 at 10:55 AM Paul Johnson p...@pjcj.net>> wrote: > > > > On Thu, Jul 28, 2016 at 10:23:19AM -0400, Chas. Owens wrote: > > > > snip > >

Re: XML::Simple Umlaute

2016-07-28 Thread Chas. Owens
On Thu, Jul 28, 2016 at 10:55 AM Paul Johnson wrote: > On Thu, Jul 28, 2016 at 10:23:19AM -0400, Chas. Owens wrote: snip > > Also, this answer on StackOverflow by tchrist (Tom Christiansen, who I > > would say knows the most about the intersection of Perl and Unicode) > &g

Re: XML::Simple Umlaute

2016-07-28 Thread Chas. Owens
outube.com/watch?v=X2FQHUHjo8M 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 Hope this helps. -- Chas. Owens http://github.com/cowens T

Re: XML::Simple Umlaute

2016-07-28 Thread Chas. Owens
Data::Dumper is dumping the internal format. To ensure compatibility, it is using the \x{df} escape to represent LATIN SMALL LETTER SHARP S. To see it rendered as a character, just print it: #!/usr/bin/perl use strict; use feature 'say'; use XML::Simple; #warnings should come last to handle an

Re: DBI.c: loadable library and perl binaries are mismatched

2016-06-30 Thread Chas. Owens
That typically occurs when the XS portion of a Perl module was compiled against a different version of perl. Since you say that you re-installed everything, then it is possible you are loading a module from a different location than you think you are. Try running this command: perl -le 'for (@IN

Re: Excessive wait time after fork

2011-04-04 Thread Chas. Owens
bytes and each value is probably around four bytes (if not eight). You have 165,000,006 entries. That means you need around 3 gigabytes of RAM for the data alone. That doesn't count the hash that holds the data, perl itself, or any other programs you may be running. -- Chas. Owens wonkde

Re: transposing %d values to %x output

2011-03-30 Thread Chas. Owens
On Wed, Mar 30, 2011 at 00:28, Brian Fraser wrote: > On Wed, Mar 30, 2011 at 12:46 AM, Chas. Owens wrote: >> >> If you are dealing exclusively with ASCII, then you should be using >>  the [bytes][0] pragma; > > It's nitpicky, but I'd advice against ever reco

Re: transposing %d values to %x output

2011-03-29 Thread Chas. Owens
By your logic, it is perfectly fine to use . to match numbers. After all, . will match [0-9]. If you have bothered to specify \d, you most likely mean [0-9]. [0]: http://perldoc.perl.org/bytes.html -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: transposing %d values to %x output

2011-03-29 Thread Chas. Owens
$2, $3, $4/e; [0]: http://perldoc.perl.org/perlop.html#s%2fPATTERN%2fREPLACEMENT%2fmsixpogce [1]: http://perldoc.perl.org/functions/sprintf.html -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: beginners-unsubscr...@per

Re: problem with naming of variables

2011-03-29 Thread Chas. Owens
me}; Symbolic references are incredibly dangerous and mostly unnecessary in Modern Perl. This is why the [strict pragma][0] bans their use. The proper solution is to use the correct data structure (in this case an array of arrays). [0]: http://perldoc.perl.org/strict.html -- Chas. Owens wonkden.n

Re: problem with naming of variables

2011-03-28 Thread Chas. Owens
formidable, you may want to start with: perldoc perlreftut or http://perldoc.perl.org/perlreftut.html. -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: perl dd

2011-03-28 Thread Chas. Owens
n"; open my $out, ">:raw", $ARGV[1] or die "could not open $ARGV[1]: $!\n"; local $/ = \4096; #read 4k at a time print $out $_ while <$in>; -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To uns

Re: assigning hash to a scalar

2011-03-27 Thread Chas. Owens
n is incredibly naive and inefficient. This was the just the bare minimum needed to understand the meaning of a hash's scalar value. -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org F

Re: assigning hash to a scalar

2011-03-26 Thread Chas. Owens
[0]: http://en.wikipedia.org/wiki/Md5 [1]: http://en.wikipedia.org/wiki/Sha1 [2]: http://en.wikipedia.org/wiki/Jenkins_hash_function#one-at-a-time [3]: http://en.wikipedia.org/wiki/Modulo_operation [4]: http://en.wikipedia.org/wiki/Hash_table -- Chas. Owens wonkden.net The most important skill a

Re: ternary operator

2011-03-25 Thread Chas. Owens
ded } $dist = ( length( $dist ) > 1 ) ? round($dist/6.6/8/2*10/10, 1) : 0; -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Garbled lines

2011-03-24 Thread Chas. Owens
Perl problem or could this be a buffer problem on the AIX server? snip Without seeing the code, or at least being told how you are writing to the file (for instance, are you writing to a named pipe that is being read by another program), it is nearly impossible to give you any hints about what is

Re: foreach loop

2011-03-23 Thread Chas. Owens
emory you expect. Perl doesn't tend to return memory to the system, so, even though no variable is using it, the memory used to hold the list will still be held by perl. Happily, perl will reuse the memory, so, as long as it isn't huge, it normally isn't a big deal. -- Chas. Ow

Re: Need Help. .Issue with format statement

2011-03-23 Thread Chas. Owens
lt;<<<<<<< "Main Body" . write DURATION; } You could also fix it with fewer steps by dup'ing STDOUT to DURATION if you weren't already opening DURATION: #!/usr/bin/perl use strict; open DURATION, ">&", \*STDOUT or die $!; &genRep(); sub genRep { format DURATION_TOP = @<<<<<<<<<<<<<<<<<<<<<<<<<<< "This is TOP" --- . format DURATION = @<<<<<<<<<<<<<<< "Main Body" . write DURATION; } -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Better Regrex

2011-03-23 Thread Chas. Owens
nings; my $message = "Why are we here? To bless, inspire and uplift one another. #TRB #inspiration #loa"; my @markers = $message =~ /#(\S+)/g; $message =~ s/\s*#\S+\s*//g; print "[$message]\nmarkers: ", join(", ", @markers), "\n"; -- Chas. Owens wonkden.net Th

Re: Error Netcdf

2011-03-18 Thread Chas. Owens
11442' > ncopen: filename "test.nc": NetCDF: Unknown file format snip There is no where near enough information to diagnose your problem, but I would say that the file test.nc does not contain what you think it does. -- Chas. Owens wonkden.net The most important skill a programme

Re: input file

2011-03-17 Thread Chas. Owens
epath or die "Could not open $filepath: $!"; #this is the best way, it is safe and $infile is scope to the enclosing block open my $infile, "<", $filepath or die "Could not open $filepath: $!"; You can read more in http://perldoc.perl.org/functions/open.html or perldoc -f open -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: sort results in ascending order

2011-03-17 Thread Chas. Owens
elpful: http://perldoc.perl.org/perlreftut.html http://perldoc.perl.org/perlref.html http://perldoc.perl.org/perldsc.html or perldoc perlreftut perldoc perlref perldoc perldsc -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mai

Re: Out of Memory!

2010-10-13 Thread Chas. Owens
://perldoc.perl.org/Scalar/Util.html#weaken-REF -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: No Output in Terminal

2010-10-01 Thread Chas. Owens
On Fri, Oct 1, 2010 at 18:56, Brandon McCaig wrote: > On Fri, Oct 1, 2010 at 1:07 AM, Chas. Owens wrote: > >> Okay, here is what I think happened: you were print a carriage return. > > I thought that Mac OS X used UNIX newlines though (though I'm not a > Mac user)

  1   2   3   4   5   6   7   8   9   10   >