Помогите отпарсить

Discussion in 'Болталка' started by pampej, 10 Jun 2011.

  1. pampej

    pampej Member

    Joined:
    29 Jul 2009
    Messages:
    0
    Likes Received:
    26
    Reputations:
    5
  2. Skofield

    Skofield Elder - Старейшина

    Joined:
    27 Aug 2008
    Messages:
    960
    Likes Received:
    392
    Reputations:
    58
    PHP:
    <?php
    $fname 
    'mails.txt';
    $mails_arr file($fname);
    $x 1;
    foreach (
    $mails_arr as $mail)
    {
        
    $post .= "friend_email".$x."=".trim($mail)."&";
        
    $x++;
    }
    echo 
    rtrim($post'&');
    ?>
     
  3. dpe_x

    dpe_x Elder - Старейшина

    Joined:
    8 Sep 2010
    Messages:
    155
    Likes Received:
    35
    Reputations:
    14
    perl

    Code:
    open(FILE,"mails.txt");
    open(GOODFILE , ">good.txt");
    $i = 1;
    while(<FILE>)
    {
    	chomp;
    	print  GOODFILE "friend_email$i=$_&";
    	$i++;
    }
    
     
  4. школьнек

    Joined:
    19 Aug 2009
    Messages:
    5
    Likes Received:
    5
    Reputations:
    0
    "Помогите отпарсить" тебя в какое отверстие отпарсить? :DD
     
  5. JoyPain

    JoyPain Banned

    Joined:
    1 May 2011
    Messages:
    9
    Likes Received:
    1
    Reputations:
    0
    Отпарьсь его так , чтобы в одно ухо залетало в другом вылетало :cool:
     
  6. AnGeI

    AnGeI Elder - Старейшина

    Joined:
    8 Dec 2008
    Messages:
    395
    Likes Received:
    79
    Reputations:
    16
    Вот вы пишите реализацию на разных ЯП, но я ни разу не видел, чтобы кто-то так "катал" на ассемблере :)
     
  7. JoyPain

    JoyPain Banned

    Joined:
    1 May 2011
    Messages:
    9
    Likes Received:
    1
    Reputations:
    0
    Да не вопрос , только мзда замучит , за такое надо сразу в три отверстия парсить . Левое , правое и переднее.
     
  8. pampej

    pampej Member

    Joined:
    29 Jul 2009
    Messages:
    0
    Likes Received:
    26
    Reputations:
    5
    Всем спасибо .тему можно закрывать
     
  9. Ins3t

    Ins3t Харьковчанин

    Joined:
    18 Jul 2009
    Messages:
    939
    Likes Received:
    429
    Reputations:
    139
    как то так..

    Code:
    #include <iostream>
    #include <fstream>
    #include <string>
    #include <vector>
    
    int main( int argc, char *argv[] ) {
    	std::string pathToInputFile;
    	std::string pathToOutFile;
    	std::string temp;
    	std::vector < std::string > mails( 0 );
    
    	std::cout << "Enter a path to input file: ";
    	std::cin >> pathToInputFile;
    
    	std::cout << "Enter a path to output file: ";
    	std::cin >> pathToOutFile;
    
    	std::ifstream input( pathToInputFile.c_str(), std::ios::in );
    	std::ofstream output( pathToOutFile.c_str(), std::ios::out );
    
    	if( !input || !output ) {
    		std::cerr << "Can't open input or output file!\n";
    		return 1;
    	}
    
    	while( !input.eof() ) {
    		std::getline( input, temp );
    		mails.push_back( temp );
    	}
    
    	for( int i = 0; i < mails.size(); i++ ) {
    		output << "friend_email" << ( i + 1 ) << "=" << mails.at( i ) << ( i < mails.size() - 1 ? "&" : "" );
    	}
    
    	return 0;
    }
    
     
  10. dpe_x

    dpe_x Elder - Старейшина

    Joined:
    8 Sep 2010
    Messages:
    155
    Likes Received:
    35
    Reputations:
    14

    вот это жесть :D
     
  11. Ins3t

    Ins3t Харьковчанин

    Joined:
    18 Jul 2009
    Messages:
    939
    Likes Received:
    429
    Reputations:
    139
    ну здесь на саму задачу всего 3 строки, все остальное для удобства использования.
     
  12. sn0w

    sn0w Статус пользователя:

    Joined:
    26 Jul 2005
    Messages:
    1,023
    Likes Received:
    1,296
    Reputations:
    327
    Си )

    Code:
    int _tmain(int argc, _TCHAR* argv[])
    {
    	if(argc != 3)
    	{
    		printf("Usage: %s input_file output_file\n", argv[0]);
    		return -1;
    	}
    
    	FILE *in = fopen(argv[1], "r");
    	FILE *out = fopen(argv[2], "w");
    
    	if(!in || !out)
    	{
    		printf("Error accessing files\n", argv[0]);
    		return -2;
    	}
    
    	char s_line[128], temp[142];
    	int n_mail = 0;
    	bool the_end = false;
    
    	while(!feof(in))
    	{
    		fgets(s_line, sizeof(s_line), in);
    		
    		strrchr(s_line,'\n')?*strrchr(s_line,'\n') = 0:the_end=true;
    		
    		sprintf(temp,"friend_email%d=%s", ++n_mail, s_line);
    		if(!the_end) strcat(temp, "&");
    
    		fputs(temp, out);
    	}
    
    	return 0;
    }
    ехешник http://www.sendspace.com/file/gpqss8
     
    #12 sn0w, 11 Jun 2011
    Last edited: 11 Jun 2011
Loading...
Similar Threads - Помогите отпарсить
  1. Turanchocks_
    Replies:
    2
    Views:
    1,510
  2. skillushqa_
    Replies:
    32
    Views:
    3,574