$_ is the default variable. It represents each line and assigns it to $_ .
Actually, you don't even need it. You can try:
split (/|/);
greg
--- Crystal Gruetzmacher <[EMAIL PROTECTED]> wrote:
> what is $_ for?
>
> -----Original Message-----
> From: Greg Meckes [mailto:[EMAIL PROTECTED]]
> Sent: Friday, June 15, 2001 1:34 PM
> To: Crystal Gruetzmacher; [EMAIL PROTECTED]
> Subject: Re: Update: Where to begin??!!??
>
>
> First :
> Your assigning a newline to the "$/" scalar: $/ = "\n";
> Why? Get rid of it.
>
> Second:
> The split: split (/|/, $/);
> Should be : split (/\|/, $_);
>
> Third:
> You should escape the pipes in the print statement:
> "$date|$time|$name|$street|....etc";
> Should be: |$date\|$time\|$name\|$street\|....etc";
>
> Hope it helps along with my previous response.
>
> Greg
>
>
>
>
> --- Crystal Gruetzmacher <[EMAIL PROTECTED]> wrote:
> > I'm trying, really I am, but I can't get this thing to work (yet). Here's
> > what I have so far. Am I missing something crucial that doesn't give an
> > error message?
> >
> > #! usr/bin/perl
> > use strict;
> >
> > open (FILE_IN, "pslbingocard.dat")|| die "failed to open file\n";
> > open (FILE_OUT, ">pslbingocard.txt");
> >
> > $/ = "\n";
> >
> > while (<FILE_IN>) {
> > my ($date, $time, $name, $street, $city, $state, $zip, $country, $email,
> > $phone, $submit, @subscriptions) = split (/|/, $/);
> > # split each line on the
> > pipe, and throw into matching
> > # variable entries - note
> > that bingo numbers are all
> > # thrown into a single
> > array.
> >
> > foreach my $subscription (@subscriptions) { # loop through the
> > subscriptions array
> > next unless $subscription +=0; #
> > next unless $subscription =~/\s/;
> > $subscription =~s/^\s+//;
> > $subscription =~s/\s+$//;
> > $new_data .=
> >
> "$date|$time|$name|$street|$city|$state|$zip|$country|$email|$phone|$subscri
> > ption|\n"; # create a new line for each bingo number.
> > }
> > print FILE_OUT $new_data;
> > }
> >
> >
> > Crystal
> >
> > ************what I wrote before****************
> > Hi all,
> >
> > I have a problem and I need to know where to begin. At the magazine I work
> > for we have what are called "bingo cards" in the magazine that people can
> > fill out and send back to us to get information on whatever of 271 topics,
> > stores, resorts, etc. of their choice. They can also fill this out online.
> > What we end up with is a DAT file with each users stuff as one entry in a
> > pipe-delimited file with hard returns at the end of each entry. Of course
> we
> > could bring this into Excel or Access or some other DB, but the problem
> then
> > becomes that there are 283 fields. Not many DB's support that many.
> >
> > The point:
> > I need to take this text file and format each entry (separated by hard
> > returns) so that the user info (name address, etc) are all in their own
> > columns still and then for each number they chose (up to 271 out of 271)
> it
> > creates a new entry with their contact info and one number in the last
> > column.
> >
> > For example: Joe Smith|123 Main
> > St.|Yourtown|US|83124|888-555-1212|[EMAIL PROTECTED]|1|2||||||8||10|11| would
> > then become:
> > Joe Smith|123 Main St.|Yourtown|US|83124|888-555-1212|[EMAIL PROTECTED]|1|
> > Joe Smith|123 Main St.|Yourtown|US|83124|888-555-1212|[EMAIL PROTECTED]|2|
> > Joe Smith|123 Main St.|Yourtown|US|83124|888-555-1212|[EMAIL PROTECTED]|8|
> > Joe Smith|123 Main St.|Yourtown|US|83124|888-555-1212|[EMAIL PROTECTED]|10|
> > Joe Smith|123 Main St.|Yourtown|US|83124|888-555-1212|[EMAIL PROTECTED]|11|
> >
> > Here is a sample entry from the DAT file.
> >
> > |6/12/2001|13:05:34|Closet Geek|456 Flibity Jibet Way|My
> >
> Town|CA|90450|US|[EMAIL PROTECTED]|760-555-1212||1|2|3|4|5|6|7|8|9|10
> >
> |11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|
> >
> 36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60|6
> >
> 1|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86
> >
> |87|88|89|90|91|92|93|94|95|96|97|98|99|100|101|102|103|104|105|106|107|108|
> >
> 109|110|111|112|113|114|115|116|117|118|119|120|121|122|123|124|125|126|127|
> >
> 128|129|130|131|132|133|134|135|136|137|138|139|140|141|142|143|144|145|146|
> >
> 147|148|149|150|151|152|153|154|155|156|157|158|159|160|161|162|163|164|165|
> >
> 166|167|168|169|170|171|172|173|174|175|176|177|178|179|180|181|182|183|184|
> >
> 185|186|187|188|189|190|191|192|193|194|195|196|197|198|199|200|201|202|203|
> >
> 204|205|206|207|208|209|210|211|212|213|214|215|216|217|218|219|220|221|222|
> >
> 223|224|225|226|227|228|229|230|231|232||234|235|236|237|238|239|240|241|242
> >
> |243|244|245|246|247|248|249|250|251|252|253|254|255|256|257|258|259|260|261
> > |262|263|264|265|266|267|268|269|270|271|
> > |6/12/2001|13:14:42|closetgeek|456 Flibity Jibet Way|Yucca
> >
> Valley|California|54444|yugoslavia|[EMAIL PROTECTED]|760-555-1212|Submit||
> >
> |||||||||||||||||||||||||||||||||||||||||||||||||||53|||||58||||||||||||||||
> >
> ||||78|||||||||||89||||||95||97|||||||||||||||||||||||||||||||||||||||||||||
> >
> ||||||||||||||||||||||||||168||||||||||178||||||||186|||||||||||197|||||||||
> > |207|||||||||||||||||||||||230||||||||||||||||||||||||||||||||||||||||||
> >
> > I really need to know where to begin. Should I put everything between the
> > first 12 pipes (including the pipes) into a variable and then run a loop
> on
> > the remainder?
> >
> > Closet Geek >^..^<
>
>
> __________________________________________________
> Do You Yahoo!?
> Spot the hottest trends in music, movies, and more.
> http://buzz.yahoo.com/
__________________________________________________
Do You Yahoo!?
Spot the hottest trends in music, movies, and more.
http://buzz.yahoo.com/