By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,541 Members | 1,476 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,541 IT Pros & Developers. It's quick & easy.

what does it do undef $/;

P: 56
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.

Nov 12 '09 #1
Share this Question
Share on Google+
2 Replies

P: 33

$/ 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

Expand|Select|Wrap|Line Numbers
  1. undef $/;
to read everything to the end of current file.

Below code will read all the sample.txt into a scalar
Expand|Select|Wrap|Line Numbers
  1. open(FILE, "</tmp/sample.txt");
  2. undef $/;
  3. my $content = <FILE>;
  4. close(FILE);
Nov 12 '09 #2

P: 56
Thanks. Thanks a lot
Nov 12 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.