(This has been edited to make sense. I'ved added additional lines of code and a definition)
I am attempting to read in a data file and then make variable assignments from the array. I don't want the '\n' at the end of each line. When I do this:
#!/usr/bin/perl -w
open SSG, "<ADRX.ssg" || die "can\'t open ADRX.ssg";
@ssg = <SSG>;
chomp @ssg;
print $ssg[93];
I get bupkis.
it means nothing in Yiddish
[ceidem@bizet ~/src/perl/ssg]$ ./pssg2.pl
[ceidem@bizet ~/src/perl/ssg]$
If I remove the chomp(), the data are there in the array as it says on the box,
#!/usr/bin/perl -w
open SSG, "<ADRX.ssg" || die "can\'t open ADRX.ssg";
@ssg = <SSG>;
#chomp @ssg;
print $ssg[93];
but then I've got the '\n'.
[ceidem@bizet ~/src/perl/ssg]$ ./pssg2.pl
2002
[ceidem@bizet ~/src/perl/ssg]$
If I use a foreach and a chomp, I get nothing.
What gives? How can I remove the newline?
Thank you in advance,
- yam
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.