在MySQL中我想克隆某些数据库.有没有这样的事情
CREATE DATABASE LIKE <template database here>
Run Code Online (Sandbox Code Playgroud)
命令?
我知道,有
CREATE TABLE LIKE
Run Code Online (Sandbox Code Playgroud) 我需要帮助从配置文件中读取端口.该行看起来像:PORT = 8888
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
int main(int ac, char **av)
{
char buf[256];
FILE *file = NULL;
char hostlist[256] = "";
int port = 8080; /* default not from config */
int i = 0;
Run Code Online (Sandbox Code Playgroud)
Run Code Online (Sandbox Code Playgroud)// open file // some feof code[..]
strcpy(hostlist,buf);
if (strstr(buf,"PORT")) { /* buf[0-3] = */
printf("%c\n",buf[5]); /* PORT=8888 */
printf("%c\n",buf[6]);
printf("%c\n",buf[7]);
printf("%c\n",buf[8]);
Run Code Online (Sandbox Code Playgroud)
这按预期工作^^但是,当尝试复制到缓冲区时,我没有得到任何端口或我得到默认端口.
for(i=4;i<9;i++) {
while (buf[i] != '\n') {
port += buf[i++];
printf("buf:%c\n",buf[i]);
}
}
printf("port=%d\n",port);
} …Run Code Online (Sandbox Code Playgroud) 我是Perl的新手,并希望每个文件在一个单独的数组中推送该文件的内容,我设法通过以下方式执行此操作,它使用if语句.但是,对于我的阵列,我想要1美元.那可能吗?
#!/usr/bin/perl
use strict;
my @karray;
my @sarray;
my @testarr = (@sarray,@karray);
my $stemplate = "foo.txt";
my $ktemplate = "bar.txt";
sub pushf2a {
open(IN, "<$_[0]") || die;
while (<IN>) {
if ($_[0] eq $stemplate) {
push (@sarray,$_);
} else {
push (@karray,$_);
}
}
close(IN) || die $!;
}
&pushf2a($stemplate,@sarray);
&pushf2a($ktemplate,@karray);
print sort @sarray;
print sort @karray;
Run Code Online (Sandbox Code Playgroud)
我想要这样的东西:
#!/bin/sh
myfoo=(@s,@k)
barf() {
pushtoarray $1
}
barf @s
barf @k
Run Code Online (Sandbox Code Playgroud)