http://www.perlmonks.org?node_id=161890
Lady_Aleena's user image
User since: Apr 25, 2002 at 08:28 UTC (17 years ago)
Last here: Aug 11, 2019 at 05:54 UTC (1 week ago)
Experience: 3426
Level: Curate (13)
Writeups: 390
Location:Woodsboro, MD
User's localtime: Aug 19, 2019 at 21:40 EDT
Scratchpad: View
For this user:Search nodes

I am Aleena, the Lady of the Gray, Saver of bytes, and the Lonely coder. White space is not my friend but a good ally. I will fight white space wherever I come across it in large amounts. A byte saved today can be used tomorrow in good cause. I am in a tower alone with nothing but silence surrounding me.

What I like about PerlMonks is the only expectation of me they have is I improve myself. To that end, PerlMonks go out of their way to give me the resources to do so. Also, I will more than likely be remembered most for the cookies I give out. :)

Over the years I have been here, most made me feel welcome here, but a few have made it plain my presence is very unwelcome. I hope to not push away those who have been friendly to me so far. I also hope that those who actively dislike me will soften their views after reading this, if they read it.

"I thought that once I get syntax OK, I would be out of the woods. That only makes the woods thicker when there is a problem." - by me

703rd Saint on 19 May 2017

Socialize with me

Goal

My programming goal is to completely rewrite my entire web site using Perl. This task is daunting as I have so many different ways I have to manipulate the data. I have gotten most of it figured out, though there are areas with which I am not quite happy.

The past

Coming from the world of markup languages into the world of programming languages was extremely daunting for me and still is upon occasion. Not knowing the right questions to ask, the correct terminology, or even what to put into searches made me feel very, very anxious. I am interested in what can be done in Perl. Until I get a grip on those areas where I am weak, would you please be extremely patient with me?

Annoyance caused me to state when my currant project was finished, you would never hear from me again. My feelings got hurt and my project was at a complete standstill when my temper got the best of me (which it does quite often when my feelings are hurt).

I had to see perl in a new light to get my project into motion again. When I wrote my first working module, I really got things going.

Coding history

A little less than a decade ago, I got 10 megabytes of complimentary web space from my internet service provider along with several e-mail addresses. Wanting to put my mark on the net, I created my first web page in Microsoft Word. Everything was going fine. My site got bigger and bigger, and Word even gave me frames. It was when I wanted to put some code on my site from somewhere else when the need to know how to write HTML caught up with me. No matter what I did in Word, the block would not go where I wanted it. I got the message, learn how to write a web page. Before that moment I did not care about the markup, I just wanted my pages to look pretty.

At first I found a site here and there which told me what all those things meant in between the < and >. With just the basics, I started to rewrite my site. I kept the frames and still did a lot wrong. I had depreciated tags everywhere. The amount of <font> tags was enough to make some throw their hands up in the air in exasperation. Not only did I have a lot of depreciated tags, I had tags unclosed. I just plain did not get it.

It took some very patient people talking me through my hysterics when something on my site did not work to finally get my site looking better and most areas working right. Then I ran out of space. I had filled my 10 megabytes rather quickly. Hysterics ensued. That is when someone casually mentioned CSS. When I saw what one line of CSS could do to cut my page size down, I nearly cried (or did I actually feel a tear?). Within weeks the size of my site was down by more than 75%. After that my whole coding philosophy became small is beautiful.

Let's pause for a moment. At the time the only browser on my computer was Internet Explorer. I was still a very lazy writer, so some of my HTML was browser specific. I was not writing for the masses, just those who were using IE. Then along came Firefox becoming the cause for a fresh bought of hysterics. I still have a few cross browser issues, but they are not critical.

The main issue causing my headaches was my frames looked bad in Firefox. So, I had to find another way of making my pages look and act the same without frames. Then I was introduced to <divs>s and in CSS scrolling. The problem with getting rid of the frames was I would have to put the same stuff on all of the pages, making them bigger. I did not want that. Then I was introduced to Server Side Includes. It was a miracle to me. I could put all kinds of stuff into one file and have it read by another. So slowly and up until six years ago, I had been altering all of my pages to have SSI.

I was talking to several people here on PerlMonks. When I told them that I was using SSI to add markup to my pages, I was told Perl could do the same thing. I was wondering, would Perl be smaller than SSI; and the answer is a resounding YES!

The present

I still have a lot of hurdles to overcome before I get anywhere near good at Perl. I have been told that I have come a long way from when I started here; yet with the amount that I have left to learn, it seems that I am still at the beginning. I am getting better at reading the perldocs and finding modules that may work for me. I have also developed a few peeves which may or may not stick with me as I learn more.

