use Strict and using module

Hello,

Purpose:
I am trying to understand the reason for the following error.

Error:
"Bareword "NetCDF::READ" not allowed while "strict subs" in use..."

Actions already taken:
1. Searched Google --> Perl Bareword not allowed while "strict subs"
Most of the hits I have looked at deal with just an OPEN Perl command in 
a subroutine. I am trying to understand why the module call NetCDF::READ 
results in similar behavior. Not understanding the parallel between the 
OPEN explanations and how to apply it to NetCDF::READ.

2. Searched http://perl.markmail.org
Definitely found some relevant strict/module questions but all I see are 
corrections to the code not an explanation of what Perl is actually 
finding a problem with and, more importantly, why.

Request:
Rather than re-invent the wheel could someone please point me to an 
existing detailed explanation what Perl is "thinking/seeing" in my code? 
I'm sure it exists but I haven't done a good job of finding it yet.
OR
Waste some of your valuable time and explain what is going on. ;)

Thanks,

Phil


Reduced code START:
########################################################################
#!/usr/local/bin/perl

# Programming conventions
use strict;
use warnings;

# Modules
use NetCDF;

# Local require files
require "/usr/local/wx/include_files/date-lib.pl";

# Setting directories
my $ownerDir   = "/home/disk/dagny/regulski";
my $mainDir    = "${ownerDir}/radar_nowcast";
my $netcdfDir  = "${mainDir}/data/netcdf_files";

# Determine if there is anything to forecast
my $doNowcast = &checkDoNowcast();

##########################################################################
# SUBROUTINES
##########################################################################
sub checkDoNowcast # Determines if there is any reflectivity to forecast
                  # If not, sets doNowcast = 0

{
   my $ncid = 
NetCDF::open("${netcdfDir}/REORDER.KATX_20091104_1651.CEDRIC.Z1.BIN.nc",NetCDF::READ); 


       # Determine if there are values inside the file that correspond
       # to weather to nowcast.


   NetCDF::close($ncid);
}

########################################################################
:Code END

-- 
======================================================
Phil Regulski
Research Meteorologist
Mesoscale Analysis and Forecasting Group
Department of Atmospheric Sciences
University of Washington, Box 351640
(Sunny) Seattle, WA 98195

Office:    612 ATG
Phone:     206 221 6359
Fax:       206 685 9302
E-mail:    regulski@atmos.washington.edu
Webpage:   http://www.atmos.washington.edu/~regulski/
======================================================

0
regulski
11/4/2009 5:54:26 PM
perl.beginners 29388 articles. 4 followers. Follow

3 Replies
1183 Views

Similar Articles

[PageSpeed] 21

Phil Regulski wrote:
> Error:
> "Bareword "NetCDF::READ" not allowed while "strict subs" in use..."
>

What is NetCDF::READ, a subroutine?

>   my $ncid =
> NetCDF::open("${netcdfDir}/REORDER.KATX_20091104_1651.CEDRIC.Z1.BIN.nc",NetCDF::READ);

If it's a sub, try:

my $ncid =
NetCDF::open("${netcdfDir}/REORDER.KATX_20091104_1651.CEDRIC.Z1.BIN.nc",
\&NetCDF::READ);


-- 
Just my 0.00000002 million dollars worth,
  Shawn

Programming is as much about organization and communication
as it is about coding.

I like Perl; it's the only language where you can bless your
thingy.
0
shawnhcorey
11/4/2009 6:09:15 PM
--------------070800090908090100080208
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

That took care of it. Didn't realize it was a sub in the module. Thanks!

Shawn H Corey wrote:
> Phil Regulski wrote:
>   
>> Error:
>> "Bareword "NetCDF::READ" not allowed while "strict subs" in use..."
>>
>>     
>
> What is NetCDF::READ, a subroutine?
>
>   
>>   my $ncid =
>> NetCDF::open("${netcdfDir}/REORDER.KATX_20091104_1651.CEDRIC.Z1.BIN.nc",NetCDF::READ);
>>     
>
> If it's a sub, try:
>
> my $ncid =
> NetCDF::open("${netcdfDir}/REORDER.KATX_20091104_1651.CEDRIC.Z1.BIN.nc",
> \&NetCDF::READ);
>
>
>   


--------------070800090908090100080208--
0
regulski
11/4/2009 6:21:03 PM
>>>>> "PR" == Phil Regulski <regulski@atmos.washington.edu> writes:

  PR> That took care of it. Didn't realize it was a sub in the module. Thanks!

