Lady_Aleena's user image
User since: Apr 25, 2002 at 08:28 UTC
Last here: May 26, 2017 at 04:24 UTC (2 seconds ago)
Experience: 3009
Level: Curate (13)
Writeups: 341
Location:Woodsboro, MD
User's localtime: May 26, 2017 at 00:24 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

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. I wrote the following function because Text::CSV with its objects drove me wild.

# written with rindolf in #perlcafe on freenode; golfed with the help +of [GrandFather] of PerlMonks. # further help from [GotToBTru] (solved the 0 problem) sub get_hash { my %opt = @_; my $file = $opt{'file'} && ref($opt{'file'}) eq 'ARRAY' ? data_file( +@{$opt{'file'}}) : $opt{'file'}; open(my $fh, '<', $file) or die("can't open $file $!"); my %hash; while (my $line = <$fh>) { chomp $line; die "This file is not for Base::Data! Stopped" if $line =~ /no Bas +e::Data/i; my @headings = $opt{'headings'} ? @{$opt{'headings'}} : ('heading' +); my @values = split(/\|/,$line); my $key = scalar @headings > 1 ? $values[0] : shift @values; my $n = 0; for my $r_heading (@headings) { goto INC if (!defined($values[$n]) || length($values[$n]) == 0); my $split = $r_heading =~ /\+$/ ? 1 : 0; (my $heading = $r_heading) =~ s/\+$//; my $value = defined($values[$n]) ? $split == 1 ? [map { $_ =~ s/ +^ //; $_ } split(/;/,$values[$n])] : $values[$n] : undef; if (scalar @headings > 1) { $hash{$key}{$heading} = $value; } else { $hash{$key} = $value; } INC: ++$n; } } return \%hash; }
[download]

get_hash is so much easier for me to use than the alternatives offered on cpan, mostly because they are not written to do what I need them to do easily.

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 which 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 I can't move because I would lose 3 out of 6 of my reciprocated links. (I don't have many people whose interests coincide with mine, so those few who agreed to reciprocate are appreciated.)

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)
[download]

SQLite test...

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

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++
[download]

Last edited and updated: 2015-05-12


Posts by Lady_Aleena
Can figure out a way to get File::Grep's fgrep to chomp matches in Seekers of Perl Wisdom
3 direct replies — Read more / Contribute
by Lady_Aleena
on May 13, 2017 at 19:36

    Hello. I've been stuck for over an hour now. I can't figure out how to get File::Grep's fgrep to return chomped values in its matches. I've tried chomping $file, chomping $_ in the fgrep, and more. Am I using it wrong, not understand something in the module description, or just plain out of luck and have to munge the values of matches later?

    #!/usr/bin/perl use strict; use warnings; use File::Grep qw(fgrep); use Data::Dumper; my @line = fgrep { /^[2-6] .+$/ } *DATA; print Dumper(\@line); __DATA__ 2 foo 3 bar 4 baz 5 qux 6 quux 7 thingy 8 widget

    The output is

    $VAR1 = [ { 'filename' => *::DATA, 'count' => 5, 'matches' => { '1' => '2 foo ', '2' => '3 bar ', '3' => '4 baz ', '4' => '5 qux ', '5' => '6 quux ' } } ];

    I'm at the end of my abilities.

    No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
    Lady Aleena
