Προς το περιεχόμενο

Perl


Daredevil

Προτεινόμενες αναρτήσεις

Δημοσ.

Γίνε ποιο συγκεκριμένος, αυτό που λες σε perl είναι δύο γραμμές. Η μία γραμμή είναι για να διαβάζει το αρχείο και να το βάζει σε assossiative array και η άλλη εφαρμόζει πάνω του ένα regular expression για να σβήσει ό,τι θέλεις. ΤΙ όμως?

Δημοσ.

tnx for ur reply katarxhn

 

loipon exw ena cgi to opoio pernei ta e3eis stoixeia apo mia html forma, name ,age,email kai gender(apo mia lista). kai ta apo8hkeyei se ena txt arxeio(log.txt) se ayto to format $name\t$Age\t$email\t$D1\n". 8elw loipon ena cgi na kanw access ayto to arxeio kai na mou deixnei ta apotelesmata se ena html arxeio apo to opoio 8a epilegw poia seira dedomenwn na sbhsw.

Δημοσ.

hreiazesai 2 cgi, apo to ena tha vlepeis ta periehomena tou log.txt kai to allo tha diagrafei to entry pou thes..

 

inview.txt

>
#!/usr/bin/perl

 open(F,"log.txt");

 print "Content-type: text/html\n\n";

 $y=-1;

 while ($x=<F>) {
   $y++;
   chomp($x);
   my @arr = split(/\t/,$x);
   print "$y. $arr[0] --- $arr[1] --- $arr[2] --- $arr[3] --- [<a href=\"indelete.cgi?entry=$y\">delete</a>] <br>";
 }

close(F);

 

 

indelete.cgi

>
#!/usr/bin/perl

use CGI qw/:standard/;


 $entry = param('entry');

 if ($entry !~ /^[0-9]+$/) {
   print "Content-type: text/html\n\nEntry must be a positive number...";
   exit;
 }

 open(F,"log.txt");
 @arr = <F>;
 close(F);

 open(F,">log.txt");
 for($x=0;$x<$entry;$x++) {
   print F "$arr[$x]";
 }
 for($x=$entry+1;$x<=$#arr;$x++) {
   print F "$arr[$x]";
 }
 close(F);

 print "Location: inview.cgi\n\n";

 

 

ean to log.txt periehei paaaara polla stoiheia mesa tote kalitera sto indelete.cgi na hrisimopoiiseis ena temporary arheio opou tha apothikeveis ena ena ta stoiheia adi na apothikevei olo ta arheio se ena array opws to ehw kanei sto indelete.cgi..

 

episis kalo einai na pernas ws parametro sto indelete.cgi ena password kai mesa na kaneis ena test etsi wste na ehoun prosvasi mono aftoi pou xeroun to password.

Δημοσ.

Mercy... RTFM.

 

-w

prints warnings about identifiers that are mentioned only once, and scalar variables that are used before being set. Also warns about redefined subroutines, and references to undefined filehandles or filehandles opened readonly that you are attempting to write on. Also warns you if you use == on values that don't look like numbers, and if your subroutines recurse more than 100 deep.

Αρχειοθετημένο

Αυτό το θέμα έχει αρχειοθετηθεί και είναι κλειστό για περαιτέρω απαντήσεις.

  • Δημιουργία νέου...