in reply to Avoiding duplicate filenames

$filename = $dateadded."-" . join("-",@words) . ".html"; $filename_base = $filename; $filename_base =~ s/\.html//g; # check to see if filename is being used $SQL = "SELECT * FROM $database_table WHERE filename = '$filename' +"; &Do_SQL;

http://bobby-tables.com/

In other words: Use placeholders! Always.

http://bobby-tables.com/perl explains how.

(And get rid of abusing global variables as parameters for functions, and calling functions with an '&' prefix. Both is considered bad style, and both may have unwanted side effects.)

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Replies are listed 'Best First'.
Re^2: Avoiding duplicate filenames
by htmanning (Friar) on Sep 25, 2018 at 23:38 UTC
    Understood. As someone mentioned earlier this is old cold. It was originally written in 1994 and is Perl 4. Thanks everyone for the input.