#!/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. Emit生成特定接口的类

    参考 动态生成类 http://www w2bc com/Article/44799 http://www.cnblogs.com/yingql/archive/2009/03/24/1420914. ...

  2. 单个html使用axios调用接口传参

    单个html页面使用axios调用接口传参(没有使用v-cli搭建框架,也没有使用qs等等) 1.使用 URLSearchParams的方法 var params = new URLSearchPar ...

  3. Linux中断分层--工作队列

    1. 工作队列是一种将任务推后执行的方式,它把推后的任务交由一个内核线程去执行.这样中断的下半部会在进程上下文执行,他允许重新调度甚至睡眠.每个被推后的任务叫做“工作”,由这些工作组成的队列称为工作队 ...

  4. 2.rabbitmq 系列教程

    rabbitmq系列教程-文章[转] 视频分享: 链接:https://pan.baidu.com/s/1s_Qr2A1o0s8Ru0exK62jqg 提取码:eb68

  5. ABP文档笔记 - 模块系统 及 配置中心

    ABP框架 - 模块系统 ABP框架 - 启动配置 Module System Startup Configuration ABP源码分析三:ABP Module ABP源码分析四:Configura ...

  6. Linux 上安装 weblogic12C (静默安装) (一)

    最近负责在linux上安装weblogic,客户说要安装最新的版本,版本号为 12.1.X(12.1.2,12.1.3).开始以为和旧版安装一样,使用控制台的方式,下载bin文件,然后一步步在cons ...

  7. ElasticSearch:集群(Cluster),节点(Node),分片(Shard),Indices(索引),replicas(备份)之间关系

    [Cluster]集群,一个ES集群由一个或多个节点(Node)组成,每个集群都有一个cluster name作为标识----------------------------------------- ...

  8. Nmap原理02 - 版本探测介绍(上)

    Nmap原理02 - 版本探测介绍(上) 1.介绍 本文将介绍如何通过修改或添加nmap-service-probes文件来实现对nmap中未知服务的探测,首先介绍服务和版本探测的相关信息,然后介绍服 ...

  9. The Definitive C++ Book Guide and List--reference

    http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list Reference Style - All ...

  10. MsysGit下GUI乱码问题解决

    在Windows下安装Git-preview-1.7.4后,使用中发现许多的乱码问题,感觉甚是不便.这是因为Git是在linux下开发的管理软件,而linux的编码方式是基于UTF-8的,所以移植到W ...