#!/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. cmd 打开mysql客户端

  2. Oracle 中 Cursor 介绍

    一  概念 游标是SQL的一个内存工作区,由系统或用户以变量的形式定义.游标的作用就是用于临时存储从数据库中提取的数据块.在某些情况下,需要把数据从存放在磁盘的表中调到计算机内存中进行处理,最后将处理 ...

  3. 移动端数据爬取(fidlde)

    一.什么是Fiddler? 1 什么是Fiddler? Fiddler是位于客户端和服务器端的HTTP代理,也是目前最常用的http抓包工具之一 . 它能够记录客户端和服务器之间的所有 HTTP请求, ...

  4. PIE SDK屏幕坐标和地图坐标转换

    1. 功能简介 屏幕坐标和地图坐标转换,就是字面意思,将电脑屏幕的坐标转换为带有空间信息的地图坐标,主要运用PIE SDK地图控件的ToMapPoint()方法,而地图坐标转换为设备坐标(屏幕),用的 ...

  5. .net: 泛型List<T> 轉換成 DataTable類型

    public static DataTable ListToDataTable<T>(List<T> entitys) { //检查实体集合不能为空 ) { return ne ...

  6. python 学习笔记一——Python安装和IDLE使用

    好吧,一直准备学点啥,前些日子也下好了一些python电子书,但之后又没影了.年龄大了,就是不爱学习了.那就现在开始吧. 安装python 3 Mac OS X会预装python 2,Linux的大多 ...

  7. shell 语法

    1). 条件表达式语法信息    [ 1 -eq 1 ] && echo 1        <-- 表示条件成功,执行相应操作    [ 1 -eq 1 ] || echo 1  ...

  8. 关于跨域登录中获取COOKIES解析BUG

    FormsAuthentication.Decrypt   报错    Length of the data to decrypt is invalid. 关于同域名不同服务器之间的登录,加密配置说明 ...

  9. 求入栈顺序为1234……N的序列的所有可能的出栈序列

    class Program { private static void Fun(int x, int n, Stack<int> stack, List<int> outLis ...

  10. 安装wine

    sudo add-apt-repository ppa:ubuntu-wine/ppa sudo apt-get update sudo apt-get install  winetricks