regardless of it being a sub, it was in a place that expected a normal
value and not a bareword. you can use classnames as barewords in certain
places (use, method calls, etc.) but not when regular values are
expected. in this case the docs of the module probably mentioned a code
ref is needed and you need the \& prefix to make a class sub name into a
code ref.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------
0
uri
11/4/2009 6:37:45 PM
Reply:

Similar Artilces:

Why using use strict;
Hi all, I know why I should use "use strict;" but what happen if I use "use strict;" then if the code is OK, I delete this line? Shouldn't it work the same without this line if the code has no problems? Thanks. Teddy, orasnita@home.ro why would you want to do that Octavian? "use strict" is a sanity safety net. What your saying is like "I know why I should use safety belt whilst driving my car but what if I took it off?" - of course you can do it but beware of the consequences. joel -----Original Message----- From: ...

why to use 1)use CGI,2)use Strict ,3)use Carp in script
hi why we r using 1)use CGI, 2)use Strict, 3)use Carp in the begining of script sometimes. What is the use of it.Is the files CGI.pm,Strict.pm,Carp.pm default with PERL. Thnx __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com On Thu, 2004-11-04 at 09:31, supriya devburman wrote: > hi Hi > why we r using > 1)use CGI, We only use CGI when we want to use methods from that module (usually on web pages); see `perldoc CGI` for more information on what you...

Using Using
I have just completed reading a chapter in my book on performance. The books says to speed up performance on your web site you should use the using statement when opening connections. My question is how do you catch errors if you are using this as apposed to a try catch block.thanksBryan  Why would you use it as an alternative to a try/catch statement. Couldn't you just do something like  public void UsingSomeMethod() { try { SomeMethod(); } catch(SomeException e) { /// do something useful }}public void SomeMethod() { using (Something) { ...