Have a cookie for making it this far into my node! I am impressed with your resilience! I tend to babble when given the chance. Have another if you intend to continue reading. :)

Objects

I have read and searched and read again about them, but they still do not make sense to me. I would need to see them in action with some code that I have already written to maybe get a grip on them. There are no promises on that score; ikegami, GrandFather, and others have tried to show me without it sinking in how they work. Because of my frustration with the topic, I am beginning to dislike almost everything to do with objects, even eschewing object oriented modules. I would rather write my own function then wrestle with an object to make it behave.

Update 1: I am giving them another try again. I hope this time that how to write them sinks in.

Update 2: They have confounded me again! I do not get it!

Update 3: I gave it yet another try, nothing. I still do not understand what is so wonderful about objects. So after Why won't a hash in a hash work as a hash reference to create an object?, RFC on how I'm doing when it comes to writing objects?, and How do I go from procedural to object oriented programming?; I give up. If one day my code morphs into objects on their own, I won't know it. To me objects are just a pain the a** especially since everyone tells me to separate my data out of them. Well, I can not do that. My data stays where it is with the subroutines that use it.

Over-complication

I have been told that I have a knack for this. There are times when reinventing the wheel is a good thing. For example, I was going to use DateTime to get the current week of the year when all I had to do was int($day_of_year / 7). Sure DateTime has something like that, but why go through all the trouble of setting it up, when something else much simpler is already around?

So called templates

I am sorry, but I can't see how any of these so called template modules really create a template that will fill in everything that I need them to fill in. HTML::Template appears to do only very basic stuff, but since I use so many conditionals and list iterations and loops, it won't work. Template Toolkit doesn't even look like perl, so I will stay as far away from that mess as possible. I don't need to get all mixed up right now. Printing the titles of my pages based on a slew of conditions seems beyond their capabilities, so how could I get them to print my site's menu and the right list of style sheets?

/*SQL*/ databases

Almost everyone I talk to here and elsewhere gets on my case about using a text based database system, with the directory structure being a part of it, over a SQL related database. I have tried to explain that I do not have access to either MySQL or SQLite on the server where my main site is, Xecu.net. When they tell me to move to somewhere that has either, I also try to explain that moving would mean a lot of trakking through the net trying to find everywhere I have a link to my site and changing the link. This is a lot of work.

I made attempts to check to see whether or not MySQL or SQLite was available to me on Xecu.net by trying to create a database at the command line. The results follow.

MySQL test...

/users/fantasy>mysql db_name ERROR 2002 (HY000): Can't connect to local MySQL server through socket + '/tmp/mysql.sock' (2)

SQLite test...

/users/fantasy>sqlite3 test.db sqlite3: Command not found.

The above tells me that they are not available, so I had to find an alternative, which I did in separated values files. I would have to have a database and the access and editing s‎crip‎ts for that database to test, but since I can't make a /*SQL*/ database, I can't play with the concept either.

The last problem with /*SQL*/ databases is that they are binary, meaning I would not be able to edit them in my text editor. If I can't get a decent front end up for my text based databases, I would be horribly disadvantaged with a binary one. I would have to keep all the text around somewhere to edit in my text editor just to stuff that text into the binary database. So, I will use what I have available to make databases.

I would like this to be the last time I have to defend my use of separated values. I try to stay away from the database topic as much as possible these days whenever it comes up.

Version control

There are two schools of thought for this one. A few seem to feel that I will crash and burn without it; while others say that since I am working alone, I don't need it. I have looked around and haven't found anything to my liking. There is the whole concept of storing all of the changes to my files that really is not appealing to me. There is also the lack of automation, where the changes are stored whenever I save in my favorite text editor. I spoke to a few of its developers who seemed interested but nothing came of it. Maybe once its integrated into my text editor and automatic, I will give version control a whirl.

Take a break

Wow! You read it all! The rest is just tools I use to write perl. Have a plate of cookies!

Toolbox

Coding Toolbox

Quote

"A man's knowledge is like an expanding sphere, the surface corresponding the boundary between the known and the unknown. As the sphere grows, so does its surface; the more a man learns, the more he realizes how much he does not know. Hence, the most ignorant man thinks he knows it all." - L. Sprague de Camp

Geek Code

GO d- s+:+ a C++ UL P+ L W++ N K- w M-- PS+ PE Y+ t+ 5++ X+ R+++ tv+ b +++ D- G e h- r++ x++

Last edited and updated: 2017-06-16


