Suppose i have a variable which pointed towards some string with special character for example : $b="abcdef^bbwk#kdbcd@"; I need a perl script which will open that file delete the first line as per the given example and if possible write them back.
Printable View
Suppose i have a variable which pointed towards some string with special character for example : $b="abcdef^bbwk#kdbcd@"; I need a perl script which will open that file delete the first line as per the given example and if possible write them back.
#!/usr/bin/perl
Code:$b = "abcdef^bbwk#kdbcd@";
$b =~ s/[^b-zA-Z0-9]*//g;
print $b . "\n";
Code:open(IN,"<perl.txt);
open(OUT,">new_perl.txt");
while (IN)
{
# if not first line ($.) write current line ($_) to out file
$. > 1 and print(OUT $_);
}
close(IN);
close(OUT);
# if you want to overwrite the original
rename("new_perl.txt","perl.txt");