我试图从数组中返回数据.代码如下:
my %ignorables = map { $_ => 1 } qw([notice mpmstats: rdy bsy rd wr ka log dns cls bsy: in);
open my $error_fh, '<', 'iset_error_log';
sub findLines {
# Iterates over the lines in the file, putting each into $_
while (<$error_fh>) {
# Only worry about the lines containing [notice
if (/\[notice/) {
if (/\brdy\b/){
print "\n";
}
else {
print ",";
}
# Split the line into fields, separated by spaces, skip the %ignorables
my @line …Run Code Online (Sandbox Code Playgroud) 我有一个在每个页面上都有问题的应用程序.目前我有一个按钮,其中OnClick指向下面的功能,但我希望它选择一个随机页面.我有10个.aspx页面.我怎样才能做到这一点?
protected void newWindow(object sender, EventArgs e)
{
Response.Redirect("Question2.aspx");
}
Run Code Online (Sandbox Code Playgroud) 我有一个foreach循环,当我点击一个按钮时,它应该显示来自txt文件的行.单击按钮时没有显示任何内容.我究竟做错了什么?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
namespace WebApplication1
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Main(object sender, EventArgs e)
{
foreach (string line in File.ReadLines(@"C:\Users\Matt\Desktop\AirportCodes2.txt"))
{
if (line.Contains("Chicago"))
{
Console.WriteLine(line);
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
文本文件以制表符分隔,格式如下:
芝加哥IL ORD奥黑尔国际