awk command with PERL

Hi All,

My Input file looks like below:

Input:
100,200,300

$fw=`head -1 test.csv | awk -F, '{print \$1}'`;
$fw="'$fw"
$fw="$fw'"
print $fw

Output:'100'

I want the first field to be printed in single quotes ('') like above.
I could get the ouptput but the problem is single quote (') is printed in next line below.
'100
'
I dont know how to avoid this space.

To remove a trailing newline in Perl, use chomp

why use awk/head when you can do all in Perl??

Why use either when you can do it all in shell?

IFS=, read first others <file.csv
echo "'$first'"

I want to capture first field in a file and check for some conditions. File has got 10 million records.

perl -e '@a=split(/ +/, <>);print $a[0]' file

You want to split on comma /,/ not whitespace.

The number of lines doesn't really matter if you only read the first line. All of the proposed solutions I believe have this property.