RE: Verifying an e-mail address

2011-07-05 Thread Mimi Cafe
I have used Email::Valid and it's simple to use as in example below: use Email::Valid; sub email_validation { my $email = shift; # return true if email address is valid. return(Email::Valid->address( -address => "$email", -mxcheck => 1 ) ? '1' : '0'); } => -O

RE: PERL MYSQL query "IF EXISTS then UPDATE else INSERT"

2010-10-20 Thread Mimi Cafe
This is the wrong list for MySQL questiosn, but I believe you are probably looking to replace the matching record, use MySQL "INSERT REPLACE INTO tablename". Mimi => -Original Message- => From: S Pratap Singh [mailto:kdari...@gmail.com] => Sent: 20 October 2010 07:37 => To: beginners

How to determine web user's location

2010-09-15 Thread Mimi Cafe
Hi I need to automatically determine web users' location and provide them with targeting products. I am aware I can capture their IP address and do DNS lookup of some kind, but how do I find their country and city from the DNS information. Recently I noticed that some of the web sites I visit aut

Insecure $ENV{PATH} while running with -T switch at /usr/local/share/perl5/MIME/Lite.pm

2010-08-19 Thread Mimi Cafe
I am using MIME::Lite::TT::HTML in my module to send emails and this worked until I decided to use taint mode. Now Perl is not happy anymore. This is the first time I am using taint mode, so I am not sure whether my code is causing this exception or the underlying MIME::Lite::TT::HTML or MIME::Lit

RE: Strange behaviour while using DBI with binding

2010-08-18 Thread Mimi Cafe
1 17 Query SELECT fname, lname, dob, substr(desc, 1, 200) FROM user LEFT JOIN personal_data ON user.id = personal_data.id WHERE gender = 'male' and position = 'HR Admin' order by lname LIMIT 20 Quit => -Original Message- => F

Strange behaviour while using DBI with binding

2010-08-17 Thread Mimi Cafe
I experienced a strange behaviour while using DBI binding for MySQL query with LIMIT clause. My CGI program behaved so strange and the result was always unpredictable and it took me several hours before I finally detected the problem. In my program I use binding as in the example below: #

RE: Example code for storing picture in MySQL DB

2010-07-22 Thread Mimi Cafe
ion.nl] => Sent: 22 July 2010 07:52 => To: beginners@perl.org => Subject: Re: Example code for storing picture in MySQL DB => => Mimi Cafe wrote: => > => > $dbh->do(qq{insert into mytable (id, pic) => values(1,$pic_file_name)}); => > => > => > Any

Example code for storing picture in MySQL DB

2010-07-21 Thread Mimi Cafe
Anyone worked on a project where they have stored pictures in MySQL db from Perl program? I need to store pictures in MYSQL and my initial thought was a normal insert statement. Now I did a bit of search and people are making it completed out there. I have not tried it, but I was thinking of grabb

RE: Calling Exit from within a subroutine

2010-07-21 Thread Mimi Cafe
t; => On Wed, Jul 21, 2010 at 6:18 AM, Mimi Cafe => wrote: => => > If my program will continue to evaluate the rest of the program, => then is it => > efficient to call exit one time at the end of the program or call => exit as => > the last line

RE: Calling Exit from within a subroutine

2010-07-21 Thread Mimi Cafe
Hi Rob I take care of everything that needs (execution errors) to be done within my sub. Perhaps this may help explain what I have: A the beginning of my program I test to see what needs to be done, and if a conditional evaluates to true, then a sub is called to work and that is it. The progra

MIME::Lite::TT::HTML - Default template

2010-07-20 Thread Mimi Cafe
I am testing MIME::Lite::TT::HTML and it works as expected using my html template. What I need to understand is why it does nit send email using my text template or both template, since I did not explicitly specify which template to use anywhere when calling new(). I specified 2 templates below fo

RE: Can't use string 1 as HASH ref while strict refs in use

2010-07-20 Thread Mimi Cafe
July 2010 04:44 => To: Mimi Cafe => Cc: 'Perl Beginners' => Subject: Re: Can't use string 1 as HASH ref while strict refs in use => => >>>>> "MC" == Mimi Cafe writes: => => MC> $received_arg = @_; => => read perldoc perl

Can't use string 1 as HASH ref while strict refs in use

2010-07-19 Thread Mimi Cafe
I passed a has reference to my sub and tried dereferencing it within the sub and get an exception Can't use string ("1") as HASH ref while strict refs in use. my %mail_parameters = ( 'Fname' => "$nickname_db_exist[1]", 'Lname' => "$nickname_db_exist[2]", 'E-mail' => "$res