When to use ( and when to use ((?
I'm just not getting it. When do you use ( in a statement, when do you need to use ((, and is the space after either or both mandatory? For example, I coded this statement: if (( $_ eq $bad_guys_ip )) { more_stuff_here }; Why the two (( in an if? And why does it seem to not work when I miss the space after the ((? Thanx! Mark me as... /Corn-fused|Dense/ > I'm just not getting it. >=20 > When do you use ( in a statement, when do you need to use ((, and is > the space after either or both mandatory? >=20 > For example, I coded this sta...

PROBLEM WITH THE USES OF USE STRICT
Hello Team, Can someone please tell me why the below code does not work correctly? Here is the problem: Once I run the program and type in a couple of wrong answers and then type in the correct answer I still get the wrong response (e.g "No that is wrong! Try again.") But if I type in the correct answer first I get the correct response. I also should add that if I don't use "use strict" and rename my variable without "my". The code then works as it should. regards, Jaimee #!/usr/bin/perl -w use strict; print (&q...

How to use the arguments to use() in the package being used
Howdy,=20 The subject says it all believe it or not :) What I'm trying to figure out is how to pass an argument=20 (pragma I believe is the proper term) to use() and do=20 sonethign in the package based on it. I've looked at CGI.pm source but can't seem to track it down.=20 (Similar idea as to CGIs -oldstyle_urls -newstyel_urls) http://search.cpan.org/~lds/CGI.pm-3.04/CGI.pm#PRAGMAS What I'd like to do is something like this: # for old time's sake we'll just use our favorite module use Foo::Monkey qw(:Foo :Bar -doamazingthings); #then in Foo::Monkey...

Loading and using modules using eval
Hi all, I have this piece of code: my @modules = ( 'Module1', 'Module2', 'Module3', 'ModuleX', 'ModuleY', 'Blah', ); my $param1 = "whatever"; my $param2 = 0; for my $module (@modules) { $param2++; eval("require $module"); if ($@) { print "$module Not found\n"; } else { eval("&${module}::process('$param1', '$param2')"); } } And it's working, but I wonder if there's any cleaner/better way to do this. The main idea is to have a XML file li...

use Getopt::Std; and use strict;
Hi everyone, I have a problem using Getopt::Std. I depend on use strict for all my code, and when I use Getopt::Std all the variables it creates (to hold the command line option values) are flagged by strict because they have not been scoped. I get errors like this: Line 70: Global symbol "$opt_m" requires explicit package name If I don't use strict the program runs fine. Is there anything I can do about this? Does anyone use both together? Thanks for the help. -Hans Yes you can say our $opt_m; or use vars qw($opt_m); at the top of your progra...

Pragmas use strict and use warnings
------=_Part_1657_33307736.1193755179713 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi Whats the exact purpose of use strict and use warnings Pragmas in the Perl Programming Language. I know use warnings turns on all useful warnings. Thanks and Regards Kaushal ------=_Part_1657_33307736.1193755179713-- On 10/30/07, Kaushal Shriyan <kaushalshriyan@gmail.com> wrote: snip > Whats the exact purpose of use strict snip The strict pragma has three effects (unless modified by arguments): 1. most var...

RE: Why do we even HAVE to... (was: Why using use strict;)
because it would reek havoc on all the perl one liners. And deter many beginners that are touching perl for the first time. And would annoy those who have to write a quick 5 line script in 3 seconds that forget a my for $line. > -----Original Message----- > From: Jake [mailto:jwebster@olemiss.edu] > Sent: Wednesday, June 05, 2002 8:56 AM > To: beginners-cgi@perl.org > Subject: Why do we even HAVE to... (was: Why using use strict;) > > > So, in post after post after post I see the comment "always > use strict"... > > I have seen thr...

How can I use the RichTextBox control used in the Text/HTML module in my custom Module
Hi,I am New to DotNetNuke and want to create my own Cutom Module and include RichTextBox control used in the Text/HTMLDoes anyone know how I can do this.I was hoping that is was one of the controls of DotNetNuke but I cannot find it anywhere.Many ThanksHenry HTML-Editor is determined by the HTMLEditorProvider. Have a look into the source code of the Text/HTML, to be found at \desktopModules\HTML\EditHTML.ascx and ~.vb. In Version 3.1 you need to unzip HTML.resources to get the source code files.Sebastian Leupoldgamma concept mbHDeutschNetNuke = DotNetNuke in GermanDNN Project Us...

Why CSK did not use datagrid in Modules? Can it use?
I want to add a Module but I found it....

Thread::Use
Another one in the category "dirty, but maybe useful". Hope this will make lean (memory wise) threaded programming a little easier. Again, comments are welcome... ;-) Liz ===================================================================== The uploaded file Thread-Use-0.01.tar.gz has entered CPAN as file: $CPAN/authors/id/E/EL/ELIZABETH/Thread-Use-0.01.tar.gz size: 2972 bytes md5: 8179f44ff8a2ed31b8052d84cb250369 =head1 NAME Thread::Use - use a module inside a thread only =head1 SYNOPSIS use Thread::Use; threads->ne...

To use signatures or not to use?
--001a11c3871a8a8fe2051b7b8b18 Content-Type: text/plain; charset=UTF-8 Dear all, Perl now has subroutine signatures. However, they are marked as experimental feature. As I really like it, I'm always tempted to use it. On the other hand, I don't want to wast efforts to something I have to roll back. So, does anyone know the tendency if signatures are going to stay? I'm not looking for the standard "do if you want to do it because TIMTOWTDI" answer, it will not help me. I'm looking for rumors, or eventually an assessment from the people who did the fe...

Web resources about - use Strict and using module - perl.beginners

Strict nature reserve - Wikipedia, the free encyclopedia
A strict nature reserve (IUCN category Ia) or wilderness area (IUCN category Ib), is the highest category of protected area recognised by the ...

CrossFit Pull Ups (Strict, Kip, Butterfly) - Northstate CrossFit - YouTube
CrossFit Pull Ups - Northstate CrossFit certified trainers show how to do proper Strict Pull Ups, Kip Pull Ups and Butterfly Pull Ups. See more ...

49% Favor Strict Legal Interpretation of the Constitution
... guide the nation? That legal debate continues to this day. But nearly half (49%) of Likely U.S. Voters believe the Constitution should be strictly ...

Syrian rebels seek strict form of Sharia
Islamist militants who favour a strict form of Sharia appear to be gaining a formidable sway in the ranks of the anti-regime forces.

John Birmingham Hampered By Strict Brisbane Dress Code
Oh, Brisbane Dress Code, we meet again.


'Isolated, insular, inflexible': ABS told it is too strict in public service review
The Australian Bureau of Statistics must "ease off on the independence" to safeguard its future.

HTTP Strict Transport Security becomes Internet standard - Internet Engineering Task Force, online safety ...
A Web security policy mechanism that promises to make HTTPS-enabled websites more resilient to various types of attacks has been approved and ...

Strict new hygiene rules for childcare will wrap kids in a bubble, says AMA
KIDS will be banned from blowing out candles on communal birthday cakes, under strict new hygiene rules for childcare.

Schapelle Corby's strict parole conditions revealed
Schapelle Corby will be free to come home to Australia almost three years earlier if she serves out her sentence in prison rather than applying ...

Resources last updated: 1/16/2016 4:40:13 AM