Re: slurp error

2018-07-27 Thread Andy Bach
open my $fh1, '<', $file_to_convert or die "Can't open $file_to_convert: $!\n"; $slurp = <$fh1> or die "Could not slurp $file_to_convert: $!"; It's just a warning (the code works) that you're using $fh1 untested. This doesn't complain if ( open my $fh1, '<', $file_to_conver

Re: slurp error

2018-07-27 Thread Uri Guttman
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

slurp error

2018-07-27 Thread Rick T
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

Re: confidence under BEGIN{}

2018-07-27 Thread Andy Bach
Lauren wrote: >there is another member on this list pointed me a more graceful way, use lib '/path/..'; That's a good one, too - note, you do want to use an absolute path in there (and elsewhere) if you're writing this in a script. Something folks often misunderstand is that the script is run re

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

Re: regex to get the rpm name version

2018-07-27 Thread Chas. Owens
But if you have to use a regex, I suggest using the /x modifier to make it easier to read an maintain the regex: #!/usr/bin/perl use strict; use warnings; for my $s (qw/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/) { my ($name, $vers

RE: regex to get the rpm name version

2018-07-27 Thread Duncan Ferguson
I would suggest you change your approach and user the query mode of RPM to get your information instead of build up a regexp: rpm -qa --queryformat "%{NAME}\n" Duncs From: Asad [mailto:asad.hasan2...@gmail.com] Sent: 27 July 2018 13:55 To: beginners@perl.org Subject: regex to get the rpm name

Re: regex to get the rpm name version

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

regex to get the rpm name version

2018-07-27 Thread Asad
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 me