Skip to main content




Hi all! This is my first Perl script.

#!/usr/bin/perl use strict; use warnings; use Curses::UI; use Data::Dumper; use JSON; # Create the root Curses::UI object my $cui = Curses::UI->new(-color_support => 1); # Set up a signal handler to exit on Ctrl+C $cui->set_binding(sub { exit(0); }, "\cC"); # Create the main window my $win = $cui->add('window_id', 'Window'); # URL to fetch email address my $response = "https://www.1secmail.com/api/v1/?action=genRandomMailbox&count=1"; # Variable my $email_address = ''; my $username = ''; my $domain = ''; my $formatted_email = ''; my $formatted_json = ''; my $formatted_inbox = ''; my $Id = ''; my $box = ''; # my $filename = '/home/ola/Work/Languages/Perl/curses-ui/1/TempMail-Curses-UI/file.txt'; # Calculate the center Y position based on the window height my $window_height = $win->height(); my $center_y = int(($window_height - 1) / 2); # Create $win->add( 'buttonbox_id', 'Buttonbox', -y => $center_y, -buttons => [ { -label => '< Get Random Email >', -onpress => sub { $email_address = `curl -sL $response`; chomp($email_address); $email_address =~ s/^\["(.*)"\]$/$1/; print $email_address; # Split the email into username and domain my ($username, $domain) = split('@', $email_address); chomp($domain); print "Username is: $username\n"; print "Domain is: $domain\n"; # Copy system("echo $email_address | xsel --clipboard --input"); # Write to file open(FH, '>', $filename) or die $!; print FH $email_address; close(FH); # print "Writing to file successfully!\n"; # Send test mail # system("perl SendMailTest.pl"); # Display the output in a dialog $cui->dialog( -message => "Random Email:\n$email_address\n Copied To Clipboard", -title => "Email Address", -buttons => [ { -label => '< OK >', -value => 1, -shortcut => 'o', } ], ); } }, { -label => '< Update Inbox >', -onpress => sub { # my $command_output = `curl -sL "https://www.1secmail.com/api/v1/?action=getMessages&login=2gqhd4oz4wb&domain=laafd.com"`; my $command_output = `curl -sL "https://www.1secmail.com/api/v1/?action=getMessages&login=$username&domain=$domain"`; chomp($command_output); $formatted_json = decode_json($command_output); $Id = $formatted_json->[0]->{id}; # Display the output in a dialog box $cui->dialog( -message => $formatted_json->[0]->{subject}, -title => "$Id = $formatted_json->[0]->{id}", -buttons => [ { -label => '< Fetch Mail Body >', -value => 1, -shortcut => 'o', } ], ); $Id = $formatted_json->[0]->{id}, # my $inbox = `curl -sL "https://www.1secmail.com/api/v1/?action=readMessage&login=2gqhd4oz4wb&domain=laafd.com&id=$Id"`; my $inbox = `curl -sL "https://www.1secmail.com/api/v1/?action=readMessage&login=$username&domain=$domain&id=$Id"`; chomp($inbox); my $formatted_inbox = decode_json($inbox); my $box = $formatted_inbox->{textBody}; # print Dumper($formatted_inbox); print $box; $cui->dialog( -message => $box, -title => "$Id = $formatted_json->[0]->{subject}", -buttons => [ { -label => '< OK >', -value => 1, -shortcut => 'o', } ], ) } }, ], -buttonalignment => 'middle', ); $cui->mainloop; 

This is a script to fetch a temp mail address from the API, then display the contents of its inbox.

Problem


Everything was working fine, but suddenly I'm getting an error about screen size. I am literally clueless at this point.

Error:


Your screen is currently too small for this application.

Resize the screen and restart the application.

Press <CTRL+C> to exit...

Info


Terminal has 45 lines and 189 coloumns, and is full screen.

This is perl 5, version 38, subversion 2 (v5.38.2) built for x86_64-linux-thread-multi

Curses::UI Version: INST_VERSION 0.9609

OS is Arch Linux

submitted by /u/GapIndividual1244
[link] [comments]



Lessons From an Idaho Potato Farmer - David Laulusa - TPRC 2024 - Lightning Talk submitted by /u/briandfoy
[link] [comments]



Fixing a fifteen-year-old curve fit bug submitted by /u/oalders
[link] [comments]


Although this StackOverflow question about "islands and gaps" is titularly about Perl, the SQL answers are very nice. Apparently this is a FAQ for SQL.

However, this has bugged me for years on the CPAN side, but never enough to make me really do anthing about.

I thought there was a Perl module that did this, and it was in the context of a usenet reader that would take a list of article IDs, such as 1, 2, 3, 4, 5, 7, 10, 11, 15 and return something like 1-5,7,10-11,15 as a more space-efficient store of all the articles you had read.

Every time I've looked I've stopped after 15 minutes because I get distracted and I've never really needed this except to answer someone else's question. I'm not asking how to solve this because there are plenty of algorithm tutorials out there. Surely this is on CPAN somewhere.

There are plenty of options to go the other way and to ask if a number is in one of the ranges.

submitted by /u/briandfoy
[link] [comments]



Actually Portable Perl - Gavin Hayes - TPRC 2024 submitted by /u/briandfoy
[link] [comments]


GitHub - PerlToolsTeam/github_workflows: Some useful (and reusable) GitHub Workflows submitted by /u/briandfoy
[link] [comments]


Party Like It's 19100+e^iπ - Curtis Poe - TPRC 2024 submitted by /u/briandfoy
[link] [comments]





I have a Mac M1 chip laptop.

While I have managed to install a couple of modules, most fail to install.

I tried perlbrew, but that was a struggle to even get it to install perl itself, but when it was installed it wasn't working the way I needed it to.

Just wondering if I am missing something with CPAN or if this is an issue because it's an M1 chip?

submitted by /u/MrCosgrove2
[link] [comments]




The final installment in the series:

"The-Quest-For-Performance" from my blog Killing It with #perl

Discussing #python #numpy #numba, #rstats #openMP enhancements of Perl code and #simd

Bottom line: I will not be migrating to Python anytime soon.

Food for thought: The Perl interpreter (and many of the modules) are deep down massive C programs. Perhaps one can squeeze real performance kicks by looking into alternative compilers, compiler flags and pragmas ?

https://chrisarg.github.io/Killing-It-with-PERL/2024/07/09/The-Quest-For-Performance-Part-IV-May-the-SIMD-Force-Be-With-You.html

submitted by /u/ReplacementSlight413
[link] [comments]