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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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).
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.