RE: Track user login status

2010-07-16 Thread Mimi Cafe
age- => From: Brandon McCaig [mailto:bamcc...@gmail.com] => Sent: 15 July 2010 16:18 => To: Jeff Pang => Cc: Mimi Cafe; beginners@perl.org => Subject: Re: Track user login status => => On Sat, Jul 10, 2010 at 11:13 PM, Jeff Pang => wrote: => > Session or Cookie

RE: Track user login status

2010-07-11 Thread Mimi Cafe
Yep, I am using mod_perl. I have had a quick look at CGI::Session and it appears to be the right way forward. Will try it. Regards => Session or Cookie is a general way for this purpose. => Are you programming under mod_perl? => Even under mod_perl CGI::Session is better than => Apache::Session

Track user login status

2010-07-10 Thread Mimi Cafe
My application has certain restriction so only users you are logged in should have access to. I want to present a login form to users who are not logged on. Once they have logged in they should only see 'log out' instead. I am using Apache::Session to manage my cgi sessions, so to achieve thi

Mobile::Wurfl vs Apache2::WURFL Filter

2010-04-24 Thread Mimi Cafe
Hi, Has anyone experience using one of these modules? Unlike Mobile::Wurfl, I seems to me that Apache2::WURFL Filter will take all the work once configured? It that accurate or am I missing something in the short documentation I have read? Mimi

RE: Regex to match a word or phrase (no special character)

2010-04-21 Thread Mimi Cafe
>> Do you have a list of these special characters or do you mean all >> non-alphanumeric and non-whitespace: >> >> #!/usr/bin/perl >> >> use strict; >> use warnings; >> >> while( <> ){ >>if( /[^[:space:][:alnum:]]/ ){ >> print "invalid: $_"; >>} >> } >> Yes all non-alphanumeri

Regex to match a word or phrase (no special character)

2010-04-21 Thread Mimi Cafe
I am trying to match words or complete phrase (excluding special characters) like: 1. Tom 2. Tom and Jerry 3. Audio A4 Quattro I need to ensure users cannot feed my program with special characters so I tried this below, but it doesn't match correctly. $string =~ s/\

RE: How to manage large Conditional Statement

2010-04-21 Thread Mimi Cafe
>> -Original Message- >> I'm talking for myself here, but the way I usually do this is that I wrap >> up each SQL query or set of related SQL queries in a subroutine. >> >> If the sub's going to be used as a predicate I make sure it returns >> true/false and pass all of the relevant data

How to manage large Conditional Statement

2010-04-20 Thread Mimi Cafe
I need to evaluate a statement in an if, elsif, else block, and the statement to evaluate in the elsif is too large as I need to run a SQL query and act on the return value. What would be a better way to achieve this? Putting the SQL statement elsewhere outside the block cannot be right, so I am wo

Re: Can't locate object method "TIEHASH" via package " Apache::Session::MySQL

2010-04-19 Thread Mimi Cafe
yes, probably the space was the cause of the issue. I did not notice it untill I went back to change the quotes. Mimi On 19 April 2010 19:16, Uri Guttman wrote: > >>>>> "MC" == Mimi Cafe writes: > > MC> Hmm, the single quotes did help. I am used to double

RE: Can't locate object method "TIEHASH" via package " Apache::Session::MySQL

2010-04-19 Thread Mimi Cafe
Hmm, the single quotes did help. I am used to double quotes as they make me feel I am properly quoting, but now I have learnt the hard way. Thanks -Original Message- From: Thomas Bätzler [mailto:t.baetz...@bringe.com] Sent: 19 April 2010 10:23 To: beginners@perl.org Cc: Mimi Cafe

Can't locate object method "TIEHASH" via package " Apache::Session::MySQL

2010-04-18 Thread Mimi Cafe
I get following error when trying to open a session using Apache::Session::MySQL. Here is what I have 38 tie %session, " Apache::Session::MySQL", undef,{ 39 Handle => $dbh, 40 LockHandle => $dbh 41 }; Could not create new session: Can't loca

Extract substring from offset to space or full stop

2010-04-18 Thread Mimi Cafe
offset I used, so I should be fine I think. Mimi -Original Message- From: John W. Krahn [mailto:jwkr...@shaw.ca] Sent: 18 April 2010 17:03 To: Perl Beginners Subject: Re: Extract substring from offset to space or full stop Mimi Cafe wrote: > I used MySQL substr function to extra 10

