The filehandle CAN be a variable... introduced in Perl 5.6? Or was it 5.8?

sub bin_urls {
    foreach (@alpha)  {
       $temp = "> $_.out";
       open ($fh, $temp);
       print $fh "Delete the file and replace it with this line";
       close($fh);
    }
}

This was likely added to Perl due to the popularity of the "use FileHandle;" stuff $Bill mentioned in his reply... but doesn't require that module. TMTOWTDI.


On approximately 11/11/2003 5:59 PM, came the following characters from the keyboard of O'K Web Design:
Hi Dominic

    The filehandle is basically a pipe to the file and to the best of my
knowledge cannot be a variable.  The loop in question should be something
like this.

sub bin_urls {
    foreach (@alpha)  {
       $temp = "> $_.out";
       open (FH, $temp);
       print "Delete the file and replace it with this line";

^ don't you need a FH there when using this technique?


       close(FH);
                              }

Mike


----- Original Message ----- From: "Maraglia, Dominicx" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: November 11, 2003 8:26 PM Subject: File handles and strict pragma



Hello,

I am experiencing serious problems when using the strict pragma with file

handles -- I have read up on the topic, but no solutions.



#!/usr/bin/perl use strict;

@alpha = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",

"n",


"o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",

"misc");


<snip>

# clean up and bin urls
sub bin_urls {
  open (FH, "test_data");  # this works fine
  foreach (@alpha)  {
     open (FH.$_, ">$_.out"); # errors with "Can't use string (FH.a) as a

symbol ref


                              # while strict refs in use..."
  }

<snip>

Basically, I need to use a variable for the file handles name -- seems

like this should work. If I do not use strict, the code runs fine...when I use strict, the error listed above is returned. What am I missing?

Thanks,
Dominic

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



-- Glenn -- http://nevcal.com/ =========================== Like almost everyone, I receive a lot of spam every day, much of it offering to help me get out of debt or get rich quick. It's ridiculous. -- Bill Gates

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to