Re: How to reboot?

2024-01-13 Thread Lars Noodén via beginners
If you go the e-mail route for signalling, you can have Perl scripts on both ends using Crypt::OpenPGP to sign and/or encrypt the commands. Other options like XMPP were mentioned. Maybe one of the MQTT modules would be suitable. /Lars -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org

Re: Tool for develop in Perl

2023-10-22 Thread Lars Noodén via beginners
On 10/21/23 07:48, William Torrez Corea wrote: What tool can I use for development in Perl? I use VIM for coding and executing programs with the Perl Command Line from GNU/Linux. In addition I have installed Eclipse but the IDE is abandoned. My theory: I can make full development from VIM but

Re: Code or tools

2023-08-17 Thread Lars Noodén
On 8/18/23 01:42, William Torrez Corea wrote: *What do I need to improve my code?* 1. Algorithms 2. Comments 3. Readability [snip] I would vote for 3. Readability. Comments are going to be part of that. Maybe a smaller or larger part depending on what you are writing, but a part

Re: Bash vs Perl

2023-07-14 Thread Lars Noodén
On 7/14/23 19:05, William Torrez Corea wrote: - cd : Change the directory to a different location. - ls : List the contents of the current directory. - mkdir : Create a new directory. - touch : Create a new file. - rm : Remove a file or directory. - cp : Copy a file or

Re: Wide character in print at HTML::TreeBuilder::XPath function

2020-01-26 Thread Lars Noodén
On 1/26/20 9:58 AM, Lars Noodén wrote: > I've got a long script that has "use utf8;" near the top. The script > parses some HTML and then I run into trouble when printing the result as > shown below: > > use utf8; > use HTML::TreeBuilder::XPath; >

Wide character in print at HTML::TreeBuilder::XPath function

2020-01-25 Thread Lars Noodén
I've got a long script that has "use utf8;" near the top. The script parses some HTML and then I run into trouble when printing the result as shown below: use utf8; use HTML::TreeBuilder::XPath; . . . my $xhtml = HTML::TreeBuilder::XPath->new; $xhtml->implicit_tags(1);

XML::Feed.pm perl on CentOS 7

2019-09-02 Thread Lars Noodén
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

Re: Making use of XML::Feed->parse() more robust

2019-08-29 Thread Lars Noodén
On 8/28/19 7:33 PM, Andy Bach wrote: > Look at eval blocks - lets you trap fatal errors from other code and not > die/abort yourself. > https://perldoc.perl.org/functions/eval.html Thanks. I went with an eval block since it was very quick to set up. > You can also wrie your own signal handling

Making use of XML::Feed->parse() more robust

2019-08-28 Thread Lars Noodén
I've been using the CPAN module XML::Feed to parse Atom and RSS feeds. Some of the feeds it fetches are a little broken from time to time and when that happens the parser produces and error and stops the program. I'd like it to just keep going. I am invoking the parser inside a subroutine like

Re: Perl invocations

2017-07-02 Thread Lars Noodén
On 07/02/2017 03:29 PM, Eric de Hont wrote: [snip] > Apart from the perldocs also have a look at https://perlmaven.com/hashbang [snip] Thanks. That was a good link. perlintro(1) was good to review but the perlmaven link went into some nice depth. They say opposite things about using

Perl invocations

2017-07-02 Thread Lars Noodén
I've grepped the first lines of a large project's source files for instances of the string perl as a word. Sorted, ranked, and slightly edited, the results can be seen below. What I am wondering is that can anything general, independent of context be said about the invocations? For example, is

Re: [solved] Re: Module to extract patterns

2017-06-13 Thread Lars Noodén
On 06/13/2017 05:14 PM, Chas. Owens wrote: > Two notes: > > Firstly, $document->find will return undef if no regexes are found, not an > empty arrayref, so you should say [snip] > Secondly, PPI does not catch all things that can be considered regexes, for > instance: [snip] Thanks. I

[solved] Re: Module to extract patterns

2017-06-13 Thread Lars Noodén
Ok. Thanks, Paul and David. I think I see how I can benefit from Text::Balanced but I now have my start with PPI and can list the expressions. Regards, Lars #!/usr/bin/perl use strict; use warnings; use PPI; use Data::Dumper; my $file = shift or ( die("Need a file name!\n") ); my $document =

Module to extract patterns

2017-06-13 Thread Lars Noodén
There are a lot of ways to write patterns. /foo/; m/foo/; m|foo|; m| foo |x; m/foo\//; qr/foo/; qr|foo|; qr/ foo /x; s/foo/bar/; s/ foo /bar/x; s| foo |bar|x; and so on. Is there a module or method that can identify and extract them from a larger bit of code regardless of style?

Re: Fwd: Parsing web pages

