#!/usr/bin/perl
#
# Find a pattern in a the book's source collection (DOS/Windows version)
#
# (C) Copyright 2000-2002 Diomidis Spinellis
#
# Permission to use, copy, and distribute this software and its
# documentation for any purpose and without fee is hereby granted,
# provided that the above copyright notice appear in all copies and that
# both that copyright notice and this permission notice appear in
# supporting documentation.
#
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
# # Heuristic to see if we are running under Windows / DOS or Unix
$windows = (-r 'nul' && !-r '/dev/null'); if ($#ARGV != 2) {
print STDERR "Usage:\t\t$0 source-directory file-suffix-regex code-regex\n";
if ($windows) {
print STDERR "Example:\tperl $0 d:\\ace \\.[ch] main\n";
} else {
print STDERR "Example:\t$0 d:\\booksrc\\ace '\\.[ch]' main\n";
}
exit 1;
} $path = shift(@ARGV);
$filepat = shift(@ARGV);
$pat = shift(@ARGV); # Open pipe to get the list of files
if ($windows) {
# Probably DOS/Windows
open(FLIST, "dir /b/s $path |") || die "Unable to get file list using dir: $!\n";
} else {
# Hope it's Unix
open(FLIST, "find $path -print |") || die "Unable to get file list using find: $!\n";
} file: while (<FLIST>) {
chop;
next unless (/${filepat}$/);
if ($windows) {
# Exclude implicit device names (e.g. /foo/prn.c)
next if (/\\com\d/i);
next if (/\\lpt\d/i);
next if (/\\prn/i);
next if (/\\aux/i);
}
next unless (-f $_);
if (!open(FCONT, $fname = $_)) {
print STDERR "Unable to open file $_:$!\n";
next file;
}
while (<FCONT>) {
print "$fname: $_" if ($_ =~ m/$pat/o);
}
}

codefind.pl的更多相关文章

  1. Oracle PL/SQL随堂笔记总结

    1.pl/sql编程 2.存储过程 3.函数 4.触发器 5.包 6.pl/sql基础 -定义并使用变量 7.pl/sql的进阶 8.oracle的视图 1.pl/sql编程 1.理解oracle的p ...

  2. Oracle学习笔记十 使用PL/SQL

    PL/SQL 简介 PL/SQL 是过程语言(Procedural Language)与结构化查询语言(SQL)结合而成的编程语言,是对 SQL 的扩展,它支持多种数据类型,如大对象和集合类型,可使用 ...

  3. PL/SQL配置Oracle数据库路径

    打开PL/SQL-Tools->Preferences-Orcacle->Connecttion 找到配置路径,打开-product\instantclient_11_2\NETWORK\ ...

  4. PL/SQL连接错误:ora-12705:cannot access NLS data files or invalid environment specified

    适合自己的解决方法: 排查问题: 1. 你没有安装Oracle Client软件.这是使用PL/SQL Developer的必须条件.安装Oracle Client后再重试.2. 你安装了多个Orac ...

  5. PL/SQL循环

    1.if循环做判断 SET SERVEROUTPUT ON accept num prompt 'qinshuu'; DECLARE pnum NUMBER :=& num ; BEGIN T ...

  6. PL/0编译器实践---后记

    花了几天时间,把清华版的<编译原理>一书中的PL/0编译器实践了一遍.颇有收获,记录如下: 理解代码的技巧,如何理解一份代码,比如这个程序,其逻辑相对于一般程序就比较复杂了,如何翻译,虚拟 ...

  7. PL/SQL存储过程编程

    PL/SQL存储过程编程 /**author huangchaobiao *Email:huangchaobiao111@163.com */ PL/SQL存储过程编程(上) 1. Oracle应用编 ...

  8. PL/SQL连接Oracle数据库,中文乱码,显示问号

    问题描述: 登陆PL/SQL,执行SQL语句后,输出的中文标题显示成问号????:条件包含中文,则无数据.         如果不是中文,需要修改注册表值,方法如下: 进入注册表:Win+r,输入re ...

  9. PL/SQL客户端中执行insert语句,插入中文乱码

    问题描述:在PL/SQL客户端中执行insert语句,插入中文乱码 解决方案: 1.执行脚本 select userenv('language') from dual;    结果为AMERICAN_ ...

随机推荐

  1. 【实战】SSL和TLS漏洞验证

    工具下载:git clone https://github.com/drwetter/testssl.sh.git 实验环境:192.168.1.22(bee-box v1.6) 192.168.1. ...

  2. 使用Maven运行Java main的3种方式使用Maven运行Java main的3种方式

    maven使用exec插件运行java main方法,以下是3种不同的操作方式. 一.从命令行运行 1.运行前先编译代码,exec:java不会自动编译代码,你需要手动执行mvn compile来完成 ...

  3. PIE SDK专题制图保存模板

    1.    功能简介 在PIE SDK中,所有的制图元素.视图范围以及排版等都可以保存成一个模板,以供多次重复使用.使用模板时只需要打开该模板,加载相应数据,就可以直接出图,省去了重复制作图幅的麻烦, ...

  4. vue-watch deep 和 immediate

    watch 是一个对象,对象就有键,有值. 值可以是函数:就是当你监控的家伙变化时,需要执行的函数,这个函数有两个形参,第一个是变化后的值,第二个是变化前的值. 值也可以是函数名:不过这个函数名要用单 ...

  5. oracle 备份恢复篇(六)---基于12c的pdb备份与恢复

    一,备份前提描述 SQL> show con_name CON_NAME ------------------------------ CDB$ROOT SQL> archive log ...

  6. unity接入讯飞教程

    [全流程]<按照这个流程做即可,有不懂得可以看下面的2个><这个是<eclipse>> http://blog.csdn.net/qq_15267341/artic ...

  7. Java反射机制一 概念和简单的使用方法。

    一 概念 java反射机制属于 java动态性之一  ,指的是可以运行时加载,探知,使用编译期间完全未知的类,程序在运行状态中,可以动态的加载一个只有, 名称的类,对于任意一个已加载的类,都能够知道这 ...

  8. Cannot connect to VM com.sun.jdi.connect.TransportTimeoutException

    Cannot connect to VM com.sun.jdi.connect.TransportTimeoutException 描述 在用eclipse进行debug的时候弹出了上面的错误,在s ...

  9. smarty中函数的使用以及二维数组的使用

    1.虽然讲究前后台分离,但是如果如果有的项目,前后台分离的不彻底,或者有些必须要在HTML中处理,还是要用到PHP中的函数的: <% if $Role|in_array:$menuRole[$c ...

  10. [转] .net core Session , Working with a distributed cache

    本文转自:https://docs.microsoft.com/en-us/aspnet/core/performance/caching/distributed By Steve Smith+ Di ...