Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  • Users: rnorton
  • Order by date
  1. rnorton

    get_files problem

    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
  2. rnorton

    Splitting

    $#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] =...
  3. rnorton

    Pinging IP addresses

    Try this: #!/usr/local/bin/perl @a = (<DATA>); foreach (@a) { $return = system(&quot;/usr/sbin/ping $_&quot;); # might need this to get just the exit value. There is # some other info in the return from system() $exit = $return >> 8; print &quot;$exit\n&quot;; if ( $exit !=...
  4. rnorton

    Need a script that will delete all folders that are older than 2 month

    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...
  5. rnorton

    editing a previous array entry

    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
  6. rnorton

    editing a previous array entry

    Here's the new version... open (DATAFILE,&quot;file2.dat&quot;) || die &quot;Can't open file\n&quot;; 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...
  7. rnorton

    editing a previous array entry

    $#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...
  8. rnorton

    Reg expression not working

    Try this one... $db = 'aaa.txt'; open(DATA, &quot;$db&quot;) or die &quot;did not open: $!\n&quot;; @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, &quot;>$db&quot;) or die &quot;did...
  9. rnorton

    editing a previous array entry

    Like this? #!/usr/bin/perl open (DATAFILE,&quot;file.dat&quot;) || die &quot;Can't open file\n&quot;; while ($line = <DATAFILE>) { chomp $line; ($number, $data) = split /\s+/,$line; if ( $list[$#list] =~ /^$number/ ) { $list[$#list] .= &quot; $data&quot;; } else { push...
  10. rnorton

    select() - How does it work?

    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...
  11. rnorton

    select() - How does it work?

    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...
  12. rnorton

    Y does it do this

    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, &quot;c:\\customers.txt&quot;) || die &quot;Shucks $!&quot;; @a = <CUST>; chomp @a; close(CUST); foreach $a...
  13. rnorton

    How to know when in process file is closed by another process.

    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
  14. rnorton

    substrings

    Don't really need the foreach, since the &quot;my $argv...&quot; 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...
  15. rnorton

    Obtain time with a specific format

    @list = localtime; print $list[5]+1900 . &quot;.$list[7].$list[2]:$list[1]\n&quot;;
  16. rnorton

    How do I parse from last \ to end of line ?

    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

Part and Inventory Search

Back
Top