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 strongm 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: cntr
  • Order by date
  1. cntr

    SCRIPT..help

    BEGIN{FS="\t";ORS=""}NR>1{print":"}{print$2} xxxx 001233 xxxxx xxxxx xxxx 001234 xxxxx xxxxx xxxx 001235 xxxxx xxxxx xxxx 001236 xxxxx xxxxx xxxx 001237 xxxxx xxxxx becomes 001233:001234:001235:001236:001237
  2. cntr

    How to extract matching data from line

    $line=~/(d:.*)(##.*)/; $var1=$1; $var2=$2; Sorry, Tony.
  3. cntr

    How to extract matching data from line

    I don't mind if I do. BEGIN{FS="d:|##"} {print $2,$3}
  4. cntr

    stdin

    Flush STDOUT?
  5. cntr

    Rookie in Perl, Parsing question

    He can simply ignore me if he likes. # Create a hash whose elements have a default value # of 0. BEGIN { $h=Hash.new(0) } # If the line just read, $_, doesn't begin with # "JOE", skip it. next if $_ !~ /^JOE/ # Each iteration of scan produces an array like this: # [n1,n2]; n1 is the number...
  6. cntr

    Rookie in Perl, Parsing question

    ruby -n sums.rb data BEGIN { $h=Hash.new(0) } next if $_ !~ /^JOE/ $_.scan(/(\d+):(\d+)/){|x| $h[x[0].to_i]+=x[1].to_i} END { puts $h.sort.map{|x| x.join(':')}.join(',') }
  7. cntr

    Rookie in Perl, Parsing question

    Is Perl not suitable for this task?
  8. cntr

    Substitution

    BEGIN {FS="="} NR==FNR {aa[$1]=$2; next} $0 in aa {$0=aa[$0]} 1 awk -f sub.awk line.txt -
  9. cntr

    stdin

    You ought to get out more, Paul.
  10. cntr

    Shorten script

    Awk BEGIN { # Make dummy data. for (i=1; i<6; i++) addresses[i] = cell( "cell: " i, 215 ) print make_table( addresses ) } function make_table( addresses ,number_of_columns,output,i) { number_of_columns = length(addresses) if (0==number_of_columns) output = empty_row() else...
  11. cntr

    Attention Regex gurus: Grabing first six character from string

    awk { $0 = six = substr($0,1,6) if (/[0-9]/ && gsub(/[a-zA-Z]/,1)>1) print six,"is good" }
  12. cntr

    re: perl questions, confused

    while ($i++ <= 5) It's $i++ not ++$i. This means that the value of $i is fetched before $i is incremented. But $i will be incremented before the print statement. So the equivalent is $i = 0; while ($i <= 5) { $i++; print $i; } and the output will be 123456 b{1,3} will match "b" or "bb" or...
  13. cntr

    extract xml tags

    <root> <root2> <tag1>some value</tag1> <tag2>some value</tag2> <tag3>some value</tag3> </root2> </root> becomes root root2 tag1 tag2 tag3 Run with awk -f xmltags.awk test.xml xmltags.awk is BEGIN { RS="<"; FS=">" } !/^\// { print $1 }
  14. cntr

    Perl with CSV file

    Oops. Made "arry" global. Change function rpldelimxy( str, delim, x, y, n,i to function rpldelimxy( str, delim, x, y, n,arry,i)
  15. cntr

    Perl with CSV file

    244000,106685045,"$7,605.40",Dell Australia Pty Ltd,"Hi, Mom!" 244000,106685045,"$1,777,605.40",Dell Australia Pty Ltd, 244000,106685045,"$9,111,777,605.40",Dell Australia Pty Ltd, becomes 244000,106685045,"$7605.40",Dell Australia Pty Ltd,"Hi Mom!" 244000,106685045,"$1777605.40",Dell...
  16. cntr

    Perl with CSV file

    gsub(/,/, "", currency) And here's an improved csv parser in Awk. The only thing it doesn't handle is records that contain linefeeds. { parse_csv( $0, rec ) printf "[" sep = "" for (i=1;i in rec; i++) { printf "%s<%s>", sep, rec[i] sep = ", " } print "]" } function...
  17. cntr

    Reading input from 2 files

    Let's say you run the program with awk -f prog.awk myfile1 myfile2 ARGV is now ["awk", "myfile1", "myfile2"] BEGIN { file2 = ARGV[2] file2 now is "myfile2" ARGC-- ARGV is now, in effect, ["awk", "myfile1"] while ( getline Read line from "myfile1" and put it in $0. +...
  18. cntr

    Reading input from 2 files

    Should have been awk -f prog.awk file1 file2
  19. cntr

    Reading input from 2 files

    awk -f file1 file2 BEGIN { file2 = ARGV[2]; ARGC-- while ( getline + (getline DNA2 <file2) > 0 ) { concat = $0 DNA2 printf "Here: %s %s\nConcatenated: %s\n", $0,DNA2,concat $0=DNA2="" } }
  20. cntr

    Testing a string for imbedded blanks

    Ruby: mystr = 'abc def' puts "Space contained in mystr" if mystr =~ /\s/

Part and Inventory Search

Back
Top