Below is a code snippet that asks for user input, and if the input is not either "csv" or "newline", the while loop is called.
For line 5, what is the correct syntax for the while loop where it attempts to match $format to either "csv" or "newline"? Currently it is only seems to be matching "csv".
1 # Request output format
2 print "Format of email addresses required (csv|newline): ";
3 $format = <>;
4 chop($format);
5 while ($format ne ("csv"||"newline")) {
6 print "Invalid format. Enter in csv or newline: ";
7 $format = <>;
8 chop($format);
9 }
If using Perl >= v5.10, the closest working example to what you tried is:
while ( not $format ~~ ["csv", "newline"] ) {
Otherwise, both of rob mayoff's solutions will work just fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With