Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Well, I guess I understand what this person is looking for as far as this posting goes, I toke the test code by someone here and added some:
#!/usr/bin/perl use strict; #use warnings; my @pics; my $test_do_insert = 0; #change value to 0 to change variables to test + a case where it should not insert my $image_name_1 = ""; $image_name_1 = "test_image1.jpg" if (!$test_do_insert); # this is +one of the images already in the database $pics[0] = 'test_image1.jpg'; # this is one of the images comi +ng from this form #$pics[0] = 'test1.jpg'; print "\n14-image_name_1=$image_name_1 - pics[0]=$pics[0]\n"; my $image_name_2 = ""; $image_name_2 = "test_image2.jpg" if (!$test_do_insert); # this is + one of the images already in the database $pics[1] = "test_image2.jpg"; # this is one of the images comi +ng from this form #$pics[1] = "test2.jpg"; print "\n20-image_name_2=$image_name_2 - pics[1]=$pics[1]\n"; my $image_name_3 = ""; #$image_name_3 = "test_image3.jpg" if (!$test_do_insert); #$pics[2] = "test3.jpg"; print "\n26-image_name_3=$image_name_3 - pics[2]=$pics[2]\n"; my $image_name_4 = ""; #$image_name_4 = "test_image4.jpg" if (!$test_do_insert); #$pics[3] = "test4.jpg"; print "\n32-image_name_4=$image_name_4 - pics[3]=$pics[3]\n\n\n"; if (@pics) { my $flag_pic = 0; # while (my $row = $sth->fetchrow_hashref()) { $flag_pic += &check_empty($image_name_1, $pics[0]); print "\n39-".$flag_pic."\n"; $flag_pic += &check_empty($image_name_2, $pics[1]); print "\n41-".$flag_pic."\n"; $flag_pic += &check_empty($image_name_3, $pics[2]); print "\n43-".$flag_pic."\n"; $flag_pic += &check_empty($image_name_4, $pics[3]); print "\n45-".$flag_pic."\n"; # } print "\n47**$flag_pic**\n"; # End check if ( $flag_pic == 0 ) { print "\n50 - YES doing insert\n"; } else { print "\n53 - NOT doing insert\n"; } } sub check_empty() { my $img = shift; my $pic = shift; print "\n60-image_name=^$img^ - pics=^$pic^\n"; if ( $img ne "" && $pic ne "" ) { print "\n63-image_name=$img - pics=$pic\n"; if ( $img=~/$pic/ ) # if they match dont do the sql insert { print "\n66-image_name=$img - pics=$pic\n"; return 1; } else { print "\n72-image_name=$img - pics=$pic\n"; return 0; } print "\n75-image_name=$img - pics=$pic\n"; } }

And thats the idea about what this person was looking for!
Enjoy!

In reply to Re^2: How to match elements of array by Anonymous Monk
in thread How to match elements of array by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-05-20 00:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found