« September 2005 | Main | November 2005 »
October 31, 2005
PHP upgrade - traps to watch
Did you want a Perl or Python course that starts on a Sunday? Or to book an old course that starts way back on 31st December 1969?
Our new online booking system's been under test on our in-house server for a while, but it was this weekend it went live together with most of the rest of the site. Yes, we've tested code and tested it again, but there are always things (such as IP address recognition) that can only be emulated in testing and I expected (and still expect) a few funnies.
Tips / traps to watch ... "there, but for the grace of God, go I" you may say:
1. Don't have a variable in your $_SESSION array that's got the same name as a local variable. Configuration issue ... worked fine in house and caused problems at the ISP! Solution once I identified the problem, was as easy as renaming a local variable
2. If your server is in a different timezone to your test machine ... beware. That's what happened with all those course that, for a few minutes, were offered to start a day earlier. You see ... when it's 07:00 this morning in the UK, it's 11 p.m. last night in California!
Remember also ... all the standard PHP traps about register_globals, conflicting session names with other applications, and magic quotes. Yes, didn't fall for those ... just the slightly more obscure traps listed above.
Posted by gje at 07:52 AM
Related topics: via article database
More about Graham Ellis of Well House Consultants
Useful link: PHP training
October 30, 2005
New look to website
If you look at our main website, you'll see the seeds of a long weekend's work planted there - a new look to the main website at http://www.wellho.net. With the "Of Course" newsletter posted out on Friday, hitting desks on Monday, we should be in for a busy week!
Right. This is important. If you spot anything grossly broken on the new website, please EMAIL ME - - I'm even providing this link - as it's vital we catch things quickly; there's a limit to how much testing can be done, and time to find thins. YOU are our eyes and ears ... and thank you ....
Posted by gje at 10:19 PM
Related topics: via article database
October 28, 2005
New servlet from old
Check list - how to modify a Servlet and install it under a new name on your Tomcat server. This scheme assumes that you're working at a machine that has Java installed, but doesn't have its own copy of Tomcat and all the extras (why would it - it's your development machine and not the server!)
1. Get hold of the source code you need to modify
2. Get servlet-api.jar
3. export CLASSPATH=.:servlet-api.jar
4. make source code changes
5. Compile the modified source
6. Upload the class file to the webapps/xxxx/WEB-INF/classes directory
7. Add a servlet mapping to the web.xml file in WEB-INF
8. Stop and restart the webapp via the Tomcat manager
Posted by gje at 10:44 AM
Related topics: via article database
October 26, 2005
Watch what you wear
I stopped wearing a wristwatch years ago ... carrying heavy Sun workstations in and out of conference rooms, I used to get the strap entangled with the door handles and nearly had some nasty accidents ... and I feel a great freedom in having clean arms, clear wrists. When in formal wear, I'll use a pocket watch that looks very Victorian, pulling it out of my pocket and clicking open the silver(ed) cover to tell the time. At work, I've simply got a clock at the top right of this screen.
I received an email this morning that told me "No matter if you believe it or not, your wristwear has everything to do with your success. ". Hmm. But, yes, I can believe it; you know my get-up-and-go approach and my positive views. They seem to be shared by only a small proportion of people, and perhaps the one who shares them closest is Lisa. She doesn't wear a wristwatch either.
Posted by gje at 06:18 PM
Related topics: via article database
October 25, 2005
Class, static and unbound variables
In Object Oriented programming, you'll have certain named blocks of code (usually known as methods) that you can perform on specific objects (type A), and others that you can perform on all the objects of a particular type (type B).
Example.
If I had a class called sandwich, I might have one method called getFilling and another called getBread which return me information as to whether a particular sandwich is Beef or Cheese, and whether it's on brown or white bread. These methods are both Type A as their actions will vary depending on which sandwich they're run.
However, if I have a method called getCount that returns me a total of the number of sandwiches I have, then it's going to return me the same value whether I call it on my "Beef and Stilton on White", or on a Plain cheese sandwich in brown bread. So that's an example of a Type B.
Type B methods are sometimes known as Class methods since they apply to the class as a whole. You'll also find that Java programmers refer to them as static methods, and Python fans call them unbound methods since they're not attached (bound) to any particular single instance of an object.
Type B methods, then, may be known as Object methods as they apply to an individual object, dynamic methods as they change in behaviour depending on which particular object they're called on, or bound methods because their behaviour is bound to a certain object.
Posted by gje at 02:47 PM
Related topics: via article database
May I be politically incorrect?
"You can fix the unix permissions on a file for a woman, and she'll be happy for an hour. You can teach a woman to fix the unix permissions on a file, and she'll be happy forever".
Posted by gje at 01:41 AM
Related topics: via article database
October 24, 2005
Where to stay in and near Melksham
We've put together a list of hotels, B&Bs and other accommodation in Melksham for our customers to use - the majority of our trainees travel to Melksham from quite a distance away.
It stuck us that there's more than just our customers who look for hotels in West Wiltshire / Melksham, so rather than just include the list in our newsletter, it's now available as a complete web site in its own right. We've not charged for the listings, neither have we restricted listings to hotels and B&Bs who offer our students special pricing. "Level playing field".
Posted by gje at 06:12 PM
Related topics: via article database
October 23, 2005
Vintage Bus Day
Today was Vintage bus day in Warminster ... there must have been some 50 buses dating back as far as 1947 running the old routes between Warminster and Bath, Warminster and Salibbury, Warminster and Frome, and the villages in between, Here, pictured at Horningsham, just behind the Longleat Estate, is the Exeter Corporation Daimler CVD6 bus of 1948. We had a lovely ride on her up from Crockerton and back ... what more can I say?
Oh - I should add that everyone else was having a great time too. Our thanks to all the folks who organised the day - back this year by popular demand. Sadly, this is likely to be the last such day due to escalating insurance costs and health and safety concerns; it was a real pleasure to have the opportunity.
Posted by gje at 09:16 PM
Related topics: via article database
October 22, 2005
Looking different in town
So there I was, walking around Melksham in this ridiculous Venetian mask, handing out leaflets for the Charity Masked Ball and also for our Save The Train campaign.
Lisa's done me an excellent job of the artwork and if you look silly enough and non-threatening and unusual, many people will stop and talk with you. Actually, one of those cases where 1 + 1 = 3 - in other words, if people wanted to talk balls, they would ... if they didn't, I still got their attention and could talk train. And it turns out that many people DID want to talk about the train; not everyone - there's a certain proportion of non-interesteds and a number of people who won't even listen to a word as you walk up to them ... and to them, I say You poor souls - you've got your eyes closed andyou don't know what you missed
Posted by gje at 07:02 PM
Related topics: via article database
October 21, 2005
Are you free on 29th October - Charity ball
I didn't know what I was going to be writing about this evening as I drove home. But then it became obvious once I got here.
This is an unashamed ADVERT for the CHARITY MASKED BALL being organised by Lisa Whelan (that's NOT my wife Lisa, by the way) of "Beauty and Beyond" in Melksham.
Lisa has organised this fabulous ball, got lots of raffle prizes, but still has some tickets for sale. The ball's next Saturday (that's on 29th October 2005) and it's in aid of MacMillan Nurses, Cancer Research and Cerebral Palsy; both Cancer and Cerebral Palsy have touched her and her team's families so it's a cause close to their hearts; it touched my family in the past too ...
Anyway - PLEASE phone Lisa or Kate at Beauty and Beyond on 01225 708900, or pop in an see them in The Market Place ... and BUY A TICKET. I know it's 40 quid, but that includes dinner and wine, dance, and comedy show and it's in aid of three good causes!
More Details on the Save The Train website ... I put them there as that site's more Melkshamcentric!
Posted by gje at 07:50 PM
Related topics: via article database
And it gets even better
Ever had a mad idea? The investigated it and found that it's not quite so mad after all? And found that everyone you talk to about it is supportive ... to the extent of saying I would use that service or I have stopped using xxx because of things which you've identified ... you're onto a winner.
We're already very busy at Well House Consultants. Nine out of every ten ideas that we get are rejected quite early on simply because we don't have the time to take on something that we're not 110% sure we want to do in the long term.
But this one - wow. We already get so much of our business by word of mouth recommendation because we ARE good (I have to say it sometime). But next year, it gets even better. Watch this space.
Posted by gje at 06:35 AM
Related topics: via article database
October 20, 2005
I wanna be a Python trainer
"I came across your name when I tried to register python-training.co.uk as you've already got it registered. I've been programming in Python for 18 months and was wondering about doing some training. I don't want to compete with you but rather wondered if we could help each other develop the market. I'm in [Town in South Midlands] so I could cover that area".
I'm paraphrasing a little, but that's the line I got when I returned a call as requested between 7 and 11 last night - or rather the third time I returned the call as my contact wasn't actually answering until late evening, even though he had given me the specific time slot. Futher discussions revealed that he's working full time for someone else and has just a few days a month to fill in, and that he doesn't actually have any Python training material ...
He may be an excellent teacher. He may know enough Python to give a good course. And if that's that's the case, I wish him well as an ambassador for the language. And he's certainly got the bottle to ring up and ask some very cheeky questions and for our assistance along a line that would be very much in his interest and perhaps slightly against ours.
Jimmy, (not his real name), sorry. We'll train on site anywhere through the British Isles, so really we don't need an extra resource in the South Midlands; a few minutes research on our webs site would give you a quote for your area, mentioning the very town you live in. And you need to plan your business approach better too; I think you've a lot of preparation to do before you give your first Python course, even if you your already technically competent. You'll need the right equipment, training facilities, and material. It takes something like 10 days of work to write one day of training material (an oft quoted statistic) and if you've only got a couple of days a month off your regular job to do that in, there will be quite a long elapsed time before your first good course ...
I welcome ambassadors for Python, PHP, Perl ... but I fear the person who thinks he can make a bit of extra money on the side because he's been able to spend a couple of quid on a domain name and - hey - he doesn't even have to buy the software because it's open source. It's not quite that simple.
We've been approached in the past about franchising courses, providing our materials to others, etc. There's certainly a financial temptation to sell these types of services and to get our materials, which are applicable through the English speaking world, out to a wider audience to the benefit of our bank balance. But, so far, we've decided against this direction. A course is made not only by good material, but also by a very knowledgable tutor, and one who can handle the people / direction / relationships too. Add to that an excellent training centre, good accommodation for public courses, the right equipment (NOT a pile of old throw-out PCs!), and a professional backroom team to cover enquiries right through to bill chasing. Now THAT's the Well House forumla ...
Posted by gje at 06:16 AM
Related topics: via article database
Useful link: Python training
October 19, 2005
Yesterday was Kiss and Ride
I've been tring not to "go on" about our Save that train campaign too much here - we've a separate web site for that, and it's much more a Melksham than an Open Source subject. But I have to tell you how fabulous it was to have a 20 litre urn of boiling water at the station at half past six yesterday morning. Yes, I know that sounds odd but I AM serious about it!
We served teas, coffees and literature to travellers joining the 06:56 and 09:12 Southampton trains, and the 07:45 Swindon train - we were so busy in the few minutes before the train stopped that the only pictures I managed to grab were afterwards :-/ Ah well - the event and publicity were more important than having the record.
On a more serious note, the more I learn about the politics and actions of the decision to slash the Melksham train service, the more disenchanted I get with political systems and decision making. We've discovered that the decision to cut the service was made PRIOR to any public consultation, that the public consultation was deliberatley set up in a way to minimise inputs - or at least there were minuted discussions as to how it could be minimised - and that ticket sales for journeys to and from Melksham have increased 8 fold in the last five years,yet still the decision is made. Hmm - don't get me going. But do visit the save the train blog and forum (link under the campaign above) if you would like to hear more.
Posted by gje at 05:49 AM
Related topics: via article database
October 18, 2005
Stand alone PHP programs
It always seems a shame when people develop a lot of code in PHP then want to use it standalone ... so they rewrite it in some other language or wrap it in a web page.
PHP is an excellent stand alone language; it wasn't designed for that use, but it does a mighty fine job if you've already got files full of functions that you want to use away from as well as on the web. Here's a sampple stand alone PHP program:
#!/usr/bin/php -q
The world of Belgian dressing
<?php
$interact = fopen("php://stdin","r");
for ($k=1; $k<11; $k++) {
print "$k dollops of mayonnaise\n";
$line = fgets($interact,1024);
}
?>
and there's a chip in there somewhere
Two notes:
1. The -q command line option supresses headers so that you don't get a "content type" line
2. The special URL php://stdin allows you to open the keyboard for read, thus it allows you to write a truly interactive program.
Posted by gje at 02:26 AM
Related topics: via article database
Useful link: PHP training
October 17, 2005
Tell them three times
I'm reminded of the quote "tell them what you're going to tell them, tell it to them, then tell them what you've told them". At first, that doesn't sound flattering but in practise it's a good philosophy - an overview introduction, a detailed middle, and an overview conclusion ... and I'll be using it in a presentation that I've got at lunchtime tomorrow.
Speaking with Dad yesterday, he was thinking that the quote originally came from IBM; I don't doubt that he's right on that.
Posted by gje at 10:23 PM
Related topics: via article database
October 16, 2005
Separating 'per instance' data from binaries and web sites
When you install Apache httpd or Apache Tomcat, everything goes into a single directory tree. That's the most natural way for the servers to ship as it means that they can be installed, tested, and then removed again easily if you wish without any complex procedure being involved.
But for a live environment, chances are you'll want to split the data into a separate directory area (that way, you can upgrade the server but retain the web site later) and you might even want to place the read-only files such as the executable binaries on a shared resource, but leave the configuration files and log files in a separate (third) area. Here are some tips / summary schemes for setting these up
Apache httpd
1. Split out the log and conf directories to the new RW area
2. Change the DocumentRoot directive in the configuration file, and also the Directory permissions directive that relates to it.
3. Create the new document root directory
4. Change /etc/init.d to start up using the -d and -f options to apachectl in the start section
5. Ensure that ServerRoot is COMMENTED OUT httpd.conf
6. Restart the Apache httpd server
Note - you can then use an environment variable input to the /etc/init.d/httpd script to control where the various parts are located
Apache Tomcat
1. Stop the Tomcat Server
2. Move the webapps directory to the new data (website) area and change the server.xml to reflect the change - alter the value for the appBase property in the Host tag
3. Create a new directory for the Read/Write area and move the conf and log subdirectories there
4. Set the CATALINA_BASE environment variable to point to the read/write area
5. Restart Tomcat using ./bin/catalina.sh start
Posted by gje at 09:13 PM
Related topics: via article database
October 15, 2005
Changing Tomcat's web.xml and reloading a web application
In the Tomcat Manager, does the "Reload" button on each application do just the same thing as "Stop" followed by "Start"? You might think so ... but, no, it doesn't.
If you stop and restart your application by using the two buttons, your web.xml configuration file will be read and any changes that you've made to it since the application was last started will be taken into consideration. But if you just "reload" then any changes made to web.xml since the application was last started will be ignored.
Posted by gje at 06:41 AM
Related topics: via article database
October 14, 2005
Technical Loneliness
"My partner cannot understand what I do for work." "When are you going to get off that computer and come to bed?" Two signs of technical loneliness.
For some, a life where technical work is left at the factory gate and a switch is thrown to a separate family compartment is possible and suits them, but for others the technical becomes an interest, a hobby, or an obsession. And it can be a source of some disappointment - a gap can be left - when they can't share with the one to whom they're otherwise closest. Both Lisa and I have been there in previous relationships; we marvel at how lucky we are today to have a good overlap between our technical fields, and we meet many, many other who don't have the same overlap of their knowledge bases.
"Come as a student, leave as a friend" say our coffee mugs and handout folders - indeed, people do. And they also leave with other technical friends.
Many people have chosen a programming role because they're bright but don't enjoy communicating/ working closely with 'typical' other people. They appear on morning 1 of a course, a little nervous, saying very little. Perhaps our long gravel driveway and imposing 4 story Georgian frontage don't help. Perhaps they're concerned that the course will be too technical for them, or the reverse. Perhaps they're worried as to how they'll spend 3 or 4 nights on their own in this little country town.
The vast majority of our trainees stay in accommodation near to us when they come on courses, and most of the time we'll note that they arrive alone on the first morning, even if they happened to travel down the night before and stay at the same little hotel or B&B as other class members. Come the second or third day of the course, though, they'll be helping each other with exercises, eating out or visiting local beauty spots together in the evening, and by the end of the course email addresses will have been exchanged; I'm not sure how much they stay in touch after the course but certainly the social aspects have come to them as something of a pleasant surprise and they've made some good network contacts in their field at the very least.
Posted by gje at 07:13 AM
Related topics: via article database
October 13, 2005
Splitting the difference
Perl's split function takes a string of text, and divides it up at a delimiter of your choice into a list of shorter strings ... it's one of the "power tool" functions of Perl and a vital part of the language. So how come that you can write a Tcl program and use its version of split - or omit the split command - and it seems to work either way. Does that seem odd
In Tcl, the split function also turns a string into a list ... it's just that a Tcl list is a string that's formatted with an unprotected space between each list element, which is probably where you started from the in the first place. In other words, the reason you can often include or leave out the call is because in Tcl's case it often does nothing at all!!
Python has two split methods - one that uses an explicit string as the delimiter on which it's to split, and the other in its regular expression class that makes it much more closely akin to the Perl flavour, and in PHP the split function splits at a literal string (you should use preg_split or explode in PHP to split at a regular expression).
Do you ever wonder why I only teach one language per day?
Posted by gje at 06:57 AM
Related topics: via article database
October 12, 2005
Big number
I was reading that the president of Google recons there's 5 million terabytes of data out there to index ... and that they're only a tiny part of the way into it. What does that look like?
5000000000000000000
Hmmm
Posted by gje at 02:34 PM
Related topics: via article database
October 11, 2005
Shortened interactive commands
In Tcl, if you're working in interactive mode you can abbreviate the commands you type in, as long as your commands remain unique. So instead of puts you can write put or even pu ... but if you try to run just the p command you'll get
% p hello
ambiguous command name "p": package pid proc puts pwd
%
If you're running from a a file of Tcl commands, though, you need to specify the command name in full - puts.
Posted by gje at 01:44 PM
Related topics: via article database
October 10, 2005
New Network
We bought our Ole Router in the days that our 512Kb connection was !fast! and we've been using it through sucessive upgrades right up to 4Mb. We bought our wireless access point in the early days of wireless access points, selecting it because it was the only option at the time. With the stepping up to 10 Mb, Old Faithful flipped. Not sure if it was because of the upgrade or because of some tired chips, but it turned into a blinking Christmas tree, even when nothing at all was connected to it and the "reset" button had been pressed with the aid of a paperclip.
And so, this Monday Morning, you find Well House Consultants switched back on 100% - off the backup systems that we had in place last week (yes - we do plan for almost any eventuallity) and onto a system with a 10Mb capacity, and with a wireless access point that now also supports the newer, faster standards. A good chance to simplify, too - two boxes replaced by one, a range of DHCP addresses set aside / configured for guest systems, and more ...
Posted by gje at 08:49 AM
Related topics: via article database
October 09, 2005
Kiss and Ride
Tuesday, 18th October will be Kiss and Ride day at Melksham Station

In the two months since I read that the train service to Melksham was to be slashed, we've gone from being users of the railway service to people who are stopped in the street and asked about the train service, and from being somewhat unknown in Melksham (since most of our business comes from outside) to having our Save the Train handout dropped through every front door in the town.
What's this about "Kiss and Ride". It's a publicity event for the train service in Melksham - encouraging commuters to get their partners to drop them off at the station and then for them to take the car into Chippenham, Swindon, Trwobridge or Westbury.
Posted by gje at 03:02 PM
Related topics: via article database
October 08, 2005
Final courses of '05 coming up ....
We've got just one opening left before Christmas for a private course, and we've already got a couple of private courses in the diary for next year. Busy or what!
We do have places on public courses, though, the next ones being:
Tcl - starting on 10th October details
PHP - starting on 31st October details
Perl (Advanced) - starting on 14th November details
Apache http/Tomcat - starting on 17th November and on 23rd November details
MySQL - starting on 21st November details
MySQL - starting on 21st November details
Linux - starting on 6th December details - basics, admin, web server
Perl (entry level course) - starting on 12th December details
We ran a public Python course last week, and the first one of the new year starts on 9th January. This is a very popular course and is increased from 3 to 6 times next year.
With the coming of Autumn a couple of weeks ago, we're hard at work getting our Autumn/Winter edition of "Of Course" off to the printer - it should be with you early next month - and we're planning a Geekmas celebration at our place on 26th and 27th November. ((Geekmas is a free technical weekend for those of you who are newcomers to the concept!))
Posted by gje at 01:49 PM
Related topics: via article database
October 06, 2005
Do the work and take the risk - a PHP contract to avoid
Here's a programming task that I won't be bidding for, and I would suggest that anyone else who looks at it be very careful ...
"We need very talented people who are willing to take a % of our advertising networks revenue, instead of an upfront payment. So the idea here is you will be working for free for the first 2 or or 3 months (casual part time), but once the intitial work is done your going to be earning a on going commission for the lifetime of the network."
Is it just me, or is the author of this post saying that he doesn't have enough faith in his scheme to put his own money in and pay you ... he wants you to take his risk.
Posted by gje at 11:06 AM
Related topics: via article database
Useful link: PHP training
October 05, 2005
Laying out a vegetarian lunch
Reminder to self. When providing a lunch that includes a vegetarian option, don't leave the vegetarian-specific food at the front of the table / entrance to the serving flow, but rather put it a little back. That's not because I want to push the vegetarians off to one side - it's because I want suitable food to be available to them even if they're not at the front of the queue!
Posted by gje at 09:25 AM
Related topics: via article database
October 04, 2005
A Stengthening day
Ever had one of those days when nothing seems to go right? I call them stengthening days, since I seem to come out of them stronger and better able to handle things ... but, my goodness, they're intense while they're happening ...
It all started with the Internet connection going on the blink - LITERALLY. The router was trying to emulate a Christmas tree - lights flashing every few seconds as it tried to go up and down and failed in all sorts of interesting ways ... just as a full class on a course that really requires net access was arriving.
Did I say "full class"? Ah yes ... I should have said "overfull class". Seven places, but eight trainees turned up; careful checking of the paperwork very clearly showed "NOT our error", but at the same time we want to do what we can for the guy who's travelled with his colleague halfway across the country - on Sunday too - to find no room at the Inn - is offered the best solution. At the same time, I'm conscious that we've had to turn business away from this course and that we cannot alienate the customers properly booked by squeezing an "extra" into facilities that can't cope with more than seven.
Then - hey, can I feel sorry for myself, I have this cold that's numbing my responses. And because I'm campaigning to save the train in Melksham, everyone seems to think that I have some control over the current service, signs at the station, and the lack of information at the Tourist Information office on the Santa Specials!
The day concluded with a trip to Swindon - to pick up a new network router. Yes - I KNOW you'll tell me that this was the least likely component to be causing the problem, but by the time er had unplugged all the cables except the power (and we had cycled power too) and it was STILL playing up, I was concluding that it was either corrupt firmware, a dry joint, a power supply problem or something else along those lines, and the economics of it tell me that it makes business sense to chuck the old and start anew. Hey - and I noticed that some boxes state "Up to 8 Mbit WAN support" and ours is just going up to 10; perhaps THAT was the problem.
The extra trainee was offered a couple of options ... and plans to be back on the next Apache Tomcat course. Left on good terms with us; he had seen the room, he realised the problem and that we were suggesting everything sensible that we could. We're on the best of terms there.
And - do you know - having the "ear" and perhaps a bit of admiration from a couple of people on the train issue WILL help to get the message across, and will encourage them to tell other about the issues, put more people in touch, etc.
So I could say it was a grotty day ... but I'm going to say it was a stengthening one instead.
Posted by gje at 07:01 AM
Related topics: via article database
October 02, 2005
Time conversions in Perl
Time isn't the easiest unit on which to do arithmetic, and dates expressed as a human-readable string are quite tricky to sort. Just imagine trying to write a program to work out whether 9 p.m. Pacific time on 28th Feb was before or after 3 a.m. in the UK on 1st March. And did you realise that, sorted alphabetically, the week starts on Friday and ends on Wednesday in England ... and it starts on Sunday and ends on Friday in France.
In Perl, all is neatly and elegantly solved for you ... you simply work in seconds from 1st January 1970, and use
localtime to convert from seconds into hour, minute, second, day, month, year
timelocal to convert the other way (from 6 values into a single number of seconds)
In order to use localtime, you need to use the Time::Local module which is supplied as standard with Perl anyway, although localtime is always available without pulling any extra module in.
gmtime and timegm provide Greenwich Mean Time convertors rather than convertors for your local time zone, and localtime and gmtime in a scalar context will give you a string rather than a list of numbers - so that makes output formatting very easy.
A final piece in the puzzle ... if you stat a file, the list you get back includes the times that the file was accessed, modified and changed each in seconds from 1.1.1970 - giving use an easy way to compare file stamps, or file ages versus some other timed happening.
Like to see an example?
use Time::Local;
# get the current time (seconds from 1.1.1970)
$now = time();
# in LIST context, localtime returns a list of each part of the time
# second, minute, hour, day, month, year, weekday, yearday, dst
# in SCALAR context, localtime returns string
@lpart = localtime($now);
$spart = localtime($now);
print "$spart ... @lpart ...\n";
# Work out the timestamp for a year ago ...
$lpart[5]--;
$past = timelocal(@lpart);
# and see if a file is over a year old ...
($finfo) = (stat("/etc/hosts"))[9];
($finfo < $past) ?
print "File is over a year old\n":
print "File is recent\n";
Posted by gje at 01:28 PM
Related topics: via article database
Useful link: Perl training