I can't find a backup file which has the getDate() still in it. But there's a change that I did indeed use a character that's not aloud in filenames... Too bad I can't tell for sure.
Thanks for all your help though!
I kind of fixed it.
$name was made by concatenating a string with the result of a function that got the date(), but apparently, getting the date takes some time to work? (The prints before the open() command were printed after the error :S).
I removed the date and now it works :)
Sorry for...
Hi,
I'm trying to do something really simple, but it just won't work: How can I create an empty file (fe .txt), and close it without writing anything in it?
I've tried this:
open(ORDER, ">$name") or die $!;But then it says:
I've tried a lot of other things, like:
open(ORDER, "+>", "$name")...
The same error as before; the one in the topic title :)
"Global symbol XXXXX requires explicit package name"
I now tried this:
$Main::counter = 1;
That seems to help. Is this supposed to be used like that?
If I don't write the 'my ' it gives the same error at that line.
my $status = undef;
sub listenForMenuChoice
{
print "Geef uw keuze en druk op enter.\n";
my $choice = <>;
chop $choice;
print "\n";
use Switch;
switch ($choice)
{
case "1"
{...
Funny, that's something I often tell other people (on a different forum :p)
It's just that scope handling in Perl is quite confusing, but thanks for your answer, it's a bit clearer to me now ;)
Ok, got that :).
But I still have a question concerning the scope issue. Little example:
my $status = 0;
sub sub1
{
my $status = 1;
&sub2;
}
sub sub2
{
print my $status;
}
&sub1;
The idea is that all those $status'es should point to the same $status (the one declared in line 1). How do I do...
Example:
sub mySub
{
open(MYFILE, "> path");
}
Is <MYFILE> accessible from everywhere in my code now? (Without having declared MYFILE outside the subroutine)
Hi,
I'm wondering how I can create a file handle from within a sub routine, that is available in the entire document.
In my routine, there is, fe:
open (MYFILE,"> /test/output.txt");
How can I declare the (empty) scalar/variable in my main scope, so that I can 'fill it' from within my...
I have the same case statement twice because I was in the middle of copy pasting when I posted the script :p.
Why do I need a return? I have declared '$status' in the main part (so not inside a routine). I just need to access THAT $status from within a routine. (Just like you would access...
Ah, I get it!
So I changed those lines to:
my $choise = <>;
chop my $choice;
And the error is gone. Now I get another error (well, same error, different place). I'm getting it at the $status = 1; in the switch. How can I access the global variable?
Also: is "glob $status = undef;"...
Hey,
I keep getting this error with the following code:
#!/usr/bin/perl -w
use strict;
sub mainMenu
{
print "Kies een optie (1-7)\n";
&listenForMenuChoice;
}
sub listenForMenuChoice
{
local($choice);
$choice = <>;
chop $choice;
use Switch;
switch...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.