Posts by Lady_Aleena
Refactoring just to refactor? in Meditations
8 direct replies — Read more / Contribute
by Lady_Aleena
on Jun 27, 2019 at 20:25

    Hello everyone.

    I wrote the following subroutine recently using map and grep in the BLOCK LIST style. Line 4 had gotten long, so as you can see, I put the map, grep, and sort on separate lines. After doing that and seeing how good it looked, I began thinking about all the times I used map and grep in the EXPR, LIST format and that I may want to rewrite all of them.

    Most, if not all, other people I have chatted with over my years here use the BLOCK LIST format instead of the EXPR, LIST format. I stubbornly stuck with the EXPR, LIST format. Now I am not sure if I am thinking of refactoring to use the format is normally used or if this is refactoring just to refactor. So, I am on the fence on whether or not I should do it.

    What do you think?

    No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
    Lady Aleena
Special character not being captured in Seekers of Perl Wisdom
1 direct reply — Read more / Contribute
by Lady_Aleena
on Jun 17, 2019 at 15:06

    Hello everyone. I am having a problem with the character Ĉ in the string Ĉon Flux not being captured by the first_alpha subroutine below. A space character is being returned. This problem arose when I recently re-encoded my files from Windows-1252 to UTF-8. I am baffled. As always, I appreciate all the help I get.

    Even substr('Ĉon Flux', 0, 1) returns a space character.

    The weird thing that I found is that the string Ĉon Flux is returned when I ran the data from the file through my make_hash subroutine then ran that hash through my alpha_hash subroutine, both in the same module as first_alpha. (You can see the full module here.)

    The following is truncated output from alpha_hash.

    As I said earlier, any and all help is appreciated.

    No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie and a very nice day!
    Lady Aleena
Symbol lookup error for my ~/perl5/lib/perl5 in Seekers of Perl Wisdom
3 direct replies — Read more / Contribute
by Lady_Aleena
on Jun 05, 2019 at 15:12

    Hello. I am getting a symbol lookup error when trying to install a module to ~/perl5/lib or use that lib in apache2.

    When trying to install a module with cpan I get the following:

    /usr/bin/perl: symbol lookup error: /home/me/perl5/lib/perl5/x86_64-li +nux-gnu-thread-multi/auto/List/Util/Util.so: undefined symbol: Perl_x +s_apiversion_bootcheck

    When I used that directory in apache2, I get the following error in my error log:

    /usr/bin/perl: symbol lookup error: /home/me/perl5/lib/perl5/x86_64-li +nux-gnu-thread-multi/auto/List/Util/Util.so: undefined symbol: Perl_x +s_apiversion_bootcheck

    I don't know if it is just List::Util that has a problem or my entire ~/perl5/lib.

    This issue happened after I upgraded my Debian distribution from 8 (Jessie) to 9 (Stretch). perl -v returns the following:

    This is perl 5, version 24, subversion 1 (v5.24.1) built for x86_64-li +nux-gnu-thread-multi

    which perl returns:

    /usr/bin/perl

    I can not think of anything else I need to add that will help with figuring out this problem.

    All help is appreciated!

    This issue appears to be resolved. The suggestion of an Anonymous Monk to rename the dir and reinstall the modules seems to have worked. Thank you all for your patience.

    No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
    Lady Aleena
Anyone working on a cbstream replacement? in Perl Monks Discussion
1 direct reply — Read more / Contribute
by Lady_Aleena
on May 12, 2019 at 00:31

    I know I haven't been around for a while, but I was very upset when I found that cbstream wasn't working anymore. I was wondering if there is a new cbstream yet, and if so, which IRC channel is it on? I really miss being able to have multi-day conversations with people in the Chatterbox, but without cbstream or something like it, those are no longer possible. The only options that are currently listed have very short time ranges, an hour or less. It used to be that I was able to have conversations for days. So, what if anything, has replaced cbstream? (Please gods let there be a replacement.)

    No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
    Lady Aleena
How to get 0 to initialize a value in Seekers of Perl Wisdom
4 direct replies — Read more / Contribute
by Lady_Aleena
on Apr 29, 2019 at 20:27

    I haven't written perl in a while, so I've forgotten how to tell perl that 0 is valid to initialize a value.

    The warning Use of uninitialized value is bugging me a lot. I don't like having any warnings.

    I have a list of characters who have appeared in one or more books. There is one character whose first book notation is the number 0. The split on line 10 is said to be uninitialized. On line 12, $first_book in the $first_type is also uninitialized. On line 13, the removal of the non-digit characters in the $first_book, also says $first_book is an uninitialized value. That value is in fact initialized. Because the first book can contain alphabetical characters, I can't simply add a +0 to it.

    Any suggestions on how to tell perl that 0 initializes the string?

    I did not come up with this notation system, but I can't think of anything to replace it that won't make the data too long. I feel silly asking this, but I can't think of anything right now. Also, if you know who Bink is or recognize the titles of the novels and want to ask me what I am doing; please use PMs. Thanks! 8)

    No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
    Lady Aleena
