Perl System script - format of the output

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:

Open in new window

the simple script is the following:


# 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\" \"".$Campi[2]."/holdings/".$Campi[1]."/items/".$Campi[0]."?op=scan&library=PETFS&circ_desk=DEFAULT_CIRC_DESK&done=true&apikey=xxxxxxxxxx\"\n");


# 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****)?

fabiano petroneAsked:
Who is Participating?
Have you tried using WWW::Curl or LWP::Curl rather than doing system calls to curl?

If you just want to output some text between system calls then you could add this just before your system call to curl.
print "***BEGIN NEW OUTPUT***\n";

Open in new window

fabiano petroneAuthor Commented:
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
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).
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.