473,326 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Using Strict and Warnings modules.

Hello everyone. Last Friday I finally found a good compiler for PERL and the "shebang" line I think I need to run. They might not be running on a server but certainly they compiling well on my hard drive.

So that's great.

Expand|Select|Wrap|Line Numbers
  1. #!C:\perl\bin\
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6. $wordCount = $wordCount +1;
  7. $calc1 = 1+1;
  8. $bookTitle;
  9. $name = "Jonnie";
  10. $sentence = "Ask " . $name . " about Football";
  11.  
  12.    print "The length of the string is $wordCount\n";
  13.    print "The second scalar returns a value of $calc1 ";
  14.    $theLine = $_;
  15.    print "The title of the Book is confirmed as $bookTitle\n";
  16.    print 'The title of the Book was stored in the scalar, $bookTitle';
  17.    print "\nwin", "dows";
  18.    print "\n$sentence";
  19.    print "\n\U$sentence";
  20.  
  21.    print "\nYou can contact me via email on jonniegrieve\@yahoo.com";
  22.  
with the above code, it compiles very well but only when i do not include strict and warnings up there in the code. I've looked it up as best as i can but can anyone tell me what they do

Expand|Select|Wrap|Line Numbers
  1. Global symbol "$wordCount" requires explicit package name at first.pl line 6.
  2. Global symbol "$wordCount" requires explicit package name at first.pl line 6.
  3. Global symbol "$calc1" requires explicit package name at first.pl line 7.
  4. Global symbol "$bookTitle" requires explicit package name at first.pl line 8.
  5. Global symbol "$name" requires explicit package name at first.pl line 9.
  6. Global symbol "$sentence" requires explicit package name at first.pl line 10.
Aug 25 '07 #1
3 1392
numberwhun
3,509 Expert Mod 2GB
This is a "side-effect" of the strict pragma. It forces you to define all of your variables, the first time they are used, with a preceding "my".

So, your re-written script would look like this:

Expand|Select|Wrap|Line Numbers
  1. #!C:\perl\bin\
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6. my $wordCount = $wordCount +1;
  7. my $calc1 = 1+1;
  8. my $bookTitle;
  9. my $name = "Jonnie";
  10. my $sentence = "Ask " . $name . " about Football";
  11.  
  12.    print "The length of the string is $wordCount\n";
  13.    print "The second scalar returns a value of $calc1 ";
  14.    my $theLine = $_;
  15.    print "The title of the Book is confirmed as $bookTitle\n";
  16.    print 'The title of the Book was stored in the scalar, $bookTitle';
  17.    print "\nwin", "dows";
  18.    print "\n$sentence";
  19.    print "\n\U$sentence";
  20.  
  21.    print "\nYou can contact me via email on jonniegrieve\@yahoo.com";
  22.  
Regards,

Jeff
Aug 25 '07 #2
It worked. :D Thanks for your help.
Aug 25 '07 #3
KevinADC
4,059 Expert 2GB
Windows ignores the shebang line. You can run a perl script with any shebang line or no shebang line on windows unless you have deliberately setup windows to read the shebang line to know where perl is. Running perl scripts as a CGI in a browser on a local sever may or maynot require the shebang line. Apache needs it be default but can be setup to find perl via a directive instead of the shebang line.
Aug 27 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Microsoft News | last post by:
I have a project that was created all with Option Strict OFF. Works great, not a problem with it. But if I turn Option Strict ON then I get a LOT of errors. My question, should I even care...
30
by: Microsoft News | last post by:
I have a project that was created all with Option Strict OFF. Works great, not a problem with it. But if I turn Option Strict ON then I get a LOT of errors. My question, should I even care...
2
by: Martin v. Löwis | last post by:
I've been working on PEP 353 for some time now. Please comment, in particular if you are using 64-bit systems. Regards, Martin PEP: 353 Title: Using ssize_t as the index type Version:...
1
by: mjobbe | last post by:
I have an installer that requires three merge modules (ATL, CRT, and MFC), and after adding them in, I get the following warnings when I build the MSI: WARNING: Two or more objects have the same...
1
by: jmalone | last post by:
I have a python script that I need to freeze on AIX 5.1 (customer has AIX and does not want to install Python). The python script is pretty simple (the only things it imports are sys and socket)....
3
by: rahatekarabhijeet | last post by:
I want to create excel sheet using perl, i had installed all the necessary modules from CPAN. The perl program i taken from CPAN itself it is given below, #!/usr/bin/perl -w use warnings; use...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
3
crazy4perl
by: crazy4perl | last post by:
Hi All, I have some doubt related to xml. Actually I want to update a file which is in some format. So I am converting that file using Tap3edit perl module in a hash. Now I m trying to create a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.