Hey all!
As a recent graduate seeking a junior developer position, I received an invitation for a job interview which included a Perl coding exercise. How can i make my code better? Additionally, are there recommended best practices for documenting my progress on this exercise? I never programmed in perl, so bare with me. Thanks a lot!!
here's the task:
- read the data from a .csv file
- store data in one hash
- outputs the data as HTML, sorted by company and within the company by name
here is my code:
#!/usr/bin/perl use strict; use warnings; use Text::CSV; my $csv_file = 'Bewerbungstest.csv'; open(my $fh, '<', $csv_file) or die "Could not open file '$csv_file' $!"; my $csv = Text::CSV->new({ binary => 1 }) or die "Cannot use CSV: ".Text::CSV->error_diag(); $csv->header($fh); # Hash Wert my %data_hash; while (my $row = $csv->getline($fh)) { my $pid = $row->[0]; # PID as key my $company = $row->[1]; # Company name as key my $last_name = $row->[2]; # Employee last name my $first_name = $row->[3]; # Employee first name push @{$data_hash{$company}}, [$pid, $last_name, $first_name]; } close($fh); # Sort the company names alphabetically foreach my $company (sort keys %data_hash) { @{$data_hash{$company}} = sort {$a->[1] cmp $b->[1]} @{$data_hash{$company}}; } # HTML Output open(HTML, '>', 'output.html') or die "Could not open file: $!"; print HTML "<html>\n"; print HTML "<head>\n"; print HTML "<title>Employee List</title>\n"; print HTML "</head>\n"; print HTML "<body>\n"; print HTML "<h1>User Liste</h1>\n"; print HTML "<table border='1'>\n"; print HTML "<tr><th>PID</th><th>Company</th><th>Last Name</th><th>First Name</th>\n"; foreach my $company (sort keys %data_hash) { foreach my $entry (@{$data_hash{$company}}) { my ($pid, $last_name, $first_name,) = @$entry; print HTML "<tr>\n"; print HTML "<td>$pid</td>\n"; print HTML "<td>$company</td>\n"; print HTML "<td>$last_name</td>\n"; print HTML "<td>$first_name</td>\n"; print HTML "</tr>\n"; } } print HTML "</table>\n"; print HTML "</body>\n"; print HTML "</html>\n"; close(HTML); print "HTML file erfolgreich generiert\n";
submitted by /u/stayin_alive23
[link] [comments]
Data objects for login.
Changes for 0.02 - 2024-03-19T14:01:19+01:00
- Regen example file.
- Rewrite to new Data::HashType@0.04 with added 'valid_from' parameter.
Random hash type objects.
Changes for 0.03 - 2024-03-19T13:59:34+01:00
- Add support for Data::HashType@0.04.
find, build and install the bowtie2 tools
Changes for 0.01 - 2024-03-19T05:13:18-06:00
So hear me out...
This idea is stupid. But on Star Trek (VOY, TNG, and DS9 at least), they measured their data as "quads". ( https://memory-alpha.fandom.com/wiki/Quad ). This was never defined because it's just Sci-Fi and doesn't need a real definition. But... what if they're quad-floats aka 128bit floating point values. This would mean then that all the storage could be done as LLM or other neural network style models, and vector embeddings and such. Given what we've got today with transformer style models for doing translation, chat, etc. If you had ultrapowerful computers that could do these calculations with such gigantic precision then you'd be able to store very accurate data and transform it back and forth from vector embeddings and other fancy structures. It'd enable very powerful searches, and the kind of analysis we're trying to use LLMs for and see them use in the shows when talking to the computers. This would also explain a lot about the universal translators from ENG onward, and could even help make sense of Darmok and Jalad at Tenagra. And then Voyager even has bio-neural circuitry for doing things faster, some kind of organic analog computing doing stuff "at the edge". Using weights and embeddings to do things with them and have them react by programming them with a machine learning model at each node could easily explain how that could work too.
This idea honestly feels too stupid to be real but it could explain so much.
Quad
A quad was a measurement of information storage in Federation computers. While Federation computers used binary code in some capacity, they also are known to have used trinary code.Contributors to Memory Alpha (Fandom, Inc.)
Recordings of the German Perl Workshop (gpw2023) are online
Config::Tiny V 2.30 supports keys with arrays as values
Perl.social server upgrades
Writing Perl with Emacs: Are there perl-mode users around?
perlbot and related status
Perl.social updates
Webservice to connect to Onfido API
Changes for 0.006 - 2023-07-02T15:36:03+00:00
- Add hook
Open a file for shared reading and/or writing
Changes for 4.05 - 2023-07-02
- Fix tests with perl-5.38.0.
Fast, safe DBI connection and transaction management
Changes for 0.59
- Fix for Windows t/load.t failures
Get stock and mutual fund quotes from various exchanges
Changes for 1.57 - 2023-07-01T12:37:07-07:00
- Correct set exchange in YahooJSON.pm - Issue #306
- Added close, change and p_change to Tradegate, XETRA and Sinvestor Added optional parameter INST_ID to specify the institute id. Fixed bug in Tradegate, XETRA and Sinvestor for numbers equal or higher than 1.000 - PR #304
- Added GoogleWeb Module
- YahooWeb module added - PR #296
- Added MarketWatch Module
- Replaced cached file with IO::String object in IndiaMutual.pm
- Fixed missing date in AEX.pm - Issue #298
- Fixed Examples in POD Documentation in a few modules - PR #295
- move use strict to be the first statement in TreasuryDirect.pm and TwelveData.pm #290
- remove old perl version requirement statements from TreasuryDirect.pm and TwelveData.pm #290
- removed Data:😁umper that caused another test to fail from TreasuryDirect.pm #290
- Fixed Fool.pm and fool.t - PR #289
A Perl module for handling webhooks sent by Stripe
Changes for 1.12
- Modified tests to prevent failure when Test::Warn is not installed Added new author test for VERSION in module and POD
Synthesizer settings librarian
Changes for 0.0029 - 2023-07-01T11:39:38Z
- Adjust make_setting() logic.
- Improve the eg/mojo-ui.pl program.
Synthesizer settings librarian
Changes for 0.0028 - 2023-07-01T10:39:18Z
- Improve the eg/mojo-ui.pl program.
Validate Japanese zip-codes
Changes for 0.20230630
- Update some table classes.
Perl extension for the GNU Readline/History Library
Changes for 1.46 - 2023-07-01
Synthesizer settings librarian
Changes for 0.0027 - 2023-07-01T01:43:35Z
- Improve the eg/mojo-ui.pl program.
- Simplify the remove_model() method.
- Improve documentation.
Ryan Voots
in reply to Ryan Voots • •