Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: =~ matches non-existent symbols

by Anonymous Monk
on Nov 16, 2014 at 07:05 UTC ( [id://1107333]=note: print w/replies, xml ) Need Help??


in reply to =~ matches non-existent symbols

Also, is chomp necessary here?

Replies are listed 'Best First'.
Re^2: =~ matches non-existent symbols
by Anonymous Monk on Nov 16, 2014 at 10:32 UTC
    No, chomping @ARGV is not necessary. The shell already splits command-line arguments by whitespace, and removes said whitespace (note that Athanasius talks about chomping lines from the file, not from @ARGV). Also, you're using two-argument form of open. The Perl's documentation says:
    The filename passed to the one- and two-argument forms of open() will have leading and trailing whitespace deleted and normal redirection characters honored. This property, known as "magic open", can often be used to good effect.
    You normally don't actually want Perl to be overly 'magical' with some redirection characters that might end up in filenames somehow; nor do you want it to chomp filenames automatically (if there is whitespace in @ARGV, the user made it so, and he probably knows why arguments must contain whitespace). It is best to use three-argument form of open:
    open my $INPUT_FILE, '<', $DNA or die;
Re^2: =~ matches non-existent symbols
by dsheroh (Monsignor) on Nov 16, 2014 at 10:28 UTC
    Yes.

    The file does contain non-[actg] characters: carriage returns and/or line feeds (depending on the operating system where the file was created). You need to either explicitly allow those characters or use chomp to remove them.

      Hi, the only chomp there that I can see is:
      chomp ( $DNA = $ARGV[0] );
      $ARGV[0] is not the file.

      Amusing...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1107333]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (1)
As of 2024-04-25 03:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found