faithless1
asked on
Word Manipulation
Hello,
I have a file with words on each line:
example:
word1
word2
word3
etc.
I'm looking for a way to output them in the following format
$i=="word1" || $i=="word2" || $i=="word3" || $i=="etc"
Thank you
I have a file with words on each line:
example:
word1
word2
word3
etc.
I'm looking for a way to output them in the following format
$i=="word1" || $i=="word2" || $i=="word3" || $i=="etc"
Thank you
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
errr ... probably need to insert "chomp $tmp;" before "print $tmp"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
...or written as a traditional script:
#!/usr/bin/perl
undef $/;
$_ = <>;
s/^(.*)$/\$i=="$1"/mg;
s/\n\$/ || \$/g;
print;
Usage: ./myscript.pl <data.in
#!/usr/bin/perl
undef $/;
$_ = <>;
s/^(.*)$/\$i=="$1"/mg;
s/\n\$/ || \$/g;
print;
Usage: ./myscript.pl <data.in
ASKER
Thanks!