codefind.pl
#!/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的更多相关文章
- Oracle PL/SQL随堂笔记总结
1.pl/sql编程 2.存储过程 3.函数 4.触发器 5.包 6.pl/sql基础 -定义并使用变量 7.pl/sql的进阶 8.oracle的视图 1.pl/sql编程 1.理解oracle的p ...
- Oracle学习笔记十 使用PL/SQL
PL/SQL 简介 PL/SQL 是过程语言(Procedural Language)与结构化查询语言(SQL)结合而成的编程语言,是对 SQL 的扩展,它支持多种数据类型,如大对象和集合类型,可使用 ...
- PL/SQL配置Oracle数据库路径
打开PL/SQL-Tools->Preferences-Orcacle->Connecttion 找到配置路径,打开-product\instantclient_11_2\NETWORK\ ...
- PL/SQL连接错误:ora-12705:cannot access NLS data files or invalid environment specified
适合自己的解决方法: 排查问题: 1. 你没有安装Oracle Client软件.这是使用PL/SQL Developer的必须条件.安装Oracle Client后再重试.2. 你安装了多个Orac ...
- PL/SQL循环
1.if循环做判断 SET SERVEROUTPUT ON accept num prompt 'qinshuu'; DECLARE pnum NUMBER :=& num ; BEGIN T ...
- PL/0编译器实践---后记
花了几天时间,把清华版的<编译原理>一书中的PL/0编译器实践了一遍.颇有收获,记录如下: 理解代码的技巧,如何理解一份代码,比如这个程序,其逻辑相对于一般程序就比较复杂了,如何翻译,虚拟 ...
- PL/SQL存储过程编程
PL/SQL存储过程编程 /**author huangchaobiao *Email:huangchaobiao111@163.com */ PL/SQL存储过程编程(上) 1. Oracle应用编 ...
- PL/SQL连接Oracle数据库,中文乱码,显示问号
问题描述: 登陆PL/SQL,执行SQL语句后,输出的中文标题显示成问号????:条件包含中文,则无数据. 如果不是中文,需要修改注册表值,方法如下: 进入注册表:Win+r,输入re ...
- PL/SQL客户端中执行insert语句,插入中文乱码
问题描述:在PL/SQL客户端中执行insert语句,插入中文乱码 解决方案: 1.执行脚本 select userenv('language') from dual; 结果为AMERICAN_ ...
随机推荐
- Tomcat启动分析
[转自] http://docs.huihoo.com/apache/tomcat/heavyz/01-startup.html 1 - Tomcat Server的组成部分 1.1 - Server ...
- vim的多窗口功能与环境参数设置
Vim的多窗口功能 多窗口情况下按键功能 :sp [filename] 打开一个新的窗口,如果有加filename,表示在新窗口打开一个新文件,否则表示两个窗口为同一文件内容 :[ctrl]+w+j( ...
- opencv java小应用:比较两个图片的相似度
package com.company; import org.opencv.core.*; import org.opencv.imgcodecs.Imgcodecs; import org.ope ...
- RabbitMQ之消息持久化
消息的可靠性是RabbitMQ的一大特色,那么RabbitMQ是如何保证消息可靠性的呢——消息持久化. 为了保证RabbitMQ在退出或者crash等异常情况下数据没有丢失,需要将queue,exch ...
- spark第四篇:Running Spark on YARN
确保HADOOP_CONF_DIR或者YARN_CONF_DIR指向hadoop集群配置文件目录.这些配置用来写数据到hdfs以及连接yarn ResourceManager.(在$SPARK_HOM ...
- pipline --学习 (-)
一,语法: 编写位置: pipline 启动docker pipeline { agent { docker 'maven:3.3.3' } stages { stage('build') { ste ...
- php二维数组排序方法(array_multisort usort)
一维数组排序可以使用asort.ksort等一些方法进程排序,相对来说比较简单.二维数组的排序怎么实现呢?使用array_multisort和usort可以实现 例如像下面的数组: $users = ...
- java线程中的 sleep() wait() yield()
sleep()方法是让线程休眠 可以指定时间 其实就是让线程进入阻塞状态 指定的时间过后 进入就绪状态 不释锁 相当于抱着锁睡觉 wait() 让线程进入等待状态 被唤醒后才会继续执行 ...
- File类--随笔
package io; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; im ...
- Entity FrameWork利用Database.SqlQuery<T>执行存储过程并返回参数
目前,EF对存储过程的支持并不完善.存在以下问题: EF不支持存储过程返回多表联合查询的结果集. EF仅支持返回返回某个表的全部字段,以便转换成对应的实体.无法支持返回部分字段的情况. 虽然可以正常导 ...