in reply to split $c
Although this gives the same effect as some of the other answers in the thread, my preferred solution is to always use \Q and \E around a string in a regex where you want the string to match literally rather than be interpretted as a regex. This means I'd rewrite your code as:
I find that this rule is easy to apply in lots of situations, sometimes easier than using quotemeta and I think it makes the code easier to understand. If I were to use quotemeta in production code, I'd have to write:(@columns) = split /\Q$opt_c\E/;
to properly document what was going on.my $delim= getDelimiter(); my $delimRegex= quotemeta($delim);
All that said, I suggest you look into Text::xSV as it handles these types of "comma-separated values" file formats more robustly than a simple split does.
- tye (but my friends call me "Tye")
|
|---|