Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

2017-12-30 Original content restored by Athanasius:

hi , I was asked "how to create database without mysql or cvs" befeor a few week ago. Thanks for answers. I tried and create a program. Maybe you want to add new properties for good program. (there aren't some properties. example delete record from table , or update data in table , ....)
#!/use/perl/bin print " #create database: CREATE TABLE dbismi\n #create database with +table: CREATE TABLE dbname tablename\n #veritaban&#305; olu&#351;turm +a ve table ekleme : CREATE TABLE dbname tablename colonname colonname + int chartext #delete database : DELETE dbname \n #delete table: DELE +TE dbname tabloname \n #insert values : INSERT INTO dbname tablename +colonname value colonname value colonname value \n #show database : F +IND ALL_DATABASES \n #show all tables in databases : FIND dbismi \n # +show values in table in database : SHOW dbname tablename \n #search v +alue in table and show record: SEARCH dbname tablename key_word\n" ; use utf8; binmode(STDOUT,":utf8"); if((uc(@ARGV[0]) eq 'CREATE') && uc(@ARGV[1]) eq 'TABLE' ){ chomp(my $dir = @ARGV[2]); my $dir = "../Desktop/$dir"; mkdir( $dir ,0755); print "Directory created successfully\n"; if(@ARGV[3]){ my $d_p = @ARGV[2]; my $file_name = @ARGV[3].".txt"; my $file = "../Desktop/$d_p/$file_name"; unless(open FILE, '>'.$file) { die "\nUnable to create $file\n"; } } my $numArgs = $#ARGV + 1; foreach my $argnum (4 .. (4+($#ARGV-4)*1/2)) { print FILE "$ARGV[$argnum]\t"; } print FILE "\n"; close FILE; } if((uc(@ARGV[0]) eq 'DELETE') ){ my $numArgs = @ARGV ; if($numArgs == 2 ){ my $del= @ARGV[1].'/*.txt'; my $deleted = unlink glob $del; print "$deleted files were removed\n"; my $dir = '../Desktop/'.@ARGV[1].''; rmdir( $dir ) or die "Couldn't remove $dir directory, $!"; print "Directory removed successfully\n"; } if($numArgs eq 3 ){ my $del= @ARGV[1].'/'.@ARGV[2].'.txt'; my $deleted = unlink $del; } } if((uc(@ARGV[0]) eq 'INSERT') and uc(@ARGV[1]) eq 'INTO' ){ my $filename = @ARGV[2].'/'.@ARGV[3].'.txt'; open(my $fh, '>>', $filename) or die "Could not open file '$filena +me' $!"; my $numArgs = $#ARGV + 1; foreach my $argnum (5 .. $#ARGV) { if($argnum%2 eq 0){ } else{ print $fh "$ARGV[$argnum]\t"; } } print $fh "\n"; close $fh; #print "done\n"; } if((uc(@ARGV[0]) eq 'FIND') ){ if(uc(@ARGV[1]) eq 'ALL_DATABASES' ){ my $path = '../Desktop'; die "Please specify which directory to search" unless -d $path +; my $num =1; opendir( my $DIR, $path ); while ( my $entry = readdir $DIR ) { next unless -d $path . '/' . $entry; next if $entry eq '.' or $entry eq '..'; print "$num ) $entry\n"; $num++; } closedir $DIR; } if(uc(@ARGV[1]) ne 'ALL_DATABASES' ){ my $dir = '../Desktop/'.@ARGV[1].''; opendir DIR,$dir; my @dir = readdir(DIR); close DIR; my $temp=1; foreach(@dir){ if (-f $dir . "/" . $_ ){ print "$temp ) Table : ".$_."\n"; } } } } if(uc(@ARGV[0]) eq 'SHOW'){ my $file =@ARGV[1].'/'.@ARGV[2].'.txt'; open my $info, $file or die "Could not open $file: $!"; while( my $line = <$info>) { print $line; } close $info; } if((uc(@ARGV[0]) eq 'SEARCH') ){ my $file =@ARGV[1].'/'.@ARGV[2].'.txt'; my $str =@ARGV[3]; chomp($str); open(my $file, '<', $file) or die "Could not open file '$filen' $!"; while(my $line = <$file>){ if($line=~/$str/){ print $line; } } close ($file); }

In reply to database without mysql by darkblackblue

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

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

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

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (3)
    As of 2019-10-16 22:57 GMT
    Find Nodes?
      Voting Booth?