FullPage Chat no longer refreshing in Perl Monks Discussion
2 direct replies — Read more / Contribute
by Lady_Aleena
on Mar 12, 2018 at 18:52

    FullPage Chat is no longer refreshing for me in my Debian Jessie Firefox-esr 52.5.2. I'm still trying to find the problem, but it is slow going. Maybe you all can give me some ideas of where to look to fix this?

    Thanks!

    No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
    Lady Aleena
System vs. User module version of List::Util in Seekers of Perl Wisdom
5 direct replies — Read more / Contribute
by Lady_Aleena
on Jun 17, 2017 at 21:12

    Hello. List::Util is a core module, but the system version has not been updated since 1.27. So I installed it in my user directory, and it is version 1.47. However, I am getting an error that uniq is not exported by List::Util. According to the docs, List::Util has had uniq since version 1.45. So, what do I do to get the system to look at the user installed List::Util instead of the system installed List::Util? Is there precedence in @INC? Do I have to beg the system administrators to update their List::Util?

    I went to the command line and read the perldoc for List::Util, and perldoc brought up the docs for 1.47 not 1.27. I am confused by that a bit.

    Here is my @INC from the command line, and it has my user directories first, so that makes this even more confusing.

    Here is my @INC from the browser, and it has my user directories first, so that makes this so much more confusing.

    Any and all help is appreciated.

    No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
    Lady Aleena
Can Text::CSV_XS return key-value pairs? in Seekers of Perl Wisdom
2 direct replies — Read more / Contribute
by Lady_Aleena
on Jun 11, 2017 at 07:17

    Hello. I'm currently rewriting one of my more loathed subs with Text::CSV_XS. I was wondering if there were a way to write it so that it returns key-value pairs instead of an array or hash of hashes when there are only two fields in the file.

    My code so far...

    The file...

    So what I want from this file is the first field to be the keys and the second field to be an array ref. Here is an example of what I want.

    Is it possible with Text::CSV_XS?

    No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
    Lady Aleena
Is what you want available? in Meditations
6 direct replies — Read more / Contribute
by Lady_Aleena
on Jun 08, 2017 at 18:07

    As some of you may know, I am trying to become a better Perl writer. Part of it is finding where I wrote something that can be done better by someone else and using the better way.

    One time I needed to do a numeric comparison of months written as text. So I wrote a module to get the month numbers needed. After I wrote it, I found to my dismay, I had not needed to write it. Date::Calc had a subroutine called Decode_Month that was much better than what I wrote. I am so embarrassed I did not think to look in Date::Calc first before I wrote my silly little module. Date::Calc is far better at date manipulation than anything I could write. So, I dropped the use of my module for Date::Calc. It was a learning experience I took forward to the rest of my code.

    Another part of becoming better is rewriting and renaming the modules I have written. To find names for my modules, I have been crawling CPAN to find what name spaces already exist.

    I was looking for a new name for my Util::Number module. I crawled CPAN and found "Number" is a top name space. Then I found Number::Format. I sighed thinking my little Util::Number's days were numbered. Number::Format has a subroutine called round and so did Util::Number. Both do the same thing. Number::Format has a subroutine called format_number that puts commas in numbers and rounds numbers together, just like commify and my pretty_number. I thought commify and pretty_number were not going to be able to match format_number's power.

    So, I installed Number::Format and was going to discontinue using my Util::Number. Why? Using Number::Format in code that I need help with, you can install it from CPAN without any trouble. Using Util::Number in code that I need help with, you would have to guess at what it does unless I also put Util::Number in the node with my problem code.

    So, I was changing over my code from pretty_number to format_number and making sure it returned what I wanted. Then I got a big surprise. format_number has limitations commify and pretty_number do not have. format_number can not put commas into very big numbers. It outputs an error about the big number and suggests using Math::BigFloat.

    format_number

    perl -e 'use Number::Format qw(format_number); print format_number(123 +45678987654321)."\n";'

    returns...

    round() overflow. Try smaller precision or use Math::BigFloat at -e li +ne 1.

    commify

    perl -e 'use Util::Number qw(commify); print commify(12345678987654321 +)."\n";'

    returns...

    12,345,678,987,654,321

    In the change over from commify and pretty_number to format_number, I got another surprise. format_number does not do ordinal numbers either. I fed it an ordianal number in Happy unbirthday redux! and other birthday stuff, and it returned the following error.

    Argument "16725th" isn't numeric in numeric comparison (<=>) at /home/ +me/perl5/lib/perl5/Number/Format.pm line 599.

    So, I went back to commify in my code and got...

    Happy 16,725th unbirthday, Aleena! You have 32 days until your next bi +rthday on July 10, 2017.

    This was all so surprising to me. Here I was ready to use a module readily available on CPAN instead of my own silly little module, but the CPAN module could not do what mine does. I was thinking "But it's is so much better than mine. It's got all those bells and whistles. And it's on CPAN!"

    This is not a rant against Number::Format. It is on CPAN and is better written than my little Util::Number. I will use Number::Format in code when I need help. Number::Format also has options I do not currently have, so I will be using it whenever one of those options is needed. Util::Number may become a fallback module when Number::Format will not work for what I am doing currently. Util::Number will not be going to CPAN since I did not write commify or round, I just put them together in pretty_number.

    Util::Number

    I am trying to make my modules more useful with better names and code. I am also trying to get better by using what is already available. However, sometimes, what is available is a little less than what is wanted. That does not mean I will stop searching.

    Afterward...

    I cracked opened my now disused month module just to look at it. Then I saw the hash of arrays. What do I do with hashes of arrays of similar data? I randomize it of course. So my Util::MonthNumber is now Random::Month... 8)

    Random::Month

    No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
    Lady Aleena
