• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

quick perl sanity check

Halz

Senior member
I've got a one-liner in perl that works at the command line, but doesn't work within my script..


Code:
from the command line...
$perl -ne 'print if /Begin of text select/ .. /End of text select/' input.txt > output.txt

Code:
#within the script..
$content =~ /Begin of text select/ .. /End of text select/;
print $content;

...am I just not using the one-liner in perl correctly? Otherwise.. How else can I easily select a block of text from a variable containing multiple lines and print it..?
 
Turns out I didn't question the '-n' option..

$ perl -n -e 'print "$. - $_"' file

is equal to...

LINE:
while (<>) {
print "$. - $_"
}
 
Back
Top