• 締切済み

マッチング

@result として格納されるデータが以下だとすると Type escape sequence to abort. Sending 5, 512-byte ICMP Echos to 201.0.0.11, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 4/5/8 ms この Percentの前の数値の値を読み取るのにどうすればいいでしょうか? Success rate is 100 percent (5/5), round-trip min/avg/max = 4/5/8 ms が$resultの変数であれば if ($result =~ /(\d*) percent /){ print "$1 \n"; } みたいな感じで確認できるのですが。 @がタブを含めた複数行あるのでいまいち分かりません。 初心者ですみませんが宜しくお願いいたします。

みんなの回答

  • Tacosan
  • ベストアンサー率23% (3656/15482)
回答No.1

単に for ループの中でパターンマッチング じゃダメ?

sjc95134
質問者

お礼

Tacosanさん 有難う御座いました。 最終的に結局やりたいことが"is 0 percent"を@resultから見つけたかったのでこんなかんじですっきりできました。 foreach(@result){ if ($_ =~ /is 0 percent/){   print "Failed!\n";     }else{   print "Passed!\n"; }

全文を見る
すると、全ての回答が全文表示されます。

関連するQ&A

  • 外部ネットワークへpingが通らなくなりました

    自宅サーバー構築にトライ中なのですが、とちゅうでyumが動かなくなりました(どのタイミングなのか分かりません、申し訳ありません) 以下のようなメッセージが表示されています。 Error Downloading Packages: firefox-3.0.10-1.fc10.i386: failure: firefox-3.0.10-1.fc10.i386.rpm from updates: [Errno 256] No more mirrors to try. 構築環境は OS:fedora10 IPアドレス 192.168.1.100 です。 yumのリポジトリが込んでるのかと思ったのですが、時間がたっても解決せず、pingをやってみたところ以下のようになりました。 ルーターへのpingは通る [root@server ~]# ping 192.168.1.1 PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data. 64 bytes from 192.168.1.1: icmp_seq=1 ttl=255 time=1.53 ms 64 bytes from 192.168.1.1: icmp_seq=2 ttl=255 time=0.000 ms ^C --- 192.168.1.1 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1079ms rtt min/avg/max/mdev = 0.000/0.765/1.530/0.765 ms 外部へのpingが通らない [root@server ~]# ping yahoo.co.jp connect: ネットワークに届きません LAN内のその他の端末からはping等通りますので、ルータには問題ないのではないかと思っています。 macbook:~ muttuwo$ ping yahoo.co.jp PING yahoo.co.jp (203.216.227.176): 56 data bytes 64 bytes from 203.216.227.176: icmp_seq=0 ttl=52 time=12.399 ms 64 bytes from 203.216.227.176: icmp_seq=1 ttl=52 time=10.760 ms ^C --- yahoo.co.jp ping statistics --- 2 packets transmitted, 2 packets received, 0% packet loss round-trip min/avg/max/stddev = 10.760/11.579/12.399/0.820 ms 以上の状況で、どの辺りに原因があるか、推測つきますでしょうか。 なにぶん知識不足なもので、見当だけでもつけばと思い質問させて頂きました。

  • sendmailを使えるようにしたいです。

    sendmailで送受信できるようにしたいのですが、 リモートからの接続で拒否されてしまいます。 firewallとselinuxは無効にしています。 ほかにはどういった理由が考えられるでしょうか? [root@hogehoge mail]# ping 58.70.82.251 PING 58.70.82.251 (58.70.82.251) 56(84) bytes of data. 64 bytes from 58.70.82.251: icmp_seq=0 ttl=64 time=1.70 ms 64 bytes from 58.70.82.251: icmp_seq=1 ttl=64 time=0.827 ms 64 bytes from 58.70.82.251: icmp_seq=2 ttl=64 time=0.817 ms 64 bytes from 58.70.82.251: icmp_seq=3 ttl=64 time=0.835 ms 64 bytes from 58.70.82.251: icmp_seq=4 ttl=64 time=0.825 ms --- 58.70.82.251 ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4005ms rtt min/avg/max/mdev = 0.817/1.001/1.705/0.353 ms, pipe 2 [root@hogehoge mail]# telnet 58.70.82.251 25 Trying 58.70.82.251... telnet: connect to address 58.70.82.251: Connection refused telnet: Unable to connect to remote host: Connection refused [root@hogehoge mail]# telnet localhost 25 Trying 127.0.0.1... Connected to localhost.localdomain (127.0.0.1). Escape character is '^]'. 220 hogehoge ESMTP Sendmail 8.13.1/8.13.1; Sat, 16 Sep 2006 05:39:54 +0900 quit 221 2.0.0 hogehoge closing connection Connection closed by foreign host. [root@hogehoge mail]#

  • cisco2500 rxbootでethernet 0 にipを設定したがping が通りません

    cisco2500 rxbootでethernet 0 にipを設定しました。 10.0.0.1です。しかしcisco2500にコンソール接続して10.0.0.1にpingを実行しても失敗します。こんなとき何を確認すべきでしょうか? test(boot)>ping 10.0.0.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 10.0.0.1, timeout is 2 seconds: ..... Success rate is 0 percent (0/5) >show interface Ethernet0 is up, line protocol is down Hardware is Lance, address is 00e0.1e3e.abc3 (bia 00e0.1e3e.abc3) Internet address is 10.0.0.1, subnet mask is 255.0.0.0 MTU 1500 bytes, BW 10000 Kbit, DLY 1000 usec, rely 128/255, load 1/255 Encapsulation ARPA, loopback not set, keepalive set (10 sec) ARP type: ARPA, ARP Timeout 4:00:00 Last input never, output 0:00:03, output hang never Last clearing of "show interface" counters never Output queue 0/40, 0 drops; input queue 0/75, 0 drops 5 minute input rate 0 bits/sec, 0 packets/sec 5 minute output rate 0 bits/sec, 0 packets/sec 0 packets input, 0 bytes, 0 no buffer Received 0 broadcasts, 0 runts, 0 giants 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort 0 input packets with dribble condition detected 2817 packets output, 330633 bytes, 0 underruns 2817 output errors, 0 collisions, 2 interface resets, 0 restarts

  • 知らない間にping接続していたのでしょうか?

    http://www.cman.jp/network/support/ping.html というサイトのピングチェックをしました。チャットの履歴に残っていた人のIPを入れてみたところ PING 119.xxx.xxx.xx () 56(84) bytes of data. 64 bytes from 119.238.227.44: icmp_seq=1 ttl=47 time=23.5 ms 64 bytes from 119.238.227.44: icmp_seq=2 ttl=47 time=17.9 ms 64 bytes from 119.238.227.44: icmp_seq=3 ttl=47 time=18.6 ms 64 bytes from 119.238.227.44: icmp_seq=4 ttl=47 time=18.3 ms 64 bytes from 119.238.227.44: icmp_seq=5 ttl=47 time=18.6 ms --- 119.xxx.xxx.xx ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4002ms rtt min/avg/max/mdev = 17.974/19.435/23.594/2.095 ms -------------------------------------------------------------------------------- ping接続が確認できました。 と表示されました。 どのような意味なのか教えていただけないでしょうか?

  • クイックWeb設定

    WR8500nのルータを無線LANで使用してます。 クイックWeb設定のIPをデフォルトゲートウェイ(192.168.0.1)に設定したハズなんですが、なぜか繋がりません。 pingを使って192.168.0.xで繋がったものだけコピーしてみました。 Pinging 192.168.0.1 with 32 bytes of data:  Reply from 192.168.0.1: bytes=32 time<1ms TTL=255 Ping statistics for 192.168.0.1: Packets: Sent = 1, Received = 1, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms Pinging 192.168.0.2 with 32 bytes of data:  Reply from 192.168.0.2: bytes=32 time=53ms TTL=64 Ping statistics for 192.168.0.2: Packets: Sent = 1, Received = 1, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 53ms, Maximum = 53ms, Average = 53ms Pinging 192.168.0.3 with 32 bytes of data:  Reply from 192.168.0.3: bytes=32 time=81ms TTL=255 Ping statistics for 192.168.0.3: Packets: Sent = 1, Received = 1, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 81ms, Maximum = 81ms, Average = 81ms 現在、インターネットには繋がってますが、クイックWeb設定には繋がりません。原因はどこにあるのか教えていただけないでしょうか。 以上よろしくお願いします。

  • traceroute -pのオプション指定について

    以下の環境で uname -a Linux linux 2.4.20-8 #1 Thu Mar 13 17:54:28 EST 2003 i686 i686 i386 GNU/Linux traceroute -pのオプション指定についてアドバイス下さい pingは通るが、xinetd上でtelnetdは有効ですがftpdは無効になっているPCがあります。 しかし、traceroute -pオプションでそれぞれのポートを指定しても結果がOKになっているようにみえます。 []# traceroute -p21 10.0.0.2 traceroute to 10.0.0.2 (10.0.0.2), 30 hops max, 38 byte packets 1 linux (10.0.0.2) 0.243 ms 0.186 ms 0.074 ms [1 root]# traceroute -p23 10.0.0.2 traceroute to 10.0.0.2 (10.0.0.2), 30 hops max, 38 byte packets 1 linux (10.0.0.2) 0.258 ms 0.187 ms 0.059 ms 下記【エビデンス】に示すように、各サービスは設定どおりtelnetdは有効ですがftpdは無効になっています。 raceroute -pオプションの指定方法がちがうのでしょうか?アドバイスいただければ幸です 【エビデンス】 ping linux PING linux (10.0.0.2) 56(84) bytes of data. 64 bytes from linux (10.0.0.2): icmp_seq=1 ttl=64 time=0.127 ms 64 bytes from linux (10.0.0.2): icmp_seq=2 ttl=64 time=0.093 ms --- linux ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 999ms rtt min/avg/max/mdev = 0.093/0.110/0.127/0.017 ms []$ ftp linux ftp: connect: Connection refused ?Ambiguous command ftp> quit []$ telnet linux Trying 10.0.0.2... Connected to linux. Escape character is '^]'. Red Hat Linux release 9 (Shrike) Kernel \r on an \m login:

  • C言語で分からないところがあるのですが・・・

    こんにちは。 C言語で分からないところがあったので質問しに来ました。 ここ一週間の最高気温をユーザから受け取り、それを受けて、一週間の最高気温のmax,min,分散、標準偏差、中央値を求めるプログラムを書いてみました。以下にソースコードと実行結果を貼っておきます。 それで質問なんですが、標準偏差って簡単にいえば分散にルートをかぶせればいいんですよね? C言語でルートってどうやればいいんですか?ただ単純にsqrをつけたところ、エラーが発生したのでよく分からないままです。 もし宜しければお助け下さい。お願いします。 #include <stdio.h> int main(void) { float temp[7]; float min , max , avg; int i,k,l; for(i=0; i < 7 ; i++){ printf("%f INPUT the Maximam tempreture. : ", i + 1); scanf("%f", &temp[i]); } /*平均最高気温を求める*/ avg = 0; for(i = 0; i < 7; i++) avg = avg + temp[i]; printf("The Average Temperature is : %f .\n", avg/7); /*さすがに↓はありえない。minを下回ったり上回ったりした場合は以下に設定されている数値とする。*/ min = 1000000; max = -1000000; for(i=0; i < 7; i++){ if(min > temp[i]) min = temp[i]; if(max < temp[i]) max = temp[i]; } /*様々な値。上から最低、最高、分散、標準偏差、中央値(バブルソード使用)*/ /*英語のスペルが間違っている可能性が高いが無視*/ printf("The Lowest tempreture is : %f\n", min); printf("The Highest tempreture is : %f\n", max); printf("The variance is : %f\n", ((temp[0]-avg/7)*(temp[0]-avg/7)+(temp[1]-avg/7)*(temp[1]-avg/7)+(temp[2]-avg/7)*(temp[2]-avg/7)+(temp[3]-avg/7)*(temp[3]-avg/7)+(temp[4]-avg/7)*(temp[4]-avg/7)+(temp[5]-avg/7)*(temp[5]-avg/7)+(temp[6]-avg/7)*(temp[6]-avg/7))/7); /*↓が例の分からないところです。*/ printf("The standard deviation is : %f\n",((temp[0]-avg/7)*(temp[0]-avg/7)+(temp[1]-avg/7)*(temp[1]-avg/7)+(temp[2]-avg/7)*(temp[2]-avg/7)+(temp[3]-avg/7)*(temp[3]-avg/7)+(temp[4]-avg/7)*(temp[4]-avg/7)+(temp[5]-avg/7)*(temp[5]-avg/7)+(temp[6]-avg/7)*(temp[6]-avg/7))/7); for(i = 1; i < 7 ; ++i) for(k = 6; k >= i; --k){ if (temp[k-1] > temp[k]){ l = temp[k-1]; temp[k-1] = temp[k]; temp[k] = l; } } for(l = 0; l < 7; l++) printf("The tyuuouti is %f.\n", temp[3]); return 0; }

  • 英文(数学?)の問題がわかりません

    The anticipated income from an investment is $40000 per year for the first 5 years and $30000 per year for the remaining 5 years of life. The desired rate of return on the investment is 12 percent. The salvage value at the end of 10 years is expected to be 20 percent of the first cost. Determine the first cost that will result in the 12 percent return. Ans.:$219,700 考え方と途中式をお願い致します。

  • Excelでの文字検索

    Excelのマクロでpingをとばしてその結果をA2に表示させるようにしました。 pingの結果 「Ping statistics for 10.81.13.170: Packets: Sent = 30, Received = 30, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 10ms, Average = 0ms」 この中から 「Ping statistics for 10.81.13.170」をB2に抽出 「0% loss」をC2に抽出 「Average = 0ms」をD2に抽出 したいのです。 関数でもマクロでもいいのでわかる方がいましたらよろしくお願いします

  • ルータ壊れてしまって(2)

    1階から Microsoft(R) Windows 98 (C)Copyright Microsoft Corp 1981-1999. C:\WINDOWS>ping 192.168.0.2 Pinging 192.168.0.2 with 32 bytes of data: Reply from 192.168.0.2: bytes=32 time=5ms TTL=128 Reply from 192.168.0.2: bytes=32 time=3ms TTL=128 Reply from 192.168.0.2: bytes=32 time=2ms TTL=128 Reply from 192.168.0.2: bytes=32 time=3ms TTL=128 Ping statistics for 192.168.0.2: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 2ms, Maximum = 5ms, Average = 3ms 異常ありませんでした。 2階から C:\WINDOWS>ping 192.168.0.1 Pinging 192.168.0.1 with 32 bytes of data: Request timed out. Request timed out. Request timed out. Request timed out. Ping statistics for 192.168.0.1: Packets: Sent = 4, Received = 0, Lost = 4 (100% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms PINGは、通りませんでした。 ルータ壊れてしまって(3)へ 関連URL:http://www.okweb.ne.jp/kotaeru.php3?q=423352