2017-03-03 Thread Lars Noodén
On 03/03/2017 02:15 AM, kavita kulkarni wrote: > Hello, > > Can you suggest some effective ways to parse multiple web pages from the > web site. > I cannot use web crawling as the format of the pages is not same. I am > interested in the data from specific table on each page. > > Thanks in

Net::ISC::DHCPd or Net::DHCP::Info

2017-01-30 Thread Lars Noodén
Hello, When there are several CPAN modules that seem to do something similar, how does one identify which one is more mature and well-maintained? For example, which one is best for parsing DHCPd configuration (dhcpd.conf) files? Net::ISC::DHCPd or Net::DHCP::Info? I'm guessing that since the

Re: Processing binary data

2016-04-04 Thread Lars Noodén
Thanks, Shlomi. On 04/04/2016 11:58 AM, Shlomi Fish wrote: [snip] >> Is substr() always byte-safe? (Using perl 5.20.2 for example) >> > > What do you mean by something being "byte-safe" exactly? I'm not sure I > understand. I am looking for a way to be sure that substr always treats the data

Re: Processing binary data

2016-04-04 Thread Lars Noodén
On 04/03/2016 02:42 PM, Shlomi Fish wrote: > Hi Lars and all, > > On Thu, 31 Mar 2016 11:38:44 + > Duncan Ferguson wrote: > >> Lars, >> >> I believe 'unpack' is the right way to go, you just need to get the template >> right ('N' in your example) >> > > in

Processing binary data

2016-03-31 Thread Lars Noodén
What are the best practices for working with binary data? If I read a span of binary data, say, into $packet like with read() below my ( $packet_size, $packet ); read( $client_socket, $packet_size, 4 ); $packet_size = unpack( "N", $packet_size ); read(

Re: Forking as another user

2016-03-14 Thread Lars Noodén
On 03/13/2016 02:14 PM, Peter Scott wrote: > On Sat, 12 Mar 2016 18:44:18 +0200, Lars Noodén wrote: [snip] >> What modification can prevent zombies yet allow multiple concurrent >> clients to attach? > > You need the WNOHANG option on your wait() to make it nonblocking

Re: Forking as another user

2016-03-12 Thread Lars Noodén
Thanks, David and Shlomi (and those that read), I understand fork() and the style of writing better. Strange that the defaults for 'use English' are not optimal. The snippet below works to fork as a specific user, if run as root. However, it generates zombies. The functions wait() or waitpid()

Forking as another user

2016-03-11 Thread Lars Noodén
If I have the code below to fork a child process, how would the right way be to fork as a different user? I gather that fork() itself does not support that, so some other method must be used. Regards, Lars - #!/usr/bin/perl use strict; use warnings; use English;# for $UID and such my

Re: Storing Output file.

2016-01-28 Thread Lars Noodén
On 01/28/2016 04:59 PM, Logust Yu via beginners wrote: > You can probably achieve this easily with 'sed' on bash. > >> On 28 Jan 2016, at 09:37, Frank Larry wrote: >> >> Hi Team, >> >> could you please let me? i have a file which contains "Debug", i would like >> to

Bulk editing of JPEG metadata

2015-11-01 Thread Lars Noodén
I need to bulk edit the metadata in a large number of JPEG files. Which is the best CPAN module to help with that? Would it be Image::ExifTool ? Regards, Lars -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org

Re: File::Sluprer (Re: Multi line file handling)

2015-10-20 Thread Lars Noodén
On 10/19/2015 07:40 PM, Kent Fredric wrote: > On 20 October 2015 at 03:55, Lars Noodén <lars.noo...@gmail.com> wrote: >> What is the main reason for the preference of File::Slurper over >> File::Slurp these days? > > > http://blogs.perl.org/users/leon_timmerma

File::Sluprer (Re: Multi line file handling)

2015-10-19 Thread Lars Noodén
On 10/19/2015 05:49 PM, Shlomi Fish wrote: > Just for the record, using File::Slurp is no longer recommended and one should > be using https://metacpan.org/pod/Path::Tiny or perhaps > https://metacpan.org/pod/File::Slurper instead. What is the main reason for the preference of File::Slurper over

CRC16 from Digest::CRC

2015-06-05 Thread Lars Noodén
I have some data, hexadecimal encoded, that comes with a checksum: data : 26a435dea66b0200081c8f000e6f crc : f497 I've tried the combinations of parameters for Digest::CRC that I could think of (about 24) but have not found the right ones, for example the script below. Apparently, the C

Re: Reading first 6 bytes of binary data

2015-06-02 Thread Lars Noodén
On 06/02/2015 01:18 PM, Shlomi Fish wrote: Hi Lars, please reply to all recipients. On Tue, 02 Jun 2015 12:54:54 +0300 Lars Noodén lars.noo...@gmail.com wrote: I have a calculated variable $otp which is decrypted using AES key $key. If the variable was properly decrypted, the first

Reading first 6 bytes of binary data

2015-06-02 Thread Lars Noodén
I have a calculated variable $otp which is decrypted using AES key $key. If the variable was properly decrypted, the first six bytes of the decrypted data should match what is in $userid, I think. How do I extract the first six bytes of $plaintext and compare it to what's in $userid ? Regards,

Re: Match HTML div ...... /dv string over multiple

2014-11-18 Thread Lars Noodén
On Tue, Nov 18, 2014 at 12:22 PM, mimic...@gmail.com mimic...@gmail.com wrote: I am trying to extract a table (table class=trtd.. until /table) and its content from an HTML file. Because there can be nested tables and other elements that can throw off simple regex parsing, I would try

Re: Apologetic request for simple one-off script

2014-07-17 Thread Lars Noodén
On 07/17/2014 03:30 PM, Michael Lynch wrote: how about using awk to print the last column, using number of columns variable $NF: awk '{print $NF}' file Regards, Mike Or maybe something like this in perl itself? perl -ne 'print @{[split(/\s+/,)]}[-1],qq(\n);' file Regards, /Lars --

Re: Apologetic request for simple one-off script

2014-07-17 Thread Lars Noodén
On 07/17/2014 05:16 PM, Uri Guttman wrote: On 07/17/2014 09:02 AM, Lars Noodén wrote: Or maybe something like this in perl itself? perl -ne 'print @{[split(/\s+/,)]}[-1],qq(\n);' file much earlier in this thread there were one liner examples of perl using the -a (autosplit option) which

Re: Internet Search

2014-03-18 Thread Lars Noodén
On 03/18/2014 12:39 PM, Anant kumar wrote: Dear Lars Nooden, I am finding difficulty in installing the Program. Can you please take a look and advice me the solution. Sincerely yours, Anant Kumar B.Tech; Biotechnology From the error messages

Re: Internet Search

2014-03-15 Thread Lars Noodén
On 03/15/2014 07:43 AM, Anant kumar wrote: Hi Jim Gibson, I want to write a search engine of my own. Similar to Google but not as complex as that. Just for simple data mining for my research work. Sincerely yours, Anant Kumar B.Tech; Biotechnology No need

Re: Suppressing Carp in a module

2014-01-01 Thread Lars Noodén
Yes, happy new year 2014. On 01/01/2014 12:09 PM, Shlomi Fish wrote: If it's a warning you can do «local $SIG{__WARN__} = sub { ... }». See %SIG in «perldoc perlvar» (see http://perldoc.perl.org/perlvar.html - it's also «perldoc -v '%SIG'» in recent versions of the perldoc command).

