Re: Are there any ALSA Perl Modules?

2024-01-29 Thread Shlomi Fish
hi Martin,

On Mon, 29 Jan 2024 22:38:27 -0600
"Martin McCormick"  wrote:

> Shlomi Fish  writes:
> > hi Martin,
> > you can try using an FFI, eg:
> > 
> > https://metacpan.org/dist/Inline-C/view/lib/Inline/C.pod
> > 
> > https://metacpan.org/dist/Inline-Python/view/Python.pod
> > 
> > https://metacpan.org/pod/FFI::Platypus  
> 
> Many thanks.  I am glad I asked the question but it has taken me
> some time to digest your answer as I wasn't familiar with the
> term FFI so, after exercising duckduckgo, I now know those
> letters stand for Foreign Function Interface which makes perfect
> sense based on what needs to be done.  Unfortunately, FFI's are
> usually used by higher-level languages to take advantage of the
> capabilities found in lower-level languages such as C which is
> closer to assembler and can efficiently access the hardware such
> as an audio or video device.
> 

I meant that you can use Inline::C or perlxs or similar to write
wrappers/bindings for libalsa/etc.

>   I was hoping there might be a perl module like a
> fictional one I will call Device::ALSA which would understand the
> syntax used in capturing audio from a microphone or line input,
> like a microphone input, only not as sensitive, where one
> customarily feeds sound from the output of whatever one is
> recording from.
> 
>   There are standard alsa conventions for setting sample
> rate and other parameters which I mentioned in the earlier
> posting so if one knows what sort of digital stream they nead,
> they just stuff those values in to the function whose output is
> that stream of digital  data.  What you do with those data is up
> to you but the module takes care of getting the bits from the
> hardware or sending the bits to your speakers or headphones and
> would also support the alsa plugins which are used by the arecord
> and aplay utilities for added capabilities.
> 
>   I can understand why there is no perl module like
> Device::alsa because it would not be portable between Windows and
> Linus.  The l in alsa is for Linux so basically, I was just
> curious to see if anything like Device::ALSA existed and it
> apparently does not exist.
> 

Devs *have* written linux-only or mswindows-only perl5/CPAN modules.

>   Anyway, the FFI concept will probably someday come in
> handy for a different project so I will continue with the C I was
> working on.
> 
>   Thanks again.
> 
> Martin
> 



-- 

Shlomi Fish   https://www.shlomifish.org/
https://www.shlomifish.org/open-source/resources/tech-tips/

XSLT isn't like violence. XSLT is violence - there is no such thing as using
it too little.
— https://www.shlomifish.org/humour/bits/facts/XSLT/

Please reply to list if it's a mailing list post - https://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Are there any ALSA Perl Modules?

2024-01-28 Thread Shlomi Fish
hi Martin,

On Sun, 28 Jan 2024 13:27:45 -0600
"Martin McCormick"  wrote:

> Several years ago, I wrote some C code which turns one's
> computer's sound interface in to a sound-activated recorder that
> I could then connect to radio receivers or microphones and record
> when audio started and stop recording when there is nothing but
> silence.  One essentially sets a sound card to record
> continuously but the sound samples go through code that knows
> what silence looks like.  In short, silence looks like samples
> whose numeric value is exactly half-way between the lowest and
> highest voltage that the analog-to-digital converter reads,
> commonly either 32,767 representing silence, give or take a count
> or two due to digital sampling errors or decimal 128, hex 80 for
> 8-bit mono audio.
> 
>   The Advanced Linux Sound Architecture Project has C library
> functions for setting sample rates, mono, stereo, big or little
> endianness and 8 or 16-bit audio, whatever one needs for their
> application.  One can even define samples as signed or unsigned
> integers.
> 
>   Once one gets a stream of ints which are usually 32-bits
> wide for stereo or 16-bit shorts for mono, the sound processing
> can begin which C is really good at but perl is just as good at
> so if one could get the same alsa modules which are used by aplay
> and arecord for setting up one's audio interfaces or sound cards,
> the manipulation of those data that was done in C could also be
> done in perl without hardly any modification to it at all.
> 
>   Perl has just the right mix of low-level logic and
> bitwise operators plus a much more easy-to-use string handling
> capability which is why I am asking this question.
> 
>   I may be looking in the wrong places but, so far, I seem
> to be batting zeros when looking for perl and alsa together.
>

you can try using an FFI, eg:

https://metacpan.org/dist/Inline-C/view/lib/Inline/C.pod

https://metacpan.org/dist/Inline-Python/view/Python.pod

https://metacpan.org/pod/FFI::Platypus
 
>   Any good ideas are greatly appreciated, here.
> 
>   Martin McCormick
> 



-- 

Shlomi Fish   https://www.shlomifish.org/
Selina Mandrake - The Slayer (Buffy parody) - https://shlom.in/selina

If the miller travelled to the market with Emma, they would have each rided
their own donkey. Problem solved.
— https://www.shlomifish.org/humour/bits/facts/Emma-Watson/

Please reply to list if it's a mailing list post - https://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Knowledge for a basic programmer and advanced programmer

2024-01-02 Thread Shlomi Fish
On Sat, 16 Dec 2023 08:10:49 -0600
William Torrez Corea  wrote:

> What needs to know a basic and advanced programmer?
> 
> I am a basic programmer, I don't have enough experience to be an advanced
> programmer.
> 
> How many years of experience must an advanced programmer have?
> 

hi William,

I answered many of your questions in the FAQs I comaint. List here:

https://www.shlomifish.org/meta/FAQ/which_faqs_do_you_comaint.xhtml

-- 

Shlomi Fish   https://www.shlomifish.org/
Parody of "The Fountainhead" - https://shlom.in/towtf

Golden rule #12: When the comments do not match the code, they probably are
both wrong. ;)  — Steven Rostedt, https://lwn.net/Articles/433900/

Please reply to list if it's a mailing list post - https://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Performance Issue

2023-06-16 Thread Shlomi Fish
hi,

On Fri, 16 Jun 2023 10:37:07 +0200
LEROYER Benoit  wrote:

> Hello,
> I am usually used perl 5 on Centos system and I  recently installed a Rocky
> Linux system. When I execute an important perl program on Centos 7 it is
> very fast but the same program on Rocky Linux 8 is very slow. The server
> hardware is similar (RAM / Speed disk, CPU ...)
> Have you some ideas about this issue ?
> 

please see:  https://perl-begin.org/topics/optimising-and-profiling/ .

> Perl Version on Rocky Linux 8 is 5.26
> Perl Version on Centos 7 is 5.16
> 
> Thanks



-- 

Shlomi Fish   https://www.shlomifish.org/
https://www.shlomifish.org/humour/Summerschool-at-the-NSA/

Gödel’s Incompleteness Theorem is about to be replaced by the
[Clarissa] Darling “Like, Totally!” Completeness Theorem.
— https://www.shlomifish.org/humour/bits/facts/Clarissa/

Please reply to list if it's a mailing list post - https://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Recommendations for setting up local Perl dev environment

2023-05-23 Thread Shlomi Fish
hi all,

On Wed, 24 May 2023 09:25:46 +0800
Ken Peng  wrote:

> On 2023-05-24 09:21, Joe Sliva Jr. wrote:
> > I've been on this list for years but haven't actually used Perl lately.
> > That being said, I have an old Perl script that I would like to start
> > working with again but would prefer to work on it within a local dev
> > environment.
> > 
> > Can anyone please recommend a local Perl dev install that would work on
> > Windows?  
> 
> Maybe this one?
> https://strawberryperl.com/
> 

strawberry perl is FOSS and decent. but note that it seems like windows will
become more GNU-like:
https://www.shlomifish.org/humour/bits/facts/Windows-Update/#see_also

-- 

Shlomi Fish   https://www.shlomifish.org/
Parody of "The Fountainhead" - https://shlom.in/towtf

"Consistency requires you to be as ignorant today as you were a year ago."
— Bernard Berenson, https://en.wikiquote.org/wiki/Consistency

Please reply to list if it's a mailing list post - https://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: json to disk

2023-05-23 Thread Shlomi Fish
hi, Tom,


On Tue, 23 May 2023 11:53:25 +0800
"Tom Reed"  wrote:

> Hello list,
> 
> How can I sync json object to disk? so that other processes (or next
> startup) can use this json.
> 

see https://metacpan.org/pod/JSON::MaybeXS ; make sure to use 'canonical'.

> Thanks.
> 
> 



-- 

Shlomi Fish   https://www.shlomifish.org/
First stop for Perl beginners - https://perl-begin.org/

Chuck Norris makes sure his ciphers are unbreakable by killing all the crypto
experts that could possibly break them.
— https://www.shlomifish.org/humour/bits/facts/Chuck-Norris/

Please reply to list if it's a mailing list post - https://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: How to can develop a program

2022-08-01 Thread Shlomi Fish
Hi William!

On Mon, 1 Aug 2022 14:50:21 -0600
William Torrez Corea  wrote:

> On Mon, Aug 1, 2022 at 8:16 AM Christian Walde 
> wrote:
> 
> > On Sat, 23 Jul 2022 21:03:18 +0200, William Torrez Corea <  
> > willitc9...@gmail.com> wrote:  
> >
> > My goal: I want to create
> >
> >
> > Being that you barely know anything about Perl, you should start with
> > learning how Perl works by reading Modern Perl and Ovid's Beginning Perl.
> >
> > Right now you're doing the moral equivalent of asking how to draw Mona
> > Lisa's eye when you don't even know which end of a paint brush paints.
> >
> > --
> > With regards,
> > Christian Walde
> >  
> 
> Do you have some roadmap that I can follow?. I receive the basics in my
> class of computation (control structure, data structure, algorithms,
> syntax, tools). I certainly have experience with C but never I make a long
> program in Perl.

see:

1. https://perl-begin.org/

2.
https://github.com/shlomif/Freenode-programming-channel-FAQ/blob/master/FAQ_with_ToC__generated.md

3. https://perl-begin.org/FAQs/freenode-perl/

welcome aboard!

-- 

Shlomi Fish   https://www.shlomifish.org/
https://www.shlomifish.org/humour/bits/facts/Emma-Watson/

“You are banished! You are banished! You are banished!
Hey! I’m just kidding!”
— https://www.shlomifish.org/humour.html

Please reply to list if it's a mailing list post - https://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Which distribution of PERL to use

2022-07-05 Thread Shlomi Fish
hi all,

On Mon, 4 Jul 2022 20:06:55 -0500
Mike  wrote:

> Strawberry Perl would be my preference if it works.
> 
> 

I agree that strawberry Perl is recommended.

See https://perl-begin.org/learn/Perl-perl-but-not-PERL/ though.

> Mike
> 
> 
> On 7/4/22 19:52, Mr. Faiz Ul Haq Zia wrote:
> > Hello,
> >   Which one of the PERL distribution should I use on windows 11.
> > regards
> > Faiz ul haque Zeya
> > Senior Associate professor BUKC  
> 



-- 

Shlomi Fish   https://www.shlomifish.org/
https://www.shlomifish.org/lecture/C-and-CPP/bad-elements/

When Chuck Norris uses git, he takes a coffee break after initiating every git
commit. And then he waits for the commit to finish.
— https://www.shlomifish.org/humour/bits/facts/Chuck-Norris/

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: A Philosophical Point To Be Made: The Truth

2021-10-26 Thread Shlomi Fish
Hi Brandon!

On Sun, 17 Oct 2021 01:15:13 -0400
Brandon McCaig  wrote:

> Hello All,
> 
> It has been a while. I haven't been active on the list in years.
> Something much bigger has been stealing my focus. And now I think
> I might be ready to share it with the world.
> 
> Do be warned, I make best efforts to be inclusive of all, but I
> only know what I know. But if I'm right I have the answer to all
> of this for all of us.
> 
> https://castopulence.org/
> 
> To summarize, I think I know what the "correction" to
> insensitivity is. A better social network. Based upon the truth.
> 
> I wonder too if the Perl developers themselves might be
> interested in this discussion because of its relationship to
> linguistics and software. Though I dare not try to send it their
> way directly without a push (and maybe a direction).
> 
> Feedback, constructive or otherwise, is welcomed and encouraged.
> 

After reading that page, I still don't understand how the issue manifests
itself as well as how the proposed solution will be implemented. Perhaps try
giving concrete examples.

> Regards,
> 
> 
> 
> Brandon McCaig   <
> bamb...@castopulence.org>  
> Castopulence Software <https://www.castopulence.org/>
> Blog <https://www.bambams.ca/ <http://www.bambams.ca/>>
> perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }.
> q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.};
> tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say'



-- 

Shlomi Fish   https://www.shlomifish.org/
Beginners Site for the Vim text editor - https://vim.begin-site.org/

Buddha has the Chuck Norris nature.
— https://www.shlomifish.org/humour/bits/facts/Chuck-Norris/

Please reply to list if it's a mailing list post - https://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: socket recive problem

2021-04-04 Thread Shlomi Fish
On Fri, 2 Apr 2021 13:46:35 -0400
Uri Guttman  wrote:

> On 4/2/21 4:47 AM, stefano cerbioni wrote:
> > hi i try to recive  a stream string  by  a client (write in C++) , if 
> > i use netcat ,  work ok but  when i use a  script in perl work 
> > partially , recive "Connection recieved from $name\n";,  but  $name 
> > is  blank , why ?? thanks
> > this is a script
> >  
> 
> don't use low level socket stuff as it is tricky to get correct. use the 
> IO::Socket module as it is correct and very easy to use.
> 

I agree. See:

* https://perl-begin.org/uses/multitasking/ ( IO::Async / etc.)

* https://metacpan.org/pod/IO::Socket and
https://metacpan.org/pod/IO::Socket::IP .

> uri
> 
> 



-- 

Shlomi Fish   https://www.shlomifish.org/
Emma Watson Factoids - https://shlom.in/emwatson-facts

Sarah: Tell you what, Ken? Why not come to the diner, and I’ll pay for your
food and drinks. I’ve been earning quite a lot of cash from tips. You can tell
us stories from this dimension of evil of yours.
— https://www.shlomifish.org/humour/Buffy/A-Few-Good-Slayers/

Please reply to list if it's a mailing list post - https://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: perl's pulsar client

2021-01-26 Thread Shlomi Fish
Hi Wesley!

On Wed, 27 Jan 2021 09:09:06 +0800
"Wesley Peng"  wrote:

> I saw apache pulsar has many clients in other languages such as python's:
> http://pulsar.apache.org/docs/en/client-libraries-python/
> 
> But it lacks a perl client library.
> Would anyone have the plan to make one?
> 
> Thanks.

See:

* https://metacpan.org/pod/distribution/Inline-Python/Python.pod

* http://shlomifishswiki.branchable.com/Self-Sufficiency/ :

* * “If I am not to myself, who will be? And if I am only to myself, who am I?
And if not now - when?” -- Hillel the Elder

* * https://www.cpan.org/misc/cpan-faq.html

If you want, you can pay someone to do the work for you. I charge 50 USD /
hour and abide by
https://www.shlomifish.org/humour/fortunes/show.cgi?id=shlomif-multiply-by-pi
, but there are other contractors you can hire.

-- 

Shlomi Fish   https://www.shlomifish.org/
The Case for File Swapping - https://shlom.in/file-swap

The Chuck Norris of the Buffyverse, has been secretly training under Buffy’s
supervision, and so far - lost every battle with her.
— https://www.shlomifish.org/humour/bits/facts/Buffy/

Please reply to list if it's a mailing list post - https://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: question about change text in frame

2020-12-01 Thread Shlomi Fish
Hi Stefano!

On Sun, 29 Nov 2020 18:49:13 +0100
stefano cerbioni  wrote:

> Hi guys i find in internet  but nothing  , how  is possible change a text
> inside a frame ??
> 
> example i have this frame
> 

Please go over these documents:

* https://github.com/shlomif/how-to-share-code-online

* https://github.com/shlomif/writing-the-perfect-question

Non-runnable / not self-contained fragments make it hard for us to help you.

> 
> my $labeled_frame2 = $mw->LabFrame(-label => "FRAME",-labelside =>
> "bottom")->pack(-fill => "x");
> $labeled_frame2->Label(-text => "de ma de")->pack();
> 
> 
> i try
> with this
>  $labeled_frame2->configure (-text=>"BaoBABB");
> $mw->update();
> 
> but if is a simple  label like this :
> $mw->Label(-text => 'ciao')->pack(-anchor => 'nw');
> work but  in frame not  anyone  has an idea ?? thanks  in advice at all
> ciao



-- 

Shlomi Fish   https://www.shlomifish.org/
https://youtu.be/n6KAGqjdmsk - “Hurt Me Tomorrow”

   rindolf: yeah because Perl’s crypt() is TOTALLY different from all
the other crypt()s. ;)
   Su-Shee: crypts are like snowflakes - no one alike.
  * rindolf has a huge and comprehensive collection of crypts on his disk.

Please reply to list if it's a mailing list post - https://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: IO::Socket::Multicast::mcast_send

2020-04-05 Thread Shlomi Fish
Hi James,

On Sun, 5 Apr 2020 14:58:26 +0100
James Kerwin  wrote:

> Hi All,
> 
> I'm trying to connect to a smart bulb on my home WIFI using mcast_send
> in IO::Socket::Multicast.
> 
> It works on my main Linux Mint laptop. The same script does not work on my
> Raspberry PI.
> 
> Despite the script running as expected on one laptop I've checked that this
> is all set up correctly:
> 
> sub new {
> #my $class = shift;
> my $data  = {
> address => '239.255.255.250',
> port=> 1982,
> timeout => 3,
> devices => [],
> };
> return bless( $data );
> }
> 

It is a good idea to use bless with an explicit package name or just use
https://metacpan.org/pod/Moo or Moose or similar.

> my $socket = IO::Socket::Multicast->new(
> PeerAddr  => $self->{address},
> PeerPort  => $self->{port},
> Proto => "udp",
> ReuseAddr => 1,
> ) or croak $!;
> 
> But it's this part that fails on the PI:
> 

A few things to check:

1. Which OS/distro/version and perl version  on both machines?

2. Does it happen with the latest stable perl installed from source?

3. Did you try using https://en.wikipedia.org/wiki/GDB and/or perl -d:
https://perl-begin.org/topics/debugging/ ?

4. Is there anything in the rpi's firewall config?

For more advice, see https://github.com/shlomif/writing-the-perfect-question .

> $socket->mcast_send( $query, "$self->{address}:$self->{port}" ) or croak $!;
> 
> I've checked that $socket, $query and $self->{address}:$self->{port}
> contain the info I expect and they do.
> 
> On my Linux laptop I can use tcpdump and see the communication between
> laptop and bulb. Doing this on the Pi shows no communication. I've replaced
> the "croak" with "die "" so I can be certain it's failing at
> that point. I get the output "" (makes it easier to spot).
> 
> I've just used a command recently that allows me to access the specific ip
> and port of the lamp and it indicates the connection is successful. I'm out
> of ideas and if anyone can advise I'd appreciate it.
> 
> Slightly (very) out of my depth when it comes to ports and IPs etc.
> 
> Thanks,
> James



-- 

Shlomi Fish   https://www.shlomifish.org/
https://github.com/shlomif/validate-your-html - Validate Your HTML

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Unsatisfied dependencies detected during OALDERS/HTTP-Date-6.05.tar.gz

2020-01-29 Thread Shlomi Fish
Hi Jeffrey,

On Tue, 28 Jan 2020 18:34:50 -0500
Jeffrey Walton  wrote:

> Hi Everyone,
> 
> I'm trying to build Perl 5.30.1 from sources. I'm using:
> 
>./Configure -des -Dextras="HTTP::Daemon HTTP::Request Test::More
> Text::Template"
> 
> I'm seeing this in an endless loop (ad infinitum) on Fedora 1, Ubuntu
> 4, CentOS 5 and Fedora 31.
> 

I can reproduce this on fedora 31 x86-64 too.

> Running make for O/OA/OALDERS/HTTP-Date-6.05.tar.gz
>  Unsatisfied dependencies detected during 
>    OALDERS/HTTP-Date-6.05.tar.gz  
> Time::Zone [requires]
> Running make for module 'Time::Zone'
>   ATOOMIC/TimeDate-2.31.tar.gz
>   Has already been unwrapped into directory /root/.cpan/build/TimeDate-2.31-0
>   ATOOMIC/TimeDate-2.31.tar.gz
>   Has already been prepared
>   ATOOMIC/TimeDate-2.31.tar.gz
>   Has already been made
>   OALDERS/HTTP-Date-6.05.tar.gz
>   Has already been unwrapped into directory /root/.cpan/build/HTTP-Date-6.05-0
>   OALDERS/HTTP-Date-6.05.tar.gz
>   Has already been prepared
> Running make for O/OA/OALDERS/HTTP-Date-6.05.tar.gz
>  Unsatisfied dependencies detected during 
>    OALDERS/HTTP-Date-6.05.tar.gz  
> Time::Zone [requires]
> Running make for module 'Time::Zone'
>   ATOOMIC/TimeDate-2.31.tar.gz
>   Has already been unwrapped into directory /root/.cpan/build/TimeDate-2.31-0
>   ATOOMIC/TimeDate-2.31.tar.gz
>   Has already been prepared
>   ATOOMIC/TimeDate-2.31.tar.gz
>   Has already been made
>   OALDERS/HTTP-Date-6.05.tar.gz
>   Has already been unwrapped into directory /root/.cpan/build/HTTP-Date-6.05-0
>   OALDERS/HTTP-Date-6.05.tar.gz
>   Has already been prepared
> ...
> 
> I believe this break is partially due to building artifacts during
> 'make install'. The GNU Coding Standards explicitly states _DO NOT DO
> IT_. The only time things get built is during 'make'.
> 
> Does anyone know how to work around this (or any of the other build
> problems I am having)?
> 
> Do the Perl devs actually test this stuff?
> 

