为什么我的Perl计算器总是返回0?

时间:2016-08-05 21:22:24

标签: regex perl if-statement do-while

你好我是Perl的新手,我学习了基础知识,想法就是编写一个可以运行的计算器,并执行乘法,加法等基本操作......还使用RegEx。

现在的问题是,无论如何我都会0,我想知道是否有人可以检查代码,也许我可以告诉我是否做错了什么我也想问{{1}它比chomp更好吗?

我的Perl代码是这样的:

STDIN

我错过了什么吗?

1 个答案:

答案 0 :(得分:2)

你的函数only_number没有返回值,也没有实际改变它的参数。你的程序应该这样工作。

public void FinishLogFile()
    {
        var word = new Microsoft.Office.Interop.Word.Application();
        word.Visible = false;

        object missing = System.Reflection.Missing.Value;

        var document = word.Documents.Add(ref missing, ref missing, ref missing, ref missing);
        document.Content.SetRange(0, 0);

        document.Content.Text = "User: " + userName + Environment.NewLine;

        if (processedFiles.Count > 0)
        {
            document.Content.Text += "Successful files";
            foreach (var file in processedFiles)
            {
                document.Content.Text += "File name: " + file.FileName;
                document.Content.Text += file.Path + Environment.NewLine;
            }
        }

        if (unprocessedFiles.Count > 0)
        {
            document.Content.Text += "********************************************************************************";
            document.Content.Text += "" + Environment.NewLine;
            document.Content.Text += "Unsuccessful files" + Environment.NewLine;
            foreach (var file in unprocessedFiles)
            {
                document.Content.Text += "File name: " + file.FileName;
                document.Content.Text += file.Path + Environment.NewLine;
            }
        }

        document.Content.Text += "********************************************************************************";
        document.Content.Text += "Application Log" + Environment.NewLine;
        foreach (var line in activityLogs)
        {
            document.Content.Text += line;
        }

        object filename = logFileName + ".docx";
        document.SaveAs2(ref filename);
        document.Close(ref missing, ref missing, ref missing);
        document = null;
        word.Quit(ref missing, ref missing, ref missing);
        word = null;
    }