I want to repeat a process for every key in a hash, with numeric keys. So there are 3 possibilities, with 3 if, and each one compares the value of the index of an array, so that if that position eq to "sp", "sp2" or "sp3" it will search in a document some value so then it can be printed. It doesn´t work and every times gives me only one value, i would like to get the values that correspond with the hash. For example the hash could be %grupos=(1,'A',2,'G',3,'J')
and the array @hibridaciones=("sp","sp2",sp3")
The document .txt (simplified) is:
HS0.32 CS0,77 CD0.62 CT0,59 C10,77 C20,62 C30,59 OS0.73 OD0,6 O10,73 O20,6 NS0.75
The code is:
open (covalencia,"<", "cov.txt") or die "$!\n"; print keys %grupos; keys %grupos; foreach my $z (keys %grupos) { print "\n$z\n"; if (@hibridaciones[my $z-1] eq “sp") { while (my $line = <covalencia>) { if ( $line=~/C1/) { $line =~s/C1//; $radio=$line; print "\n$radio"; } } } if (@hibridaciones[my $z-1] eq "sp2") { while (my $line = <covalencia>) { if ($line=~/C2/) { $line =~s/C2//; $radio=$line; print "\n$radio"; } } } if (@hibridaciones[my $z-1] eq "sp3") { while (my $line = <covalencia>) { if ($line=~/C3/) { $line =~s/C3//; $radio=$line; print "\n$radio"; } } } } close (covalencia);
submitted by /u/SamuchRacoon
[link] [comments]
[link] [comments]
(cdxcv) 8 great CPAN modules released last week
Updates for great CPAN modules released last week. A module is considered great if its favorites count is greater or equal than 12. DBD...niceperl.blogspot.com
Making a Super Cal if Rage Will Stick Ex Paella Down Us
submitted by /u/Adriaaaaaaaan [link] [comments] |
gpw2024 - Deutscher Perl/Raku Workshop 2024
Der Deutsche Perl/Raku-Workshop ist eine jährlich in Deutschland stattfindende Open-Source-Konferenz für jedermann. Der Workshop in 2024 fand vom 15.04.2024 ...YouTube
On this site: https://codegolf.stackexchange.com/questions/246845/convert-json-object-of-directories-to-list-of-paths
There is an interesting perl solution but I'm trying to wrap my head around it and am baffled.
map/}/?/{/&&say($s)..$s=~s|[^/]+/$||:($s.=s/"//gr."/"),/{?}|".+?"/g When I do a simple test: my $s = <some json string> .. the map above I don't get any output. Thanks in advance
submitted by /u/UnicodeConfusion
[link] [comments]
Convert JSON object of directories to list of paths
Task The input consists of a JSON object, where every value is an object (eventually empty), representing a directory structure. The output must be a list of the corresponding root-to-leaf paths.Code Golf Stack Exchange
I have a bunch of files that I am parsing out a simple tag
<institution content-type="division">(.+?)?<\/institution>
Everything is going fine until I hit this result:
2) School of Chemical & Biomolecular Engineering
This is complaining because it thinks the ) is unmatched. How do I get it to accept whatever is in the capture? I tried playing around with \Q and \E but that isn't working. For clarity, I won't know what is in this tag, it could be anything at all and the tag is simple enough that I don't want to use some XML parser.
submitted by /u/sirhalos
[link] [comments]
I'm experimenting with different frameworks and I've come across this wonderful catalyst framework based on Perl, does anyone know of a front end (which is website, forums, etc.) coupled with a back end (tracker engine) for use with modern Perl? I have a PHP based one and was wondering if it was possible to do the same using Perl.
submitted by /u/Otherwise-Tune-257
[link] [comments]
MariaDB 10 and Perl DBIx::Class::Schema::Loader
https://blogs.perl.org/users/usna78/2024/05/mariadb-10-and-perl-dbixclassschemaloader.html
Asking for a friend. No really, I don't use VSCode but I know that a lot of people do and in one week I had two different people ask me this. I didn't see anything in the Visual Studio Marketplace. I'm looking for something like markdown-preview enhanced, but for Pod.
If you don't have that, is it something that you would want?
If it's something you want, would you throw in some money to have it? This isn't something I'd do myself, but I know some people with some free time who could use a little money. I could crowdfund it or whatever. The intent is to have something free in the Marketplace.
Would you care if it's not implemented in Perl? If it was JS or whatever VSCode prefers but does the job, that's fine with me (and remember I don't use VSCode). I have no idea how much that matters, but I'd hate for people to have to do all sorts of crazy setup, which for many people is installing anything from CPAN.
submitted by /u/briandfoy
[link] [comments]
m, n → m+n
is the hello world of dependent types. I hacked this together over two evenings:use 5.038; use strictures; use Kavorka qw(fun); use Moops; our %TypeVarRegistry; class MyTypes extends Type::Library :ro { use Type::Library -declare => qw(TypeVar TypeVarExpr); use Types::Common::String qw(NonEmptyStr); use Types::Standard qw(ArrayRef); use Types::Common::Numeric qw(PositiveOrZeroInt); my $TypeVar = Type::Tiny->new( name => 'TypeVar', constraint_generator => fun(NonEmptyStr $name → CodeRef) { fun {} } ); my $TypeVarExpr = Type::Tiny->new( name => 'TypeVarExpr', constraint_generator => fun(NonEmptyStr $name → CodeRef) { fun {} } ); my $SizedArray = Type::Tiny->new( name => 'SizedArray', parent => ArrayRef, constraint_generator => fun( Enum["type"] $literal_type, Type::Tiny $parameterized, Enum["length"] $literal_length, $expr → CodeRef ) { if (PositiveOrZeroInt->check($expr)) { fun { $expr == ArrayRef->of($parameterized)->assert_return($_)->@* } } elsif ('TypeVar' eq $expr->parent->name) { fun { $TypeVarRegistry{$expr->parameters->[0]} = ArrayRef->of($parameterized)->assert_return($_)->@*; 1 } } elsif ('TypeVarExpr' eq $expr->parent->name) { fun { my $eval; # world's worst symbolic expr parser if ( my ($var1, $op, $var2) = $expr->parameters->[0] =~ /(\w+)(\+)(\w+)/ ) { $eval = $TypeVarRegistry{$var1} + $TypeVarRegistry{$var2}; } else { die; } $eval == ArrayRef->of($parameterized)->assert_return($_)->@* } } else { die } }, ); __PACKAGE__->meta->add_type($_) for $TypeVar, $TypeVarExpr, $SizedArray; __PACKAGE__->meta->make_immutable; } use MyTypes qw(SizedArray TypeVar TypeVarExpr); fun add_ok( SizedArray[type => Str, length => TypeVar["m"]] $A, SizedArray[type => Str, length => TypeVar["n"]] $B → SizedArray[type => Str, length => TypeVarExpr["m+n"]] ) { [$A->@*, $B->@*] } use Data::Dx; Dx add_ok([qw(e r t)], [qw(e r t)]); fun add_broken( SizedArray[type => Str, length => TypeVar["m"]] $A, SizedArray[type => Str, length => TypeVar["n"]] $B → SizedArray[type => Str, length => TypeVarExpr["m+n"]] ) { [$A->@*, $B->@*, 'this must not work'] } use Data::Dx; Dx add_broken([qw(a s d f)], [qw(g h j k)]);
submitted by /u/daxim
[link] [comments]
How to install CRISPRCasFinder (for detection of CRISPRs and cas genes)
I need to find the distance between two GPS coordinates. Geo::Calc does this effectively, but it hasn't been updated in over a decade, and, more seriously, it adds a significant startup delay just by loading the module:
root@1c8fb16bd7bb:/app# time perl -e 'use v5.38' real 0m0.005s user 0m0.001s sys 0m0.004s root@1c8fb16bd7bb:/app# time perl -e 'use v5.38; use Geo::Calc' real 0m0.679s user 0m0.631s sys 0m0.048s
This isn't a deal-breaker (honestly, it barely matters at all in production, but it's annoying for repeated loads during dev/testing), but I was wondering if anyone knew of a more-modern/more-efficient alternative. I searched google and metacpan but it's tough to wade through the noise for such a generic search term.
submitted by /u/tyrrminal
[link] [comments]
The portions of B::Generate associated with PADOP construction use static variables, and thus are not thread safe.
This release imports that section of Generate.xs into sealed.xs and removes the static variable dependencies.
submitted by /u/joesuf4
[link] [comments]
Carp::Object, an object-oriented replacement for Carp and Carp::Clan
[link] [comments]
(cdxciv) 17 great CPAN modules released last week
Updates for great CPAN modules released last week. A module is considered great if its favorites count is greater or equal than 12. App...niceperl.blogspot.com
submitted by /u/singe [link] [comments] |
Use bash , ncal , Perl to list years, months, and weeks with week numbers
Use bash , ncal , Perl to list years, months, and weeks with week numbers - gist:efa21bd6374824ba8332a3a4ac7b4585Gist
I am hopeful someone has done this before as I'm stuck... I have a 3TB disk image file and I am trying to find all the different email addresses that I've used over the past 22 years.
I can use hex editor tools to find them but it takes days to look at the data and pick out even a handful of matches.
I use Perl regularly but I normally scan text files and do non binary file actions. That's easy since I can do a line by line search. But binary seems different.
If I want to search for zeropoint@ (no domain because I've used dozens of ISPs over the years and that's why I am trying to figure this out.) inside the entire 3TB file, what's the best way to do that? I can dump the results to a file and then clean it up but the search part has me stuck
Thank you
submitted by /u/zeropointlabs
[link] [comments]
[link] [comments]
PTS 2024: Lisbon
Almost exactly a year since the last Perl Toolchain Summit, it was time for the next one, this time in Lisbon. Last year, I wrote:Ricardo Signes (rjbs forgot what he was saying)
Benchmark::DKbench Perl benchmark suite now supports custom benchmarks.
submitted by /u/perlancar [link] [comments] |
List of new CPAN distributions – Apr 2024
dist author abstract date AI-Ollama-Client CORION Client for AI::Ollama 2024-04-05T09:15:33 Acme-CPANModules-BPOM-FoodRegistration PERLANCAR List of modules and utilities related to Food Registrati…perlancar's blog
Crypt Base Functions, using the OpenSSL libraries
Changes for 0.038 - 2024-04-26
- ec_conv.pl
Override subroutines in a module for unit testing
Changes for v0.178.0
- 6724a30 - Simplify CI workflow - Nicolas R
- 1801372 - Multiple improvements - Nicolas R
- e97e316 - Add protection to _replace_sub - Nicolas R
search nested hashref/arrayref structures using JSONPath
Changes for 1.0.6 - 2024-04-26T11:58:01-05:00
- Other
Perl CPU Benchmark
Changes for 2.6 - 2024-04-25
- Custom benchmark improvements.
- Fix BSD tar xattr.
Code coverage metrics for Perl
Changes for 1.41
- Spelling, linting and formatting changes
load Data::Dumper output, including self-references
Changes for 0.01 - 2024-04-25
Experimental features made easy
Changes for 0.032 - 2024-04-25T22:30:41+01:00
- Add the newly-stable features to stable.pm - extra_paired_delimiters, const_attr, for_list