Разделить и сохранить в Perl

Es posible que desee probar git pull -r. Este (intenta )agregar cambios remotos "debajo" de sus cambios locales, luego puede git pushrecuperar el resultado.

0
02.07.2019, 07:43
1 ответ

Если никакой другой обработки данных не требуется, то и Perl для этого не нужен. Достаточно простого awkскрипта:

$ awk -F '/' '/^Ref/ { printf("%s\nThe pad present in module is %s\n", $(NF-1), $NF) }' file
HMLSBLK4BIT0P0_0
The pad present in module is LSVCC15
HMLSBLK4BIT0P0_0
The pad present in module is LSVCC3
HMLSBLK4BIT0P0_0
The pad present in module is LSVSS
IOP054_VINREG5_0
The pad present in module is R0T
IOP055_VINREG5_1
The pad present in module is R0T

Это обрабатывает ввод как поля с разделителями/-и выводит последние два таких поля в форматированной текстовой строке для каждой строки, начинающейся с Ref.


С Perl:

#!/usr/bin/env perl

use strict;
use warnings;

while (<>) {
    /^Ref/ || next;

    chomp;
    my ($module, $pad) = (split('/'))[-2,-1];

    printf("%s\nThe pad present in module is %s\n", $module, $pad);
}

Запуск:

$ perl script.pl file
HMLSBLK4BIT0P0_0
The pad present in module is LSVCC15
HMLSBLK4BIT0P0_0
The pad present in module is LSVCC3
HMLSBLK4BIT0P0_0
The pad present in module is LSVSS
IOP054_VINREG5_0
The pad present in module is R0T
IOP055_VINREG5_1
The pad present in module is R0T
0
28.01.2020, 03:31

Теги

Похожие вопросы