More Related Content
Similar to 正規表現勉強会入門 (20)
More from Shugo Numano (15)
正規表現勉強会入門
- 2. 正規表現とは
• 文字列の集合を一つの文字列で表現する方法の一つ
• ほとんどのプログラミング言語では、(中略)正規表
現を使うことができる。AWK、Sed、Perl、
Python、Ruby、Java、JavaScript、PHPなど
• それぞれの言語やアプリケーションで細部の仕様が
異なっているが、POSIXにより標準規格も定められ
それに準拠するものも増えてきてはいる。
引用:wikipedia
- 4. 今日のお題
$ diff getstat_fw_vlan_***.pl.orig getstat_fw_vlan_***.pl
---snip---
62,65c62,64
<
< if($ifDescr[$i] =‾ /IF-MIB¥:¥:ifDescr¥.(¥d+)¥s+¥=¥s+STRING¥:¥s+(¥d+)¥n/){
< $ifindex = $1;
< $ifname = $2;
---
> if($ifDescr[$i] =‾ /IF-MIB¥:¥:ifDescr¥.(¥d+)¥s+¥=¥s+STRING¥:¥s+([¥S]+)¥n/){ #修正①
> $ifindex = $1;
> $ifname = $2;
68c67
< if($ifStatus[$i] =‾ /IF-MIB¥:¥:ifOperStatus¥.¥d+¥s+¥=¥s+INTEGER¥:¥s+(¥d+)¥n/){
---
> if($ifStatus[$i] =‾ /IF-MIB¥:¥:ifOperStatus¥.¥d+¥s+¥=¥s+INTEGER¥:¥s+¥w+¥((¥d+)¥)¥n/){ #修正②
79c78
<
---
>
82c81
< if ( $stats == up(1) ) {
---
> if ( $stats == 1 ) { #修正③
- 5. その他
• また、statsの/home/noah/snumano/PerlTestに下記ファイル
を用意しましたので、各自コピーしてください。当日い
ろいろといじっていきましょう。
• test.pl # test用perl script
• test_ifDescr # snmp ifDescrのoutput
• test_ifOperStatus # snmp ifOperStatusのoutput
• あと、dumperとかも説明します。