Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

The Monastery Gates

( [id://131]=superdoc: print w/replies, xml ) Need Help??

Notices:

erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

If you're new here please read PerlMonks FAQ
and Create a new user.

Quests
Wall of Larry Quest
Starts at: Feb 26, 2024 at 05:00
Ends at: Dec 31, 2024 at 04:59
Current Status: Active
2 replies by jdporter

    By now you've all seen The St. Larry Wall Shrine. Well, it could use a fresh coat of gold leaf and shellac. Therefore, we are soliciting Larry-related items to be placed on the shrine. Links to offsite content are good; or if you have small bits of content, such as quotes, you'd like to contribute, that's fine too. Please reply to this Quest with your humble offerings. Thank you! And may St. Larry bless your codings and your debuggings.

poll ideas quest 2024
Starts at: Jan 01, 2024 at 00:00
Ends at: Dec 31, 2024 at 23:59
Current Status: Active
4 replies by pollsters
    First, read How do I create a Poll?. Then suggest your poll here. Complete ideas are more likely to be used.

    Note that links may be used in choices but not in the title.

Perl News
List of 2024 TPRC Science Track Talks Videos
on Jul 02, 2024 at 15:08
0 replies by oodler
2024 Golden PERL Award voting ends 6/27 4PM PDT
on Jun 27, 2024 at 00:51
2 replies by oodler
    Sorry I didn't get this out here earlier, but Perl Community (parent org of the Science Perl Committee that is initiated the Science Track) is giving out a "peoples choice" award at the end of Conference Lightning Talks. It's sincere gesture from us and allows anyone to vote for anyone in the Perl community at large, as a "thank you" from us.

    link to Google voting form

    The Science Track talks have been great, some are even starting to come online. Thanks to everyone who made this happen, especially the TPRC Planning Committee.
Supplications
SQLite returns funny characters
2 direct replies — Read more / Contribute
by jmClifford
on Jul 09, 2024 at 09:58

    Hi. I have SQLite with the Perl, where some text values returned are Degrees C and Degrees F and the "Degrees" is a small super scripted °. And when this is returned to my Perl console it can show as °F. How can I easily convert / display this new font which I assume is not the usual ASCII (or my keyboard) font.

    Regards JC.....

Private variable in class method does not go out of scope
3 direct replies — Read more / Contribute
by daniel85
on Jul 08, 2024 at 06:19

    Dear Monks,
    I have encountered a quite crazy issue with Perl. Please look at the following example:

    { package FooObj; sub new { bless { _count => 1, _data => 0 }, $_[0] } sub add_data { my $self = shift; my $data = shift if (@_); print "\nCalled: data value is " . ($data || "NONE") . "\n"; if (defined $data) { die "\nError: data does not look like num +ber\n\n" if ($data !~ /^\d+$/); } if ($self->{_count}) { $data = 5 if (!defined $data); $self->{_data} += $data; $self->{_count}--; return($self->{_data}); } } } my $bar = FooObj->new; while(my $val = $bar->add_data()) { # do something here }

    In the above example, the method add_data() should be called twice. Both times, the method is called with no argument, therefore the private variable $data should be undefined. Later on, inside the method, if $data was not defined, it gets assigned a value of 5.

    Here comes the weird part. If you run the above code, it outputs:

    Called: data value is NONE

    Called: data value is 5

    It looks like, the second time add_data() gets called, $data did not go out of scope and its previous value is still there.
    However, if I replace the line my $data = shift if (@_); with my $data = shift;, I get the expected output:

    Called: data value is NONE

    Called: data value is NONE

    Can someone please explain me what is going on? Is this a Perl bug or am I missing something??

    Thanks!!!

    Cheers,
    Daniel

Meditations
Who's still around?
17 direct replies — Read more / Contribute
by stevieb
on Jul 08, 2024 at 03:29

    In 1998, a friend gave me a computer. It was in pieces. I knew nothing about nothing. Within a year, I was communicating over dual telephone lines. Within two years of that, I was a sysadmin at an ISP. This was the year I found Perlmonks. I read a book, 'Perl in 21 days' or some such, and found Perl was what I wanted... a way to automate processes.

    Within months, I learned a dangerous amount about MySQL, CGI and Perl to allow any invader to break everything. Thankfully, during that time, everyone was out for themselves, and exploitation hadn't yet become a thing.

    By 2009, I'd grown a lot in many areas. No where near perfect in the security arena, but I was becoming proficient on how to interact with the open source world, and how to interact with the CPAN. It was this year that I joined Perlmonks as a member, and became a vocal person, not just a listener.

    Now, as some of the old timers will attest to, I always claimed "I'm not a programmer". With that said, I have done much work in fields so closely related to programming, that I have to bend and say that yeah, maybe I can classify as a hacker.

    Anyone else around who have claimed "I'm not a programmer", or who has been around since the very early days of Perlmonks who would just like to say "I'm still here!!!"?.

    -stevieb

Cool Uses for Perl
Tree::RB::XS now doubles as a LRU cache
No replies — Read more | Post response
by NERDVANA
on Jul 08, 2024 at 04:59

    So, I was experimenting with LRU caches (where the least-recently-used elements get discarded if the cache is full) and realized I could implement it much more efficiently inside of my Red/Black Tree module, and at almost no extra cost. (well, 16 bytes per tree node, but they were already big)

    The short version is that there is now an optional linked list running through the tree nodes in the order of insertion, and you may also omit nodes from that list (if you want them to persist in the cache) and you may re-order the list however you like.

    I'm currently using it for marking positions within a log file, where I parse the timestamp at a given address while performing a binary search of the log, and write down the timestamps and addresses in the cache to speed up later seeks. This problem requires a tree so that I can say "what is the timestamp address before and after my desired timestamp", followed by a binary search of the records in that range.

    Meanwhile, you can also insert duplicates for things like statistical tracking over time, such as inserting IP addresses who are abusing your system, and then answer queries about how many violations they've had in the cache's time window (maybe causing you to add them to a firewall blacklist), then expire the events individually. Being a tree, you can also sum up the violations for arbitrary subnets in Log(N) time.

    My implementation fares rather excellently vs. the other LRU cache implementations benchmarked by the script in Hash::Ordered.
    Benchmark code:

    Results:
PerlMonks Discussions
Rapid access to posting by "self"
3 direct replies — Read more / Contribute
by jmClifford
on Jul 10, 2024 at 01:54

    Hi. As the title suggests, is it possible to access one own postings.

    Regard JC......

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2024-07-14 16:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.