Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hi sellinios,

As talexb said, you really need to show some code for us to see where you're having problems.

That said, it's a fair bet the first error you've got:

rm: cannot remove ‘/home/meteo/Build_WRF/DATA/WRF/greece-9km/201604211 +2/wps/FILE:*’: No such file or directory

happened because the code was trying to remove all files a bunch of files that didn't exist. You're probably running on Linux because of the /home dir, and the "rm" command. On my Linux system, the same error (and the same exit status, 256) happen with this test script:

#!/usr/bin/perl -w use strict; use warnings; system("rm dir/FILE:*"); my $err = $?; print "Error is $err\n"; # Output is: rm: cannot remove ‘dir/FILE:*’: No such file or directory Error is 256

If I change that script to use glob and unlink (better because they're Perl builtin functions, hence don't rely on calling the shell which is a more expensive operation):

#!/usr/bin/perl -w use strict; use warnings; foreach my $file (glob("dir/FILE:*")) { if (!unlink($file)) { print "Warning: failed to remove file '$file' ($!)\n"; } }

That way, if there aren't any files, it won't fail due to shell not finding any matches.

It's interesting to note that the shell will always do its own globbing before passing results to the command (rm in your case) -- to verify this, you can try "echo *" and see all your files/dirs the way they'd look prior to passing them to any Unix command ("ls" for example).

And unlike Perl, the shell will throw an error if a wildcard such as "*" or "?" fails to find any matching files.

say  substr+lc crypt(qw $i3 SI$),4,5

In reply to Re: Perl script error by golux
in thread Perl script error by sellinios

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-24 18:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found