You'll tend to run into this sort of problem a lot if you use commands in backticks on scripts that need to run in both a unix and microsoft environment.
For this particular case, you might try using the perl opendir/readdir/closedir commands to build your array of filenames.
Richard
$#dirs is the index to the last entry in the array @dirs.
The split creates one array element for each / in the string, so after the command
my @dirs = split /\//, $mypage;
@dirs looks like this:
$dirs[0] = http:
$dirs[1] = ""
$dirs[2] = mypage
$dirs[3] = directory
$dirs[4] =...
Try this:
#!/usr/local/bin/perl
@a = (<DATA>);
foreach (@a)
{
$return = system("/usr/sbin/ping $_");
# might need this to get just the exit value. There is
# some other info in the return from system()
$exit = $return >> 8;
print "$exit\n";
if ( $exit !=...
You could do this with a script if you really want to, but there's a simple command that can do exactly what you're looking for.
find directory -mtime 60 -exec rm -rf {} \;
directory would be the top of your array of directories.
This command will remove any file or directory in the search...
One side benefit to the new version is that it no longer matters if the input data list is sorted, and the output will be sorted regardless of the input sort state.
Richard
Here's the new version...
open (DATAFILE,"file2.dat") || die "Can't open file\n";
while ($line = <DATAFILE>) {
chomp $line;
($number, $data) = split /\s+/,$line;
# This adds the value of $data to the existing hash entry
# in %list that has the key $number. If...
$#list gives the index of the last element of array @list, so the line:
if ( $list[$#list] =~ /^$number/ ) {
says use $#list to get the last element of @list using $list[$#list] and use the /^$number/ regex to check if it's the same starting number.
But, given the new information that the...
Try this one...
$db = 'aaa.txt';
open(DATA, "$db") or die "did not open: $!\n";
@dat = (<DATA>);
close(DATA);
# I assume you meant this to open to rewrite the massaged
# data too? You forgot to tag the open for output.
open(DATA, ">$db") or die "did...
You may not need $ein, but if you don't want to test the results for $ein, you should also remove it from the select() call. Just change the $ein to an undef, and get rid of the $ein = $rin during initialization.
Another thing to look at... if your select says there's something to read, but...
All checking $nfound tells you is that one or more of your descriptors hit. It doesn't tell you which ones...you have to check $rin and $ein for that. Try this
while(1)
{
vec($rin,fileno(READSOCKET),1) = 1;
$ein = $rin;
# Since you're calling select with a timeout of 0, you
# don't...
You can also save a little time in your loop. If you're going to chomp the entire list anyway, you could do this, since chomp accepts list context as well as scalar:
open(CUST, "c:\\customers.txt") || die "Shucks $!";
@a = <CUST>;
chomp @a;
close(CUST);
foreach $a...
If you were on a Unix-like system, I'd have a solution for you, but I'm pretty sure windows systems don't support hard links, and I don't know enough about windows file handling to give you any ideas.
Sorry,
Richard
Don't really need the foreach, since the "my $argv..." line gives you a single value, rather than a list.
For the substr itself, you're close...
substr($argv, 2, 0) = $argv;
will do what your example request shows. Using 0 for the LENGTH parameter makes it insert, instead of...
Could also try this one.
$base = (split /[\\:\n]/,$line)[-1];
This splits $line on \, :, or newline (so you don't have to chop it off, if you're reading this list from a file), then returns the last element of the list.
Richard
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.