Link to home
Start Free TrialLog in
Avatar of fabiano petrone
fabiano petroneFlag for Italy

asked on

Perl System script - format of the output

Hello,
I must "execute" some commands on some books (scan-in of the items) using POST API and I've tought at a call to the CURL command via system.
Say we have a input.csv with all the books data.
The script is called via:
perl script.pl<input.csv>output.txt

Open in new window

the simple script is the following:

#!/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&circ_desk=DEFAULT_CIRC_DESK&done=true&apikey=xxxxxxxxxx\"\n");

	$cntRecord++;
}

# close(FD_IN);

Open in new window


In output.txt I've some interesting data returned by the server at EVERY CURL call.
The question is simple: my I add a bit of format to output.txt (I.E. separe the output of every CURL call with something like "***BEGIN NEW OUTPUT****)?

Thanks,
Fabiano
ASKER CERTIFIED SOLUTION
Avatar of wilcoxon
wilcoxon
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of fabiano petrone

ASKER

Hi, wilcoxon
you're right! I've not though to this simple & good solution! :=)
I need only a "quick & dirty" parsing of a lot of API URLs (pratically, every URL is something like a "scan" operation of a book barcode done with a barcode reader) so I've not examined other solutions.
Is there any advantage using WWW::Curl or LWP::Curl
Thanks,
Fabiano
I'm honestly not sure.  I've never used either module (I haven't needed to use curl much and it's been a long time since I did any web-grabbing/scraping for my job).