473,386 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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...
Nov 12 '09 #1
2 3433
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

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);
Regards,
Mohan
Nov 12 '09 #2
Thanks. Thanks a lot
Nov 12 '09 #3

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

Similar topics

0
by: DP | last post by:
(2nd post, I think my first may have been to the wrong group - sorry) Hello Perl-ers - I´m hoping I can get some help here, because I'm very lost. Don't know Perl, I'm not a programmer. And...
2
by: Sriram | last post by:
Hi, I am having trouble matching a regex that combines a negated character class and an anchor ($). Basically, I want to match all strings that don't end in a digit. So I tried: ...
6
by: Mark Healey | last post by:
I have a program that runs an array through several loops in a single function. For readability I'd like to use descriptive variable names in each loop. I could just declare them at the beginning...
15
by: informativeguy | last post by:
Hi, I did typedef int Man; After some code I get a necessity to use the same name Man for char. I mean to say,I need to typedef char Man; But how can I do this???
2
by: Old Wolf | last post by:
Is this program alright? #include <stdio.h> #undef EOF int EOF(void) { return 0; } int main(void) { return EOF(); }
3
by: johnperl | last post by:
Hi, I have a question about the perl 'undef' function. I am using it to read all line at once in once string. In the same script i am using sftp to transfer the file created by the script which...
45
by: loudking | last post by:
Hello, all I don't quite understand what does ((time_t)-1) mean when I execute "man 2 time" RETURN VALUE On success, the value of time in seconds since the Epoch is retu rned. On error,...
2
by: contactsakthi | last post by:
Hi All, What does the following pre-processor directive do? #define X {{0xff, 0xffff}} Thanks in advance
0
by: myheartinamerica | last post by:
Hello, I was working on a piece of code where a vendor's #define was causing compiler warnings, which led me to try and do the following: #if defined(VAR1) #define VAR1_SAVE VAR1 #undef VAR1...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.