in reply to Using $"

> I am working on this tutorial and the exercise asks us to use $"

Which tutorial?

See perlvar

$"

When an array or an array slice is interpolated into a double-quoted string or a similar context such as/.../ , its elements are separated by this value. Default is a space.

There is no double quote interpolation in your code.

Cheers Rolf

(addicted to the Perl Programming Language and ☆☆☆☆ :)

Replies are listed 'Best First'.
Re^2: Using $"
by BillKSmith (Monsignor) on Dec 22, 2014 at 23:46 UTC
    There is double quote interpolation in the first print of the original post. I think this is what the author of the exercise expected. The only problem is that it would not edit the first line. That could be fixed with:
    $" = '#'; print "#@lines";
    The OP's I/O problems hide the fact that he had basically solved the exercise.
    Bill
Re^2: Using $"
by Bugz (Acolyte) on Dec 22, 2014 at 20:21 UTC
    http://www.comp.leeds.ac.uk/Perl/filehandling.html
    #!/usr/local/bin/perl # # Program to open the password file, read it in, # print it, and close it again. $file = '/etc/passwd'; # Name the file open(INFO, $file); # Open the file @lines = <INFO>; # Read it into an array close(INFO); # Close the file print @lines; # Print the array

    Exercise
    Modify the above program so that the entire file is printed with a # symbol at the beginning of each line. You should only have to add one line and modify another. Use the $" variable.

      http://www.comp.leeds.ac.uk/Perl/
      Is Perl4 Archives! Perl5 is in 5.21 and Perl6 is almost here!
      I will advice, you use the alternative link, the webpage link to after some seconds.

      If you tell me, I'll forget.
      If you show me, I'll remember.
      if you involve me, I'll understand.
      --- Author unknown to me
      Did you read the intros? :)

      Legacy Tutorials

      These are old Perl tutorials that are well written and good references for old versions, but should not be used by newcomers to learn Perl.

      ... and. ..

      Please note: This tutorial was written in the early 1990's for version 4 of Perl. Although it is now significantly out of date, it was a popular source of information for many people over many years. It has therefore been left on-line as part of the historical archive of the Internet.

      Cheers Rolf

      (addicted to the Perl Programming Language and ☆☆☆☆ :)

      besides from being outdated (the others already said it), the task would have been to just print the modified data, not to rewrite the original file...