Text::CSV_XS function does not accept headers and key together in Seekers of Perl Wisdom
1 direct reply — Read more / Contribute
by Lady_Aleena
on Jun 07, 2017 at 05:03

    Hello. In my effort to improve my perl writing, I was going to take some of my own advice and stop trying to find reasons to not use something. With that in mind, I finally decided to look into Text_CSV_XS to replace my hand rolled flat file processor. I gravitated right to the function csv in the module as it looked easier to use. However, I came upon a problem. In the POD it says that when key is set, headers is set to auto, so the headers I set would not work.

    So, other than going through every flat file I have and adding the headers, can anyone think of a way to work around? I have so very many flat files and could possibly miss a few, so adding headers in now would be problematic.

    What I want is a hash of hashes with the first item on each line to be the key to the hash along with being a named value in the hash.

    Is there maybe someone who would hold my hand as I try to work through the method in Text::CSV_XS?

    My data

    Crystal Skull|Stargate SG-1, Crystal Skull;The Librarian: Return to Ki +ng Soloman's Mines;Indiana Jones and the Kingdom of the Crystal Skull Spear of Destiny|The Librarian: Quest for the Spear;Hellboy;Constantin +e Book or Key of Soloman|The Librarian: Return to King Soloman's Mines;S +eason of the Witch Necronomicon|H.P. Lovecraft

    My code

    #!/usr/bin/perl use strict; use warnings; use Text::CSV_XS qw(csv); my $file = '/home/me/Documents/www/files/data/Miscellany/Magic_items.t +xt'; open(my $fh, '<', $file) || die "Can't open $file $!"; my $list = csv ( in => $file, sep_char => '|', headers => ['item', 'seen in'], key => ['item'], ); use Data::Dumper; print Dumper $list;

    My result

    Use of uninitialized value in anonymous hash ({}) at /home/me/perl5/li +b/perl5/x86_64-linux-gnu-thread-multi/Text/CSV_XS.pm line 1223, <$fh> + line 4. Use of uninitialized value in anonymous hash ({}) at /home/me/perl5/li +b/perl5/x86_64-linux-gnu-thread-multi/Text/CSV_XS.pm line 1223, <$fh> + line 4. Use of uninitialized value in anonymous hash ({}) at /home/me/perl5/li +b/perl5/x86_64-linux-gnu-thread-multi/Text/CSV_XS.pm line 1223, <$fh> + line 4. Use of uninitialized value in anonymous hash ({}) at /home/me/perl5/li +b/perl5/x86_64-linux-gnu-thread-multi/Text/CSV_XS.pm line 1223, <$fh> + line 4. $VAR1 = { '' => { 'seen in' => 'H.P. Lovecraft', 'item' => 'Necronomicon' } };

    Update: This is as far as I have gotten with the method version.

    $csv = Text::CSV_XS->new ({ sep_char => '|', quote_char => undef, blank_is_undef => 1, empty_is_undef => 1, allow_whitespace => 1, });
    No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
    Lady Aleena