Confession of a hard headed Monk in Meditations
2 direct replies — Read more / Contribute
by Lady_Aleena
on May 05, 2017 at 23:43

    Over the last few days, I've been doing a project that is forcing me take a new harder look at everything I've written: code and markup. One of the items which came up in my audit was a little subroutine which takes a number (usually scalar(@list)) and returns how many columns the list would be in according to exponential calculations. The default behavior of this subroutine is to return a word number not an integer. When I looked at it again, a voice in the back of my head told me the subroutine should return the integer by default because integers are more useful. I also had the sinking feeling someone here probably pointed that out to me, and I ignored it. I wanted what I wanted, and no one was going to make me change my mind at the time. I had to change my own mind and pay the price for it later.

    So, this is my confession. I am a doofus. I am hard headed and obstinate when it comes to attaining my short term goals. I crawled into my shell to avoid any good advice about coding for the future.

    So here is my old sub...

    use Lingua::EN::Inflect qw(NUMWORDS); sub get_columns { my ($max_cols, $amount, $number) = @_; if ($amount <= $max_cols ** 2) { for my $num (1..$max_cols) { if ($amount >= $num ** 2 && $amount < ($num + 1) ** 2) { return $number && $number =~ /^[yt1]/ ? $num : NUMWORDS($num); } } } else { return $number && $number =~ /^[yt1]/ ? $max_cols : NUMWORDS($max_ +cols); } }

    And the new more useful sub...

    use Lingua::EN::Inflect qw(NUMWORDS); sub get_columns { my ($max_cols, $amount, $word) = @_; if ($amount <= $max_cols ** 2) { for my $num (1..$max_cols) { if ($amount >= $num ** 2 && $amount < ($num + 1) ** 2) { return $word && $word =~ /^[yt1]/ ? NUMWORDS($num) : $num; ############################################# Delete to + get rid of Lingua::EN::Inflect } } } else { return $word && $word =~ /^[yt1]/ ? $NUMWORDS($max_cols) : $max_co +ls; ################################################### Delete +to get rid of Lingua::EN::Inflect } }

    I feel bad for only now realizing returning a integer by default would be more useful than returning a number word. I think I spoke aloud when I called myself a doofus for returning a number word by default.

    I've been doing a lot of rethinks lately. Some of my "utility" scripts seem useless in a broader sense.

    The great advice I got from Monks long ago is finally settling into my head. I hope I am better with future advice, but that is to be seen.

    No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
    Lady Aleena
Opening files to write in browser returns Permission denied in Seekers of Perl Wisdom
9 direct replies — Read more / Contribute
by Lady_Aleena
on May 02, 2017 at 18:14

    Hello. I just recently noticed when I try to open a file for writing in a script running in my browser, permission denied is returned. So, is there a way to programatically tell my script running in my browser it is okay to write to that file? Also, how do I do it?

    I've looked at open and nothing popped up at me say this is where permissions are granted. Even File::Slurp's write_file returned permission denied. I think this is weird because I can open files to be read in the browser without any issues with either open or File::Slurp's read_file.

    In the mean time, I have set both files' permissions to 666.

    Note: Please tell newbies to die to always include the $! at the end. If I had $! at the end of my die message, it would have cut at least 15 minutes of me traversing directories thinking the file did not exist. I felt like a doofus.

    Edit per hippo: My OS is Debian jessie.

    Update: Running the same script from my web host does not require me to set the permissions to 666. It writes to the file while it is 644.

    No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
    Lady Aleena
The Cookies account in Perl Monks Discussion
4 direct replies — Read more / Contribute
by Lady_Aleena
on Apr 26, 2017 at 04:47

    A little over four years ago, I created the Cookies account for fun. I was known for my chatterbox antics with cookies; so on April Fools 2013, I decided to have some fun. Two years ago I went in for surgery, which is scary. I was thinking something could happen, and Cookies would be left without someone to maintain the account.

    Some users still play with the buttons from time to time. I would not want the account to die just because I did. So, if anything happened to me, would there be someone who would be willing to take over this very silly account?

    P.S. I am always willing to add more flavors and options to the account. Just let me know.

    P.P.S. This thread can be for anything related to the Cookies account that might merit general discussion, too. 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, the Cookie Lady
Happy unbirthday redux! and other birthday stuff in Cool Uses for Perl
1 direct reply — Read more / Contribute
by Lady_Aleena
on Apr 15, 2017 at 01:34

    Hello everyone! About five and a half years ago, I posted Happy unbirthday!. When I saw my fifteenth PerlMonks anniversary, I decided to write something new. However, I began to notice the new code I was writing had similar aspects to the old code I wrote for Unbirthdays, specifically the date verification subroutines I was was writing. So, I opened up Unbirthdays and took a second look. So here is the updated Unbirthdays and the new Birthday scripts.

    Date::Verify

    Date::Verify verifies in input and returns the appropriate value.

    • four_digit_year verifies the user input a four digit year. Usage: four_digit_year($year)
    • month_name verifies the mount input is correct (such as inputting 13 as a month or the too short Ju). It returns a fully spelled out month name. Usage: month_name($month)
    • month_number verifies the same as month_name, but it returns a month number instead. Usage: month_number($month)
    • day_number verifies the day is a number and that the day exists within the month of the year. It returns the day number. Usage: day_number($year, $month, $day)

    I am thinking on localizing this to the various countries available on Date::Calc.

    unbirthdays.pl

    I have made several changes to unbirthdays.

    • First, I got rid of the Q&A. That became annoying to me while testing the changes I made to the script. To that end, I moved the input to the command line as @ARGV.
    • Second, the Q&A was written to recurse until the input was in the correct form, however, the script now dies if the input is not in the correct form.
    • Third, I fixed several things from the former unbirthdays thread.

    Usage is: unbirthdays.pl name month day year. However, if unbirthdays.pl help is used, a helpful message appears.

    birthday.pl

    I was writing birthday.pl when I realized I was writing similar code as was in unbirthdays.pl. This script will tell the user their tropical zodiace sign, their birth stone and flowers (flowers for the US and UK are listed), and birth day stone (based on day of the week the user was born).

    This is a silly little script, but it helped me fix the previous one.

    Usage is: birthday.pl name month day year. However, if birthday.pl help is used, a helpful message appears.

    In closing

    I know these scripts probably still need work. I just hope you find them fun, or at least interesting.

    No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
    Lady Aleena
My local libs are not being used by my browser in Seekers of Perl Wisdom
3 direct replies — Read more / Contribute
by Lady_Aleena
on Sep 28, 2016 at 19:50

    Hello all. I am having a problem with my browser not recognizing my local libs. I set them up because I was told installing modules with sudo cpan and putting them in the main libs was not great. So I set up my local libs and installed all kinds of modules into them, got apache set up so I could view my website in my browser, but the browser does not use my local libs.

    Here is the result of perl -e 'print "$_\n" for sort @INC' on the command line:

    . /etc/perl /home/me/Documents/fantasy/files/lib /home/me/perl5/lib/perl5 /home/me/perl5/lib/perl5/5.20.0 /home/me/perl5/lib/perl5/5.20.2 /home/me/perl5/lib/perl5/5.20.2/x86_64-linux-gnu-thread-multi /home/me/perl5/lib/perl5/x86_64-linux-gnu-thread-multi /usr/lib/x86_64-linux-gnu/perl/5.20 /usr/lib/x86_64-linux-gnu/perl5/5.20 /usr/local/lib/site_perl /usr/local/lib/x86_64-linux-gnu/perl/5.20.2 /usr/local/share/perl/5.20.2 /usr/share/perl/5.20 /usr/share/perl5

    Here is the list of libs my browser is looking in:

    files/lib /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.20.2 /usr/local/share/perl/5.20.2 /usr/lib/x86_64-linux-gnu/perl5/5.20 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.20 /usr/share/perl/5.20 /usr/local/lib/site_perl

    I ran echo 'eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"' >>~/.bashrc at the command line, and it added the following lines to my .bashrc file:

    PATH="/home/me/perl5/bin${PATH:+:${PATH}}"; export PATH; PERL5LIB="/home/me/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export P +ERL5LIB; PERL_LOCAL_LIB_ROOT="/home/me/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCA +L_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT; PERL_MB_OPT="--install_base \"/home/me/perl5\""; export PERL_MB_OPT; PERL_MM_OPT="INSTALL_BASE=/home/me/perl5"; export PERL_MM_OPT; eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"

    I already have several PATH statements above these lines and a PERL5LIB line, so I do not know if there is a conflict. Here are the lines:

    # My changes to things # export LC_ALL=C export LC_COLLATE=C export LESS=-SXi export PERL5LIB="$HOME/Documents/fantasy/files/lib" PATH="$PATH:$HOME/bin" PATH="$PATH:$HOME/Documents/fantasy" PATH="$PATH:$HOME/Documents/scripts" export PATH setterm --linewrap off

    So can anyone tell me what I am missing here?

    Thank you!

    No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
    Lady Aleena
Getting numeric month for comparisons in Cool Uses for Perl
4 direct replies — Read more / Contribute
by Lady_Aleena
on Mar 05, 2016 at 07:47

    I wrote this little script to get numeric months for comparisons. The input can be in initial uppercase, all uppercase, and all lowercase. I added a few other languages for fun.

    #!/usr/bin/perl use strict; use warnings; my @month_numbers = (1..12); my %month_names = ( 'English' => [qw(January February March April May June July Aug +ust Spetember October November December)], 'English abbr' => [qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Now De +c)], 'Dutch' => [qw(januari februari maart april mei juni juli aug +ustus september oktober november december)], 'French' => [qw(janvier février mars avril mai juin juillet ao +űt septembre octobre novembre décembre)], 'German' => [qw(Januar Februar März April Mai Juni Juli August + September Oktober November Dezember)], 'Greek' => [qw(Ianuários Fevruários Mártios Aprílios Máios Iú +nios Iúlios Avghustos Septémvrios Októvrios Noémvrios Thekémvrios)], 'Italian' => [qw(gennaio febbraio marzo aprile maggio giugno lu +glio agosto settembre ottobre novembre dicembre)], 'Spanish' => [qw(enero febrero marzo abril mayo junio julio ago +sto septiembre octubre noviembre diciembre)], ); my %months; for my $language (keys %month_names) { @months{@{$month_names{$language}}} = @month_numbers; @months{map(uc $_, @{$month_names{$language}})} = @month_numbers; @months{map(lc $_, @{$month_names{$language}})} = @month_numbers; } sub get_month_number { my $month = shift; return $months{$month}; }

    So, if you want the month number for July, you use it like the following.

    print get_month_number('July');

    The above will return 7.

    Now you can put dates in the right order. I'll be modularizing this shortly. 8)

    Updates

    Code simplified from morgon's (no @month_numbers array) and poj's (case insensitive input) suggestions.

    my %months; for my $language (keys %month_names) { my $number = 0; $months{lc $_} = ++$number for @{$month_names{$language}}; } sub get_month_number { my $month = lc shift; return $months{$month}; }

    Added aprile to Italian list of months from AnomalousMonk.

    No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
    Lady Aleena
RFC: Playing with glob in Seekers of Perl Wisdom
3 direct replies — Read more / Contribute
by Lady_Aleena
on Sep 15, 2015 at 15:25

    Several weeks ago I was playing around with glob's ability to create lists from stringified lists. (The forth paragraph in the doc.) I at first wanted to see if I could feed it arrays directly, but I was shown by jeffa the lists had to be comma separated strings. After playing around with it for a few minutes, I thought about finding a way use arrays, so wrote the following.

    Note: I do not like the name of the subroutine, so I am open to suggestions.

    sub glob_array { my (%opt) = @_; my $joiner = $opt{'joiner'} ? $opt{'joiner'} eq ' ' ? "' '" : $opt{ +'joiner'} : ''; my $space = $opt{'space holder'} ? $opt{'space holder'} : '_'; # The arrays have to be strinified into comma separated lists. Thank + you to jeffa for showing me. my $arrays = [map { $_ = '{'.join( ',', @{$_} ).'}'; $_ =~ s/ /$spac +e/g; $_; } @{$opt{'arrays'}}]; my $string = join( $joiner, @$arrays ); my @raw_array = glob "$string"; my @array = map { $_ =~ s/$space/ /g; $_; } @raw_array; return \@array; }
    • The joiner is the character you wish to use to join the values of the arrays together. (If the joiner is a space, it has to be quoted, hence the complicated line of code for it.)
    • The space holder converts the spaces in the values into the character of your choice. Spaces in the array values will muck up your output. (Sorry I can't explain that better.)
    • The arrays are the list of array (refs) you want to use to make the list.

    Here are some sample arrays and how they would look once glob has done its work.

    my @colors = qw(red green blue); my @directions = qw(north south east west); my @numbers = (1..3); my $array = glob_array( 'arrays' => [\@colors, \@directions, \@numbers +], 'joiner' => ' ', 'space holder' => '__' );

    Output

    $VAR1 = [ 'red north 1', 'red north 2', 'red north 3', 'red south 1', 'red south 2', 'red south 3', 'red east 1', 'red east 2', 'red east 3', 'red west 1', 'red west 2', 'red west 3', 'green north 1', 'green north 2', 'green north 3', 'green south 1', 'green south 2', 'green south 3', 'green east 1', 'green east 2', 'green east 3', 'green west 1', 'green west 2', 'green west 3', 'blue north 1', 'blue north 2', 'blue north 3', 'blue south 1', 'blue south 2', 'blue south 3', 'blue east 1', 'blue east 2', 'blue east 3', 'blue west 1', 'blue west 2', 'blue west 3' ];

    I have yet to figure out how to make this more interesting by including a pattern or a single joiner. From the above output, instead of plain green west 2 having green sector west tower 2nd floor or something akin to it. I could pre-munge the lists, but adding the ability to use a pattern would be nice too.

    So, I would like a new name for the subroutine and maybe some pointers on how to add in a pattern to this. Also, maybe a few good reasons to use this I may not be seeing other than making a list to use for random selection.

    No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
    Lady Aleena
Never say never in Meditations
2 direct replies — Read more / Contribute
by Lady_Aleena
on May 05, 2015 at 23:37

    A thud can be heard throughout the monastery as Lady Aleena's head hits her desk in the scriptorium. Shortly thereafter the sound of breaking glass filters through the monastery's halls as her preconceptions are shattered.

    Never say you will never do a thing because, one day, you will do the thing then feel foolish.

    Now here is some history and what happened tonight. I said I would never use pipes in my data fields. Tonight I did. Now I am feeling more than foolish. (And I've made more work for myself while trying to make less work for myself.) I just learned my lesson.

    If you feel you are about to say "I will never...", stop, think very hard, count to ten, whatever. Just do not say it! One day you will be writing a piece of code, humming a little tune stuck in your head, then you will crash into a wall because you did not take into consideration the exception you just wrote.

    Have a nice day!

    I started this thought in the CB and continued it here.

    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 do I go from procedural to object oriented programming? in Seekers of Perl Wisdom
12 direct replies — Read more / Contribute
by Lady_Aleena
on Apr 20, 2015 at 16:43

    (Jenda corrected me on what my subroutines are. They are procedures not functions. The title of this node and where ever the word, or any derivatives of, function has been changed to procedure.)

    Going from procedural programming to object oriented programming has been on my mind a lot lately. I have been told by a couple of people my code is very close to being OO, however when I gave OO a try the first time, I was told I was doing it all wrong. I would like to see how close I am, but I am having a hard time learning objects because the tutorials I have found start writing code right away. I have yet to find a tutorial which starts with the objective of the objects being written. For example I want...

    Criminal Minds is a 2005 television series which is still running.

    Iron Man is a 2008 film based on comics by Marvel Comics.

    The tutorials also do not show the data being munged up front like...

    They all start right in on the objects, leaving me completely in the dark about what the end goal for the objects is. From above you know my objective and have the data to reference while reading the procedures I wrote to get to my objective. The whole module is here if you would like to see the bigger picture.

    Now putting it all together to get my objective.

    I would like to know how close I am to having objects, what they would look like if I am close, and if there is anything which does not fit into OO. Is there anywhere I need to change my thinking (which will be hard since I have been doing things as above for a long while now)?

    If any of the OO tutorials were written with the objective, data, code, and wrap-up in that order; I might get them.

    Another reason I am doing this is to get my mind off of my pain and impending surgery. I am doing everything I can think of to get my mind off of them and stave off panic. Would you please help me?

    I hope I am not asking too much. Please sit back and enjoy a cookie.

    No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
    Lady Aleena