Re: [CentOS] Assitance with perl

2022-02-03 Thread H
On 02/02/2022 11:34 PM, Jon LaBadie wrote:
> On Wed, Feb 02, 2022 at 08:54:38PM -0500, H wrote:
> I am writing a long bash script under CentOS 7 where perl is used for 
> manipulating some external files. So far I am using perl one-liners to do 
> so but ran into a problem when I need to append text to an external file.
>
> Here is a simplified example in the bash script where txt is a bash 
> variable which I built containing a longish text with multiple newlines:
>
> txt="a b$'\n'cd ef$'\n'g h$'\n'ij kl"
>
> A simplified perl one-liner to append the text in the variable above to 
> some file in the bash script would be:
>
> perl -pe 'eof && do{print $_'"${txt}"'; exit}' someexternalfile.txt
>
> This works when fine when $txt does /not/ contain any spaces but falls 
> apart when it does.
>
> In a shell script why not stick to shell tools?
>
>   printf "%s" "${txt}" >> someexternalfile.txt
>
I want to use similar patterns of perl one-liners for more complicated text 
substitutions. If I cannot get the simple example above to work, I surely 
cannot get more complicated text substitutions, including substitutions 
spanning multiple lines, to work.

___
CentOS mailing list
CentOS@centos.org
https://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] Assitance with perl

2022-02-03 Thread Joe Kline

I avoid using ' or " in one-liners or even programs.

I use q() or qq().

These are quote-like operators for single quote and double quote.

There are, of course, many more:

https://perldoc.perl.org/perlop#Quote-and-Quote-like-Operators

gizmo
___
CentOS mailing list
CentOS@centos.org
https://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] Assistance with perl

2022-02-03 Thread H
On 02/03/2022 08:39 AM, Joe Kline wrote:
> I avoid using ' or " in one-liners or even programs.
>
> I use q() or qq().
>
> These are quote-like operators for single quote and double quote.
>
> There are, of course, many more:
>
> https://perldoc.perl.org/perlop#Quote-and-Quote-like-Operators
>
> gizmo
> ___
> CentOS mailing list
> CentOS@centos.org
> https://lists.centos.org/mailman/listinfo/centos

Thank you, I will look at those (the page says they should be q{} and q{} 
rather than q() and q()). It would still be useful for me to understand why my 
combination of single and double quotes in the perl command does not work? Just 
for "fun" I also tried concatenating the different strings in the perl command 
with . which I understand is the perl string concatenation symbol but again to 
no avail.

May I ask you what the correct way of including a literal $ in a substitution 
string would be? In bash I would precede it with a single \ but that led to 
loss of any text after that on that same line when used in the text string I 
use in my perl command, neither did preceding it with  \\ work.

I have seen that using an ENV() construct would work but I would prefer 
something simpler, if at all possible.

I have used literal # in my substitution string without any problems but have 
not gotten literal $ to work.

Thanks.

___
CentOS mailing list
CentOS@centos.org
https://lists.centos.org/mailman/listinfo/centos


[CentOS] EPEL repo RPM in CentOS 9-stream?

2022-02-03 Thread Chris Adams
Will the Fedora EPEL repo RPM be added to any CentOS 9-stream core
repos, like epel-release is in 7 and 8-stream extras?

-- 
Chris Adams 
___
CentOS mailing list
CentOS@centos.org
https://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] Assistance with perl

2022-02-03 Thread Joe Kline

On 2/3/22 09:21, H wrote:

On 02/03/2022 08:39 AM, Joe Kline wrote:

I avoid using ' or " in one-liners or even programs.

I use q() or qq().

These are quote-like operators for single quote and double quote.

There are, of course, many more:

https://perldoc.perl.org/perlop#Quote-and-Quote-like-Operators

gizmo
___
CentOS mailing list
CentOS@centos.org
https://lists.centos.org/mailman/listinfo/centos


Thank you, I will look at those (the page says they should be q{} and q{} rather than q() 
and q()). It would still be useful for me to understand why my combination of single and 
double quotes in the perl command does not work? Just for "fun" I also tried 
concatenating the different strings in the perl command with . which I understand is the 
perl string concatenation symbol but again to no avail.

May I ask you what the correct way of including a literal $ in a substitution 
string would be? In bash I would precede it with a single \ but that led to 
loss of any text after that on that same line when used in the text string I 
use in my perl command, neither did preceding it with  \\ work.

I have seen that using an ENV() construct would work but I would prefer 
something simpler, if at all possible.

I have used literal # in my substitution string without any problems but have 
not gotten literal $ to work.


I think it's been pointed out that it might be a lot easier to stick 
with either perl or shell.


For shell you could probably do:

( cat - ; echo $txt ) >output

As for perl, I guess I'll leave that as an exercise for you how to 
translate from shell to perl.


For the quote-like operators you can use either () or {} for the 
delimiter for almost all of the quote-like operators, in fact, from the doc:


"In the following table, a {} represents any pair of delimiters you choose."

gizmo
___
CentOS mailing list
CentOS@centos.org
https://lists.centos.org/mailman/listinfo/centos