Redirigir la salida de print a un array
Publicado: 2016-08-31 05:47 @282
¡Muy buenas! Soy nuevo en el foro, aunque llevo un tiempo leyendo respuestas para resolver alguna duda puntual que me haya podido surgir. Llevo muy poco tiempo programando en Perl y mi base de programación tampoco es demasiado potente.
Necesito guardar el string entero que está imprimiendo (necesito que imprima también) para poderlo recuperar más adelante.
Espero haber creado el mensaje de forma correcta, ¡¡es mi primera vez!!
¡Un saludo y muchas gracias de antemano!
Necesito guardar el string entero que está imprimiendo (necesito que imprima también) para poderlo recuperar más adelante.
Using perl Syntax Highlighting
- if ( @lines1 eq @lines2 ) {
- for ( $i = 0; $i < @lines1; $i++ ) {
- my @var1 = split( /\s+/, $lines1[$i] );
- my @var2 = split( /\s+/, $lines2[$i] );
- if ( $var1[ $_[0] ] eq $var2[ $_[0] ] ) {
- print "Line #" . ( $i + 1 ) . " is equal in both documents\n";
- }
- else { #NECESITO GUARDAR ESTOS DOS PRINTS PARA PODERLOS MANIPULAR POSTERIORMENTE
- print "\nLine #" . ( $i + 1 ) . " is different between documents\n";
- print "This is the value from file 1: '"
- . $var1[ $_[0] ]
- . "' and this is the value from file 2: '"
- . $var2[ $_[0] ] . "'\n\n";
- }
- }
- }
- else { #NECESITO GUARDAR ESTOS 3 PRINTS PARA PODERLOS MANIPULAR POSTERIORMENTE
- print "The number of lines in each file do not match.\n";
- print "\n\nTotal number of lines in file 1: " . @lines1 . "\n";
- print "Total number of lines in file 2: " . @lines2 . "\n\n";
- }
Coloreado en 0.003 segundos, usando GeSHi 1.0.8.4
Espero haber creado el mensaje de forma correcta, ¡¡es mi primera vez!!
¡Un saludo y muchas gracias de antemano!