HTML::TokeParser munging characters

2013-12-28 Thread Lars Noodén
If there is a better list for discussing HTML::TokeParser, I can post there. I have a code snippet which successfully extracts a piece of a web page. However, something goes south with the conversion to text. What should come out as the following Temperature 3.2°C Humidity 94%

Re: HTML::TokeParser munging characters

2013-12-28 Thread Lars Noodén
On 12/28/2013 05:52 PM, Shawn Wilson wrote: The parser has done what its supposed to. IDK you can alter the encoding in it. Maybe you can and that's what you're looking for (encoding or character set). I'd first try binmode UTF-8 but you'll probably just end up handling this with a regex.

Suppressing Carp in a module

2013-12-28 Thread Lars Noodén
DateTime::Event::Sunrise carps to stderr during the polar day or night. From the man page: 'the module carps that the sun never rises or never sets.' How can that output to stderr be suppressed so that the module is quiet? The sun not rising or setting is quite normal in certain

DBD::Pg::st execute failed: execute called with an unbound placeholder

2013-12-11 Thread Lars Noodén
I have an sql statement which works fine in the psql client: delete from sessions where current_timestamp - time interval '00:02:00'; but when I try it using DBI, it produces this error: DBD::Pg::st execute failed: execute called with an unbound placeholder ... That part of the code is

Re: DBD::Pg::st execute failed: execute called with an unbound placeholder

2013-12-11 Thread Lars Noodén
On 12/11/2013 06:42 PM, John SJ Anderson wrote: [snip] With most drivers, placeholders can't be used for any element of a statement that would prevent the database server from validating the statement and creating a query execution plan for it. I suspect you're running afoul of that... j.

perlre(1) and substitution evaluations

2013-11-30 Thread Lars Noodén
perlre(1) seems to be missing information about substitution evaluations with the /e option. The functionality is present in perl: perl -e '$_=2; s/2/1+3/e; print' But it is not listed in the pod documentation for v5.16.3 or v5.18.1. The modifier /e is described in Programming Perl, 4th

Re: perlre(1) and substitution evaluations

2013-11-30 Thread Lars Noodén
On 11/30/2013 02:55 PM, Charles DeRykus wrote: See the substitution operator in perlop: |||http://perldoc.perl.org/functions/s.html| A |/e| will cause the replacement portion to be treated as a full-fledged Perl expression and evaluated right then and there. It is, however, syntax checked