comp.lang.perl.misc
  Home FAQ Contact Sign in
Your Ad Here
comp.lang.perl.misc only
 
Advanced search
May 2008
motuwethfrsasuw
   1234 18
567891011 19
12131415161718 20
19202122232425 21
262728293031  22
2008
 Jan   Feb   Mar   Apr 
 May   Jun   Jul   Aug 
 Sep   Oct   Nov   Dec 
2008 2007 2006  
total
comp.lang.perl.misc Profile…
RELATED GROUPS

POPULAR GROUPS

more...


 Up
  Trying to catch invalid emails         


Author: Samik R.
Date: May 6, 2008 19:58

Hello,
I use the following regular expression to catch typical invalid email
addresses:
------------
my @Email=("sam._\@abc.org", "sam_.\@abc.org", "sam_.\@abc.org");
foreach (@Email)
{

if(/^[A-z0-9]+([_\.][A-z0-9\-]+)*[@][A-z0-9_\-]+([.][A-z0-9_\-]+)?\.[A-z]{2,3}$/)
{ print "$_ is a valid email id\n"; }
else
{ print "$_ is an invalid email id\n"; }
}
-------------

This expression does not catch the above 3 emails in the array (the
program says that they are valid emails).

Can someone help me to discard these three?
Thanks.
7 Comments
  FAQ 4.16 How can I find the Julian Day?         


Author: PerlFAQ Server
Date: May 6, 2008 18:03

This is an excerpt from the latest version perlfaq4.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

--------------------------------------------------------------------

4.16: How can I find the Julian Day?

(contributed by brian d foy and Dave Cross)

You can use the "Time::JulianDay" module available on CPAN. Ensure that
you really want to find a Julian day, though, as many people have
different ideas about Julian days. See
http://www.hermetic.ch/cal_stud/jdn.htm for instance.

You can also try the "DateTime" module, which can convert a date/time to
a Julian Day.

$ perl -MDateTime -le'print DateTime->today->jd'
2453401.5

Or the modified Julian Day

$ perl -MDateTime -le'print DateTime->today->mjd'
53401
Show full article (1.77Kb)
no comments
  FAQ 4.13 How do I find the current century or millennium?         


Author: PerlFAQ Server
Date: May 6, 2008 12:03

This is an excerpt from the latest version perlfaq4.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

--------------------------------------------------------------------

4.13: How do I find the current century or millennium?

Use the following simple functions:

sub get_century {
return int((((localtime(shift || time))[5] + 1999))/100);
}

sub get_millennium {
return 1+int((((localtime(shift || time))[5] + 1899))/1000);
}

On some systems, the "POSIX" module's "strftime()" function has been
extended in a non-standard way to use a %%C format, which they sometimes
claim is the "century". It isn't, because on most such systems, this is
only the first two digits of the four-digit year, and thus cannot be
used to reliably determine the current century or millennium.
Show full article (1.71Kb)
no comments
  perl PNG image searching         


Author: elie
Date: May 6, 2008 11:02

Hello,

so I have some images (all PNG)

I have a small image, ( a checkered box) and other larger images that
may or may not contain the checkered box small image.
I want to somehow find out if the small image (the checkered box)
apprears anywhere in the larger PNG's or not.

any hits would be appreciated.

Regards,
15 Comments
  retrieve info from searching site         


Author: batman
Date: May 6, 2008 08:24

there is a website that cotains 2 search input fields: ID and Lastname

i can input to search using either one but lastname uses fuzzy logic.

if more than one result comes back (like if i pass in %% for last
name), i get a selection list of all the people.

i can then click on a single person and click the 'info' button to get
a table returned back with all the pertinent info about that person.

i'm trying to come up with a way to do the above and then cycle
through each person in the selection list and get 'info' and pull the
returned table into a local SQL database.

im familiar with programming but never done any perl before-
anybody have an idea?
2 Comments
  FAQ 4.2 Why is int() broken?         


Author: PerlFAQ Server
Date: May 6, 2008 06:03

This is an excerpt from the latest version perlfaq4.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

--------------------------------------------------------------------

4.2: Why is int() broken?

Your "int()" is most probably working just fine. It's the numbers that
aren't quite what you think.

First, see the answer to "Why am I getting long decimals (eg,
19.9499999999999) instead of the numbers I should be getting (eg,
19.95)?".

For example, this

print int(0.6/0.2-2), "\n";

will in most computers print 0, not 1, because even such simple numbers
as 0.6 and 0.2 cannot be presented exactly by floating-point numbers.
What you think in the above as 'three' is really more like
2.9999999999999995559.

--------------------------------------------------------------------
Show full article (1.57Kb)
no comments
  Why doesn't Perl complain about this bareword?         


Author: Ronny
Date: May 6, 2008 04:25

By chance I found out that no error is issued on the following
program:

perl -w -e 'use strict; print(Does::Not::Exist,"\n")'

Instead, "Does::Not::Exist" is printed. Shouldn't there be a warning
about
the improper use of a bareword? Similarily, the program

perl -w -e 'use strict; system(Does::Not::Exist,"\n")'

results in the message

Can't exec "Does::Not::Exist": No such file or directory at -e line 1.

which too seems to suggest that Does::Not::Exist is simply interpreted
as string.
But when I use it like this:

perl -w -e 'use strict; print(ref(Does::Not::Exist),"\n")'

I get the more reasonable:

Bareword "Does::Not::Exist" not allowed while "strict subs" in use at -
e line 1.

Why is this bareword treated differently in these contexts?

Ronald
11 Comments
  Error in Handling Unicode(UTF16-LE) File & String         


Author: iaminsik
Date: May 6, 2008 01:00

In most cases, I converted utf-16le files into utf-8 encoding.
But, I want to handle utf-16le files directly.

My first source is "read a line from utf-16le file and write it in
utf-16le encoding".
It works well.

==========================================================
use utf8;
use Encode;

open ($infile, "<:encoding(UTF-16LE):crlf", "unicodefile.dat");
binmode $infile;
open ($outfile, ">:raw:encoding(UTF-16LE):crlf", "unicodefile.out");
binmode $outfile;

while ($line = <$infile>)
{
print $outfile $line;
}

close($infile);
close($outfile);
==========================================================
Show full article (2.17Kb)
5 Comments
Your Ad Here
  FAQ 4.8 How do I perform an operation on a series of integers?         


Author: PerlFAQ Server
Date: May 6, 2008 00:03

This is an excerpt from the latest version perlfaq4.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

--------------------------------------------------------------------

4.8: How do I perform an operation on a series of integers?

To call a function on each element in an array, and collect the results,
use:

@results = map { my_func($_) } @array;

For example:

@triple = map { 3 * $_ } @single;

To call a function on each element of an array, but ignore the results:

foreach $iterator (@array) {
some_func($iterator);
}

To call a function on each integer in a (small) range, you can use:

@results = map { some_func($_) } (5 .. 25);
Show full article (2.18Kb)
no comments