what does it do undef $/;

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rasmidas
    New Member
    • Jun 2007
    • 56

    what does it do undef $/;

    Hi,
    I am new to Perl and could not understand the below line from an existing Perl Code.

    undef $/;

    Could anyone please let me know, what does it do? Thanks in advance.

    Regards...
  • mohanprasadgutta
    New Member
    • Dec 2007
    • 33

    #2
    re: what does it do undef $/;

    Hi,

    $/ is the input record seperator.
    By default its newline. if you set it to undef no record seperator is matched. usually people used to do

    Code:
    undef $/;
    to read everything to the end of current file.

    Below code will read all the sample.txt into a scalar
    Code:
    open(FILE, "</tmp/sample.txt");
    undef $/;
    my $content = <FILE>;
    close(FILE);
    Regards,
    Mohan

    Comment

    • rasmidas
      New Member
      • Jun 2007
      • 56

      #3
      Thanks. Thanks a lot

      Comment

      Working...