raku: Support for utf8-c8 issue in Raku 2020.10 [closed] - utf-8

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I have a file from Wild Wild Web and it contains malformed UTF8. I handled malformed UTF8 in my other codes in previous versions of Raku. In 2020.10 version, I am running into this issue below. Has the support for utf8-c8 changed (this page says it should work, but it doesn't seem to) :
https://docs.raku.org/language/unicode#index-entry-UTF-8_Clean-8
This page has this example:
say slurp($test-file, enc => 'utf8-c8');
Now my code on the command line:
raku -e 'my $a = slurp("zlist"); for $a.lines { .say }'
Malformed UTF-8 near bytes 73 e2 5f at line 55 col 14
in block <unit> at -e line 1
Then using this:
raku -e 'my $a = slurp("zlist", enc => 'utf8-c8'); for $a.lines { .say }'
===SORRY!=== Error while compiling -e
Undeclared routine:
utf8-c8 used at line 1
My code is simple and essentially copied from the example. What am I doing wrong?

Related

Bash string literal comparison to variable failing [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I have the following simple bash code to test string comparison:
#!/bin/sh
BRANCH="master"
echo $ref
if [[ "$ref" = "refs/heads/$BRANCH" ]]
then
echo "Matches"
else
echo "Do not match"
fi
When I ran the code using export ref=/refs/heads/master && . sample I get the following result:
/refs/heads/master
Do not match
What may be causing the problem?
What is causing the problem is the missing slash in your test: /refs/heads/master is not equal to refs/heads/master!

ruby Unexpected keyword else error [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I have this ruby program to parse a CSV file. I am missing a endif somewhere and I cannot figure out.
require 'csv'
prevrow=nil
newarray=Array.new
CSV.foreach("\\\\192.168.0.1\\fe18cb0618cabd41\\ninjatrader\\uniqueside.csv", col_sep: ',') do |row|
if(prevrow==nil)
# do nothing
newarray<<row
prevrow=row
elsif (prevrow!=nil and row[0]!=prevrow[0] )
# do something
newarray<<row
prevrow=row
##count=1
elsif(prevrow!=nil and row[0]=prevrow[0] and ##count<4)
puts "new date"
newarray<<row
prevrow=row
##count++
end
end
removesamedirctiontop4.rb:23: syntax error, unexpected keyword_else
removesamedirctiontop4.rb:27: syntax error, unexpected end-of-input, expecting keyword_end
#count++ is not valid ruby. The final "plus" is expecting another parameter and thinks it's on the next line, so the line ends up being interpreted as...
`#count + +end`
So you have an invalid statement and you lose an end.
Change the offending line to
#count += 1

Unable to find the reason for this: bash missing' [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 6 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
why am I getting "bash missing'" for this:
function get_xserver ()
{
case $TERM in
xterm )
XSERVER=$(who am i | awk '{print $NF}' | tr -d ')''(' )
;;
aterm | rxvt)
# Find some code that works here. ...
;;
esac
}
This is the exact error:
bash: [: missing `]'
The error is not in the code you posted. The error message:
-bash: [: missing `]'
Means exactly what it says - there is a missing ] character, namely in a [ test ] statement.
Try it:
$ [ 1 -eq 2
-bash: [: missing `]'
You need to identify where the error actually is, and add the missing closing bracket.

Append to variable within shell script loop [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I'm trying to loop over all environment variables in a shell script, and create an HTML query string from ones which match a pattern. Unfortunately, I can't seem to assign to variables in the loop. I've got this:
#!/bin/sh
IFS=$'\n'
TAGS=""
for item in $(printenv)
do
if [[ $item == FOO_TAG_* ]]
then
TAGS = "${TAGS}&${item}"
fi
done
But this gives me
/etc/script.sh: line 9: TAGS: command not found
/etc/script.sh: line 9: TAGS: command not found
How do I fix this?
In the assignment, remove space between variable name and =
TAGS="${TAGS}${item}"

Throw away all text after a blank line in bash [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
Using bash, I want to throw away all of the text in a file after the first blank line. The blank line is used as a delimiter between records, and I only want the first record in the file. Unfortunately, the number of lines per record can change depending on what the record refers to exactly, so I can't just keep the first n lines as a global solution.
[EDIT] Here is a solution that works:
qstat -f > out.tmp
grep -A90 -B0 $1 out.tmp > out2.txt
awk '/^$/{exit}{print}' out2.txt
rm out.tmp out2.txt
where $1 points to the name of the text file to be analyzed (passed as an argument to the script that I'm writing). Thanks.
You can do this with pretty much any generic text processing tool, e.g.:
awk '$0==""{exit}{print}'
awk '/^$/{exit}{print}'
sed '/^$/q'

Resources