in reply to $/ variable

$/ is the input record seperator (default is "\n"), and if you change it to something else (such as "a" or "\n\n"), perl changes where it seperates "lines" on a file. For instance, here is a script that will read a file on paragraphs (defined as "\n\n") rather than newlines, and print !!!!!PARAGRAPH!!!!! before each one, to let you know that its working:
#!/usr/bin/perl -w use strict; open (FILE, "input.txt"); while (<FILE>) { print "\n!!!!!PARAGRAPH!!!!!\n", $_; }
Here is a sample text file to try it on: (because im nice :))
dstgs dahfgvsd kjghkls djgklsdjgl ksdjglk;j sdkl;ghsd jkljg lkds;j glk +;dsjglk; sdjgkldsjgl ;ksdjgkl;d sjglk;s djgkjdskgjdsjg lkdsjglk;sdjg +l;ksdjglkd sjglkdsjlg sd glsd dstgs dahfgvsd kjghkls djgklsdjgl ksdjglk;j sdkl;ghsd jkljg lkds;j glk +;dsjglk; sdjgkldsjgl ;ksdjgkl;d sjglk;s djgkjdskgjdsjg lkdsjglk;sdjg +l;ksdjglkd sjglkdsjlg sd glsd dstgs dahfgvsd kjghkls djgklsdjgl ksdjglk;j sdkl;ghsd jkljg lkds;j glk +;dsjglk; sdjgkldsjgl ;ksdjgkl;d sjglk;s djgkjdskgjdsjg lkdsjglk;sdjg +l;ksdjglkd sjglkdsjlg sd glsd

Replies are listed 'Best First'.
Re: Re: $/ variable
by little (Curate) on Aug 21, 2001 at 21:29 UTC
    where did you modify $/ in your script? Whether I cant see it or I cant follow your great art of obfuscation. :-)
    So just for readability I'd suggest to add a line to play with
    # (un)comment or modify one of the following #undef $/; #tread all as one line $/ = "d"; # whatever you want it to be
    For cool examples on how to use that take a look at Obfuscation. Well sometimes its not only cool but also clever.

    Have a nice day
    All decision is left to your taste