Search.bat from the command line

B

bdy120602

I'm doing a search from the DOS prompt using the Perl search function
and I would like to search for a special character ($), but the Perl
command doesn't seem to be able to find it. I surround the dollar sign
in quotation marks, and it listed all the files in the directory,
which led me to believe that it couldn't initiate the search properly
because not all the documents contain the $. If I use search from the
Perl command line, meaning after I type "Perl" at the commadn prompt,
I receive

search/"$"
Final $ should be \$ or $name at - line 1, within string
syntax error at - line 1, near "/"$""

Also, I'm searching RTF files. which have HTML coding behind them. Is
there anyway to have Perl search just the text and not the code?

Thanks.
 
B

Brian Helterlilne

I'm doing a search from the DOS prompt using the Perl search function
and I would like to search for a special character ($), but the Perl
command doesn't seem to be able to find it. I surround the dollar sign
in quotation marks, and it listed all the files in the directory,
which led me to believe that it couldn't initiate the search properly
because not all the documents contain the $. If I use search from the
Perl command line, meaning after I type "Perl" at the commadn prompt,
I receive

search/"$"
Final $ should be \$ or $name at - line 1, within string
syntax error at - line 1, near "/"$""

perl doesn't have a search function. I think you mean you have a perl
program called search.pl that searches files.

Since you haven't shown us the code, it is hard to tell what the problem
is, but an educated guess is that your program is using regular
expressions to locate the search string. the '$' character is special
within a regular expression. Depending on what you want, you can either
escape it within the string \$ or modify the program to not treat any
characters as special within the RE (e.g. \Q$string)
Also, I'm searching RTF files. which have HTML coding behind them. Is
there anyway to have Perl search just the text and not the code?

you would need to parse the file using one of the many HTML parsing modules.
 
B

bdy120602

perl doesn't have a search function.  I think you mean you have a perl
program called search.pl that searches files.

Since you haven't shown us the code, it is hard to tell what the problem
is, but an educated guess is that your program is using regular
expressions to locate the search string.  the '$' character is special
within a regular expression.  Depending on what you want, you can either
escape it within the string \$ or modify the program to not treat any
characters as special within the RE (e.g. \Q$string)




you would need to parse the file using one of the many HTML parsing modules.

Oh, OK. Yes, I want to treat the "$" as a string literal, and the
backslash allowed me to do that. Would you provide me with the options
that are available when using search? Yes, I forgot to mention that
that's the name of the program. Search is a batch file found in /Perl/
bin, but I can't find instruction for it with perldoc.

Also, would you provide more informatino on how I would use an HTML
parser to search only the text instead of the HTML? Thanks.
 
B

Brian Helterlilne

Oh, OK. Yes, I want to treat the "$" as a string literal, and the
backslash allowed me to do that. Would you provide me with the options
that are available when using search? Yes, I forgot to mention that
that's the name of the program. Search is a batch file found in /Perl/
bin, but I can't find instruction for it with perldoc.

I'd start with search -help. If you look at the code, all the
documentation is within the file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top