Ask a Question related to PERL Miscellaneous, Design and Development.
-
Jay #1
help with regular expressions
Hello,
just getting grips with Perl and RE, but need your help.
I am trying to open a file, print its contents to a textbox, but
extract certain bits of information before outputing them to the
textbox. LAter I want to save the contents back to the same file with
the bits added back to the file. All this done without the user even
realising. The bits I want to take out (and put back) are always
located at the beginning and end of each file.
This is what I have come up with so far:
# places a specified file into the textarea to be edited
sub get_file
{
open(FILE, "< $selected_file") or die "Cannot open file\n";
while ()($thisrow = <FILE>))
{
$thisrow =~ s/\<\/textarea\>/\<\*textarea\>/;
if ($thisrow !~ m/<^TMPL_INCLUDE/)
# "<TMPL_INCLUDE" is the string to be removed
{
print $thisrow;
}
}
close FILE;
This obviously doesn't work and I was wondering if any of you guys
could shed some light to the darkness that I am experiencing.
Thanks so much!!
Jay Guest
-
RE : RE : Regular expressions
I think I begin to understand... I begin by fetching the results of the ps -efA command and split it into many variables ($uid, $pid, etc.) ... -
PHP regular expressions
Hello, I am writing an elearning software with php. I need a script to recognize any inut of the type ab,aabb,aaabbb,aaaabbbb..... And so on.... -
[PHP] Q on Regular Expressions
* Thus wrote jsWalter (jsWalter@torres.ws): have you looked at strtotime()? http://php.net/strtotime The Date formats it can find are defined... -
[PHP-DEV] PHP regular expressions
Hello. In regex/utils.h there is a definition for DUPMAX: #ifdef _POSIX2_RE_DUP_MAX #define DUPMAX _POSIX2_RE_DUP_MAX #else #define DUPMAX 255... -
Help with regular expressions.
Apples and Oranges: I think your format string is wrong, try: {0:d} "Pablo Pecora" <pablo.pecora@itau.com.ar> wrote in message... -
Tad McClellan #2
Re: help with regular expressions
Jay <jranchordas@hotmail.com> wrote:
> while ()($thisrow = <FILE>))
What's with all those (unbalanced) parenthesis?
^ ^ ^ ^ ^> $thisrow =~ s/\<\/textarea\>/\<\*textarea\>/;
^ ^ ^ ^ ^
What's with all those unnecessary backslashes?
> This obviously doesn't work and I was wondering if any of you guys
> could shed some light to the darkness that I am experiencing.
You have a syntax error in the while statement.
--
Tad McClellan SGML consulting
[email]tadmc@augustmail.com[/email] Perl programming
Fort Worth, Texas
Tad McClellan Guest
-
j355 #3
Re: help with regular expressions
You description is a bit vague, but you could try this for starters:
perl -i -ne 's/foo/bar/;print if !/whatever/;' myfilename.dat
[email]jranchordas@hotmail.com[/email] (Jay) wrote in message news:<15724ad0.0307030111.5642894c@posting.google. com>...> Hello,
>
> just getting grips with Perl and RE, but need your help.
>
> I am trying to open a file, print its contents to a textbox, but
> extract certain bits of information before outputing them to the
> textbox. LAter I want to save the contents back to the same file with
> the bits added back to the file. All this done without the user even
> realising. The bits I want to take out (and put back) are always
> located at the beginning and end of each file.
>
> This is what I have come up with so far:
>j355 Guest



Reply With Quote

