Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I have been testing some code on a smaller scale and something is confusing me. Why does the  print "$csv2\n"; command at the end of this script print each full line of the csv. $csv2 has been populated with the key data of csv2hash, so I'm confused as to why it would print each line? Is each line considered a key in this instance?
#!/bin/perl my @csv2 = (); # Creates new empty array @csv2 open CSV2, "<csv2" or die; # Creates the file handle CSV2, input +s the data from csv2 into CVS2 @csv2=<CSV2>; # populates @csv2 array with data from file handle + CSV2 close CSV2; my %csv2hash = (); # Creates empty hash csv2hash for (@csv2) { # for data in @csv2 array #chomp; my ($title) = $_ =~ /^.+?,\s*([^,]+?),/; #/define the data whic +h is the title #Indicate that title data will input into csv2hash $csv2hash{$_} = $title; } foreach my $csv2 (keys %csv2hash) { # iterates over all the keys in %c +sv2hash, assigning each one to $csv2 my $value = $csv2hash{$csv2}; print "$csv2\n"; # This prints the data line by line in the csv2

In reply to Re^20: Addional "year" matching functionality in word matching script by bms9nmh
in thread Addional "year" matching functionality in word matching script by bms9nmh

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2022-05-27 17:58 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (97 votes). Check out past polls.