Perhaps we should report a bug.

> Jeff
> 



-- 

Shlomi Fish   https://www.shlomifish.org/
http://is.gd/htwEXQ - Integrating GNU Guile into GNU coreutils

"Not totally broken" might be a suitable marketing strategy for Microsoft,
but I'm not convinced it's a level we want to be particularly aiming for.
— Matthew Palmer ( https://is.gd/Eil4Io )

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: How to remove BerkleyDB dependency when building Perl from sources

2020-01-28 Thread Shlomi Fish
Hi Jeffrey,

On Tue, 28 Jan 2020 01:02:46 -0500
Jeffrey Walton  wrote:

> Hi Everyone,
> 
> I regression test on old machines. The older machines need an updated
> Git, SSH and Wget. To update Git, SSH and Wget I need to build a lot
> of dependent software. Perl is one of them.
> 
> On Fedora 1 while trying to build Perl 5.10.1:
> 

perl 5.10.1 is very old and no longer maintained (see what I wrote at
https://github.com/shlomif/supporting-older-perl5-releases ), but OTOH so is
Fedora 1.

> 
> I've tried to compile and run the following simple program:
> 
> #include 
> int main() { printf("Ok\n"); return(0); }
> 
> I used the command:
> 
> cc -o try -O2 -fno-strict-aliasing -pipe -I/usr/local/include
> -L/usr/local/lib try.c -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc
>  ./try
> 
> and I got the following output:
> 
> ./try: error while loading shared libraries: libdb-6.2.so: cannot open
> shared object file: No such file or directory
> The program compiled OK, but exited with status 127.
> You have a problem.  Shall I abort Configure [y]
> Ok.  Stopping Configure.
> 
> 
> I don't need database functions at this point so I would like to
> disable Berkley DB. 'Configure --help' does not list an option to
> disable the database gear.
> 
> I can't downgrade Perl because OpenSSL 1.1.x needs Perl 5.10. (OpenSSL
> really screwed us when the EOL'd 1.0.2 last month).
> 
> How do I remove or disable the BerkleyDB dependency?
> 

You can try editing the "Configure" script by hand. It is written in
https://en.wikipedia.org/wiki/Bourne_shell .

I recall trying to use Red Hat Linux 6.2 in a vbox VM and giving up after
the new openssl failed to compile using the old gcc there.

Good luck!

> Thanks in advance.
> 



-- 

Shlomi Fish   https://www.shlomifish.org/
Interview with Ben Collins-Sussman - https://shlom.in/sussman

Chuck Norris refactors 10 million lines of Perl code before lunch.
— http://www.shlomifish.org/humour/bits/facts/Chuck-Norris/

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: reading data from a web site

2019-11-20 Thread Shlomi Fish
On Wed, 20 Nov 2019 19:52:46 +0100
hw  wrote:

> On Wednesday, November 20, 2019 3:29:00 AM CET Olivier wrote:
> > hw  writes:  
> > > Hi,
> > > 
> > > how can I read data from a web site which is using multiple frames and
> > > some
> > > javascript?  
> > 
> > Provided that the web site does not change too often and that they don't
> > implement stupid "security" features, this should not be too complicate.
> > 
> > Each frame is a web page, with it own URL. So you can examine the source
> > code of the web page to find the URL of the first frame and second frame
> > 
> > Them you can use any Perl library you like to load that URLand pars it
> > for what you are looking for.
> > 
> > Then use that data to load the second frame with a URL modified to
> > include the type of data you have selected.
> > 
> > Being frames makes it much easier, you hould not have to care about the
> > javascript too much.  
> 
> The web site seems to be created by a program running on the server, i. e. 
> there is not really a web site.  When I access it with lynx or with 
> WWW::Mechanize, the answer from the server says that neither frames, nor 
> javascript is supported, and it is not possible to log in.
> 
> Can WWW::Mechanize somehow trick the server into assuming that frames and 
> javascript are supported by the client?
> 

Hi!

See:

https://github.com/shlomif/Freenode-programming-channel-FAQ/blob/master/FAQ_with_ToC__generated.md#how-can-i-write-code-to-perform-operations-on-web-sites-for-me-that-otherwise-should-be-done-manually

(short URL: https://is.gd/ExAHTa )

Regards,

Shlomi


-- 

Shlomi Fish   https://www.shlomifish.org/
https://github.com/shlomif/Freenode-programming-channel-FAQ

Chuck Norris knows exactly which thing is rotten in the kingdom of Denmark.
— http://www.shlomifish.org/humour/bits/facts/Chuck-Norris/

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: XML::Feed.pm perl on CentOS 7

2019-09-03 Thread Shlomi Fish
Hi Lars,

On Tue, 3 Sep 2019 08:06:36 +0300
Lars Noodén  wrote:

> I'm not finding CPAN's XML::Feed.pm for perl 5 for centos 7 via yum.
> 
> $ yum -q search all XML-Feed
> Warning: No matches found for: XML-Feed
> 
> $ grep PRETTY /etc/os-release
> PRETTY_NAME="CentOS Linux 7 (Core)"
> 
> Is there an additional package repository containing CPAN material for
> CentOS 7 which I can add?
> 

See https://pkgs.org/download/perl-XML-Feed .

Perhaps these pages will also help: 

* https://perl-begin.org/topics/cpan/

* https://perl-begin.org/topics/cpan/wrappers-for-distributions/


> /Lars
> 



-- 
-----
Shlomi Fish   http://www.shlomifish.org/

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Problem executing command via ssh

2019-08-27 Thread Shlomi Fish
Hi Eliza,

On Mon, 26 Aug 2019 18:37:10 +0800
Eliza  wrote:

> Hello,
> 
> on 2019/8/26 18:06, Shlomi Fish wrote:
> > seehttps://perl-begin.org/uses/remote-login-and-commands/  - use a CPAN
> > dist. Also note thathttps://metacpan.org/pod/IPC::Run  is a commonly cited
> > alternative to IPC::Open3 .  
> 
> Why not just using the native Net::SSH around modules.
> 
> https://metacpan.org/pod/Net::SSH
> https://metacpan.org/pod/Net::SSH::Perl
> https://metacpan.org/pod/distribution/Net-SSH-Expect/lib/Net/SSH/Expect.pod
> 

1. I linked to some of them on
https://perl-begin.org/uses/remote-login-and-commands/ (please follow and read
links)

2. No ssh module is part of the perl5 core -
https://shadow.cat/blog/matt-s-trout/but-i-cant-use-cpan/

3. What do you mean by "native"?


> regards,
> Eliza
> 



-- 
-----
Shlomi Fish   http://www.shlomifish.org/
My Aphorisms - http://www.shlomifish.org/humour.html

At this point, I'd like to take a moment to speak to you about the Adobe PSD
format. PSD is not a good format. PSD is not even a bad format. Calling it
such would be an insult to other bad formats, such as PCX or JPEG. No, PSD is
an abysmal format.
— https://github.com/gco/xee/blob/master/XeePhotoshopLoader.m

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Problem executing command via ssh

2019-08-26 Thread Shlomi Fish
On Fri, 23 Aug 2019 19:16:55 +0300
Mario Galindez  wrote:

> Folks,
> 
> I need to execute a program in a remote machine, that takes its input from
> STDIN.
> 
> I created a user in such remote machine, and set my program as the shell
> for that account (so I don't need to provide shell access).
> 
> On my local node, I have this program:
> 
> #!/usr/bin/perl
> 
> use IPC::Open3;
> use POSIX;
> 
> 
> $inputfile= $ARGV[0];
> open(FILE, '<', "$ARGV[0]") or die $!;
> $command= "ssh user\@remotehost.com";
> $pid = open3('<', '>', '>', $command);
> 
> waitpid( $pid, 0 );
> 

Hi Mario,

see https://perl-begin.org/uses/remote-login-and-commands/ - use a CPAN dist.
Also note that https://metacpan.org/pod/IPC::Run is a commonly cited
alternative to IPC::Open3 .

Finally, see https://perl-begin.org/tutorials/bad-elements/ and
https://github.com/shlomif/Freenode-programming-channel-FAQ/blob/master/FAQ_with_ToC__generated.md#what-are-some-best-practices-in-programming-that-i-should-adopt
for some best practices advice.

> 
> What I expect is that I pass the name of the file as arguments of this
> program ($ARGV[0]), and the contents of this file is fed as STDIN of the
> child I've spawn with open3. This should be received as STDIN of my remote
> program, and the results of the remote program would be printed on STDOUT.
> 
> This works well. However, my program only reads the first line, and then
> terminates.
> 
> If I do a manual test, and do ssh u...@remotehost.com, and type multiple
> lines of input, then things work as expected.
> 
> Any clues?
> 
> Thanks!
> -m



-- 
-
Shlomi Fish   http://www.shlomifish.org/
http://www.shlomifish.org/humour/bits/Google-Discontinues-Services/

Knuth is not God! Typing “God” into Google and pressing “I’m Feeling Lucky”
will not lead you to his homepage.
— http://www.shlomifish.org/humour/bits/facts/Knuth/

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Open and perl sub

2019-08-08 Thread Shlomi Fish
Hi Mike,

On Thu, 8 Aug 2019 15:40:42 +0100
Mike Martin via beginners  wrote:

> Is it possible to have the output of a perl module piped to open (open3 in
> my case), so I can use a file handle contains the output passed to sysread
> 
> Odd question I know
> 

you can use https://en.wikipedia.org/wiki/Fork_(system_call) ,
https://duckduckgo.com/?q=dup+unix=v140-1=web , "open >&" , etc.

> Thanks



-- 
---------
Shlomi Fish   http://www.shlomifish.org/
Best Introductory Programming Language - http://shlom.in/intro-lang

A person with one watch knows what time it is; a person with two watches is
never sure.   — Proverb [via fortune-mod]

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: how to catch die in a module

2019-08-08 Thread Shlomi Fish
Hi,

On Thu, 8 Aug 2019 08:21:24 +0530
Chankey Pathak  wrote:

> You can create a signal handler for die and handle the exception in there.
> Refer https://users.cs.cf.ac.uk/Dave.Marshall/PERL/node116.html
> 

Also see block eval - https://perldoc.pl/functions/eval - or one of its
wrappers like https://metacpan.org/pod/Try::Tiny .

Caveat: I maintain https://metacpan.org/pod/Error and recommend against using
the latter.

> On Thu, 8 Aug, 2019, 8:15 AM Eliza,  wrote:
> 
> > Hello,
> >
> > I use such a module from other people.
> > In this module there is the "die" statement, for example,
> >
> > connect(...) or die $!;
> >
> > Then my main program will die follow up this "die".
> > But I don't want the caller to die even if "die" was happened in the
> > module.
> > How to handle with it?
> >
> > Thank you.
> > Eliza
> >
> > --
> > To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> > For additional commands, e-mail: beginners-h...@perl.org
> > http://learn.perl.org/
> >
> >
> >  



-- 
-
Shlomi Fish   http://www.shlomifish.org/
Perl Elems to Avoid - http://perl-begin.org/tutorials/bad-elements/

John: Hey, we are completely non-violent vampires. We don’t suck blood.
Selina: I thought all vampires suck blood.
John: Bullocks, hen. Vampires come in all shapes and sizes.
— http://www.shlomifish.org/humour/Selina-Mandrake/

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Install Problems: Net::Google::Spreadsheets

2019-08-05 Thread Shlomi Fish
are for release
> candidate testing
> t/release-kwalitee.t  skipped: these tests are for release
> candidate testing
> t/release-pod-syntax.t .. skipped: these tests are for release
> candidate testing
> t/release-unused-vars.t . skipped: these tests are for release
> candidate testing
> 
> Test Summary Report
> ---
> t/00_compile.t(Wstat: 256 Tests: 1 Failed: 1)
>   Failed test:  1
>   Non-zero exit status: 1
> t/01_new.t(Wstat: 512 Tests: 0 Failed: 0)
>   Non-zero exit status: 2
>   Parse errors: No plan found in TAP output
> Files=11, Tests=1,  1 wallclock secs ( 0.03 usr  0.01 sys +  0.98 cusr
>  0.07 csys =  1.09 CPU)
> Result: FAIL
>   HIROSE/Net-Google-Spreadsheets-V4-0.002.tar.gz
> one dependency not OK (Net::Google::DataAPI::Auth::OAuth2); additionally
> test harness failed
>   ./Build test -- NOT OK
> //hint// to see the cpan-testers results for installing this module, try:
>   reports HIROSE/Net-Google-Spreadsheets-V4-0.002.tar.gz
> Failed during this command:
>  TODDR/XML-Parser-2.44.tar.gz : make NO
>  MANWAR/XML-XPath-1.44.tar.gz : make_test NO one dependency
> not OK (XML::Parser); additionally test harness failed
>  MIYAGAWA/XML-Atom-0.42.tar.gz: make_test NO one dependency
> not OK (XML::XPath)
>  DANJOU/Net-Google-DataAPI-0.2805.tar.gz  : make_test NO one dependency
> not OK (XML::Atom); additionally test harness failed
>  HIROSE/Net-Google-Spreadsheets-V4-0.002.tar.gz: make_test NO one
> dependency not OK (Net::Google::DataAPI::Auth::OAuth2); additionally test
> harness failed



-- 
-
Shlomi Fish   http://www.shlomifish.org/
https://github.com/shlomif/shlomif-computer-settings/ - my dotfiles

Ever notice that even the busiest people are never too busy to tell you
just how busy they are?
— Source unknown, taken from Linux’s fortune-mod

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Device::SerialPort on debian Buster

2019-07-11 Thread Shlomi Fish
Hi Martin,

commenting on your code:

On Wed, 10 Jul 2019 08:51:08 -0500
"Martin McCormick"  wrote:

>   Before I take this too far, I want to make sure I am not
> doing something wrong with use of the Device::SerialPort module
> in perl.
> 
>   The code below talks to what it thinks is a RS-232 serial
> port and controlls a radio scanner so that one can program the
> scanner's settings and enter frequency and operational data.
> Don't worry about all that.  It used to work on debian stretch
> which is last year's version of debian.  After an upgrade to
> buster which is this year's version, also known as debian 10, all
> RS-232 ports appear to be dead.  Interestingly enough, a debian
> system running stretch, containing perl was upgraded to buster
> and serial communications between that system and a native serial
> port on it's mother board are fine.  The very same code ported to
> the buster system also fails with
> Can't call method "baudrate" on an undefined value at /home/martin/etc/mm
> line 121.
> 
>   It doesn't matter what serial port or whether it is
> native mother board hardware or what.  Serial ports are all
> broken right now.
> 
>   Here is the scanner control code.  I am sending it to see
> if I am using some deprecated method that is wrong to set the
> serial port or we really do have big trouble.
> 
>   Thanks for any and all constructive ideas.  Code follows:
> 
> 
> 
> #!/usr/bin/perl -w

See https://perl-begin.org/tutorials/bad-elements/#the-dash-w-flag .

> use strict;

good!

> use warnings::unused;
> use File::Basename;
> use File::Copy;
> use File::Spec;
> use Time::Local;
> use Device::SerialPort;
> 

Use explicit imports -
https://perl-begin.org/tutorials/bad-elements/#non_explicitly_imported_symbols

> sub waitfor {#Receive from serial port.
> 
> my $received = "";
> our $port;

"our" inside a function?

> 
> until ( "" ne $received ) {

double negative and perhaps use
https://stackoverflow.com/questions/223393/how-do-i-get-the-length-of-a-string-in-perl
> $received = $port->lookfor;
> }
> return ($received);
> }#Receive from serial port.
> 
> #no more sub routine code past this point
> 
> #main global variables
> our @dbstrings;
> 
> #main local variables
> my $response;
> my $cmd= "";
> my $ONEARG = "";
> 
> #my $counter = 1;
> 
> #Setup the comm port.
> my $dev = "/dev/ttyACM0";
> our $instring = "";
> our $port = Device::SerialPort->new("$dev");

why our?
> $port->baudrate(115200);
> $port->databits(8);
> $port->parity("none");
> $port->stopbits(1);
> $port->handshake("none");
> $port->read_const_time(500);# 500 milliseconds = 0.5 seconds
> $port->are_match( "\r", "\n", );# possible end strings
> 
> foreach $ONEARG (@ARGV) {   #each argument

see https://perl-begin.org/tutorials/bad-elements/#non_lexical_loop_iterators

> $ONEARG =~ s/^\s+//;
> $ONEARG =~ s/\s+$//;

perhaps use \A and \z

> $cmd = $cmd . " " . $ONEARG;

use ".="

> $cmd =~ s/^\s+//;
> $cmd =~ s/\s+$//;
> }#each argument
> 
> $cmd = uc $cmd;
> $port->write("$cmd\r");
> $instring = waitfor;


see https://perl-begin.org/tutorials/bad-elements/#declaring_all_vars_at_top .

> my @chars = split( "", $instring );
> foreach my $char (@chars) {#
> 
> #print ord($char);
> if ( $char =~ /[\,\s\.\-\+\_0-9A-Za-z]/ ) {#printable
> $response = $response . $char;

use .= and you can use https://perldoc.perl.org/functions/join.html and regex
matches. it is good that you follow
https://perl-begin.org/tutorials/bad-elements/#using-character-classes-with-unicode-text
.
> }#printable
> }#
> print "$response\n";
> $instring = "";
> exit(0);
>

Why the assignment right before exiting? 

I'm not sure if any of the issues I pointed are the culprit.

-- 
-
Shlomi Fish   http://www.shlomifish.org/
https://github.com/sindresorhus/awesome - curated list of lists

Chuck Norris does not code; when he sits at a computer, it just does whatever
he wants. — Kattana on Freenode’s #perl6 .
— http://www.shlomifish.org/humour/bits/facts/Chuck-Norris/

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: stupid question about to protect source code of perl web application scripting

2019-07-08 Thread Shlomi Fish
On Mon, 8 Jul 2019 15:07:41 +0700
Eko Budiharto  wrote:

> >> 2. if someone has a problem, he does not want to try to find a way to
> >> solve the problem first, and then he asks your help and then problem
> >> solved, then he is blaming the person who already helped him and
> >> claimed, that is his work. what will you do?
> >>  
> > What do you mean?
> >
> >  
> dear Shlomi,
> 
> what I mean in this one is the person has a problem, but he does not 
> make any efforts first, he just ask the solution from someone else. 
> After the problem is solved, he blames the person.
> 
> For example:
> 
> I have a problem and then I do not do anything or make my own effort and 
> then I ask your help to solve it for me. After the problem solved 
> because you helped me, I blame you instead you being grateful and thank 
> you and plus I said to anyone that I am the one who solved if instead of 
> your name.
> 

I understand now, thanks. That seems like a very ungrateful and "bastard"y
thing to do. I won't like it, but not sure how i'll act.

-- 
-
Shlomi Fish   http://www.shlomifish.org/
http://youtu.be/xZLwtc9x4yA - Anime in Real Life!! (Parody)

An apple a day keeps the doctor away.
Two apples a day will keep two doctors away.
— one of Shlomi Fish’s relatives

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: stupid question about to protect source code of perl web application scripting

2019-07-08 Thread Shlomi Fish
Hi,

On Mon, 8 Jul 2019 08:44:46 +0700
Eko Budiharto  wrote:

> dear all,
> 
> first of all, thank you for the respond of my inquiry. And then, there 
> is a few questions I would like to ask:
> 
> 1. if someone takes your works and then he steals the credit by claiming 
> the work is his work instead of your work, what will you do?
> 

First note that it never happened to me.

Anyway, in this case, I will try to find evidence that I originated the works
first, e.g:

* https://en.wikipedia.org/wiki/Wayback_Machine

* https://en.wikipedia.org/wiki/Version_control histories

* https://en.wikipedia.org/wiki/Internet_forum archives

Note that I think the most restrictive licences I used are
https://en.wikipedia.org/w/index.php?title=CC-by-nc-sa=no and
https://en.wikipedia.org/wiki/Affero_General_Public_License which also allow
asserting copyright on derivative changes.

If the person who claims my work is theirs does not sue me for infringement, I
will likely not care much:

* https://fc-solve.shlomifish.org/faq.html#abuse_of_fc_solve

* https://www.mail-archive.com/linux-il@cs.huji.ac.il/msg56378.html

> 2. if someone has a problem, he does not want to try to find a way to 
> solve the problem first, and then he asks your help and then problem 
> solved, then he is blaming the person who already helped him and 
> claimed, that is his work. what will you do?
> 

What do you mean?

> This is kind of some images of this dishonest person.
> 
> I do not mind to share my code to the person, if he does not have that 
> character.
> 
> So far, I am using the perl code for web application in a hosting 
> server. But this time, I have to create a web application on a on 
> premise server.
> 
> I am not an expert yet in perl and still learning although I know perl 
> when I got still in my university 19 years ago.
> 
> regards,
> 
> Eko Budiharto
> 
> 

-- 
-
Shlomi Fish   http://www.shlomifish.org/
The Case for File Swapping - http://shlom.in/file-swap

Do you always begin conversations this way?
— https://en.wikipedia.org/wiki/The_Princess_Bride_%28film%29

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: stupid question about to protect source code of perl web application scripting

2019-07-07 Thread Shlomi Fish
Hi all,

On Sun, 7 Jul 2019 19:54:30 +1200
Kent Fredric  wrote:

> > On 7/6/19 11:21 PM, Eko Budiharto wrote:  
> > > it is a web application but it is on premise. The user is not honest.
> > > That's why I am trying to find a way to protect the source code like
> > > in java we can compile into java class and still can be run.  
> 
> That's a false sense of securtiy. A sufficiently "dishonest" person
> can decompile your class files back into source.
> 
> It may not be the original source, comments may be lost, function
> names and variables may become nonsensical, ( but this last part
> typically requires additional obfuscation beyond the standard java
> compiler )
> 
> But the logic, the interface, and all the metadata required to make
> backtraces remotely comprehensible, is all still there for anyone who
> wants to look.
> 

In addition see these FAQ replies:

*
https://perl-begin.org/FAQs/freenode-perl/#How_can_I_compile_my_code_to_obscure_.2F_obfuscate_the_source.3F

*
https://github.com/shlomif/Freenode-programming-channel-FAQ/blob/master/FAQ_with_ToC__generated.md#how-do-i-hideobscureencrypt-my-source-code-to-prevent-end-users-from-learning-how-it-works

This question is very old...


-- 
-
Shlomi Fish   http://www.shlomifish.org/
http://www.shlomifish.org/humour/bits/facts/Summer-Glau/

Cogito cogito ergo cogito sum --
"I think that I think, therefore I think that I am."
— Ambrose Bierce, "The Devil's Dictionary"

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: PAUSE

2019-06-30 Thread Shlomi Fish
Hi all,

can someone try to help Mike here?

On Sun, 30 Jun 2019 05:10:19 -0500
Mike  wrote:

> I understand that to upload a module to CPAN is need
> to obtain a PAUSE account.  I have tried twice to get
> that, but I don't receive an e-mail with a password.
> 
> http://www.mflan.com/temp/pause.jpg
> 
> If anybody can notify the PAUSE people that the PAUSE
> program appears to be broke, please do.
> 
> 
> 
> Mike
> 



-- 
---------
Shlomi Fish   http://www.shlomifish.org/
Understand what Open Source is - http://shlom.in/oss-fs

“Did you sleep well?”
“No, I made a couple of mistakes.”
— https://en.wikiquote.org/wiki/Steven_Wright via Nadav Har’El

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: can I use some kind of binary string?

2019-05-18 Thread Shlomi Fish
Hi,

On Sat, 18 May 2019 14:02:46 +0200
hwilmer  wrote:

> On 5/16/19 9:56 PM, Shlomi Fish wrote:
> > On Thu, 16 May 2019 13:13:16 +0200
> > hwilmer  wrote:
> >   
> >> On 5/11/19 11:07 AM, Shlomi Fish wrote:  
> [...]
> >>>> So I would want to use something like
> >>>>
> >>>>
> >>>> my $binary_data = `curl -k "https://www.example.com/some.jpg"`;
> >>>> 
> >>>
> >>> Perl distinguishes between 8-bit/binary strings and unicode ones. See
> >>> https://perldoc.perl.org/perlunitut.html .  
> >>
> >> What kind of string do I get when using backticks like in the above
> >> example?  
>  > [...]
> > Perhaps use open "-|" with an encoding - see
> > https://perldoc.perl.org/functions/binmode.html .  
> 
> I didn't know I could do that ...  I tried it and it works, too.
> 

Nice.

> >>> Note however that you should see
> >>> https://perl-begin.org/uses/web-automation/ and use a module instead of
> >>> trapping curl.exe's output. Perl has bindings to libcurl too if that is
> >>> what you want.  
> >>
> >> First I tried to use WWW::Mechanize, and that failed because it can't
> >> deal witch the self-signed certificates the web server is using.  I
> >> couldn't find anywhere in the documentation how to allow such
> >> certificates.  Otherwise it seemed to be able to do what I wanted.
> >>  
> > 
> > See
> > https://stackoverflow.com/questions/47662461/how-to-accept-self-signed-certificates-with-
> >  
> lwpuseragent
> 
> That gives an error: 'Bareword "IO::Socket::SSL::SSL_VERIFY_NONE" not 
> allowed while "strict subs" in use ...'.  But this works:
> 
>my $ua = LWP::UserAgent->new(
>  max_size => $MAX_DOWNLOAD_SIZE,
>  ssl_opts => {
>   ssl_verify => 0,
>   verify_hostname => 0
>  }
> );
> 

Great! Thanks for the tip.

-- 
-
Shlomi Fish   http://www.shlomifish.org/
https://is.gd/MQHVF3 - The Atom Text Editor edits a 2,000,001B file

The Bajoran scholars have positively identified Benjamin Sisko as The Emissary.
They also positively identified the NSA headquarters as The Dungeon.
— http://www.shlomifish.org/humour/bits/facts/NSA/

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: can I use some kind of binary string?

2019-05-16 Thread Shlomi Fish
On Thu, 16 May 2019 13:13:16 +0200
hwilmer  wrote:

> On 5/11/19 11:07 AM, Shlomi Fish wrote:
> > Hi hwilmer,
> > 
> > On Fri, 10 May 2019 19:09:50 +0200
> > hwilmer  wrote:
> >   
> >> Hi,
> >>
> >> I would like to use curl to retrieve an image from a web server which I
> >> want to store in a table in a mariadb database without downloading the
> >> image to a file.  For this application, I do not want to store
> >> references to files stored in some file system instead.
> >>
> >> So I would want to use something like
> >>
> >>
> >> my $binary_data = `curl -k "https://www.example.com/some.jpg"`;
> >>  
> > 
> > Perl distinguishes between 8-bit/binary strings and unicode ones. See
> > https://perldoc.perl.org/perlunitut.html .  
> 
> What kind of string do I get when using backticks like in the above 
> example?  One that perl considers as a text string I could use stuff 
> like uc or lc on, or as a binary string I could use pack or unpack on? 
> Variables are without types, so there is no way to tell.  If I was using 
> curl to receive a text string, how would I know which encoding is being 
> used?  For all I know that could depend on the machine my program is 
> running on after lots of factors I would never know about.  And this 
> same encoding could happen to the image data.
> 
> Why would I use pack or unpack on the image data curl puts into the 
> string?  Do I need to worry that somewhere --- like in my program or in 
> some method DBI provides or somewhere else --- some kind of string 
> transformation might take place that damages the image data?  Is there a 
> way to tell perl that this is actually not a string but some binary data 
> that must not be transformed or encoded?
> 
> So far, it's working, but that could be just luck ...
> 

Perhaps use open "-|" with an encoding - see
https://perldoc.perl.org/functions/binmode.html .

> > Note however that you should see https://perl-begin.org/uses/web-automation/
> > and use a module instead of trapping curl.exe's output. Perl has bindings to
> > libcurl too if that is what you want.  
> 
> First I tried to use WWW::Mechanize, and that failed because it can't 
> deal witch the self-signed certificates the web server is using.  I 
> couldn't find anywhere in the documentation how to allow such 
> certificates.  Otherwise it seemed to be able to do what I wanted.
> 

See
https://stackoverflow.com/questions/47662461/how-to-accept-self-signed-certificates-with-lwpuseragent

> Using curl via the library bindings is somewhat going to lengths I would 
> rather avoid.
> 



-- 
-
Shlomi Fish   http://www.shlomifish.org/
http://youtu.be/xZLwtc9x4yA - Anime in Real Life!! (Parody)

Well, one thing I can tell you about parenthood is that such things
can progress from figurative to literal, extremely quickly.
— http://www.shlomifish.org/humour/Summerschool-at-the-NSA/

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: can I use some kind of binary string?

2019-05-11 Thread Shlomi Fish
Hi hwilmer,

On Fri, 10 May 2019 19:09:50 +0200
hwilmer  wrote:

> Hi,
> 
> I would like to use curl to retrieve an image from a web server which I 
> want to store in a table in a mariadb database without downloading the 
> image to a file.  For this application, I do not want to store 
> references to files stored in some file system instead.
> 
> So I would want to use something like
> 
> 
> my $binary_data = `curl -k "https://www.example.com/some.jpg"`;
> 

Perl distinguishes between 8-bit/binary strings and unicode ones. See
https://perldoc.perl.org/perlunitut.html .

Note however that you should see https://perl-begin.org/uses/web-automation/
and use a module instead of trapping curl.exe's output. Perl has bindings to
libcurl too if that is what you want.

> 
> The image then needs to be inserted into a LONGBLOB field via DBI in 
> such a way that the image can be restored as it was.
> 
> Will string conversions or something prevent this from working?
> 
> What is the usual way to do this?  It is certainly not ideal to have no 
> check on the amount of data that might be retrieved from the web server, 
> regardless whether I save it to an intermediate file or not.
> 
> To make things more difficult, the web server is using a self-signed 
> certificate.
> 



-- 
-
Shlomi Fish   http://www.shlomifish.org/
http://www.shlomifish.org/humour/bits/New-versions-of-the-GPL/

He who reinvents the wheel will likely design a square wheel and spend a year
trying to figure out why it doesn’t work properly.
— Nadav Har’El, http://www.shlomifish.org/humour.html

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: proper use of TEMPLATE

2019-03-14 Thread Shlomi Fish
Hi Rick,

On Thu, 14 Mar 2019 12:14:59 -0500
Rick T  wrote:

> I’m sure this is a “newbie question,” but I am only a shade above that status
> and would appreciate some clarification.
> 
> I have
> 
> use TEMPLATE
> 

do you mean https://metacpan.org/pod/Template ?
> in my code to control whether the attribute 
> 
> selected 
> 
> appears with one of the < options> of the list following  in my
> served html document. Here’s one line from that list
> 
>  Full Course (1 credit)
> 
> My code can easily replace the correct var with ‘selected’ and the other vars
> on the list with a blank. But what should that blank be?
> 
> Should I make it an empty string, a space, undef, or something else? I can
> try them out to see what will work (perhaps all will work), but I want to
> know what is considered best practice and why.
> 

an empty string should be fine.

> Perhaps there’s even a whole better way to approach this! I will be grateful
> to chew over any and all comments you experienced people send me. Thanks!
> 
> Rick Triplett



-- 
-
Shlomi Fish   http://www.shlomifish.org/
Parody of "The Fountainhead" - http://shlom.in/towtf

I’d give my right arm to be ambidextrous.
— Source unknown via Nadav Har’El and fortune-mod

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: covert perl code to binary

2019-01-17 Thread Shlomi Fish
Hi,

On Thu, 17 Jan 2019 17:48:50 +0200
"Octavian Rasnita"  wrote:

> From: "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 you need to is to discourage casual lookers from
> > seeing the source, then you only need something like Acme::Bleach.
> > Yes, you can unbleach the code, but it takes effort and knowledge and
> > with those no code is safe behind any form of obfuscation (including
> > compilation to binary).
> >
> > If you are trying to hide the code because you are distributing
> > secrets (like passwords, api keys, etc) in your code, then you have a
> > fundamental design issue that needs to be fixed.
> >  
> 
> 
> 
> Decompiling C/C++/asm code in a form that can be re-compiled again is hard 
> to do for most programmers.
> Finding/unhiding the provided Perl code is not as hard.
> 
> So the real answer is that if the protection of the source code is so 
> important, then Perl is not an appropriate programming language for this, 
> because it doesn't have a way of compiling the code and storing it in files 
> that can be distributed and ran by the final users. C/C++/Java/C# or even Go 
> or Python are better for this.
> 

Please see
https://github.com/shlomif/Freenode-programming-channel-FAQ/blob/master/FAQ.mdwn#how-do-i-hideobscureencrypt-my-source-code-to-prevent-end-users-from-learning-how-it-works

(short URL: https://is.gd/pLk1b2 )

Python is not suitable for that either. Also note that while decompiling is
problematic, https://en.wikipedia.org/wiki/Reverse_engineering is usually
doable with some effort if you wish to learn about a certain key technique.

> As far as I know, perlcc never really worked for complex programs. It might 
> work for Hello, world programs, but not fore more, so it is not a solution 
> either.
> 
> ActiveState PDK could be a good enough solution for hiding the source code, 
> but it is not a very clean solution that works well for any kind of 
> programs, and it doesn't compile the code.
> 
> Creating web-based apps that run on a server might not be a solution either, 
> because in some cases a local (desktop) app with a OS native interface is 
> needed.
> 
> Perl still has its advantages, but not for compiling/hiding code and for 
> distributing the programs to final users, and because it is used less and 
> less for new projects, probably it will never have that kind of advantage 
> unfortunately.
> 
> Other people used to recommend to distribute a license and put the loyers 
> sue those that don't respect it, but it is obvious that this is not a 
> solution either.
> 
> Perl is good only when is not necessary to hide the code, for example for 
> very complex web-based apps that can't be replaced with an already-made free 
> CMS, or for special programs that run on a server by a cron job, but not for 
> applications ran by common users on their desktop computers. 
> ...unfortunately.
> 
> --Octavian
> 



-- 
-
Shlomi Fish   http://www.shlomifish.org/
Beginners Site for the Vim text editor - http://vim.begin-site.org/

Wikipedia deletionists Don’t Die. They lose notability and get deleted.
— http://www.shlomifish.org/humour.html

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: covert perl code to binary

2019-01-11 Thread Shlomi Fish
Hi Uday,

On Fri, 11 Jan 2019 15:29:23 +0530
Uday Vernekar  wrote:

> Hi all,
> 
> I have a perl code which I need to covert to binary so that nobody can see
> the code.
> 
> we used pp package to make the perl code binary but here the user can see
> the code which gets created in tmp.
> 
> Need help if anybody knows kindly reply
> 

first of all, see
https://github.com/shlomif/Freenode-programming-channel-FAQ/blob/master/FAQ.mdwn#how-do-i-hideobscureencrypt-my-source-code-to-prevent-end-users-from-learning-how-it-works

(short url: https://is.gd/pLk1b2 .)

Otherwise perhaps https://metacpan.org/pod/B::C will work for you or you can
try paying a C programmer to translate the code for you (I can do that!).

> With regards
> Uday V G



-- 
-----
Shlomi Fish   http://www.shlomifish.org/
Optimising Code for Speed - http://shlom.in/optimise

The Klingon warriors’ motto is “It’s a good day to die.” Chuck Norris’s motto
is “It’s a good day to kill.”
— http://www.shlomifish.org/humour/bits/facts/Chuck-Norris/

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Perl Email and WuFoo Forms.

2018-10-04 Thread Shlomi Fish
Hi James,

On Tue, 2 Oct 2018 14:18:35 +0100
James Kerwin  wrote:

> Hi All,
> 
> I have a Perl script that pulls in some information, generates an email,
> sends the email to a person and provides a URL to a WuFoo form. This URL
> contains the information to populate most fields in the form and could
> populate all of the fields.
> 
> What I don't know is how to submit the form. WuFoo uses POST to submit
> forms so I'm quietly confident I can't trigger that via the URL (happy to
> be surprised!).
> 
> The email generated by Perl is plain text so far as I can tell, using the
> JavaScript API that WuFoo has is out of the question (again, very happy to
> be told otherwise).
> 
> Does anybody have any idea how I could go about this? I have access to a
> server in which to host scripts on etc. and I'm not necessarily looking for
> a hand-holding solution, just a nudge in the right direction would be
> brilliant.
>

see http://perl-begin.org/uses/web-automation/ and
https://github.com/shlomif/Freenode-programming-channel-FAQ/blob/master/FAQ.mdwn#how-can-i-write-code-to-perform-operations-on-web-sites-for-me-that-otherwise-should-be-done-manually

(short URL: https://is.gd/Tjo3KR .)

Regards,

Shlomi
 
> Thanks,
> James



-- 
-----
Shlomi Fish   http://www.shlomifish.org/
List of Text Processing Tools - http://shlom.in/text-proc

Skill without imagination is craftsmanship and gives us many useful objects
such as wickerwork picnic baskets.  Imagination without skill gives us modern
art.— Tom Stoppard

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: reading form values from POST

2018-09-03 Thread Shlomi Fish
Hi Rick,

On Sun, 2 Sep 2018 16:04:26 -0500
Rick T  wrote:

> I am trying to wean myself from CGI.pm, an easy task for most of you, but I
> am a beginner. The code below works, but that does not mean it always will or
> that it cannot be improved. I found the main part of this in CGI Programming
> with Perl, which is 18 years old, and I’ve given up hoping that a new edition
> of it will come out. I’ve read somewhere that servers can give the wrong
> value for CONTENT_LENGTH, so I stuck in a second chance before bailing out;
> and of course this may not be necessary or done well.  I look forward to any
> and all comments. I also would appreciate any guidance on how I can learn
> more about CGI and how to deal with it. This book has been extremely valuable
> to me, but even I can see that some of its guidance is a bit creaky! — Rick
> 
> sub get_form_data {
> my $query = q{}; # Empty string
> my @name_value_pairs;
> if ( read( STDIN, $query, $ENV{'CONTENT_LENGTH'} ) 
>   == $ENV{CONTENT_LENGTH}
>){
> @name_value_pairs = split /&/, $query;
> }elsif (! read( STDIN, $query, $ENV{'CONTENT_LENGTH'} ) # Second chance
> == $ENV{CONTENT_LENGTH}
>){
> die "Trouble parsing POST request: $!"
> }
>

please  use a module - whether CGI.pm or other. See:

* https://leejo.github.io/2016/02/22/all_software_is_legacy/

* https://plackperl.org/

* https://metacpan.org/release/CGI-Minimal 

Thanks to Uri too.

Regards,

Shlomi Fish

> foreach my $pair (@name_value_pairs){
> my ($key, $value) = split /=/, $pair;
> chomp ($key, $value);
> $pf{$key} = $value;
>     }
> return;
> }
> 



-- 
-
Shlomi Fish   http://www.shlomifish.org/
http://is.gd/i5eMQd - Emma Watson’s Interview for a Software Dev Job

I love being convinced that I was wrong before. That way I knew I
improved and am now wiser. Like the Klingon warriors say when it happens:
“What a great day it was for me to die!”.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: slurp error

2018-08-06 Thread Shlomi Fish
Hi all!

On Fri, 27 Jul 2018 14:42:35 -0400
Uri Guttman  wrote:

> On 07/27/2018 02:37 PM, Rick T wrote:
> > I tried to implement some advice about slurping that I read on this 
> > mailing list (using local) but cannot get it to work. I get the 
> > message “Value of  construct can be "0"; test with defined() 
> > at line 23” (the $slurp = <$fh1> line). I’m using perl version 5.18.2 
> > installed in 2014.
> >
> > I’ve googled this error and think (ha!) I understand it, but though 
> > I’ve tried many changes, I cannot make the error go away. I need the 
> > advice of folks who are way ahead of me!
> >
> > Rick Triplett
> >
> >
> >  
> use File::Slurp ; #from cpan
> 

Please see
http://blogs.perl.org/users/leon_timmermans/2015/08/fileslurp-is-broken-and-wrong.html
and
https://www.reddit.com/r/perl/comments/3hfsqt/fileslurp_is_broken_and_wrong/
for better alternatives to File::Slurp .



> my $text = read_file( $file_to_convert ) ;
> $text =~ s/\r/\n/g;
> $text =~ s/\x0b//g ;
> 
> no need for xms if you aren't using those features.
> 
> uri
> 
> 
> 



-- 
-
Shlomi Fish   http://www.shlomifish.org/
My Aphorisms - http://www.shlomifish.org/humour.html

Don't worry over what other people are thinking about you.  They're too
busy worrying over what you are thinking about them.
— Unknown Source

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: tie a hash to a file

2018-08-01 Thread Shlomi Fish
On Wed, 01 Aug 2018 19:16:54 +0800
"Lauren C."  wrote:

> Do you know how to tie a hash to a disk file thus read by another process?
> 
> Currently my solution is writing the data to a JSON file and read it from the
> other program.
> 
> Thank you.
> 

See http://perl-begin.org/uses/databases/ . I also maintain this page -
http://www.shlomifish.org/open-source/resources/databases-list/ .

-- 
---------
Shlomi Fish   http://www.shlomifish.org/
UNIX Fortune Cookies - http://www.shlomifish.org/humour/fortunes/

When you say “I wrote a program that crashed Windows”, people just stare at
you blankly and say “Hey, I got those with the system, *for free*”.
— https://en.wikiquote.org/wiki/Linus_Torvalds

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: regex to get the rpm name version

2018-07-27 Thread Shlomi Fish
Hi Asad,

On Fri, 27 Jul 2018 18:24:39 +0530
Asad  wrote:

> Hi All ,
> 
>  I want to get a regex to actually get the rpm name and version for
> comparison :
> 
> 
> binutils-2.23.52.0.1-12.el7.x86_64",
> compat-libcap1-1.10-3.el7.x86_64"
> compat-libstdc++-33-3.2.3-71.el7.i686
> 
> (^[a-zA-Z0-9\-]*)\-\d'
> 
> First part of the regular expression is ^[a-zA-Z0-9\-]
> 
> which means search for anything that begins with a letter
> 
> (lower or upper) or a number up until you reach an
> 
> hyphen sign (‘-‘).
> 
> but it fails to match
> 
> compat-libstdc++-33-3.2.3-71.el7.i686
> 
> Please let me know what regex should i use to extract all 3
> 
> rpms.
> 
> Also let me know if there are web tools to build regex
> 
> Good websites for regex tutorials.
> 

for that, see:

* http://perl-begin.org/topics/regular-expressions/

* https://github.com/aloisdg/awesome-regex

* https://www.regular-expressions.info/


> 
> 
> 
> Thanks,
> 
> 
> 
> 
> 



-- 
-
Shlomi Fish   http://www.shlomifish.org/
https://youtu.be/GoEn1YfYTBM - Tiffany Alvord - “Fall Together”

C++ is complex, complexifying and complexified.
(With apologies to the Oxford English Dictionary).
— http://www.shlomifish.org/humour.html

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: regex matches Chinese characters

2018-07-26 Thread Shlomi Fish
Hi Lauren,

On Fri, 27 Jul 2018 11:28:42 +0800
"Lauren C."  wrote:

> greetings,
> 
> I was doing the log statistics stuff using perl.
> There are chinese characters in log items.
> I tried with regex to match them, but got no luck.
> 
> $ perl -mstrict  -le 'my $char="汉语"; print "it is chinese" if $char =~ 
> /\p{Han}+/'
> 
> $ perl -mstrict -mutf8 -le 'my $char="汉语"; print "it is chinese" if 
> $char =~ /\p{Han}+/'
> 
> both output nothing.
> 
> My terminal is UTF-8:
> 

According to http://perldoc.perl.org/perlrun.html , you probably need -Mstrict
and -Mutf8 instead of the lowercase -m, so "sub import" will get called:

shlomif@telaviv1:~$ perl -Mstrict -Mutf8 -le 'my $char="汉语"; print "it is
chinese" if $char =~ /\p{Han}+/'
it is chinese
shlomif@telaviv1:~$ 

HTH,

Shlomi

> $ locale
> LANG=en_US.UTF-8
> LANGUAGE=
> LC_CTYPE="en_US.UTF-8"
> LC_NUMERIC="en_US.UTF-8"
> LC_TIME="en_US.UTF-8"
> LC_COLLATE="en_US.UTF-8"
> LC_MONETARY="en_US.UTF-8"
> LC_MESSAGES="en_US.UTF-8"
> LC_PAPER="en_US.UTF-8"
> LC_NAME="en_US.UTF-8"
> LC_ADDRESS="en_US.UTF-8"
> LC_TELEPHONE="en_US.UTF-8"
> LC_MEASUREMENT="en_US.UTF-8"
> LC_IDENTIFICATION="en_US.UTF-8"
> LC_ALL=
> 
> 
> Can you help? thanks in advance.
> 



-- 
-
Shlomi Fish   http://www.shlomifish.org/
https://github.com/sindresorhus/awesome - curated list of lists

Cats are smarter than dogs. You can’t get eight cats to pull a sled through
snow.— Source unknown, via Nadav Har’El.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: interpolation without double quotes

2018-07-05 Thread Shlomi Fish
On Thu, 5 Jul 2018 09:58:52 -0500
p...@reason.net wrote:

> Many thanks to Shlomi and Uri: as always, you’ve greatly boosted my
> understanding of Perl! — Rick
> 

You're welcome.


-- 
-----
Shlomi Fish   http://www.shlomifish.org/
http://is.gd/htwEXQ - Integrating GNU Guile into GNU coreutils

Mephiqoleth: THERE ARE JEWS OF MANY SPECIES.
Selina: Really? That’s great - can I have a Jewish lady-cat? I want one
so she can mother cute little Jewish kittens.
— http://www.shlomifish.org/humour/Selina-Mandrake/

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: interpolation without double quotes

2018-07-04 Thread Shlomi Fish
Hi Rick,

On Wed, 4 Jul 2018 09:16:19 -0500
Rick T  wrote:

> The following line works, even though I forgot to double quote the variable.
> 
> my $student_directory =  '/data/students/' . $student_id;
> 

see http://perl-begin.org/tutorials/bad-elements/#vars_in_quotes . Perl often
stringifies expressions even outside interpolation, such as when being
string-concatenated.

> When I noticed this, I thought this was convenient: perl is trying to “do the
> right thing.” But I worry that leaving them out may be bad coding practice;
> if so, or you see other worthwhile improvements, please let me know.
> 
> More importantly, I wonder how perl knows to do this. Perhaps  context
> provided by the assignment operator or the concatenation operator? If there
> is a general rule on this, it would help me to know more widely when I can
> omit double quotes.
> 
> Thanks!
> 
> Rick Triplett


-- 
-----
Shlomi Fish   http://www.shlomifish.org/
First stop for Perl beginners - http://perl-begin.org/

After all is said and done, a hell of a lot more is said than done.
— Unclear source, via fortune-mod.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Replacing 10 year old web server

2018-06-29 Thread Shlomi Fish
Hi Gary!

On Fri, 29 Jun 2018 15:54:33 +0100
Gary Stainburn  wrote:

> I'm replacing my old F9 web server with a new C7 one.  While I've used RPM's 
> for most packages there have been times when I've had to use CPAN and PEAR.
> 
> For the PEAR items I'm able to do 
> 
> pear list -a > pear_list.txt
> 
> to get a list of all modules installed that way. Is there an equivelent 
> command for CPAN to tell me which modules I've installed that way?
> 

There are some answers for that here -
https://stackoverflow.com/questions/115425/how-do-i-get-a-list-of-installed-cpan-modules
 .
Found in a google search.

-- 
-----
Shlomi Fish   http://www.shlomifish.org/
What Makes Software Apps High Quality -  http://shlom.in/sw-quality

XSLT is the number one cause of programmers’ suicides since Visual Basic 1.0.
— http://www.shlomifish.org/humour/bits/facts/XSLT/

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: can not locate installe module

2018-06-14 Thread Shlomi Fish
On Mon, 4 Jun 2018 11:20:53 +0100
Gary Stainburn  wrote:

> On Monday 04 June 2018 10:39:28 Shlomi Fish wrote:
> > is there anything in https://en.wikipedia.org/wiki/Environment_variable ?  
> 
> I do have some interesting perl settings, although I have no idea where they 
> have come from.  This is a brand new Centos 7 install, and prior to trying to 
> install the three modules everything had been done by installing RPM's
> 
> This does seem to corroborate your theory below about it being local only to 
> root, and wh 'perl -c' works.  However, shouldn't the perldoc also have 
> worked in that instance?
> 
> [root@ollie2 ~]# set|grep -i perl
> PATH=/root/perl5/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
> PERL5LIB=/root/perl5/lib/perl5:
> PERL_LOCAL_LIB_ROOT=:/root/perl5
> PERL_MB_OPT='--install_base /root/perl5'
> PERL_MM_OPT=INSTALL_BASE=/root/perl5
> if type perl &>/dev/null; then
> COMPREPLY=($( compgen -W '$( perl -e '"'"'while (($gid) = 
> (getgrent)[2]) { print $gid . "\n" }'"'"' )' -- "$cur" ));
> --perl-regexp
> if type perl &>/dev/null; then
> COMPREPLY=($( compgen -W '$( perl -e '"'"'while (($uid) = 
> (getpwent)[2]) { print $uid . "\n" }'"'"' )' -- "$cur" ));
> [root@ollie2 ~]#  
> 
> > Perhaps you have https://metacpan.org/pod/local::lib enabled or similar.  
> 
> I have checked and I do indeed have local::lib installed.  It got installed
> as a depencancy of perl-CPAN.rpm.  When I tried to remove it, it wouldn't 
> because of the dependancy.  When I removed both that and perl-CPAN that was 
> okay, although it didn't remove the Env Vars.
> 
> However, when I re-installed the perl-CPAN RPM it pulled perl-local-lib in 
> again too.
> 
> Looks like I need to move over to the Centos list as this appears to be a 
> Centos problem now rather than a perl one.
> 

good luck, and I am glad I could help.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Removing a Pattern using a Regular Expression

2018-06-14 Thread Shlomi Fish
Hi Dmitri,

On Thu, 14 Jun 2018 11:34:34 +0300
Дмитрий Ананьевский  wrote:

> On Wed, 13 Jun 2018 21:21:12 -0500
> "Martin McCormick"  wrote:
> 
> > I wrote a small perl program to more quickly read all the
> > subjects in an email list.  One of the things the script does is
> > to remove the mailing list name which repeats for every message
> > and consists of a [, some English text and finally a ].
> > 
> > I was able to write a RE that identifies that text and
> > cause the script to save that string in a variable called
> > $remove.  That part works and looks like:
> > 
> > foreach my $field (@fields) {#Assemble the new subject.
> > if($field =~ m/\[(.*?)\]/) 
> > { #$field is the blocked field.
> > $remove = $field;
> > } #field is the blocked field.
> > else
> > { #$field is not the blocked string.
> > $newest = $newest . $field;
> > } #$field is not the blocked string.
> > }#Assemble the new subject.
> > 
> > if ( $newest eq $previous ) {#Skip this iteration.
> > $newest = "";
> > next;
> > }#Skip this iteration.
> > else
> > { #they are different.
> > 
> > This is where things don't quite work yet.  At this
> > point, I have $remove which contains that bracketted list name
> > such as
> > 
> > [BLIND-HAMS] or any number of other names enclosed in brackets.
> > So, the next thing I do is to attempt to remove just that part of
> > the subject line, keeping everything else that was there.
> > 
> >$subject =~ s/'$remove'//;
> > print( $subject, "\n" );
> > 
> > The example, here is the closest thing to anything
> > happening.  In the case of [BLIND-HAMS] the B is gone but the
> > brackets and everything else remains
> > 
> > I looked around for examples of similar code and found
> > 
> > $subject =~ s/$remove\K.*?(?=\d+)//;
> > 
> > It looks like it should keep everything else in the $subject
> > string except [BLIND-HAMS] but it keeps everything including that
> > so there is no change.
> > 
> > I actually think I am close but the line with the
> > brackets may be confusing the shell although single and double
> > quotes don't make any difference.
> > 
> > I also may have damaged that last example when I modified
> > it to work with a string called $subject which is the whole
> > subject line and $remove which is the part I am trying to remove.
> > 
> > The rest of the script appears to work and is designed to
> > only list the first message in a list of N messages of the same
> > subject. so, if there are 120 messages with the subject of "how
> > did you spend your Summer?", I read the first of those subject
> > lines and none until the first message that doesn't have that
> > title.
> > 
> > Any constructive ideas are appreciated.  Thank you.
> > 
> > Martin McCormick
> > 
> > -- 
> > To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> > For additional commands, e-mail: beginners-h...@perl.org
> > http://learn.perl.org/
> > 
> >   
> 
> I think it's because you have 
> 
> $subject =~ s/[BLIND-HAMS]//;
> 
> and it deletes first appeared symbol from the diapason.
> 

https://en.wiktionary.org/wiki/diapason - perhaps you mean "character class".

> You can try smth like $remove =~ s/([\[\]])/\\$1/g;
> 

Why not use http://perldoc.perl.org/functions/quotemeta.html ?

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Removing a Pattern using a Regular Expression

2018-06-14 Thread Shlomi Fish
Hi,

On Wed, 13 Jun 2018 21:21:12 -0500
"Martin McCormick"  wrote:

> I wrote a small perl program to more quickly read all the
> subjects in an email list.  One of the things the script does is
> to remove the mailing list name which repeats for every message
> and consists of a [, some English text and finally a ].
> 
>   I was able to write a RE that identifies that text and
> cause the script to save that string in a variable called
> $remove.  That part works and looks like:
> 
> foreach my $field (@fields) {#Assemble the new subject.
> if($field =~ m/\[(.*?)\]/) 
> { #$field is the blocked field.
> $remove = $field;
> } #field is the blocked field.
> else
> { #$field is not the blocked string.
> $newest = $newest . $field;
> } #$field is not the blocked string.
> }#Assemble the new subject.
> 
> if ( $newest eq $previous ) {#Skip this iteration.
> $newest = "";
> next;
> }#Skip this iteration.
> else
> { #they are different.
> 

1. Your indentation is erratic.

2. See http://perl-begin.org/tutorials/bad-elements/ .


>   This is where things don't quite work yet.  At this
> point, I have $remove which contains that bracketted list name
> such as
> 
> [BLIND-HAMS] or any number of other names enclosed in brackets.
> So, the next thing I do is to attempt to remove just that part of
> the subject line, keeping everything else that was there.
> 
>$subject =~ s/'$remove'//;
> print( $subject, "\n" );
> 

1. why did you add single quotes?

2. Perhaps use
http://perl-begin.org/tutorials/bad-elements/#re_string_interpolate

>   The example, here is the closest thing to anything
> happening.  In the case of [BLIND-HAMS] the B is gone but the
> brackets and everything else remains
> 
>   I looked around for examples of similar code and found
> 
> $subject =~ s/$remove\K.*?(?=\d+)//;
> 
> It looks like it should keep everything else in the $subject
> string except [BLIND-HAMS] but it keeps everything including that
> so there is no change.
> 
>   I actually think I am close but the line with the
> brackets may be confusing the shell although single and double
> quotes don't make any difference.
> 
>   I also may have damaged that last example when I modified
> it to work with a string called $subject which is the whole
> subject line and $remove which is the part I am trying to remove.
> 
>   The rest of the script appears to work and is designed to
> only list the first message in a list of N messages of the same
> subject. so, if there are 120 messages with the subject of "how
> did you spend your Summer?", I read the first of those subject
> lines and none until the first message that doesn't have that
> title.
> 
> Any constructive ideas are appreciated.  Thank you.
> 
> Martin McCormick
> 



-- 
-
Shlomi Fish   http://www.shlomifish.org/
Funny Anti-Terrorism Story - http://shlom.in/enemy

Every successful open source project will eventually spawn a sub‐project.
— http://www.shlomifish.org/humour/fortunes/osp_rules.html

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: project euler #8

2018-06-07 Thread Shlomi Fish
Hi,

why did you resurrect a one year old's thread for which there were proper
replies here -
https://www.nntp.perl.org/group/perl.beginners/2017/05/msg126502.html and here
- https://github.com/shlomif/project-euler/tree/master/project-euler/8 . just
let sleeping dogs rest. Some comments on your code:

 On Wed, 06 Jun 2018 19:23:11 -0700
"John W. Krahn"  wrote:

> On Tue, 2017-05-16 at 14:01 +0800, derr...@thecopes.me wrote:
> 
> 
> I am working on problem #8 of the euler project. see below.
> > 
> > 
> > 
> > The four adjacent digits in the 1000-digit number that have the
> > greatest product are 9 × 9 × 8 × 9 = 5832.
> > 
> > 73167176531330624919225119674426574742355349194934
> > 96983520312774506326239578318016984801869478851843
> > 85861560789112949495459501737958331952853208805511
> > 12540698747158523863050715693290963295227443043557
> > 66896648950445244523161731856403098711121722383113
> > 6222989342338030813533627661428280686645238749
> > 30358907296290491560440772390713810515859307960866
> > 70172427121883998797908792274921901699720888093776
> > 65727333001053367881220235421809751254540594752243
> > 52584907711670556013604839586446706324415722155397
> > 53697817977846174064955149290862569321978468622482
> > 83972241375657056057490261407972968652414535100474
> > 82166370484403199890008895243450658541227588666881
> > 16427171479924442928230863465674813919123162824586
> > 17866458359124566529476545682848912883142607690042
> > 2421902267105562632109370544217506941658960408
> > 07198403850962455444362981230987879927244284909188
> > 84580156166097919133875499200524063689912560717606
> > 05886116467109405077541002256983155200055935729725
> > 71636269561882670428252483600823257530420752963450
> > 
> > Find the thirteen adjacent digits in the 1000-digit number that have
> > the greatest product. What is the value of this product?  
> 
> 
> 
> #!/usr/bin/perl
> use warnings;
> use strict;
> 
> ( my $x = < 73167176531330624919225119674426574742355349194934
> 96983520312774506326239578318016984801869478851843
> 85861560789112949495459501737958331952853208805511
> 12540698747158523863050715693290963295227443043557
> 66896648950445244523161731856403098711121722383113
> 6222989342338030813533627661428280686645238749
> 30358907296290491560440772390713810515859307960866
> 70172427121883998797908792274921901699720888093776
> 65727333001053367881220235421809751254540594752243
> 52584907711670556013604839586446706324415722155397
> 53697817977846174064955149290862569321978468622482
> 83972241375657056057490261407972968652414535100474
> 82166370484403199890008895243450658541227588666881
> 16427171479924442928230863465674813919123162824586
> 17866458359124566529476545682848912883142607690042
> 2421902267105562632109370544217506941658960408
> 07198403850962455444362981230987879927244284909188
> 84580156166097919133875499200524063689912560717606
> 05886116467109405077541002256983155200055935729725
> 71636269561882670428252483600823257530420752963450
> STUFF
> 
> my @z = ( 0 ) x 5;

why 5?
> while ( $x =~ / ( . ) (?= ( . ) ( . ) ( . ) ( . ) ( . ) ( . ) ( . ) ( .
> ) ( . ) ( . ) ( . ) ( . ) ) /xg ) {
> my $y = $1 * $2 * $3 * $4 * $5 * $6 * $7 * $8 * $9 * $10 * $11 *
> $12 * $13;
> @z = ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $y )
> if $z[ -1 ] < $y;
> }
> 

this code is full of duplicate functionality and you are abusing the capture
vars as arrays.

The ?= trick is nice, though.

> print "@z\n";
> 
> 
> __END__
> 

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: can not locate installe module

2018-06-04 Thread Shlomi Fish
Hi,

On Mon, 4 Jun 2018 10:28:09 +0100
Gary Stainburn  wrote:

> On Monday 04 June 2018 09:36:02 Shlomi Fish wrote:
> > what does "perldoc -l MIME::Parser" say? Also see
> > http://perl-begin.org/FAQs/ and http://perl-begin.org/topics/cpan/ .  
> 
> I have tried this for all three modules installed through CPAN and all three 
> come up with the same thing:
> 
> [root@ollie2 ~]# perldoc -l MIME::Parser
> No documentation found for "MIME::Parser".
> [root@ollie2 ~]# perldoc -l Net::SCP
> No documentation found for "Net::SCP".
> [root@ollie2 ~]# perldoc -l Net::SSH
> No documentation found for "Net::SSH".
> [root@ollie2 ~]# 
> 
> If I try to find the perl modules it it looks like they haven't been 
> installed, but if that is the case, why does 'perl -c' come up OK?
> 

is there anything in https://en.wikipedia.org/wiki/Environment_variable ?
Perhaps you have https://metacpan.org/pod/local::lib enabled or similar.

> [root@ollie2 ~]# find / -iname Parser.pm
> /root/.cpan/build/MIME-tools-5.509-umkw_d/lib/MIME/Parser.pm
> /root/.cpan/build/MIME-tools-5.509-umkw_d/blib/lib/MIME/Parser.pm
> /root/ollie/root/.cpan/build/MIME-tools-5.427-bhvQQE/blib/lib/MIME/Parser.pm
> /root/ollie/root/.cpan/build/MIME-tools-5.427-bhvQQE/lib/MIME/Parser.pm
> /root/perl5/lib/perl5/MIME/Parser.pm

Looks like it isn't installed system-wide - only under the "/root" home dir.

> /usr/lib64/perl5/vendor_perl/XML/Parser.pm
> /usr/lib64/perl5/vendor_perl/HTML/Parser.pm
> /usr/share/perl5/vendor_perl/TAP/Parser.pm
> /usr/share/perl5/vendor_perl/Mail/SpamAssassin/Conf/Parser.pm
> /usr/share/perl5/vendor_perl/Convert/ASN1/parser.pm
> [root@ollie2 ~]# find / -iname SCP.pm
> /root/.cpan/build/Net-SCP-0.08-q8mDLD/SCP.pm
> /root/.cpan/build/Net-SCP-0.08-q8mDLD/blib/lib/Net/SCP.pm
> /root/perl5/lib/perl5/Net/SCP.pm
> [root@ollie2 ~]# 
> 



-- 
-
Shlomi Fish   http://www.shlomifish.org/
Understand what Open Source is - http://shlom.in/oss-fs

I’m not an actor — I just play one on T.V.
— http://www.shlomifish.org/humour.html

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: difficulty with matching

2018-06-04 Thread Shlomi Fish
On Sat, 2 Jun 2018 07:30:48 -0500
p...@reason.net wrote:

> Very useful advice, Shlomi; thanks!
> 

you are welcome! Also see http://perl-begin.org/tutorials/bad-elements/ , which
I also maintain.

> 
> > On Jun 2, 2018, at 3:57 AM, Shlomi Fish  wrote:
> > 
> > On Fri, 1 Jun 2018 15:54:55 -0500
> > Rick T mailto:p...@reason.net>> wrote:
> >   
> >> This is a newbie question, I’m sure. But I get perplexed easily!
> >> 
> >> The follow code segment expects to receive a $student_id consisting of a
> >> surname followed by a hyphen followed by a number. The die is for testing
> >> what I’m doing. 
> >> 
> >> If I feed it 'jones-123’ it dies with ‘jones, - , 123’ as I expected. But
> >> if I feed it ‘jones-‘ omitting the number on the end, it dies with no
> >> matches at all (or blanks): ‘ , , ‘ and I cannot figure out why it does
> >> not die with ‘jones, -, ' and would appreciate an explanation. Many thanks!
> >> 
> >>$student_id = lc $student_info_hash{student_id}; # Impose lower case
> >>$student_id =~ s/\s//xmsg;   # Remove whitespace
> >> 
> >>$student_id =~
> >>m{
> >>\A([a-z]+)  # match and capture leading alphabetics 
> >>(-) # hyphen to separate surname from student number
> >>([0-9]+\z)  # match and capture trailing digits
> >> }xms;  # Perl Best Practices
> >>$student_surname = $1;
> >>my $hyphen   = $2;
> >>$student_number  = $3;  
> > 
> > In addition to the other comments, Instead of that, you should do:
> > 
> > if (my ($surname, $hyphen, $num) = $student_id =~ m{ ... }xms)
> > {
> > # match successful.
> > }
> > else
> > {
> > die "match failed ...";
> > }
> > 
> > always check for regex match successes and use the return captures of regex
> > ops. See PBP for more.
> >   
> >> die "$student_surname, $hyphen, $student_number”;
> >> 
> >> Rick Triplett
> >>   
> > 
> > 
> > 
> > -- 
> > -
> > Shlomi Fish   http://www.shlomifish.org/ <http://www.shlomifish.org/>
> > Best Introductory Programming Language - http://shlom.in/intro-lang
> > <http://shlom.in/intro-lang>
> > 
> > A horse! A horse! My kingdom for a horse!
> >— https://en.wikiquote.org/wiki/Richard_III_%28play%29
> > <https://en.wikiquote.org/wiki/Richard_III_%28play%29>
> > 
> > Please reply to list if it's a mailing list post - http://shlom.in/reply
> > <http://shlom.in/reply> .
> > 
> > --
> > To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> > <mailto:beginners-unsubscr...@perl.org> For additional commands, e-mail:
> > beginners-h...@perl.org <mailto:beginners-h...@perl.org>
> > http://learn.perl.org/ <http://learn.perl.org/>  



-- 
-
Shlomi Fish   http://www.shlomifish.org/
NSA Factoids - http://www.shlomifish.org/humour/bits/facts/NSA/

Chuck Norris wrote an interpreter for a Turing-complete language using only
NOPs.
— http://www.shlomifish.org/humour/bits/facts/Chuck-Norris/

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: can not locate installe module

2018-06-04 Thread Shlomi Fish
Hi,

On Mon, 4 Jun 2018 07:55:16 +0100
Gary Stainburn  wrote:

> I've juts built a new Centos 7 email server and all has gone well.
> 
> I have used RPM's where possible, but for some modules I have had to use
> CPAN. One such module was MIME::Parser, which installed without errors.
> 
> If I check my program it now says that it's fine.  If I try to re-install the 
> module it says it's up to date.
> 
> however, when I try to run the program (as a pipe via exim) it complains that 
> it cannot locate the module.
> 
>  Does anyone have any ideas?
> 
> 
> cpan[1]> install MIME::Parser  
> Reading '/root/.cpan/Metadata'
>   Database was generated on Sun, 03 Jun 2018 04:17:03 GMT
> MIME::Parser is up to date (5.509).
> 
> cpan[2]> Lockfile removed.  
> [root@ollie2 ~]# perl -c /etc/exim/bin/admin_doc_gateway4
> /etc/exim/bin/admin_doc_gateway4 syntax OK
> [root@ollie2 ~]# 
> 
> 
> -- pipe to |/etc/exim/bin/admin_doc_gateway4 -e >>/var/log/faxgateway 2>&1
>        generated by dealpa...@ringways.co.uk --
> 
> Can't locate MIME/Parser.pm in @INC (@INC 
> contains: /usr/local/lib64/perl5 /usr/local/share/perl5 
> /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 
> /usr/share/perl5 .) 
> at /etc/exim/bin/admin_doc_gateway4 line 9.
> BEGIN failed--compilation aborted at /etc/exim/bin/admin_doc_gateway4 line 9.
> 

what does "perldoc -l MIME::Parser" say? Also see http://perl-begin.org/FAQs/
and http://perl-begin.org/topics/cpan/ .

-- 
-
Shlomi Fish   http://www.shlomifish.org/
http://youtu.be/KxGRhd_iWuE - Never Give Up!!

What's the point of claiming your code is illegal?
I might anger a few, but I just wanna sue
— http://www.shlomifish.org/humour/bits/Can-I-SCO-Now/

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: difficulty with matching

2018-06-02 Thread Shlomi Fish
On Fri, 1 Jun 2018 15:54:55 -0500
Rick T  wrote:

> This is a newbie question, I’m sure. But I get perplexed easily!
> 
> The follow code segment expects to receive a $student_id consisting of a
> surname followed by a hyphen followed by a number. The die is for testing
> what I’m doing. 
> 
> If I feed it 'jones-123’ it dies with ‘jones, - , 123’ as I expected. But if
> I feed it ‘jones-‘ omitting the number on the end, it dies with no matches at
> all (or blanks): ‘ , , ‘ and I cannot figure out why it does not die with
> ‘jones, -, ' and would appreciate an explanation. Many thanks!
> 
> $student_id = lc $student_info_hash{student_id}; # Impose lower case
> $student_id =~ s/\s//xmsg;   # Remove whitespace
> 
> $student_id =~
> m{
> \A([a-z]+)  # match and capture leading alphabetics 
> (-) # hyphen to separate surname from student number
> ([0-9]+\z)  # match and capture trailing digits
>  }xms;  # Perl Best Practices
> $student_surname = $1;
> my $hyphen   = $2;
> $student_number  = $3;

In addition to the other comments, Instead of that, you should do:

if (my ($surname, $hyphen, $num) = $student_id =~ m{ ... }xms)
{
# match successful.
}
else
{
die "match failed ...";
}

always check for regex match successes and use the return captures of regex
ops. See PBP for more.

> die "$student_surname, $hyphen, $student_number”;
> 
> Rick Triplett
> 



-- 
-
Shlomi Fish   http://www.shlomifish.org/
Best Introductory Programming Language - http://shlom.in/intro-lang

A horse! A horse! My kingdom for a horse!
— https://en.wikiquote.org/wiki/Richard_III_%28play%29

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Read a huge text file in perl

2018-05-24 Thread Shlomi Fish
Hi,

On Thu, 24 May 2018 20:27:23 +0530
SATYABRATA KARAN <satyabratakara...@gmail.com> wrote:

> Hello,
> Does anyone guide me how to handle a huge file (>50GB) in perl?
> 
> I tried open method this way, but it's hanging the terminal. I think that
> is out of memory error internally.
> 
> open my $FILE, "<", "Log_file.txt";
> 
> while (<$FILE>) {
>  chomp;
>  some task;
>  ...
> }
> 
> close $FILE;
>

1. How long are the lines in the file?

2. Can you try https://en.wikipedia.org/wiki/Htop or similar to be sure?

 
> 
> Thanks,
> Satya



-- 
-
Shlomi Fish   http://www.shlomifish.org/
http://www.shlomifish.org/humour/bits/New-versions-of-the-GPL/

How many “one-liners” do I actually write? I don’t know; maybe a couple dozen
a day. But I guess I must be unusual, because as we all know, AWK was a
complete failure and vanished into obscurity since it didn’t address anyone’s
real needs. (That was sarcasm.) — “Twelve Views of Mark Jason Dominus”

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: regex with HEX ascii chars

2018-04-12 Thread Shlomi Fish
On Thu, 12 Apr 2018 17:26:57 +0100
Gary Stainburn <gary.stainb...@ringways.co.uk> wrote:

> I have a text file (created by  pdftotext) that I've imported into my script.
> 
> It contains ASCII characters 251 for crosses and 252 for ticks.  If I load
> the file in gvim and do :as
> 
> it reports the characters as 
> 
>  251, Hex 00fb, Octal 373
>  252, hex 00fc, Octal 374
> 
> However, when I try to seacch for it using
> 
> if ($line=~/[\xfb|\xfc]/) {
> 
> or even just 
> 
> if ($line=~/\xfb/) { 
> 
> it always fails.  What am I doing wrong?
> 

Perhaps see http://perldoc.perl.org/perlunitut.html - you may need to read the
file as binary or iso8859-1 or whatever. Also see
https://github.com/shlomif/how-to-share-code-online and read what Andy noted.

> Gary
> 



-- 
-
Shlomi Fish   http://www.shlomifish.org/
https://github.com/shlomif/what-you-should-know-about-automated-testing

It’s easier to port a shell than a shell script.
— http://en.wikiquote.org/wiki/Larry_Wall

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Syntax problem

2018-03-28 Thread Shlomi Fish
Hi,

On Wed, 28 Mar 2018 13:00:47 +0700
Olivier <olivier.nic...@cs.ait.ac.th> wrote:

> Hi,
> 
> I am building a script to modify my LDAP directory and I want to use
> something like:
> 
> $mesg = $ldap->modify( $dn,
>   replace => {
> description => 'New List of members',
> seeAlso => 'Some reference'
>   }
> );
> 
> But I would like to build the list of replacements dynamically, that is,
> have a variable of the appropriate type, where I can first store
> "description" and "New List of members" then also store "seeAlso" and
> "Some reference"; and then only use that variable to do the replace.
> 

please see http://perl-begin.org/topics/references/ .

> I have two questions:
> 
> - What type should I use for the variable?
> 
> - What will be the syntax for the $ldap->modify statement?
> 
> Thanks in advance,
> 
> Olivier
> 
> 
> 



-- 
-
Shlomi Fish   http://www.shlomifish.org/
“So, who the hell is Qoheleth?” - http://shlom.in/qoheleth

When people agree with me I always feel I must be wrong.
— https://en.wikiquote.org/wiki/Oscar_Wilde (via fortune-mod)

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: [^/]* Is Not Working

2018-03-24 Thread Shlomi Fish
On Sun, 18 Mar 2018 12:32:44 +0100
hw <h...@adminart.net> wrote:

> John SJ Anderson <j...@genehack.org> writes:
> 
> >> But this one in its place does not work:
> >> if ($link =~ m/\/([^/]*)$/) { # Oddly this does not work  
> >
> > You still need to escape the `/` inside the character class.
> >
> > This works in my testing: `m/\/([^\/]*)$/`.
> >
> > IMO this is a case where an alternative delimiter for `m//` — such as the
> > `#` in your working example — is a better approach.   
> 
> IIRC it´s said in best practises or so that brackets ({, }) should be
> used for an alternative delimiter and that they should probably be the
> only substitute to use.
> 

I don't blindly follow https://en.wikipedia.org/wiki/Perl_Best_Practices and
disagree about this. I find it useful to use #, % and other delimiters which do
not naturally occur in regexes or otherwise.


-- 
-
Shlomi Fish   http://www.shlomifish.org/
Selina Mandrake - The Slayer (Buffy parody) - http://shlom.in/selina

*Chuck*: Indeed. Anyway, I invited a friend who is even crazier than I am.
*Kermit*: Really, who is this crazy guy?
*Chuck*: Actually, it’s a crazy girl.
— http://is.gd/htmOCv

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Help debugging some old Bugzilla perl scripts

2018-02-26 Thread Shlomi Fish
Hi jose,

please see http://www.shlomifish.org/Files/files/code/bugzilla.patch for my
patch against bugzilla 3.2 to get it to compile with recent perls.

 On Mon, 26 Feb 2018 05:43:45 +0100
"jose cabrera"  wrote:

> On Sunday, February 25, 2018 at 11:26 PM, "Uri Guttman" wrote...
> > >
> > > 
> > > syntax error at Bugzilla/Bug.pm line 1085, near "$type qw(dependson
> > > blocked)"
> > >
> > > Here is line 1085:
> > >  foreach my $type qw(dependson blocked) {
> > >  my @bug_ids = split(/[\s,]+/, $deps_in{$type});  
> > 
> > put parens around the qw(). it used to be allowed as the () in the for 
> > loop but not anymore.  
> 
> Thanks.
> 
> > >
> > > 
> > > Can't use global @_ in "my" at Bugzilla/Bug.pm line 1134, near "= @_"
> > >
> > > Here is line 1133, 1134, 1135:
> > > sub _check_dup_id {
> > >  my ($self, $dupe_of) = @_;
> > >  my $dbh = Bugzilla->dbh;
> > >  
> 
> Yeah, I could not see anything wrong with it, but what I did was to install
> perlbrew and I am downloading 5.8.9, which should be the version that was
> released with Bugzilla 3.2.  I am going to see if this new change fixes all
> of these errors. ;-)  Thanks for the support.
> 
> josé
> 
> --
> What if eternity is real? Where will you spend it? Hmmm...
> 

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Does perl v5.8.9 supports Ubuntu 64 bit?

2018-02-26 Thread Shlomi Fish
Hi jose,

On Mon, 26 Feb 2018 05:56:19 +0100
"jose cabrera"  wrote:

> Greetings!
> 
> I just installed perlbrew and I tried installing perl v5.8.9 to prevent
> trying to fix a bunch of v5.8.9 perl code, but it failed.  The first thing
> that came to mind was x64 vs x32.  Can this perl version v5.8.9 be installed
> on an Ubuntu x64 bit?  Thansk.
> 

were the only failing tests in op/numconvert? If so, it does not seem serious.
and you can use --force or --notest. That put aside, this is an old version of
perl with many known bugs that have been fixed in later versions and many
missing features. Please don't use it.

> josé
> 
> --
> What if eternity is real? Where will you spend it? Hmmm...
> 

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: ssh::command

2018-02-13 Thread Shlomi Fish
Hi Lancelot,

some comments on your code:

On Tue, 13 Feb 2018 17:19:03 +0800
Lancelot Mak <lancelot@computer.org> wrote:

> #!/usr/bin/perl -W
> 

1. don't use -w - http://perl-begin.org/tutorials/bad-elements/#the-dash-w-flag

2. use strict and warnings instead.

> use SSH::Command;
> 
> $cmdln = `grep $ARGV[0] list.txt`;
> chomp($cmdln);

use file i/o or IO-All or Path-Tiny instead of ``:
http://perl-begin.org/tutorials/bad-elements/#calling-the-shell-too-much

> ($cmdhost,$user,$pass) = split(':',$cmdln);
> $p = `echo $pass|base64 -d`;
> chomp($p);
> 

use https://metacpan.org/release/MIME-Base64 instead and avoid people snooping
on ps.
> $cmdlog = ssh_execute(
> host => $cmdhost,
> username => $user,
> password => $p,
> command => "$ARGV[1]",
> );
> 

See http://perl-begin.org/tutorials/bad-elements/#vars_in_quotes .

> 
> print $cmdlog;
> 
> print "\n";
> 
> 
> On 13 February 2018 at 16:36, Chas. Owens <chas.ow...@gmail.com> wrote:
> 
> > 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 <lancelot@gmail.com> wrote:
> >  
> >> Hi all,
> >> I am using SSH::Command module to do ssh stuff but it does not return
> >> full reply from server. Any clue? It just returns part of it. Is it
> >> timeout? or what?
> >> Thanks.
> >>
> >>
> >> --
> >> --
> >> Lancelot Mak
> >>  
> >  
> 
> 



-- 
-
Shlomi Fish   http://www.shlomifish.org/
http://is.gd/htwEXQ - Integrating GNU Guile into GNU coreutils

Give me ASCII or give me deaþ!
— http://www.shlomifish.org/humour.html

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Checking if a website is up doesn't work correctly

2018-02-13 Thread Shlomi Fish
Hi Manfred!

On Tue, 13 Feb 2018 12:25:31 +0100
Manfred Lotz <ml_n...@posteo.de> wrote:

> Hi there,
> Somewhere I found an example how to check if a website is up.
> 
> Here my sample:
> 
> #! /usr/bin/perl
> 
> use strict;
> 
> use LWP::Simple;
> my $url="https://notabug.org;;
> if (! head($url)) {
> die "$url is DOWN" 
> }
> 
> Running above code I get
>   https://notabug.org is DOWN at ./check_url.pl line 8.
> 

This code seems to work fine here:

#!/usr/bin/perl

use strict;
use warnings;

use LWP::Simple;
  my $url="https://shlomif.github.io/;;
# my $url="https://notabug.org/;;
if (! head($url)) {
die "$url is DOWN";
}

seems like notabug blocks libwww-perl.


> 
> However, firefox shows the site works ok.
>

same here.

Regards,

Shlomi
 
> 
> What am I doing wrong?
> 
> 



-- 
-
Shlomi Fish   http://www.shlomifish.org/
Chuck Norris/etc. Facts - http://www.shlomifish.org/humour/bits/facts/

 “Hey, I have a flat tire. Can you help me change it with a can opener
and a pound of sesame seeds?”
— talexb on parsing HTML or XML with regular expressions.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: What is the substitute for $#?

2018-01-26 Thread Shlomi Fish
Hi Peng,

On Fri, 26 Jan 2018 15:33:43 -0600
Peng Yu <pengyu...@gmail.com> wrote:

> Hi, $# is deprecated. Could anybody let me know what is the substitute for it?
> 
> https://perldoc.perl.org/perlvar.html
> 
> $# was a variable that could be used to format printed numbers. After
> a deprecation cycle, its magic was removed in Perl v5.10.0 and using
> it now triggers a warning: $# is no longer supported.
> 

according to
https://metacpan.org/pod/release/NWCLARK/perl-5.8.3/pod/perlvar.pod - it seems
it used printf/sprintf format so just use those explicitly where needed. See:

* http://perldoc.perl.org/functions/sprintf.html

* http://perl-begin.org/uses/text-generation/

e.g:

print "I am ", sprintf("%e", $age), " years old.";

Regards,

Shlomi
-- 
-----
Shlomi Fish   http://www.shlomifish.org/
http://www.shlomifish.org/humour/bits/New-versions-of-the-GPL/

A positive attitude may not solve all your problems, but it will annoy enough
people to make it worth the effort. — Herm Albright (via On Gossamer Wings)

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Find::Perl find not returning

2017-12-13 Thread Shlomi Fish
{resending}

Hi Mike,

On Wed, 13 Dec 2017 11:28:55 +
Mike Martin  wrote:

> Hi
> I have the following code
> 
> use strict;
> use File::Find;
> my @vsbe;
> my $top='P:\PT-6\PT-60\PT-603\Shared\Data Store\Files Dump Folder';
> my $max_depth=9;
> my $cnt1=0;
> 
> find({wanted=>\,preprocess=>\},$top) ;  
> 
> sub wanted1 {
> 
> if ($cnt1 <=1000){
> my $file = $File::Find::name;
> if (grep {/vsb$/} $file){
> push @vsbe, $file if $cnt1 <=1000 ;
> $cnt1++;
> print $cnt1,"\n" ;
> }
> else {return}
> 
> return if $cnt1 >=1000
> }
> return
> 
> }
> sub preprocess1 {
> my $depth = $File::Find::dir =~ tr[\\][];
> #print 'depth',"\t",$depth,"\t",$File::Find::dir,"\n";
> return  @_ if $depth < $max_depth;
> return grep { not -d } @_ if $depth == $max_depth;
> return;
> }
> 
> Unfortunately the wanted function never returns, it (at best) stays stuck
> on print the last value of $cnt1 (1000)
> 
> Any ideas what is happening here

my guess based on reading your code is that File::Find continues to scan the
directory tree recursively and calling wanted1() for every file. This is one of
the design quirks of the F::F interface and I suggest looking at better
alternatives on CPAN, such as
http://www.shlomifish.org/open-source/projects/File-Find-Object/ which I
maintain. See https://shlomif-tech.livejournal.com/29315.html for an article I
wrote about some other philosophical limitations of F::F that I solve (one of
them is similar to your use case).

Regards,

Shlomi

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Find::Perl find not returning

2017-12-13 Thread Shlomi Fish
Hi Mike,

On Wed, 13 Dec 2017 11:28:55 +
Mike Martin <redt...@gmail.com> wrote:

> Hi
> I have the following code
> 
> use strict;
> use File::Find;
> my @vsbe;
> my $top='P:\PT-6\PT-60\PT-603\Shared\Data Store\Files Dump Folder';
> my $max_depth=9;
> my $cnt1=0;
> 
> find({wanted=>\,preprocess=>\},$top) ;  
> 
> sub wanted1 {
> 
> if ($cnt1 <=1000){
> my $file = $File::Find::name;
> if (grep {/vsb$/} $file){
> push @vsbe, $file if $cnt1 <=1000 ;
> $cnt1++;
> print $cnt1,"\n" ;
> }
> else {return}
> 
> return if $cnt1 >=1000
> }
> return
> 
> }
> sub preprocess1 {
> my $depth = $File::Find::dir =~ tr[\\][];
> #print 'depth',"\t",$depth,"\t",$File::Find::dir,"\n";
> return  @_ if $depth < $max_depth;
> return grep { not -d } @_ if $depth == $max_depth;
> return;
> }
> 
> Unfortunately the wanted function never returns, it (at best) stays stuck
> on print the last value of $cnt1 (1000)
> 
> Any ideas what is happening here

my guess based on reading your code is that File::Find continues to scan the
directory tree recursively and calling wanted1() for every file. This is one of
the design quirks of the F::F interface and I suggest looking at better
alternatives on CPAN, such as
http://www.shlomifish.org/open-source/projects/File-Find-Object/ which I
maintain. See https://shlomif-tech.livejournal.com/29315.html for an article I
wrote about some other philosophical limitations of F::F that I solve (one of
them is similar to your use case).

Regards,

Shlomi

-- 
-
Shlomi Fish   http://www.shlomifish.org/
http://is.gd/i5eMQd - Emma Watson’s Interview for a Software Dev Job

In the beginning the Universe was created. This has made a lot of people very
angry and been widely regarded as a bad move.
— https://en.wikiquote.org/wiki/The_Hitchhiker's_Guide_to_the_Galaxy

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: perlbrew and modules

2017-12-07 Thread Shlomi Fish
On Thu, 7 Dec 2017 12:44:51 -0800
SSC_perl <p...@surfshopcart.com> wrote:

> > On Dec 7, 2017, at 12:04 PM, Shlomi Fish <shlo...@shlomifish.org> wrote:
> > 
> > What does:
> > 
> > say "@INC";
> > 
> > say if you add it to the script?  
> 
>   I get:
> 
> /home/user/perl5/perlbrew/perls/perl-5.26.1/lib/site_perl/5.26.1/x86_64-linux
> /home/user/perl5/perlbrew/perls/perl-5.26.1/lib/site_perl/5.26.1
> /home/user/perl5/perlbrew/perls/perl-5.26.1/lib/5.26.1/x86_64-linux
> /home/user/perl5/perlbrew/perls/perl-5.26.1/lib/5.26.1
> 
>   I found a .cpanm directory in /home/user where all the modules are
> being installed.  Could that have anything to do with it?  I tried adding
> that directory with "use lib" but I still get the 500 error.
> 

you should make sure that the modules you wish to use are in one of the
dirs in @INC. cpanm should install to  the global directories.

> Thanks,
> Frank



-- 
-
Shlomi Fish   http://www.shlomifish.org/
https://youtu.be/GoEn1YfYTBM - Tiffany Alvord - “Fall Together”

   Writing your own nirvana may be easier than writing a good
 blog engine ;)
— http://is.gd/3Hh82T

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: perlbrew and modules

2017-12-07 Thread Shlomi Fish
On Thu, 7 Dec 2017 11:50:17 -0800
SSC_perl <p...@surfshopcart.com> wrote:

>   I've run into another strange problem that I don't understand.
> Running the script below produces the output "Perl v5.26.1".  However, if I
> add the line: use CGI::Carp qw(fatalsToBrowser);  it produces a 500 error.
> 
>   On the shared server, this worked as it should, with
> 'fatalsToBrowser' showing any errors.  But the VPS is just backwards - adding
> it crashes the script!  This actually happens with any module and, yes, they
> are installed:
> 
> > cpanm install CGI::Carp  
> install is up to date. (0.01)
> CGI::Carp is up to date. (4.38)
> 
>   I have been fighting with this VPS setup for almost 2 weeks now just
> to get a functioning modern Perl environment and I'm about at my wits end.
> It shouldn't be this hard.
> 
>   I'd appreciate any help.
> 
> Thanks,
> Frank
> 
> 
> 
> 
> #!/home/user/perl5/perlbrew/perls/latest/bin/perl
> 
> use v5.26;
> use warnings;
> use diagnostics;
> 
> print "Content-type: text/html\n\n";
> say 'Perl '. $^V;

Hi Frank!

What does:

    say "@INC";

say if you add it to the script?


-- 
-
Shlomi Fish   http://www.shlomifish.org/
The Case for File Swapping - http://shlom.in/file-swap

Real men don’t listen to sentences that start with “Real men don’t”.
— http://whatsup.org.il/article/6023

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: [OT] converting a script to a distribution

2017-12-07 Thread Shlomi Fish
Hi Luca,

On Wed, 29 Nov 2017 13:56:48 +0100
Luca Ferrari <fluca1...@infinito.it> wrote:

> Hi all,
> This is not quite tied to Perl itself, but I'm trying to migrate a few
> stand-alone scripts I've written to fully distributions, may be
> uploaded to CPAN.
> Now, using a tool like distzilla, or alike, and assuming each script
> has already its git story and configuration files laying around, what
> is the better way to start at? Any pointer?

See http://perl-begin.org/topics/cpan/ and also read about modulinos -
https://duckduckgo.com/?q=perl+modulino=web . There is also
App::Cmd https://metacpan.org/search?q=app%20cmd and similar modules.

> 
> Thanks,
> Luca
> 



-- 
---------
Shlomi Fish   http://www.shlomifish.org/
http://www.shlomifish.org/humour/bits/New-versions-of-the-GPL/

Rindolf is the Evil twin brother of Rudolph and Randolph, Santa’s goody-two-
shoes reindeer, who are among his arch-enemies. He is also one of the
cornerstones of the Evil Reindeer Evil World Domination Evil Conspiracy, which
aims to spread Evil in general and Reindeer Evil in particular around the world.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Using Pack and Unpack

2017-12-07 Thread Shlomi Fish
On Wed, 06 Dec 2017 21:53:37 -0600
"Martin McCormick" <marti...@suddenlink.net> wrote:

> A perl program needs to send binary data to an external device
> such that 0xff looks like 
> 
>   I have a line in the program as follows:
> 
> my $txstart = pack("h*","fefe5a95");
> 
> Are those 4 bytes usable as the binary data 
> 
> fe fe 5a 95?
> 
>   Is there a good way when running perl -d to view the
> contents of the string to make sure it is what it should be?
> 

Yes, see the "x" command
( http://perl-begin.org/tutorials/perl-for-newbies/part2/#page--debugger--DIR ),
https://metacpan.org/pod/Data::Dumper , https://metacpan.org/pod/DDP , and some
debugger GUIs such as https://en.wikipedia.org/wiki/Data_Display_Debugger .

Regards,

Shlomi

> Thank you.
> 
> Martin McCormick
> 



-- 
-
Shlomi Fish   http://www.shlomifish.org/
http://www.shlomifish.org/humour/ways_to_do_it.html

Open source software: each person contributes a brick, but ultimately each
person receives a house in return.
— Brendan Scott (Attributed)

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Getting the results of a remote script

2017-11-10 Thread Shlomi Fish
Hi Gary,

On Fri, 10 Nov 2017 09:48:30 +
Gary Stainburn <gary.stainb...@ringways.co.uk> wrote:

> On Friday 10 November 2017 00:08:09 SSC_perl wrote:
> > > On Nov 9, 2017, at 2:06 PM, David Precious <dav...@preshweb.co.uk> wrote:
> > >
> > > you'll get whatever the script output to STDOUT.  
> >
> > Thanks a million, Dave!  STDOUT was what I was missing.  I've never
> > used that before, so this was news to me.  The remote script now returns a
> > string that I can manipulate and use in the local script.
> >
> > Thanks again,
> > Frank  
> 
> I would also look at using JSON for anything other than simple examples.  I 
> use this technique extensively for custom peer-to-peer apps. 
> 
> I have even develope a small xinetd service to accept incoming connections.
> 
> This has then enabled me to use Net::telnet in client scripts to generate 
> interactive services. JSON is a good, consistent method of transferring
> data.

While I agree, see http://seriot.ch/parsing_json.php for a roundup of security
problems and inconsistencies in JSON parsers.

>It also helps when combining PERL and PHP apps
> 

"Perl" is not an acronym - see
http://perl-begin.org/learn/Perl-perl-but-not-PERL/ and
https://github.com/perl-doc-cats/perlfaq/blob/master/lib/perlfaq1.pod#whats-the-difference-between-perl-and-perl
 .

Regards,

Shlomi

-- 
-
Shlomi Fish   http://www.shlomifish.org/
http://is.gd/i5eMQd - Emma Watson’s Interview for a Software Dev Job

Chuck Norris once jumped out of a plane, and the parachute did not open. So
instead Chuck Norris opened and brought him and the parachute down safely.
(By Andrew Brehm) — http://www.shlomifish.org/humour/bits/facts/Chuck-Norris/

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Getting the results of a remote script

2017-11-09 Thread Shlomi Fish
On Thu, 9 Nov 2017 08:16:47 +0700
thelip sia <hei...@gmail.com> wrote:

> you can use backtick to store the output.
> $list = `ssh usern...@domain.com '/usr/bin/perl /cgi-bin/dir-list.pl'`;
> 

Indeed, but note that one should be careful when interpolating strings there:

* http://perl-begin.org/topics/security/code-markup-injection/

* https://metacpan.org/pod/String::ShellQuote

Also see
http://perl-begin.org/tutorials/bad-elements/#declaring_all_vars_at_top
regarding predeclaration.


> Regards,
> Heince
> 
> On Thu, Nov 9, 2017 at 7:15 AM, SSC_perl <p...@surfshopcart.com> wrote:
> 
> > I have a script on a remote server that creates a list of all
> > directories on the server that end in a dash.  I need that list on my
> > laptop.  Is it possible to get the result into a variable in my local
> > script by triggering the remote script via ssh?  I've tried this:
> >
> > $list = system('ssh usern...@domain.com '/usr/bin/perl /cgi-bin/
> > dir-list.pl'");
> >
> > but it just returns '0'.  The system call is working fine - I just can't
> > get the result returned in $list.
> >
> > Searching hasn't returned an answer.  Is there another way to get
> > what I'm after?
> >
> > Thanks,
> > Frank
> > --
> > To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> > For additional commands, e-mail: beginners-h...@perl.org
> > http://learn.perl.org/
> >
> >
> >  



-- 
-
Shlomi Fish   http://www.shlomifish.org/

At this point, I'd like to take a moment to speak to you about the Adobe PSD
format. PSD is not a good format. PSD is not even a bad format. Calling it
such would be an insult to other bad formats, such as PCX or JPEG. No, PSD is
an abysmal format.
— https://github.com/gco/xee/blob/master/XeePhotoshopLoader.m

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Warnings::Unused Linux perl

2017-11-06 Thread Shlomi Fish
Hi,

On Sun, 05 Nov 2017 18:21:25 -0600
"Martin McCormick" <marti...@suddenlink.net> wrote:

> Shlomi Fish <shlo...@shlomifish.org> writes:
> > Hi Martin,
> > 
> > please see https://metacpan.org/release/warnings-unused as well as
> > http://perl-begin.org/topics/cpan/wrappers-for-distributions/ and
> > http://perl-begin.org/topics/cpan/ . It should not be hard to install and 
> > your
> > Linux distro may already have it packaged. It is just that it was already
> > available on your FBSD system.  
> 
>   Thank you.  I will give these a try as I thought the
> same functionality might be there in a module by another name
> when cpanp -i basically said it couldn't find anything by that
> name.
> 

The problem may have been the https://en.wikipedia.org/wiki/Letter_case . That
module has no uppercase letters.

> Martin
> 



-- 
-
Shlomi Fish   http://www.shlomifish.org/

That’s why I feed my leprechaun every day — because there are not enough
phonemes in Navajo to tell him to get his act together and find a job.
— My comment on http://www.youtube.com/watch?v=izne8XcaBBg .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Warnings::Unused Linux perl

2017-11-05 Thread Shlomi Fish
On Sun, 05 Nov 2017 16:51:09 -0600
"Martin McCormick" <marti...@suddenlink.net> wrote:

> Most of the work I did in perl was on a FreeBSD system and not
> surprisingly, perl under Linux behaves essentially the same but
> one thing I notice is that Warnings::Unused doesn't appear as a
> module.  It is quite useful in keeping one's code free of clutter
> so the question is whether there is another module that performs
> the same task?
> 
> use Warnings::Unused
> 
> in code produces:
> 
> Can't locate warnings/unused.pm in @INC (@INC
> contains: /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 
> /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 
> /usr/local/lib/site_perl .)
> at ./232start line 3. Thank you.
> 
> Martin McCormick
> 

Hi Martin,

please see https://metacpan.org/release/warnings-unused as well as
http://perl-begin.org/topics/cpan/wrappers-for-distributions/ and
http://perl-begin.org/topics/cpan/ . It should not be hard to install and your
Linux distro may already have it packaged. It is just that it was already
available on your FBSD system.




-- 
-
Shlomi Fish   http://www.shlomifish.org/
Freecell Solver - http://fc-solve.shlomifish.org/

If the mountain does not come to Muhammad, then Chuck Norris will bring the
mountain over.
— http://www.shlomifish.org/humour/bits/facts/Chuck-Norris/

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Archive::Zip->addTree returned 2

2017-10-05 Thread Shlomi Fish
On Wed, 4 Oct 2017 23:26:31 +0530
Asad  wrote:

> Hi All
> 
> I have perl script abc.pl and module abc.pm . When i execute abc.pl which
> is using one the modules
> 

Hi Asad!

Please see https://github.com/shlomif/how-to-share-code-online and comply with
the instructions there.



> Archive::Zip > I am getting the following errors :
> 
> patch_zip: /Location/patch1//patch1.zip Creating zip file
> /Location/patch1//patch1.zip for apply pwd: The file access
> permissions do not allow the specified action. A process terminated prior
> to completion. pwd: The file access permissions do not allow the specified
> action. pwd: The file access permissions do not allow the specified action.
> error: undef returned by _untaintDir on cwd at
> /Location/lib/Archive/Zip/Archive.pm line 754
> Archive::Zip::Archive::addTree('Archive::Zip::Archive=HASH(0x1113ceee8)',
> '/Location/patch1//')
> 
> 
> Seems to me a permission issue but unable to identify what permission issue
> is there if the Filesystem or directory underneath it .
> 
> How to identify .

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: do something when using Gtk3

2017-09-05 Thread Shlomi Fish
On Tue, 05 Sep 2017 04:24:31 +0200
hw <h...@adminart.net> wrote:

> Shlomi Fish <shlo...@shlomifish.org> writes:
> 
> > Hi hw,
> >  
> > On Mon, 28 Aug 2017 04:54:04 +0200
> > hw <h...@adminart.net> wrote:
> >  
> >> Hi,
> >> 
> >> when writing a program that uses Gtk3, how can I make it so that the
> >> program does something at regular time intervals?
> >>   
> >
> > This DDG search - https://duckduckgo.com/?q=gtk3+timer=qa - has some
> > relevant results including
> > https://stackoverflow.com/questions/8352027/gtk-timer-how-to-make-a-timer-within-a-frame
> >  .
> > There are examples for using it in Perl in t/9.t here -
> > https://git.gnome.org//browse/perl-Glib .  
> 
> Thanks, at least this some indication that it might be possible.  Now I
> need to figure out how to use it with a perl program that uses gtk3 ...
> 

You're welcome!

-- 
-
Shlomi Fish   http://www.shlomifish.org/
“So, who the hell is Qoheleth?” - http://shlom.in/qoheleth

Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the universe trying to produce
bigger and better idiots. So far, the universe is winning.
— https://en.wikiquote.org/wiki/Rick_Cook  (via Oron Peled)

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: do something when using Gtk3

2017-08-29 Thread Shlomi Fish
Hi hw,
 
On Mon, 28 Aug 2017 04:54:04 +0200
hw <h...@adminart.net> wrote:

> Hi,
> 
> when writing a program that uses Gtk3, how can I make it so that the
> program does something at regular time intervals?
> 

This DDG search - https://duckduckgo.com/?q=gtk3+timer=qa - has some
relevant results including
https://stackoverflow.com/questions/8352027/gtk-timer-how-to-make-a-timer-within-a-frame
 .
There are examples for using it in Perl in t/9.t here -
https://git.gnome.org//browse/perl-Glib .

Hope it helps!

-- 
-----
Shlomi Fish   http://www.shlomifish.org/
Rethinking CPAN - http://shlom.in/rethinking-cpan

The nice thing about standards is that you have so many to choose from.
— https://en.wikiquote.org/wiki/Andrew_S._Tanenbaum

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




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

2017-07-01 Thread Shlomi Fish
Hi hw!

Please see
http://www.shlomifish.org/philosophy/computers/netiquette/email/reply-to-list.html
.

On Sat, 1 Jul 2017 19:15:22 +0200 hw <h...@gc-24.de> wrote:

> Shlomi Fish wrote:
> > Hi Shawn!
> >
> > On Sat, 1 Jul 2017 11:32:30 -0400
> > Shawn H Corey <shawnhco...@gmail.com> wrote:
> >  
> >> On Sat, 1 Jul 2017 17:27:02 +0200
> >> hw <h...@gc-24.de> wrote:
> >>  
> >>>
> >>> Hi,
> >>>
> >>> can someone please explain this:
> >>>
> >>>
> >>> perl -e 'my $i = 0; $i = defined($i) ? (!!$i) : 0; print "i: $i\n";'
> >>> i:
> >>>
> >>>
> >>> Particularly:
> >>>
> >>>
> >>> + Why doesn´t it print 1?  
> >>
> >> Because !!$i is zero
> >>  
> >>>
> >>> + How is this not a bug?  
> >>
> >> Nope, no bug.
> >>  
> >>>
> >>> + What is being printed here?  
> >>
> >> !!$i which is !(!(0)) which is !(1) which is 0
> >>  
> >
> > I suspect !1 returns an empty string in scalar context.  
> 
> What would be the reasoning for a numerical operator turning
> numerical values into (empty) strings within a numerical context?
> 

"!" is not a numerical operator - it is a *logical* operator. If one passes a
true value to it one gets a false value. Else, one gets a true value. See
http://perldoc.perl.org/perlop.html . If used in a numerical context, false
values are treated as zeroes, but not all of them are zeroes in other contexts.

Regards,

Shlomi


> 
> 
> >  
> >>>
> >>> + How do you do what I intended in perl?
> >>>  
> >>
> >> How do we know what you intend?
> >>
> >>  
> >
> >
> >  
> 



-- 
-
Shlomi Fish   http://www.shlomifish.org/
UNIX Fortune Cookies - http://www.shlomifish.org/humour/fortunes/

Real programmers don’t write workarounds. They tell their users to upgrade
their software.
— http://www.shlomifish.org/humour.html

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




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

2017-07-01 Thread Shlomi Fish
Hi Shawn!

On Sat, 1 Jul 2017 11:32:30 -0400
Shawn H Corey <shawnhco...@gmail.com> wrote:

> On Sat, 1 Jul 2017 17:27:02 +0200
> hw <h...@gc-24.de> wrote:
> 
> > 
> > Hi,
> > 
> > can someone please explain this:
> > 
> > 
> > perl -e 'my $i = 0; $i = defined($i) ? (!!$i) : 0; print "i: $i\n";'
> > i:
> > 
> > 
> > Particularly:
> > 
> > 
> > + Why doesn´t it print 1?  
> 
> Because !!$i is zero
> 
> > 
> > + How is this not a bug?  
> 
> Nope, no bug.
> 
> > 
> > + What is being printed here?  
> 
> !!$i which is !(!(0)) which is !(1) which is 0
> 

I suspect !1 returns an empty string in scalar context.

> > 
> > + How do you do what I intended in perl?
> >   
> 
> How do we know what you intend?
> 
> 



-- 
-
Shlomi Fish   http://www.shlomifish.org/
http://shlomifishswiki.branchable.com/Self-Sufficiency/

I don’t believe in fairies. Oops! A fairy died.
I don’t believe in fairies. Oops! Another fairy died.
— http://www.shlomifish.org/humour.html

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Confused with File::Find

2017-06-24 Thread Shlomi Fish
Hi Harry!

On Fri, 23 Jun 2017 16:56:13 -0400
Harry Putnam <rea...@newsguy.com> wrote:

> Trying for a better understand of using File::Find, butI'm missing
> something pretty basic I think
> 
> First: The directory structure in this test:
> 
> ./one/tst.pl
> two/tst.pl
>   three/tst.pl
> 
> So each directory in the layering has the same type -f file in it.
> 
> Or
>   ls -R ./one
>   ./one:
>   tst.pl  two
> 
>   ./one/two:
>   three  tst.pl
> 
>   ./one/two/three:
>   tst.pl
> 
> I'm sure its something in my formulation (in other words, pilot
> shooting self in foot) but; This bit of code seems not to do what one
> would expect:
> 
> ---   ---   ---=---   ---   ---
> 
>   use strict;
>   use warnings;
>   use File::Find;
> 
>   my $d = './one';
> 
>   find sub {
> return if -f;
> print "\$File::Find::dir<$File::Find::dir>\n";
>   }, $d;
> 
> ---   ---   ---=---   ---   --- 
> 
> Output:
>   reader > ./tst.pl
>   $File::Find::dir<./one>
>   $File::Find::dir<./one>
>   $File::Find::dir<./one/two>
> 

$File::Find::dir is the containing directory of the path item (= the dirname in
http://perldoc.perl.org/File/Basename.html ). Finally, note that File::Find has
some severe philosophical limitations, and you should look into alternatives on
CPAN such as https://metacpan.org/pod/File::Find::Object (which I happen to
maintain) or https://metacpan.org/pod/Path::Iterator::Rule#SEE-ALSO . For more
about that, see:

http://shlomif-tech.livejournal.com/29315.html

Regards,

Shlomi Fish

-- 
-
Shlomi Fish   http://www.shlomifish.org/
My Aphorisms - http://www.shlomifish.org/humour.html

Trying to block Internet pornography is like climbing a waterfall and trying
to stay dry. (— one of Shlomi Fish’s Internet Friends)
— http://www.shlomifish.org/humour.html

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: project euler #8

2017-05-25 Thread Shlomi Fish
Hi lee,

I decided to try to give you another chance to be educated, despite Uri's
conclusion in the other thread. Hopefully you won't let me down.

On Thu, 25 May 2017 16:48:13 +0100
lee <l...@yagibdah.de> wrote:

> Shlomi Fish <shlo...@shlomifish.org> writes:
> 
> > [...]  
> >> >> while ( my $numbline =  ) {
> >> >> chomp $numbline;
> >> >> my @numbline = split //, $numbline;
> >> >
> >> > You're processing the input number line-by-line, but it's one whole
> >> > number and the products may span across more than one line. You need to
> >> > slurp it and prepare an array of digits.
> >> 
> >> Isn't it more efficient to put all the digits into a string rather than
> >> into an array and use substr()?
> >>   
> >
> > I believe it should be more space efficient, but perl shouldn't have a
> > problem managing an array of a 1,000 digits on most machines.  
> 
> Yes, I'm just wondering.
> 
> It doesn't even depend on how many digits there are because it's
> possible to consider only the relevant portion of the digits in each
> step.
> 

Thinking about it one may wish to use the
https://en.wikipedia.org/wiki/Stream_(computing) pattern (if one calls it
that) and just keep a https://en.wikipedia.org/wiki/Circular_buffer of the last
13 or so elements.

> > See https://duckduckgo.com/?q=premature+optimization+evil+quote=web
> > - we should worry about optimising when we need to - not before.  
> 
> I don't agree that all optimization is evil to begin with.  I can not
> write a line of code without optimizing first because otherwise, I
> wouldn't know what to write.  Can you?
> 
> Knowing what is more efficient helps me before the first line of a
> program is written and with every single line of it.  I couldn't do any
> overall design without knowing.
> 
> Even syntax highlighting, reasonable formatting and reasonable use of
> comments is an optimization.
> 
> The point is to do the right amount of optimization which allows you to
> make appropriate progress towards a working version.  Once you have that,
> you can optimize more or leave it as is.
> 
> Programming is a creative process of optimization.
> 

First of all note that I strongly believe the quote referred to speed / runtime
optimisation - not to https://en.wikipedia.org/wiki/Code_refactoring ,
cleanups , bug fixes , code design and other unrelated activities. Secondly, it
talked about *premature* optimisation, where you spend a lot of time optimising
before there is a proven and genuine need for it. There is such a thing as
"Time to market" and also needlessly changing the code always risks introducing
bugs, so one should try to avoid it.

> 
> Since we're looking at a mathematical excersise here, we might use it to
> learn something about programming :)
> 
> > Using arrays allows us to use convenient operators and functions that
> > are less native to strings.  
> 
> Ok, let me be a smartass:
> 
> substr() is only so native to strings as perl does not do implicit
> typecasting.

What is "typecasting" in this context?

> 
> The operator in question is multiplication.  Are there different
> multiplication operators in perl which are more or less convenient?
> 

There is https://metacpan.org/pod/List::Util#product and I also refer to array
slicing (e.g @array[@indices]), map, grep, and lots of other stuff.

> Did I use inconvenient operators?
> 
> > Also note that using http://perldoc.perl.org/functions/vec.html should
> > allow to store a digit within 4 bits in a binary buffer, which is even
> > better than using a string.  
> 
> Hm, I don't understand this documentation.  This function seems to be
> designed to mess up things by confusing strings with bytes and could be
> considered as a symptom of perl not having variables of fixed types.
> 

vec uses a binary buffer as input, which is usable as a non-unicode string.

> Maybe I'd understand from a safe and evident use case for it.
>

Let's say you want to have a https://en.wikipedia.org/wiki/Bit_array that maps
non-negative integers to a false/true value. You can initialise it as
all-Falses using «my $bit_vec = '';» and then set or lookup «vec($bit_vec,
$idx, 1)». This is useful for
https://en.wikipedia.org/wiki/Generating_primes#Prime_sieves - prime sieving.

> > Some comments about your code:
> >  
> 
> > [...]  
> >> 
> >> my $data = "
> >> 73167176531330624919225119674426574742355349194934
> >> 96983520312774506326239578318016984801869478851843  
> > [...]  
> >> ";
> >>   
> >
> > Please use here-documents for mul

Re: project euler #8

2017-05-25 Thread Shlomi Fish
Hi lee!

On Thu, 25 May 2017 02:24:05 +0100
lee <l...@yagibdah.de> wrote:

> Shlomi Fish <shlo...@shlomifish.org> writes:
> 
> > Hi all!
> >
> > Resending because the original message does not appear to have arrived at
> > the list.
> >
> > =
> >
> > Hi Derrick,
> >
> > On Tue, 16 May 2017 14:01:34 +0800
> > derr...@thecopes.me wrote:
> >  
> >> Hi All,
> >> 
> >> I am working on problem #8 of the euler project. see below.
> >> 
> >> 
> >> I have the below solution below for this which works fine but gives me the
> >> wrong answer. I checked shlomifish's solution on github and his is similar
> >> to mine, more elegant since he uses "map", but he gets a different answer.
> >> I feel like I have some basic misunderstanding about how something should
> >> work. Or maybe I am misunderstanding the problem. Thanks in advance for
> >> any push in the right direction. see my solution below.
> >> 
> >> Derrick
> >> 
> >> #! /usr/bin/env perl
> >> 
> >> use strict;
> >> use warnings;
> >> use 5.024;
> >> use List::Util qw(max product);
> >> 
> >> my $totalmax = 0;
> >> 
> >> while ( my $numbline =  ) {
> >> chomp $numbline;
> >> my @numbline = split //, $numbline;  
> >
> > You're processing the input number line-by-line, but it's one whole number
> > and the products may span across more than one line. You need to slurp it
> > and prepare an array of digits.  
> 
> Isn't it more efficient to put all the digits into a string rather than
> into an array and use substr()?
> 

I believe it should be more space efficient, but perl shouldn't have a problem
managing an array of a 1,000 digits on most machines. See
https://duckduckgo.com/?q=premature+optimization+evil+quote=web - we should
worry about optimising when we need to - not before. Using arrays allows us to
use convenient operators and functions that are less native to strings.

Also note that using http://perldoc.perl.org/functions/vec.html should allow to
store a digit within 4 bits in a binary buffer, which is even better than using
a string.

Some comments about your code:

> 
> With a bit extra ado you could omit, for the sake of verifyability (It
> doesn't matter in which order you do the multiplications of the adjacent
> digits as long as they are adjacent.):
> 
> 
> #!/usr/bin/perl
> 
> use strict;
> use warnings;
> 
> 
> my $data = "
> 73167176531330624919225119674426574742355349194934
> 96983520312774506326239578318016984801869478851843
> 85861560789112949495459501737958331952853208805511
> 12540698747158523863050715693290963295227443043557
> 66896648950445244523161731856403098711121722383113
> 6222989342338030813533627661428280686645238749
> 30358907296290491560440772390713810515859307960866
> 70172427121883998797908792274921901699720888093776
> 65727333001053367881220235421809751254540594752243
> 52584907711670556013604839586446706324415722155397
> 53697817977846174064955149290862569321978468622482
> 83972241375657056057490261407972968652414535100474
> 82166370484403199890008895243450658541227588666881
> 16427171479924442928230863465674813919123162824586
> 17866458359124566529476545682848912883142607690042
> 2421902267105562632109370544217506941658960408
> 07198403850962455444362981230987879927244284909188
> 84580156166097919133875499200524063689912560717606
> 05886116467109405077541002256983155200055935729725
> 71636269561882670428252483600823257530420752963450
> ";
> 

Please use here-documents for multi-line strings - see
http://perl-begin.org/tutorials/bad-elements/#string-notation .

> $data =~ s/\n//g;
> 

Nice! Perhaps use \s or [^0-9] instead though.
> my $adjacency = 13;
> my $maxprod = 0;
> 
> my $start = 0;
> my $end = length($data) - $adjacency;
> 
> while($start < $end) {

This should be a «for my $idx ($start .. $end-1)» loop.
>   my $adjunct = 1;
>   my $prod = substr($data, $start, 1);
>   print "$prod";
>   while($adjunct < $adjacency) {

Again.

> my $ad = substr($data, $start + $adjunct, 1);
> print " * $ad";
> $prod *= $ad;
> $adjunct++;
>   }
>   print " = $prod\n";
>   $maxprod = $prod if($maxprod < $prod);
> 
>   $start++;
> }
> 
> print "The largest product of $adjacency adjacent numbers is $maxprod.\n";
> 
> exit 0;
> 

No need for the exit statement here.

> 
> Is this supposed to be a programming exercise?  It's a purely
> mathematical one to me.
> 

See https://en.wikipedia.org/wiki/Project_Euler for the Project Euler mission
and motivation.

Regards,

Shlomi Fish

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Perl/Tk

2017-05-16 Thread Shlomi Fish
On Tue, 16 May 2017 20:35:55 +0900
Masayoshi Fujimoto  wrote:

> Hi.
> I really appriciate your help. It worked for me.
> 

You're welcome!

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Perl/Tk

2017-05-16 Thread Shlomi Fish
Hi!

On Tue, 16 May 2017 20:11:52 +0900
Masayoshi Fujimoto  wrote:

> Hi.
> 
> I would like to get $celebrity.
> 
> How should I do?
>

I have modified your code based on
https://metacpan.org/pod/distribution/Tk/pod/Entry.pod to get what seems to be
the desired result:

« «
#!/usr/local/bin/perl

use strict;

use warnings;

use autodie;

use v5.10;

use Tk;

my $top = MainWindow->new();

my $f1 = $top->Frame()->pack();

my $f2 = $top->Frame()->pack();

$f1->Label(-text => "Celebrity:")->pack(-side => "left");

my $celebrity = $f1->Entry();

$celebrity->pack(-side => "left");

my $name = "Ayumi Kinoshita";

$f2->Button(-text => "OK",-command => [ \,
$celebrity,$name])->pack(-side => "left");

$f2->Button(-text => "Cancel",-command => sub {exit;})->pack();

MainLoop();

sub onButton {

my ($celebrity,$name) = @_;

say $celebrity;

say $name;

say "Celebrity string = <", $celebrity->get(), ">";

}

»

One note is http://perl-begin.org/tutorials/bad-elements/#prototypes ,
otherwise your code seems pretty solid.

Regards,

Shlomi

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: project euler #8

2017-05-16 Thread Shlomi Fish
On Tue, 16 May 2017 17:53:17 +0800
"derrick" <derr...@thecopes.me> wrote:

> OK thanks, I understand now. I was reading 20 50-digit numbers rather than 1
> 1000-digit numbers. I knew it a fundamental misunderstanding somewhere. Thank
> you again,
>

You're welcome!

-- Shlomi
 
> Derrick
> 
> ------
> 发件人:Shlomi Fish<shlo...@shlomifish.org>日 期:2017年05月16日
> 16:54:39收件人:<derr...@thecopes.me>抄 送:Beginners Perl
> List<beginners@perl.org>主 题:Re: project euler #8Hi all!
> 
> Resending because the original message does not appear to have arrived at the
> list.
> 
> =
> 
> Hi Derrick,
> 
> On Tue, 16 May 2017 14:01:34 +0800
> derr...@thecopes.me wrote:
> 
> > Hi All,
> > 
> > I am working on problem #8 of the euler project. see below.
> > 
> > 
> > I have the below solution below for this which works fine but gives me the
> > wrong answer. I checked shlomifish's solution on github and his is similar
> > to mine, more elegant since he uses "map", but he gets a different answer. I
> > feel like I have some basic misunderstanding about how something should
> > work. Or maybe I am misunderstanding the problem. Thanks in advance for any
> > push in the right direction. see my solution below.
> > 
> > Derrick
> > 
> > #! /usr/bin/env perl
> > 
> > use strict;
> > use warnings;
> > use 5.024;
> > use List::Util qw(max product);
> > 
> > my $totalmax = 0;
> > 
> > while ( my $numbline =  ) {
> > chomp $numbline;
> > my @numbline = split //, $numbline;  
> 
> You're processing the input number line-by-line, but it's one whole number and
> the products may span across more than one line. You need to slurp it and
> prepare an array of digits.
> 
> > say "@numbline ";
> >my @product = (); 
> > for (0..$#numbline - 13) {  
> 
> This should be "@numbline - 13" - an off-by-one error.
> 
> Regards,
> 
>   Shlomi Fish

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: project euler #8

2017-05-16 Thread Shlomi Fish
Hi all!

Resending because the original message does not appear to have arrived at the
list.

=

Hi Derrick,

On Tue, 16 May 2017 14:01:34 +0800
derr...@thecopes.me wrote:

> Hi All,
> 
> I am working on problem #8 of the euler project. see below.
> 
> 
> I have the below solution below for this which works fine but gives me the
> wrong answer. I checked shlomifish's solution on github and his is similar to
> mine, more elegant since he uses "map", but he gets a different answer. I
> feel like I have some basic misunderstanding about how something should work.
> Or maybe I am misunderstanding the problem. Thanks in advance for any push in
> the right direction. see my solution below.
> 
> Derrick
> 
> #! /usr/bin/env perl
> 
> use strict;
> use warnings;
> use 5.024;
> use List::Util qw(max product);
> 
> my $totalmax = 0;
> 
> while ( my $numbline =  ) {
> chomp $numbline;
> my @numbline = split //, $numbline;

You're processing the input number line-by-line, but it's one whole number and
the products may span across more than one line. You need to slurp it and
prepare an array of digits.

> say "@numbline ";
>my @product = (); 
> for (0..$#numbline - 13) {

This should be "@numbline - 13" - an off-by-one error.

Regards,

Shlomi Fish

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: keyboard input without pressing return?

2017-05-14 Thread Shlomi Fish
On Sun, 14 May 2017 12:08:59 +0300
Shlomi Fish <shlo...@shlomifish.org> wrote:

> Hi lee,
> 
> On Sat, 06 May 2017 02:06:19 +0100
> lee <l...@yagibdah.de> wrote:
> 
> > Hi,
> > 
> > how can a sleeping program react to a key that was pressed without
> > return being pressed?
> > 
> > 
> > perl -e 'use Term::ReadKey; my $ke = ReadKey(10); print "k: $ke\n";'
> > 
> > 
> > ... shows that:
> > 
> > 
> > + ReadKey() returns undef after the timeout
> > 
> > + ReadKey() returns undef after the timeout even when you pressed keys
> > 
> > + ReadKEy() returns the first key of those that were pressed before the
> > timeout expires when you hit return before it does
> > 
> > 
> > So you always have to hit return :(
> > 
> > I'm finding that entirely useless for instances in which a program is
> > sleeping for some time (let's say 10 minutes) but supposed to do
> > something immediately when a key is pressed, and without pressing
> > return.  For example, I might want to press 'q' to quit and don't want
> > to wait 10 minutes for the program to react, and of course, I don't want
> > to press enter.
> > 
> > How can that be done?
> > 
> >   
> 
> This program from perldoc Term::ReadKey is working as advertised:
> 
> «
> #!/usr/bin/perl
> 
> use strict;
> use warnings;
> 
> use Term::ReadKey;
> ReadMode 4; # Turn off controls keys
> my $key;
> while (not defined ($key = ReadKey(-1))) {
> # No key yet
> }
> print "Get key $key\n";
> ReadMode 0; # Reset tty mode before exiting
> 
> »
> 
> Note that it may be a busy loop. It mad be a bug in Term::ReadKey or you're
> doing something wrong.
> 

I've now tried this program and it seems to do what you want:

perl -e 'use Term::ReadKey; ReadMode 4; my $ke = ReadKey(3); print "k: $ke\n";
ReadMode 0;'

The key (pardon the pun) is adding the ReadMode calls.

Regards,

Shlomi Fish

> Regards,
> 
>   Shlomi Fish
> 



-- 
-
Shlomi Fish   http://www.shlomifish.org/
Perl Humour - http://perl-begin.org/humour/

XSLT is the number one cause of programmers’ suicides since Visual Basic 1.0.
— http://www.shlomifish.org/humour/bits/facts/XSLT/

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: keyboard input without pressing return?

2017-05-14 Thread Shlomi Fish
Hi lee,

On Sat, 06 May 2017 02:06:19 +0100
lee <l...@yagibdah.de> wrote:

> Hi,
> 
> how can a sleeping program react to a key that was pressed without
> return being pressed?
> 
> 
> perl -e 'use Term::ReadKey; my $ke = ReadKey(10); print "k: $ke\n";'
> 
> 
> ... shows that:
> 
> 
> + ReadKey() returns undef after the timeout
> 
> + ReadKey() returns undef after the timeout even when you pressed keys
> 
> + ReadKEy() returns the first key of those that were pressed before the
> timeout expires when you hit return before it does
> 
> 
> So you always have to hit return :(
> 
> I'm finding that entirely useless for instances in which a program is
> sleeping for some time (let's say 10 minutes) but supposed to do
> something immediately when a key is pressed, and without pressing
> return.  For example, I might want to press 'q' to quit and don't want
> to wait 10 minutes for the program to react, and of course, I don't want
> to press enter.
> 
> How can that be done?
> 
> 

This program from perldoc Term::ReadKey is working as advertised:

«
#!/usr/bin/perl

use strict;
use warnings;

use Term::ReadKey;
ReadMode 4; # Turn off controls keys
my $key;
while (not defined ($key = ReadKey(-1))) {
# No key yet
}
print "Get key $key\n";
ReadMode 0; # Reset tty mode before exiting

»

Note that it may be a busy loop. It mad be a bug in Term::ReadKey or you're
doing something wrong.

Regards,

Shlomi Fish

-- 
-
Shlomi Fish   http://www.shlomifish.org/
http://www.shlomifish.org/humour/bits/New-versions-of-the-GPL/

As it turns out, compiling a C program from more than 20 years ago is actually
a lot easier than getting a Rails app from last year to work.
— https://passy.svbtle.com/building-vim-from-1993-today

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: prime factors

2017-05-03 Thread Shlomi Fish
Hi Derrick,

On Wed, 03 May 2017 06:58:44 +0800
"derrick" <derr...@thecopes.me> wrote:

> Thank you for your complete answer. How much memory is used per array element?
>

In Perl, it can be quite a bit because an array contains a vector of pointer to
"SV"s, and each SV may contain an integer, a string, a reference, a floating
point number, etc. There's also the issue of memory fragmentation.

You can mitigate some of that by using
http://perldoc.perl.org/functions/vec.html or something like
https://en.wikipedia.org/wiki/Perl_Data_Language . 
> I will work on a shorter algorithm. This one worked on shorter numbers so I
> just used it for this.
> 

By shorter do you mean 'faster in runtime speed'? There's also
https://en.wikipedia.org/wiki/Code_golf .



> Derrick
> 
> 
> --发件人:Jim
> Gibson<jimsgib...@gmail.com>日 期:2017年05月03日 00:35:53收件人:derrick
> cope<derr...@thecopes.me>; beginners<beginners@perl.org>主 题:Re: prime
> factors
> > On May 2, 2017, at 7:58 AM, derrick cope <derr...@thecopes.me> wrote:
> > 
> > I was writing a program to solve the #3 exercise on project Euler. I needed
> > to find the prime factors of a given number. I have solved it already but a
> > couple of the ways I tried to solve the problem caused a problem.  
> 
> Exercise #3 is to find the largest prime factor of the number 600,851,475,143.
> 
> > 
> > The below worked for smaller numbers but when I used the 12 digit number
> > given by project Euler I got "Out of memory!"
> > 
> > chomp( my $factor = <>);
> > my @primefactor = grep { ( $_ ) } ( grep { $factor % $_ == 0 }
> > 1..$factor );  
> 
> Presumably, you have entered the number 600851475143 into the command line
> that executes your program. Therefore, $factor is equal to 600851475143  and
> the expression 1..$factor will be a list of 600851475143 elements; ( 1, 2, 3,
> … , 600851475143 ). You will need a computer with several petabytes of memory
> to store that list.
> 
> > 
> > sub isprime { 
> > my $numb = shift;
> > my @quot = grep { 
> >if ( $numb % $_ == 0 ) {1;
> >} else { 0;} 
> > } 2..$numb-1;
> > unless ( @quot ) {
> >1;
> >#say "prime";
> >} else {
> >0;
> >#say "not prime";
> >}
> > }  
> 
> This function also generates a very long list of integers (2..$numb-1).
> 
> > 
> > 
> > This one worked but caused my computer to crash.
> > 
> > my $xxx = 1;
> > while ( $xxx < $factor ) {
> >if ( $factor % $xxx == 0 and ($xxx) ) {
> >say $xxx;
> >}
> >$xxx++
> > }
> > 
> > what is causing perl to do this?  Would using a module save memory?
> > Thanks for any help.  
> 
> Using a module would not save significant memory. You need to devise an
> algorithm that does not require long lists of numbers. You need to test each
> potential prime factor one at a time. You will also need to address the fact
> that Perl’s integers cannot represent the number 600851475143 in their normal
> 32- or 64-bit formats. See ‘perldoc bignum’.
> 
> Also note that the smallest factor of any number cannot be larger than the
> square root of that number, so the function isprime need not consider
> potential factors larger than the square root of its argument.
> 
> 
> 
> 
> Jim Gibson
> 
> 



-- 
-
Shlomi Fish   http://www.shlomifish.org/
http://www.shlomifish.org/humour/Summerschool-at-the-NSA/

Buffy will always find a wooden stake to slay vampires, even if it means
she will have travelled 100 years back in time, to plant a tree nearby.
— http://www.shlomifish.org/humour/bits/facts/Buffy/

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: prime factors

2017-05-02 Thread Shlomi Fish
Hi derrick!

Welcome aboard!

See below for my reply.

On Tue, 02 May 2017 22:58:58 +0800
"derrick cope" <derr...@thecopes.me> wrote:

> I was writing a program to solve the #3 exercise on project Euler. 

For reference, it is https://projecteuler.net/problem=3 .

>I needed
> to find the prime factors of a given number. I have solved it already but a
> couple of the ways I tried to solve the problem caused a problem.
> 
> The below worked for smaller numbers but when I used the 12 digit number
> given by project Euler I got "Out of memory!"
> 
> chomp( my $factor = <>);
> my @primefactor = grep { ( $_ ) } ( grep { $factor % $_ == 0 }
> 1..$factor ); 

First of all, please go over http://perl-begin.org/tutorials/bad-elements/ and
avoid these bad elements. add 'use strict;' and 'use warnings;' and avoid
calling subroutines with ampersands.

In that line's case you're building several very long lists. In this case a
foreach loop will be better. Also not that you can also write the nested greps
as grep { $factor % $_ == 0 and isprime($_)} ... .

>sub isprime { 
> my $numb = shift;
> my @quot = grep { 
>     if ( $numb % $_ == 0 ) {1;
>     } else { 0;} 
> } 2..$numb-1;
> unless ( @quot ) {
>     1;
>     #    say "prime";
>     } else {
>     0;
>     #    say "not prime";
>     }
> }
>

your indentation is lacking, and better see
http://perl-begin.org/tutorials/bad-elements/#grep_instead_of_any . Also use
an explicit return and don't use if or unless to return a value. (you can try
using the ? : ternary conditional operator instead).

> 
> This one worked but caused my computer to crash.
> my $xxx = 1;
> while ( $xxx < $factor ) {
>     if ( $factor % $xxx == 0 and ($xxx) ) {
>     say $xxx;
>     }
>     $xxx++
> }
> what is causing perl to do this?  Would using a module save memory?Thanks for
> any help.

That looks better memory wise. But "isprime()" is still sub-optimal.

Note that you can optimise the algorithm considerably by using some tricks. See:

https://duckduckgo.com/?q=project+euler+3=web

Perhaps see https://duckduckgo.com/?q=prime+factorization=web too.

Regards,

Shlomi Fish

-- 
-
Shlomi Fish   http://www.shlomifish.org/
https://youtu.be/n6KAGqjdmsk - “Hurt Me Tomorrow”

I love being convinced that I was wrong before. That way I knew I
improved and am now wiser. Like the Klingon warriors say when it happens:
“What a great day it was for me to die!”.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Perl reserved words

2017-04-23 Thread Shlomi Fish
Hi Frank,

On Sun, 23 Apr 2017 10:07:56 -0700
SSC_perl <p...@surfshopcart.com> wrote:

>   Is ‘vendor’ a reserved word of some type in either Perl, MySQL, or
> DBM?  

It is not a reserved word of Perl. No idea about MySQL.

> I tried to add a ‘vendor’ field to SurfShop but it didn’t work.  I
> don’t recall exactly what happened now (sorry), but I had to settle on
> another word to get it to work.
> 
>   Any ideas on what it could have been?
> 
> Thanks,
> Frank
> 
> It’s not listed here:
> http://learn.perl.org/docs/keywords.html
> 



-- 
-----
Shlomi Fish   http://www.shlomifish.org/
Let’s talk about restores instead of backups - http://is.gd/WatQqu

A rose by a name picked by Chuck Norris, will smell sweeter.
— http://www.shlomifish.org/humour/bits/facts/Chuck-Norris/

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
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 Shlomi Fish
Hi Uri!

Some notes.

On Wed, 12 Apr 2017 15:19:33 -0400
Uri Guttman <u...@stemsystems.com> wrote:

> On 04/12/2017 03:00 PM, David Emanuel da Costa Santiago wrote:
> > Hello!
> >
> > What's the best way to delete multiple indices from an array?
> >
> > i'm doing:
> >
> > ---
> > my @array=qw/zero one two three four five six seven eight nine ten/;
> >
> > my @indicesToDelete = (2,4,6,7);  
> 
> if you have the indexes to keep, this would be a simple slice:
> 
> my @keep_indexes = ( 0, 1, 3, 5, 8,9 10 );
> @array = @array{ @keep_indexes } ;
> 

it should be «@array = @array[ @keep_indexes ] ;» instead. With curly braces
it's a hash slice.

> so one idea is to make that list of kept indexes from the list of 
> indexes to delete:
> 
> my %keep_hash ;
> @keep_hash{ 0 .. 10 } = () ; # no need for any values so this save space
> delete @keep_hash{ @keep_indexes } ;
> @array = @array{ keys %keep_hash } ;

1. again - square brackets instead of curly braces.

2. You should sort the keys numerically using sort { $a <=> $b }.

3. Better use « keys@array» or in older perls «0 .. $#array» to avoid hard
coding the values and magic constants.



some other ways I can think of doing it:

1.

my %blacklist;
@blacklist{@remove} = ();
@array = @array[grep {!exists $blacklist{$_} } keys@array];

2. 

my @new;
while (my ($i, $v) = each@array)
{
if (@remove and $i == $remove[0])
{
shift@remove;
}
else
{
push @new, $v;  
}
}
@array = @new

===

https://en.wikipedia.org/wiki/There%27s_more_than_one_way_to_do_it

Regards,

Shlomi Fish

> >
> > my %hash;
> >
> > @hash{(0..scalar(@array)-1)} = @array;
> >
> > delete $hash{$_} for @indicesToDelete;  
> delete can be used on a slice
> 
> delete @hash{ @indicesToDelete } ;
> 
> uri
> 
> Perl Guru for hire. Available for contract/full time/part time Perl hacking.
> 

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: WWW::Mechanize requires wget

2017-04-04 Thread Shlomi Fish
On Tue, 4 Apr 2017 10:43:27 -0700
SSC_perl <p...@surfshopcart.com> wrote:

>   This is a heads up for anyone wanting to use WWW::Mechanize on OS X.  
> 
>   I’ve been fighting with WWW::Mechanize all morning, trying to get it
> to work with no success.  There were no error messages telling me what was
> wrong.  I checked my firewall to see if anything was being blocked, but it
> wasn’t.  I finally ran across a post where someone was asked if they were
> able to access the target web site using wget, so I decided to try that
> myself.  Terminal told me that wget wasn’t found.  So… off to homebrew to
> install wget, and lo and behold, Mech now works!  I went back to see if Mech
> had wget as a dependency, but nothing was mentioned on CPAN.
> 
>   So just in case someone else was having the same trouble, I thought
> I’d post this.  Not sure why wget wasn’t installed with Xcode Developer Tools.
> 
> Frank

Hi Frank!

What you say sounds strange. WWW-Mech should not require wget. Perhaps they
both use a common dependency.

-- 
---------
Shlomi Fish   http://www.shlomifish.org/
http://shlomifishswiki.branchable.com/Encourage_criticism_and_try_to_get_offended/

Chuck Norris killed the fat lady before she could sing.
— http://www.shlomifish.org/humour/bits/facts/Chuck-Norris/

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Fw: how to recursion

2017-03-29 Thread Shlomi Fish
Forwarding to the list.

Begin forwarded message:

Date: Wed, 29 Mar 2017 11:32:08 -0400
From: Shawn H Corey <shawnhco...@gmail.com>
To: Shlomi Fish <shlo...@shlomifish.org>
Subject: Re: how to recursion


On Wed, 29 Mar 2017 17:22:36 +0300
Shlomi Fish <shlo...@shlomifish.org> wrote:

> my_recursion accepts $self as its first argument, so you should pass
> it there. Doing «my_recursion($self);» is one option for doing that
> but : 1. It looks ugly. 2. It's less future proof. 3. It's a bad
> practice for OOP perl.
> 
> The original code was fine.  

Oops, you're right. the OOLs I've been using lately take care self (or
this) automatically. I had forgotten that Perl is an OO toolkit, not an
OOL. ☺


-- 
Don't stop where the ink does.

Shawn H Corey

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: how to recursion

2017-03-29 Thread Shlomi Fish
Hi Shawn!

On Wed, 29 Mar 2017 08:09:12 -0400
Shawn H Corey  wrote:

> On Wed, 29 Mar 2017 09:25:06 +0800
> PYH  wrote:
> 
> > sub my_recursion {
> >  my $self = shift;
> >  
> >  if (...) {
> >  $self->my_recursion;  
> 
> # you don't need $self. subroutine lookup starts
> # in the same package. Just the sub by itself
> # is good enough.
> my_recursion();
> 

my_recursion accepts $self as its first argument, so you should pass it there.
Doing «my_recursion($self);» is one option for doing that but : 1. It looks
ugly. 2. It's less future proof. 3. It's a bad practice for OOP perl.

The original code was fine.

--
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 Shlomi Fish
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 a very old application from the command line (unix), it
> > seems to me a ncurses application but I'm not sure that is the real
> > case (let's say it seems ncurses).
> > Anyway, I have to launch 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/projects/xdotool/
> 

The original poster was asking about automating an ncurses/etc. unix *terminal*
app - not an X11-based app which is what xdotool is for. Note that for X11,
there's https://metacpan.org/release/X11-GUITest on CPAN and other similar
toolkits in other languages as well.


-- 
-
Shlomi Fish   http://www.shlomifish.org/
Original Riddles - http://www.shlomifish.org/puzzles/

The devil created a 10th circle of hell for the inventors of XSLT, because
the first nine circles were too mild for them.
— http://www.shlomifish.org/humour/bits/facts/XSLT/

--
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 Shlomi Fish
Hi Luca,

On Mon, 27 Mar 2017 16:04:22 +0200
Luca Ferrari  wrote:

> Hi all,
> I've to run a very old application from the command line (unix), it
> seems to me a ncurses application but I'm not sure that is the real
> case (let's say it seems ncurses).
> Anyway, I have to launch 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?
> 

See https://metacpan.org/release/Expect . 

> Thanks,
> Luca
> 



-- 
-

God gave us two eyes and ten fingers so we will type five times as much as we
read.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Using PerlPod creatively

2017-03-24 Thread Shlomi Fish
Hi, Sami!

Please reply to all recipients.

On Fri, 24 Mar 2017 00:17:33 -0700
Sami Joseph <sami.jos...@gmail.com> wrote:

> Hi,
> 
> I am interested to understand what this guy did, but i am unable to, can
> someone please break it down to a newbie
> 
> I've spent the last several days at work, trying to "take over" some work
> left behind by a departing colleague. I realized we didn't have some of his
> bash scripting in ansible or in a repo, so I decided this would be a good
> opportunity to fix all of those problems. After a little while it became
> clear his script was a set of functions, run in a loop-within-a-loop to
> iterate through a bunch of things. In the middle, between these two loops,
> is a pile of inline *PERL* that runs as a bash function and passes data

See http://perl-begin.org/learn/Perl-perl-but-not-PERL/ - it should not be
capitalised as "PERL".

> back and forth in all directions. This Perl generates some dynamic SQL
> commands each loop.
> 
> I hate SQL.
> 
> Okay... read the Perl. Now, it's been a long time and a long way since my
> last string of PERLs, so i didn't really grok 100% what I was reading, but
> I got the gist of it. Finally figured out the SQL wasn't the problem.
> 
> Another day goes by, and I finally figure out his code is self documenting!
> That was what all the little bits were in the perl I didnt get. PerlPod. So
> now I can figure this out easy . Run it, read the code, make a change, run
> it... *boom* what?
> 
> Nope.
> 
> It took me several more hours and a few beer, and it finally clicked. He
> was using PerlPod to document out the code he didn't want to run, and
> commented out the documenting code to run the code he wanted. What looked
> commented out, wasn't, and what looked like a pile of variables being set,
> was just a bunch of commentary. He was using a documentation module for
> *flow control*.

today I learned that it can be spelled as "Perl Pod" -
http://perldoc.perl.org/perlpod.html - I thought "POD" was the correct
spelling. Anyway, you are right that it can be used for excluding code from
being compiled. The common idiom is:

=begin removed

.
.
.

=end removed

=cut

Anyway, using Pod for Perl code embedded in bash or other shells is really
"What-the-f??"-y. One should avoid embedding such long code (beyond a short
-e or -E string) in bash at all, and keep the code in a separate program file
(also see the Modulino concept -
http://perltricks.com/article/107/2014/8/7/Rescue-legacy-code-with-modulinos/
and https://www.masteringperl.org/category/chapters/modulinos/ ).

Regards,

Shlomi Fish  
> 
> What a Hacker. Holy shit. Blew. My. Mind.
> 
> I just got schooled very seriously. It's nice to know I can still improve
> *that much*, even from where I am.
> 
> 
> When PerlPod is used to document something, anything between control codes
> is not interpreted but treated as commented text. He would comment out the
> control codes (thus rendering the text interpretable) on the parts meant to
> run, which would differ between machines.



-- 
-
Shlomi Fish   http://www.shlomifish.org/
http://youtu.be/xZLwtc9x4yA - Anime in Real Life!! (Parody)

We don’t know his cellphone number, and even if we did, we would tell you that
we didn’t know it.
— http://www.shlomifish.org/humour.html

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: accessors module

2017-03-16 Thread Shlomi Fish
Hi pyh,

On Thu, 16 Mar 2017 09:49:34 +0100 (CET)
p...@vodafonemail.de wrote:

> Hello members,
> 
> I was not sure, what purpose does module accessors exist for?
> 

Do you mean https://metacpan.org/release/accessors ? If so, there are many
other accessor generators on CPAN and object systems such as Moose or Moo
provide many more features. For a little about the motivation behind setters,
getters and accessors, see this page on a site I maintain (note the anchor):

http://perl-begin.org/tutorials/perl-for-newbies/part5/#page--accessors--DIR

Regards,

    Shlomi Fish
 
> something similar to ruby's meta-programming?
> 
> Thanks.



-- 
-----
Shlomi Fish   http://www.shlomifish.org/
http://www.shlomifish.org/humour/bits/Google-Discontinues-Services/

The first phrase that needs to be taught when teaching a new language is how to
say “Do you speak English?”. The first thing that needs to be taught when
teaching a new computer tool is how to exit it.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Installing Net::SFTP

2017-03-15 Thread Shlomi Fish
Hi Uday,

On Wed, 15 Mar 2017 11:52:53 +0530
Uday Vernekar <vernekaru...@gmail.com> wrote:

> Hello,
> 
> Need some help on installing Net::SFTP perl module on RHEL.
> 
> please guide.
> 

What did you try ? What happened? You may be able to find an .rpm package of
"perl-Net-SFTP" on various package repositories. Otherwise you can try doing
"cpan -i Net::SFTP" (possibly after installing some compilers and libararies'
*-devel pacakges). Good luck!

Regards,

-- Shlomi


-- 
-----
Shlomi Fish   http://www.shlomifish.org/
http://www.shlomifish.org/humour/Summerschool-at-the-NSA/

“We’re not just doing it for money… we’re doing it for a shitload of money!”
— Spaceballs, http://www.imdb.com/title/tt0094012/

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: how to read a picture

2017-03-12 Thread Shlomi Fish
Hi community tech,

On Sun, 12 Mar 2017 13:34:21 +0800
community tech <commun...@dnsbed.com> wrote:

> Hi,
> 
> Giving a pic which is 5x5 pixels, I want to read the grayscale value of
> each pixel.
> which module should I use? thanks.

There's https://metacpan.org/release/GD and there are also the Perl bindings to
https://en.wikipedia.org/wiki/ImageMagick and
https://en.wikipedia.org/wiki/GraphicsMagick . Also of interest may be
https://en.wikipedia.org/wiki/GIMP and GUI frameworks such as the ones in
http://www.shlomifish.org/open-source/portability-libs/ (note that it's a page
on my site).

Good luck!

Regards,

Shlomi Fish

-- 
-----
Shlomi Fish   http://www.shlomifish.org/
Beginners Site for the Vim text editor - http://vim.begin-site.org/

He who reinvents the wheel, may actually invent a much better wheel.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: multiple named captures with a single regexp

2017-03-01 Thread Shlomi Fish
Hi Luca,

On Wed, 1 Mar 2017 10:01:34 +0100
Luca Ferrari <fluca1...@infinito.it> wrote:

> Hi all,
> I'm not sure if this is possible, but imagine I've got a line as follows:
> 
> command arg1 arg2 arg3 arg4 ...
> 
> I would like to capture all args with a single regexp, possibly with a
> named capture, but I don't know exactly how to do:
> 
> my $re = qr/command\s+(?\w+)+/;
> 
> the above of course is going to capture only the first one (one shoot)
> or the last one within a loop.
> How can I extract the whole array of arguments?
> 

Perhaps try using \G and the /g and possibly /o flags , see:

http://perl-begin.org/uses/text-parsing/

(Note that perl-begin is a site that I maintain).

Regards,

Shlomi Fish


> Please note, a raw solution is to remove the command and split, but
> I'm asking for a more elegant solution.
> 
> Thanks,
> Luca
> 



-- 
-----
Shlomi Fish   http://www.shlomifish.org/
Freecell Solver - http://fc-solve.shlomifish.org/

It is a good idea to stop worrying about problems (or “problems” in quotes)
that cannot be fixed.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Parsing Logfiles and fetching Macs programmed and putting in another file.

2017-02-01 Thread Shlomi Fish
On Tue, 31 Jan 2017 17:29:10 +0530
Uday Vernekar <vernekaru...@gmail.com> wrote:

> Thanks shlomi ,working on your inputs...Thanks:)
> 

You're welcome, Uday!

-- 
-----
Shlomi Fish   http://www.shlomifish.org/
http://www.shlomifish.org/humour/bits/facts/Emma-Watson/

God gave us two eyes and ten fingers so we will type five times as much as we
read.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Parsing Logfiles and fetching Macs programmed and putting in another file.

2017-01-31 Thread Shlomi Fish
; }
> }
> 
> close(SCRIPT);
> chdir($startdir) or die "Unable to change to dir $startdir:$!\n";
> }
> 
> my $date =`date`;

use localtime() - http://perldoc.perl.org/functions/localtime.html

> my $data_file2='/mnt/ONT/MAC-REPORT-FILE.txt';
> open DATAOUT, ">>$data_file2" or die "can't open $data_file2 $!";
> print DATAOUT "\n\t\t\tMAC-ID GENERATED REPORT\n";
> print DATAOUT "\nGeneteated By:$user\n";

you misspelled "Generated".

> print DATAOUT "\nDATE: $date \n";
> print DATAOUT "NOTE: THIS REPORT IS GENERATED BASED ON THE TEST LOGS
> AVAILABLE IN THE SERVER\n";
> print DATAOUT "\n";
> print DATAOUT " SERIAL NUMBER\t\tMACADDRESS\n";
> print DATAOUT "-\n";
> close(DATA);
> 
> sub CheckFile{
> my($name) = shift;
> 
> my $datafile=$name;
> #print "$datafile\n";
> my $data_file2='/mnt/ONT/MAC-REPORT-FILE.txt';
> 
> open DATA, "$datafile" or die" can't open $datafile $!";
> my @array_of_data=;
> 
> #print @array_of_data;
> 
> foreach my $i ($datafile)
> {

You're iterating over a scalar instead of a list.

> 
> my $Result = `grep "Base MAC Address" \/mnt\/backup\/$Directory\/$name |
> tail -n 1 `;

don't use /bin/grep when you can use perl's file and text processing tools.

> my ($str,@mac) = split(":",$Result);
> if($mac[1] ne "05")  {
> 
> @mac="   MAC NOT PROGRAMMED\n";
> #print "\n";
> print DATAOUT " $name\t\t@mac\n" ;
> }
> else{
> print DATAOUT " $name\t\t
> $mac[0]:$mac[1]:$mac[2]:$mac[3]:$mac[4]:$mac[5]\n" ;
> }
> }
> }
> 
> ($userPath);
> 
> close(DATAOUT);
> 
> 
> 
> 
> 

In short - this code should really be refactored, corrected, and modernised.
Perhaps you should read http://www.onyxneon.com/books/modern_perl/index.html or
a similar book or tutorial - see http://perl-tutorial.org/ and
http://perl-begin.org/ .

Regards,

Shlomi Fish

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: application starter kit

2017-01-23 Thread Shlomi Fish
On Mon, 23 Jan 2017 10:44:18 +0100
Luca Ferrari <fluca1...@infinito.it> wrote:

> On Mon, Jan 23, 2017 at 10:39 AM, Chas. Owens <chas.ow...@gmail.com> wrote:
> > 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
> > that exist today:  
> 
> No, sorry, I misexplained my aim: I want to be able to do all normal
> CPAN stuff like installing my module, testing, getting dependencies,
> but with the final result of installing an executable instead of a
> module.
> Your solutions are really interesting, and while I already knew about
> par and docker, fatpack has been an interesting hint, but I'm looking
> for something simpler.
> 
> Luca
> 

Hi Luca!

I think you should take a look at Dist-Zilla ( http://dzil.org/ ;
https://github.com/rjbs/dist-zilla/ ; https://metacpan.org/release/Dist-Zilla )
which seems to be what most modern Perl developers prefer. You can use it for
executables using https://metacpan.org/pod/Dist::Zilla::Plugin::ExecDir .

Also note that I started working on
https://github.com/shlomif/dzil-dist-ini-format-documentation but it may be
lacking in part because there are several layers to the dist.ini parser and my
breadcrumbs trail was getting longer.

Regards,

Shlomi Fish


-- 
-
Shlomi Fish

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