comp.lang.perl.misc
  Home FAQ Contact Sign in
comp.lang.perl.misc only
 
Advanced search
February 2008
motuwethfrsasuw
    123 5
45678910 6
11121314151617 7
18192021222324 8
2526272829   9
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
  Is DBI prepare() statement enough for SQL injection?         


Author: howa
Date: Feb 24, 2008 19:00

I have just found a simple cases, which is not, e.g.

#--------------------------------------------------

use strict;
use DBI;
use Data::Dumper;

my $dbh = DBI-
>connect("DBI:mysql:database=information_schema;host=localhost","root","",
{ RaiseError => 1, AutoCommit => 1 });

my $input = "%%a"; # User hack by using wildcard

my $sth = $dbh->prepare("SELECT * FROM `CHARACTER_SETS` WHERE
`CHARACTER_SET_NAME` LIKE ? ") ;
$sth->execute( $input . "%%") ; # Originally you let the user search by
prefix

while ( my $data = $sth->fetchrow_hashref() ) {
print Dumper $data;
}

#--------------------------------------------------

So we should not 100%% believe in prepare() which make you100%% SQL
injection free.
Show full article (0.76Kb)
2 Comments
  FAQ 4.27 How can I access or change N characters of a string?         


Author: PerlFAQ Server
Date: Feb 24, 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.27: How can I access or change N characters of a string?

You can access the first characters of a string with substr(). To get
the first character, for example, start at position 0 and grab the
string of length 1.

$string = "Just another Perl Hacker";
$first_char = substr( $string, 0, 1 ); # 'J'

To change part of a string, you can use the optional fourth argument
which is the replacement string.

substr( $string, 13, 4, "Perl 5.8.0" );

You can also use substr() as an lvalue.

substr( $string, 13, 4 ) = "Perl 5.8.0";

--------------------------------------------------------------------
Show full article (1.58Kb)
no comments
  How to get an account at cpan.org?         


Author: Alos Diaf
Date: Feb 24, 2008 13:15

hi,

wanna publish a module,
have to register at pause,
want to use a myname@cpan.org, who can i get such?
thx.
4 Comments
  FAQ 4.37 What's wrong with always quoting "$vars"?         


Author: PerlFAQ Server
Date: Feb 24, 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.37: What's wrong with always quoting "$vars"?

The problem is that those double-quotes force stringification--coercing
numbers and references into strings--even when you don't want them to be
strings. Think of it this way: double-quote expansion is used to produce
new strings. If you already have a string, why do you need more?

If you get used to writing odd things like these:

print "$var"; # BAD
$new = "$old"; # BAD
somefunc("$var"); # BAD

You'll be in trouble. Those should (in 99.8%% of the cases) be the
simpler and more direct:
Show full article (2.42Kb)
no comments
  pregunrta         


Author: kind.loud.912801
Date: Feb 24, 2008 10:03

como puedo utilizar el mause en turbo pascal y buscar los espacios en
blanco ejemplo: al realizar un juego de numeros que tienen que caer en
la matriz que ocupa 50 espacios luego eliminarlos cuando tienen 3 ó
mas numeros iguales(1,1,1,1) y en los lugares basillos caigan los que
estan sobre de ellos.

gracias si me dan alguna idea se los agradecere bastante
1 Comment
  hash         


Author: Newsgroups
Date: Feb 24, 2008 06:43

Hi everybody,

I can't make sense of my little perl script ; I've no idea where the
probleme is... could you give me a way to understand...

I've this short code :
use strict;
use Data::Dumper;
use Lingua::Identify qw/:language_identification/;

my %%probabilities;
my %%languages = langof_file("test.txt");

print Dumper(%%languages);

it print the text in the console :
$VAR1 = 'pt';
$VAR2 = '0.0299573389196567';
$VAR3 = 'tr';
$VAR4 = '0.0152319153730931';
$VAR5 = 'da';
$VAR6 = '0.0359140188331814';
.../...

But, I want an output like this one :
Show full article (0.76Kb)
no comments
  Re: hash         


Author: Tad J McClellan
Date: Feb 24, 2008 06:40

Newsgroups wrote:
> Hi everybody,
>
> I can't make sense of my little perl script ; I've no idea where the
> probleme is... could you give me a way to understand...
>
> I've this short code :
> use strict;
> use Data::Dumper;
> use Lingua::Identify qw/:language_identification/;
>
> my %%probabilities;
> my %%languages = langof_file("test.txt");
>
> print Dumper(%%languages);
>
> it print the text in the console :
> $VAR1 = 'pt';
> $VAR2 = '0.0299573389196567';
> $VAR3 = 'tr'; ...
Show full article (1.06Kb)
2 Comments
  FAQ 4.33 How do I pad a string with blanks or pad a number with zeroes?         


Author: PerlFAQ Server
Date: Feb 24, 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.33: How do I pad a string with blanks or pad a number with zeroes?

In the following examples, $pad_len is the length to which you wish to
pad the string, $text or $num contains the string to be padded, and
$pad_char contains the padding character. You can use a single character
string constant instead of the $pad_char variable if you know what it is
in advance. And in the same way you can use an integer in place of
$pad_len if you know the pad length in advance.

The simplest method uses the "sprintf" function. It can pad on the left
or right with blanks and on the left with zeroes and it will not
truncate the result. The "pack" function can only pad strings on the
right with blanks and it will truncate the result to a maximum length of
$pad_len.
Show full article (3.14Kb)
no comments
  FAQ 4.45 How do I find the first array element for which a condition is true?         


Author: PerlFAQ Server
Date: Feb 24, 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.45: How do I find the first array element for which a condition is true?

To find the first array element which satisfies a condition, you can use
the "first()" function in the "List::Util" module, which comes with Perl
5.8. This example finds the first element that contains "Perl".

use List::Util qw(first);

my $element = first { /Perl/ } @array;

If you cannot use "List::Util", you can make your own loop to do the
same thing. Once you find the element, you stop the loop with last.

my $found;
foreach ( @array ) {
if( /Perl/ ) { $found = $_; last }
}
Show full article (2.14Kb)
no comments