Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

nite_man's scratchpad

by nite_man (Deacon)
on Jun 03, 2004 at 09:51 UTC ( #360017=scratchpad: print w/ replies, xml ) Need Help??

Formatting a date:
use POSIX 'strftime'; my $today = strftime '%d/%m/%Y %H:%M', localtime; $today =~ s!(\d{2})/(\d{2})/(\d{4})!$3-$2-$1!;
Retrive an index of array element:
my @array = ('One', 'Two', 'Three', 'Four', 'Five'); sub get_element_index($@) { my $el = shift; $_ eq $el && return @_ while $_ = pop; -1; } print get_element_index('Four', @array); # Res: 3 print get_element_index('Six', @array); # Res: -1
Use constant in regexp
use constant TEST => 'test'; my $var = 'test'; if($var =~ qr{${\TEST}}) { print 'OK!' } else { print 'Not matched!' }
or if all constants are in the special package and access to them is realized using OO notification:
my $var = 1; if($var =~ qr{#{\C->TEST_CONST}}) { print 'OK!' } else { print 'Not matched!' }
Go to top page:
Advantages of this features is that nothing adds to the browser history:
<a href=#top onClick='scrollTo(0,0); return false;'> <font color=#FFFFFF>TOP</font> </a>
Initialize array by fixed data:
my @array = (2) x 10; __DATA__ [2,2,2,2,2,2,2,2,2,2]
Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (14)
As of 2015-07-06 16:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (77 votes), past polls