Crystal,
Some comments interspersed with your code below.
On Fri, Jun 15, 2001 at 01:25:59PM -0700, 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?
You're not using -w
> #! usr/bin/perl
> use strict;
>
> open (FILE_IN, "pslbingocard.dat")|| die "failed to open file\n";
You don't check the result of opening the output file.
> open (FILE_OUT, ">pslbingocard.txt");
No need to set $/ as "\n" is its default value.
> $/ = "\n";
>
> while (<FILE_IN>) {
This is where the _real_ problems are. The pipe character has a special
meaning in regular expressions, so you need to escape it with a
backslash. Also you're splitting $/ (which only contains "\n") instead
of $_ (which contains a line of data from your file).
Try:
split(/\|/, $_);
or even just
split(/\|/);
as split works on $_ by default.
> 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
Not entirely sure what you mean this next line to do. What it actually does
is add 0 to $subscription and then skip the rest of the loop if
$subscription is false.
> next unless $subscription +=0; #
This say, skip the rest of the loop unless $subscription contains at least
one whitespace character. Is that what you mean?
> 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;
> }
hth,
Dave...