Hey guys,
It's been a long and unwelcomed departure from the perl fold. Unfortunately, I had to take a break from Randal and Tom's _wonderful_ book to do some work mandated after work study. Wonder why no kid says "hey! I wanna be an IT guy when I grow up!"
Oh well, poor me. :) At least I have a job. But I have a passion for learning perl at this point. Took me a while to re-read through all the material a second time up to the point I left off ...chapter 13... and made sure I still understood all the exercises I did before and even tried re-writing most from scratch. I actually feel the second pass has helped me to get the material a bit deeper into my nueral pathways. After my work assignment was done I even took my dilapedated Llama copy with me onto a cruise ship to the Bahamas and did some perl whilst imbibing Bahama Mamas. Heaven! :D
But right at this point my brain seems like a frozen lump of clay and I was hoping for some help! For some godforesaken reason I seem to have forgotten how to do a simple pattern match!
Exercise 4 in chapter 13 of Llama asks the student to replicate the unix 'ln' function. The question implies that the File::Basename function can come in handy here, but I am going to try attacking that angle after I've had a good night's sleep. In the meantime, I simply can't for the _LIFFE_ of me figure out why the following code breaks at compile time!
=====================================
#!/usr/bin/perl
use strict;
use warnings;
my @list;
print "\nPlease enter the name of the file you would like to rename :
+";
chomp (my $name = <STDIN>);
print "\nPlease enter the name/location you would like the file change
+d to: ";
chomp (my $final = <STDIN>);
print "\nThe name you entered is $name and the output desired is $fina
+l.";
if ($final =~ /(\-s*)/) {
symlink $name, $final or die "\nCouldn't create symlink!";
@list = glob "$name, $final";
} else {
link $name, $final or die "\nCouldn't create link!";
@list = glob "$name, $final";
}
foreach (@list) {
print "\nYou've succesfullly linked or symlinked $_ to";
}
print "\nYou're Done\n\n";
=======================================
The error message I get back reads thus:
syntax error at ./ex4-13 line 14, near "$final ~"
BEGIN not safe after errors--compilation aborted at ./ex4-13 line 16.
Once the light dawns on this one I will be able to un-lumpify my brain. And monkish un-lumpification will be appreciated.
Much Thanks to the Monkery!
As a side note, I've moved up in the world. Before I would only do perl under vi on init level 3 to be "hardcore" about my Unix use. These days? OS X and BBEdit, baby! Oohhh yeah! BALANCE them braces! I find I have a taste for luxury after that cruise and my hard fought for new Apple laptop!