Regex to validate user input (match any word or phrase)

2010-04-18 Thread Mimi Cafe
I am trying to test user input to ensure it contains special character or symbols that could cause problems to my program or database. The user will enter a keyword in the web form to search in my database, and I want to ensure I don't play around with special character otherwise any word or phras

RE: Extract substring from offset to space or full stop

2010-04-18 Thread Mimi Cafe
Hi, It works fine and I like it. My regex is not that good, but I can see what is doing. I modified it a bit (to capture up till a full stop sign). #!/usr/bin/perl # use strict; use warnings; # my $str = "The black cat is trying to climbed the green tree. This time it failed."; print "string: $s

Extract substring from offset to space or full stop

2010-04-18 Thread Mimi Cafe
I used MySQL substr function to extra 100 characters from the result of a query, but understandably, I don't get what I want. Now I looked at Perl's substr function and it doesn't look like it can help me achieve what I need to. Let's say I have: $s = "The black cat climbed the green tr

RE: Nested if and elsif and else

2010-04-14 Thread Mimi Cafe
[mailto:jimsgib...@gmail.com] Sent: 14 April 2010 01:36 To: beginners@perl.org Subject: Re: Nested if and elsif and else On 4/13/10 Tue Apr 13, 2010 4:35 PM, "Mimi Cafe" scribbled: > I think this will work, but is it elegant.? Yes, it will work, and yes, it is elegant, as long as it enc

Nested if and elsif and else

2010-04-13 Thread Mimi Cafe
I think this will work, but is it elegant.? If (condition){ if (nexted_condition){ do this. } Elsif (nexted_condition){ Do that... } else{ Do something else. } } else{ Do something else.. } Mimi

How ro specify path in "use lib qw()"

2010-04-11 Thread Mimi Cafe
My program is in the same directory as my module directory, but when I use relative path in use lib, Perl doesn't find the module. use lib qw(MyModule/), use lib qw(./MyModule/), use lib qw(MyModule) or use lib qw(./MyModule/) # these don't work. use lib qw(/var/www/cgi-bin/MyProject/) #

Google CGI API

2009-06-18 Thread Mimi Cafe
...@entropy.homelinux.org] Sent: 16 June 2009 00:01 To: Mimi Cafe Cc: beginners@perl.org Subject: Re: Price comparison-agent On Mon, 15 Jun 2009 14:10:14 +0100, Mimi Cafe wrote: > I am trying to write a small online price comparison-agent, but I have no > experience doing something similar before. > My

RE: Price comparison-agent

2009-06-16 Thread Mimi Cafe
Yes, the search engine API should be a better way to go than parsing HTML output. I will see whether I can use Google API (sandbox) for testing. Thanks -Original Message- From: dan [mailto:d...@entropy.homelinux.org] Sent: 16 June 2009 00:01 To: Mimi Cafe Cc: beginners@perl.org Subject

Price comparison-agent

2009-06-15 Thread Mimi Cafe
I am trying to write a small online price comparison-agent, but I have no experience doing something similar before. My intention is to query search engines for a product and try to my own algorithm to parse the returned values for the prices and compare them. Can any experienced develop

Price comparison-agent

2009-06-15 Thread Mimi Cafe
I am trying to write a small online price comparison-agent, but I have no experience doing something similar before. My intention is to query search engines for a product and try to my own algorithm to parse the returned values for the prices and compare them. Can any experienced developer tell me

Re: Remote command

2008-08-19 Thread Mimi Cafe
Take a look at the CPAN module Net::SSH. Example use strict; use Net::SSH qw(ssh ssh_cmd); my @dirlist = remote_cmds("ls'"); mimi 2008/8/19 Irfan J Sayed (isayed) <[EMAIL PROTECTED]> > Hi All, > > Can somebody have the sample Perl script which will fire the "ls" > command on remote linux ma

Re: Get Clients Windows Logon ID

2008-07-16 Thread Mimi Cafe
le. I hop e you will get answer to most of your problems. Mimi On 16/07/2008, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > On Jul 15, 11:36 pm, [EMAIL PROTECTED] (Mimi Cafe) wrote: > > remote_user() or user_name() should give you the name of the user if you > are >

Re: Get Clients Windows Logon ID

2008-07-16 Thread Mimi Cafe
Someone in Timbuktu goes to your web site using their favourite browser and you want to know their authenticated user name, it that right? The user's web browser sends this information to your web application and assuming you are using CGI.pm you can say: $remote_user_login = remote_user(); In t

