Link to home
Start Free TrialLog in
Avatar of faithless1
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
SOLUTION
Avatar of a1j
a1j
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
errr ... probably need to insert "chomp $tmp;" before "print $tmp"
ASKER CERTIFIED SOLUTION
Avatar of tel2
tel2
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
...or written as a traditional script:
    #!/usr/bin/perl
    undef $/;
    $_ = <>;
    s/^(.*)$/\$i=="$1"/mg;
    s/\n\$/ || \$/g;
    print;

Usage: ./myscript.pl <data.in
Avatar of faithless1
faithless1

ASKER

Thanks!