ok, found out myself why it didn't work.
I am not  sure if it's an elegant chunk of code, but it works.
Since the data is in the $_ variable, fooling around with $date_today in 
the regex coulnd't work out.
(Omitted =~ since I use $_.)

Sven

my $date = `/bin/date +%d.%m.%y`;
$date =~ tr/./-/;
chomp $date;
my $apodataFile = "/Users/johnd0e/Desktop/apodata.txt";



open APODATA2,  "<$apodataFile"
                                        || die "Can't open $apodataFile for regex 
:$!\n";
                        my ( $date_today, $aponame, $apoaddress, $apotel );
                        while ( <APODATA2> ) {
                        ( $date_today, $aponame, $apoaddress, $apotel ) = 
split(/:/,$_);
                                if (/$date/) {
                                        print "date_today: $date_today   __ $date\n"  ;
                                                                                       
                 }
                                                                                }
On Wednesday, May 22, 2002, at 11:57 AM, Sven Bentlage wrote:

> Hi
> I'l looking for a way to use a scalar in a regex. The snibblet below 
> shows in about what it is supposed to do.
> if someone has a better idea how to compare the date value with the 
> $date_today value I extract from the text file, I'd be really happy 
> about any hints..
>
> The snibblet doesn't work, because it looks for the string "$date" and 
> not for the value of $date...
>
>
> Thanks for your help.
> Regards,
> Sven
>
> sub regex {
>                       #textfile has the following format:
>                       # DD-MM-YY:name:address:telephone
>                       #$date has the value of the current date DD-MM-YY
>                       
>               
>                       open APODATA2,  "<$apodataFile"
>                                                               || die "Can't open 
>$apodataFile for regex :$!\n";
>                       while ($date_today = <APODATA2> ) {
>                               if ($date_today =~ /$date/) {
>                                       print "date_today: $date_today\n";
>                                                                                      
> }
>               }
>
>
> -- To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to