fabiano petrone
asked on
Formatting the CURL output of a perl script
Hi, Dear Experts
I've made a simple script with two calls to the CURL command:
The script runs as:
perl script.pl<input.csv>output .txt
I need a quick way -inside the script- for formatting the CURL output registered on output.txt
Thanks a lot,
Fabiano
I've made a simple script with two calls to the CURL command:
#!/usr/bin/perl
# open(FD_IN, "<STDIN") || die "Errore apertura standard input";
while (<STDIN>) {
$Riga = $_;
$Riga =~ s/\n//;
$Riga =~ s/\r//;
@Campi = split("\t", $Riga);
system("curl -X POST -H \"Content-Type: application/xml\" \"https://api-eu.hosted.exlibrisgroup.com/almaws/v1/bibs/".$Campi[2]."/holdings/".$Campi[1]."/items/".$Campi[0]."?op=scan&library=PETFS&department=BIB1PETFSCATFLO&work_order_type=CATFLO&done=true&apikey=xxx\"\n");
system("curl -X POST -H \"Content-Type: application/xml\" \"https://api-eu.hosted.exlibrisgroup.com/almaws/v1/bibs/".$Campi[2]."/holdings/".$Campi[1]."/items/".$Campi[0]."?op=scan&library=PETFS&circ_desk=DEFAULT_CIRC_DESK&done=true&apikey=xxx\"\n");
$cntRecord++;
}
# close(FD_IN);
The script runs as:
perl script.pl<input.csv>output
I need a quick way -inside the script- for formatting the CURL output registered on output.txt
Thanks a lot,
Fabiano
ASKER
Hi,
Thanks for the answer
But I need a slice of code inside my script, something like:
...script...
system("curl -X POST -H \"Content-Type: application/xml\" \"https://api-eu.hosted.exlibrisgroup.com/almaws/v1/bibs/".....
...here code to format the output of the preceding line, probably saved on a variable?
Thanks,
Fabiano
Thanks for the answer
But I need a slice of code inside my script, something like:
...script...
system("curl -X POST -H \"Content-Type: application/xml\" \"https://api-eu.hosted.exlibrisgroup.com/almaws/v1/bibs/".....
...here code to format the output of the preceding line, probably saved on a variable?
Thanks,
Fabiano
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If the input file is not homogeneous in form ...
Pseudocode:
Open in new window
Run each line through sed, then write the reformatted lines.