Re: Get Clients Windows Logon ID

2008-07-15 Thread Mimi Cafe
remote_user() or user_name() should give you the name of the user if you are using CGI.pm. Mimi On 15/07/2008, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > On Jul 15, 11:11 am, [EMAIL PROTECTED] (Rob Dixon) wrote: > > [EMAIL PROTECTED] wrote: > > > > > On Jul 15, 12:32 am, [EMAIL PROTECTED]

Re: syntax for or {multiple; statements;}?

2008-06-23 Thread Mimi Cafe
You don't need the do {} block at all. You could print the same message without the do{}. my $dbh = DBI->connect( "DBI:mysql::$mysql_host", $mysql_user, $mysql_pass ) or die "statement before dying\nCan't connect, $DBI::errstr\n"; Above should do for you. Mimi On 20/06/2008, John W. Krahn

Re: Perl to ftp files remote to local

2008-06-23 Thread Mimi Cafe
You could use the CPAN module Net::SSH http://search.cpan.org/~ivan/Net-SSH-0.09/SSH.pm. - Install the module on you local PC. - Create a non-privileged user on the remote server - Create SSH certificate for the non-privileged user on the remote machine - Use the non-privileged user to run remote

Problem with Arrays

2008-06-23 Thread Mimi Cafe
Perl is warning you that your variables have not been declared. You need to declare the @array and $temp as my @array, my $temp. Also, the second element of @array is $array[1] not @array[1]. Mimi On 23/06/2008, luke devon <[EMAIL PROTECTED]> wrote: > > Hi , > > I tried to capture some data in S

Re: Determine upload file type

2008-06-23 Thread Mimi Cafe
use print to write all types of data as with text files, but it never worked correctly. Mimi On 20/06/2008, Beginner <[EMAIL PROTECTED]> wrote: > > On 20 Jun 2008 at 11:43, Mimi Cafe wrote: > > I need to write a cgi program to enable our users to upload files using > the >

Re: Argument for perl script

2008-06-19 Thread Mimi Cafe
You may have to parse @ARGV manually depending on how arguments are passed to your script. For instance, if you script is run as follows: perl ack --name foo --pkg bar -relno 1234 then @ARGV will contain "--name, foo, --pkg, bar, -relno, 1234," and you will have to parse the list for the values you

Compare values of two or more arrays

2008-06-02 Thread Mimi Cafe
I am trying to compare one or more lists against a master record file and find out elements of the master record which are not in the other records and compile new lists of elements which are in the master data, but not found in the other records. This works to fine, but the output list is random

Re: No such file or directory

2008-05-30 Thread Mimi Cafe
(){ chomp; $inputclient{"s_"} = $_; } close INPUTFH; #$outputfile = "NOT_IN" . "$outputfile"; my $outputfile = $list; my (@missing_clients, %outputclient); open (OUTPUTFILE, ">", $outputfile) || die "Could not open $outputfile: $!\n";

Re: No such file or directory

2008-05-29 Thread Mimi Cafe
r die "Could not open $supplied for > reading: $!\n # This does not works! Error: No such file or directory > Mimi > > > > > On 29/05/2008, Ken Foskey <[EMAIL PROTECTED]> wrote: >> >> On Thu, 2008-05-29 at 11:45 +0100, Mimi Cafe wrote: >> >&g

Re: No such file or directory

2008-05-29 Thread Mimi Cafe
29/05/2008, Ken Foskey <[EMAIL PROTECTED]> wrote: > > On Thu, 2008-05-29 at 11:45 +0100, Mimi Cafe wrote: > > my script is in the same directory as my files, but it cannot find the file > ABC.txt in open() below. > > foreach my $supplied (@ARGV){ > # Output file

No such file or directory

2008-05-29 Thread Mimi Cafe
my script is in the same directory as my files, but it cannot find the file ABC.txt in open() below. foreach my $supplied (@ARGV){ # Output file name set of element currently processed. # Open file to read from. open (INPUTFILE, "<", "$supplied") or die "Could not open $supplied: $!\n"; # Erro

Process Directory and subdirectories Recursively

2008-01-28 Thread Mimi Cafe
Hi, I am trying to process a directory and all subdirectory recursively and generate a list as the Unix command "ls -R" will display, but this seems not to behave as it should. My script only goes as far as processing the directory and the 1 step below not more. I have some like, but the script g